diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2010-2014, Galois, Inc.
+Copyright (c) 2010-2015, Galois, Inc.
 
 All rights reserved.
 
diff --git a/Setup.hs b/Setup.hs
--- a/Setup.hs
+++ b/Setup.hs
@@ -47,6 +47,11 @@
                     pkg_desc' <- abcPkgDesc (localPkgDescr lbi)
                     return lbi{ localPkgDescr = pkg_desc' }
 
+    , cleanHook = \pkg_desc unit uh cf -> do
+                    let v = fromFlag $ cleanVerbosity cf
+                    cleanAbc v
+                    cleanHook simpleUserHooks pkg_desc unit uh cf
+
     , sDistHook = \pkg_desc lbi h f -> do
                     let v = fromFlag $ sDistVerbosity f
                     setupAbc v pkg_desc
@@ -82,6 +87,11 @@
 onWindows act = case buildPlatform of
                   Platform _ Windows -> act
                   _                  -> return ()
+
+-- call "make clean" in the abc directory, if it exists
+cleanAbc :: Verbosity -> IO ()
+cleanAbc verbosity = do
+    rawSystemExit verbosity "sh" ["scripts" </> "lite-clean-abc.sh"]
 
 -- If necessary, fetch the ABC sources and prepare for building
 setupAbc :: Verbosity -> PackageDescription -> IO ()
diff --git a/abc-build/.hg_archival.txt b/abc-build/.hg_archival.txt
--- a/abc-build/.hg_archival.txt
+++ b/abc-build/.hg_archival.txt
@@ -1,5 +1,5 @@
 repo: 27f68cec826fd69da083a19ad1384a074eb56f73
-node: 0fd8533faa9695adbd48b259263c1f9446a60093
-branch: galois-abcBridge
+node: c16b9de6d2b4c7c267517efb75e50baf33a5d6f7
+branch: galois-abcBridge-0.14-dev
 latesttag: null
-latesttagdistance: 2470
+latesttagdistance: 2713
diff --git a/abc-build/Makefile b/abc-build/Makefile
--- a/abc-build/Makefile
+++ b/abc-build/Makefile
@@ -12,9 +12,9 @@
 PROG := abc
 
 MODULES := \
-	$(wildcard src/ext) src/misc/ext \
+	$(wildcard src/ext*) \
 	src/base/abc src/base/abci src/base/cmd src/base/io \
-	src/base/main src/base/ver src/base/wlc src/base/test \
+	src/base/main src/base/ver src/base/wlc src/base/cba src/base/test \
 	src/bdd/cudd src/bdd/dsd src/bdd/epd src/bdd/mtr src/bdd/parse \
 	src/bdd/reo src/bdd/cas \
 	src/map/mapper src/map/mio src/map/super src/map/if \
@@ -42,9 +42,14 @@
 	$(CC) arch_flags.c -o arch_flags
 
 ARCHFLAGS ?= $(shell $(CC) arch_flags.c -o arch_flags && ./arch_flags)
+ARCHFLAGS := $(ARCHFLAGS)
+
 OPTFLAGS  ?= -g -O #-DABC_NAMESPACE=xxx
 
-CFLAGS   += -Wall -Wno-unused-function -Wno-write-strings -Wno-sign-compare $(OPTFLAGS) $(ARCHFLAGS) -Isrc
+CFLAGS    += -Wall -Wno-unused-function -Wno-write-strings -Wno-sign-compare $(OPTFLAGS) $(ARCHFLAGS) -Isrc
+ifneq ($(findstring arm,$(shell uname -m)),)
+	CFLAGS += -DABC_MEMALIGN=4
+endif
 
 # Set -Wno-unused-bug-set-variable for GCC 4.6.0 and greater only
 ifneq ($(or $(findstring gcc,$(CC)),$(findstring g++,$(CC))),)
@@ -67,7 +72,7 @@
 endif
 
 # LIBS := -ldl -lrt
-LIBS := -ldl
+LIBS += -ldl
 ifneq ($(findstring Darwin, $(shell uname)), Darwin)
    LIBS += -lrt
 endif
@@ -94,6 +99,7 @@
 
 OBJ := \
 	$(patsubst %.cc, %.o, $(filter %.cc, $(SRC))) \
+	$(patsubst %.cpp, %.o, $(filter %.cpp, $(SRC))) \
 	$(patsubst %.c, %.o,  $(filter %.c, $(SRC)))  \
 	$(patsubst %.y, %.o,  $(filter %.y, $(SRC))) 
 
@@ -111,13 +117,23 @@
 	@$(CXX) -c $(CXXFLAGS) $< -o $@
 	@$(REMOVE_DRECTVE) $@
 
+%.o: %.cpp
+	@echo "$(MSG_PREFIX)\`\` Compiling:" $(LOCAL_PATH)/$<
+	@$(CXX) -c $(CXXFLAGS) $< -o $@
+	@$(REMOVE_DRECTVE) $@
+
+
 %.d: %.c
-	@echo "$(MSG_PREFIX)\`\` Dependency:" $(LOCAL_PATH)/$<
+	@echo "$(MSG_PREFIX)\`\` Generating dependency:" $(LOCAL_PATH)/$<
 	@./depends.sh $(CC) `dirname $*.c` $(CFLAGS) $*.c > $@
 
 %.d: %.cc
 	@echo "$(MSG_PREFIX)\`\` Generating dependency:" $(LOCAL_PATH)/$<
 	@./depends.sh $(CXX) `dirname $*.cc` $(CXXFLAGS) $*.cc > $@
+
+%.d: %.cpp
+	@echo "$(MSG_PREFIX)\`\` Generating dependency:" $(LOCAL_PATH)/$<
+	@./depends.sh $(CXX) `dirname $*.cpp` $(CXXFLAGS) $*.cpp > $@
 
 #-include $(DEP)
 
diff --git a/abc-build/abc-incl-dirs.txt b/abc-build/abc-incl-dirs.txt
--- a/abc-build/abc-incl-dirs.txt
+++ b/abc-build/abc-incl-dirs.txt
@@ -10,6 +10,7 @@
 abc-build/src/base
 abc-build/src/base/abc
 abc-build/src/base/abci
+abc-build/src/base/cba
 abc-build/src/base/cmd
 abc-build/src/base/io
 abc-build/src/base/main
@@ -48,7 +49,6 @@
 abc-build/src/misc/bbl
 abc-build/src/misc/bzlib
 abc-build/src/misc/espresso
-abc-build/src/misc/ext
 abc-build/src/misc/extra
 abc-build/src/misc/hash
 abc-build/src/misc/mem
@@ -96,6 +96,7 @@
 abc-build/src/sat
 abc-build/src/sat/bmc
 abc-build/src/sat/bsat
+abc-build/src/sat/bsat2
 abc-build/src/sat/cnf
 abc-build/src/sat/csat
 abc-build/src/sat/lsat
diff --git a/abc-build/abc-sources.txt b/abc-build/abc-sources.txt
--- a/abc-build/abc-sources.txt
+++ b/abc-build/abc-sources.txt
@@ -94,6 +94,7 @@
 abc-build/src/aig/gia/giaEquiv.c
 abc-build/src/aig/gia/giaEra.c
 abc-build/src/aig/gia/giaEra2.c
+abc-build/src/aig/gia/giaFadds.c
 abc-build/src/aig/gia/giaFalse.c
 abc-build/src/aig/gia/giaFanout.c
 abc-build/src/aig/gia/giaForce.c
@@ -122,7 +123,10 @@
 abc-build/src/aig/gia/giaMuxes.c
 abc-build/src/aig/gia/giaNf.c
 abc-build/src/aig/gia/giaPat.c
+abc-build/src/aig/gia/giaPf.c
+abc-build/src/aig/gia/giaPolyn.c
 abc-build/src/aig/gia/giaProp.c
+abc-build/src/aig/gia/giaQbf.c
 abc-build/src/aig/gia/giaResub.c
 abc-build/src/aig/gia/giaRetime.c
 abc-build/src/aig/gia/giaSat.c
@@ -244,6 +248,7 @@
 abc-build/src/base/abc/abcFunc.c
 abc-build/src/base/abc/abcHie.c
 abc-build/src/base/abc/abcHieCec.c
+abc-build/src/base/abc/abcHieGia.c
 abc-build/src/base/abc/abcHieNew.c
 abc-build/src/base/abc/abcInt.h
 abc-build/src/base/abc/abcLatch.c
@@ -341,6 +346,25 @@
 abc-build/src/base/abci/abcXsim.c
 abc-build/src/base/abci/fahout_cut.c
 abc-build/src/base/abci/module.make
+abc-build/src/base/cba/cba.c
+abc-build/src/base/cba/cba.h
+abc-build/src/base/cba/cbaBlast.c
+abc-build/src/base/cba/cbaCba.c
+abc-build/src/base/cba/cbaCom.c
+abc-build/src/base/cba/cbaLib.c
+abc-build/src/base/cba/cbaNtk.c
+abc-build/src/base/cba/cbaPrs.h
+abc-build/src/base/cba/cbaPrsBuild.c
+abc-build/src/base/cba/cbaPrsTrans.c
+abc-build/src/base/cba/cbaPtr.c
+abc-build/src/base/cba/cbaPtrAbc.c
+abc-build/src/base/cba/cbaReadBlif.c
+abc-build/src/base/cba/cbaReadSmt.c
+abc-build/src/base/cba/cbaReadVer.c
+abc-build/src/base/cba/cbaWriteBlif.c
+abc-build/src/base/cba/cbaWriteSmt.c
+abc-build/src/base/cba/cbaWriteVer.c
+abc-build/src/base/cba/module.make
 abc-build/src/base/cmd/cmd.c
 abc-build/src/base/cmd/cmd.h
 abc-build/src/base/cmd/cmdAlias.c
@@ -393,6 +417,7 @@
 abc-build/src/base/main/mainInt.h
 abc-build/src/base/main/mainLib.c
 abc-build/src/base/main/mainMC.c
+abc-build/src/base/main/mainReal.c
 abc-build/src/base/main/mainUtils.c
 abc-build/src/base/main/module.make
 abc-build/src/base/test/module.make
@@ -408,9 +433,11 @@
 abc-build/src/base/wlc/module.make
 abc-build/src/base/wlc/wlc.c
 abc-build/src/base/wlc/wlc.h
+abc-build/src/base/wlc/wlcAbs.c
 abc-build/src/base/wlc/wlcBlast.c
 abc-build/src/base/wlc/wlcCom.c
 abc-build/src/base/wlc/wlcNtk.c
+abc-build/src/base/wlc/wlcReadSmt.c
 abc-build/src/base/wlc/wlcReadVer.c
 abc-build/src/base/wlc/wlcWriteVer.c
 abc-build/src/bdd/cas/cas.h
@@ -799,8 +826,6 @@
 abc-build/src/misc/espresso/unate.c
 abc-build/src/misc/espresso/util_old.h
 abc-build/src/misc/espresso/verify.c
-abc-build/src/misc/ext/ext.h
-abc-build/src/misc/ext/module.make
 abc-build/src/misc/extra/extra.h
 abc-build/src/misc/extra/extraBdd.h
 abc-build/src/misc/extra/extraBddAuto.c
@@ -820,9 +845,11 @@
 abc-build/src/misc/extra/extraUtilMemory.c
 abc-build/src/misc/extra/extraUtilMisc.c
 abc-build/src/misc/extra/extraUtilPerm.c
+abc-build/src/misc/extra/extraUtilPrime.c
 abc-build/src/misc/extra/extraUtilProgress.c
 abc-build/src/misc/extra/extraUtilReader.c
 abc-build/src/misc/extra/extraUtilSupp.c
+abc-build/src/misc/extra/extraUtilThresh.c
 abc-build/src/misc/extra/extraUtilTruth.c
 abc-build/src/misc/extra/extraUtilUtil.c
 abc-build/src/misc/extra/extraZddTrunc.c
@@ -882,6 +909,7 @@
 abc-build/src/misc/util/utilCex.h
 abc-build/src/misc/util/utilColor.c
 abc-build/src/misc/util/utilFile.c
+abc-build/src/misc/util/utilIsop.c
 abc-build/src/misc/util/utilMem.c
 abc-build/src/misc/util/utilMem.h
 abc-build/src/misc/util/utilNam.c
@@ -1371,6 +1399,7 @@
 abc-build/src/sat/bmc/bmcCexMin1.c
 abc-build/src/sat/bmc/bmcCexMin2.c
 abc-build/src/sat/bmc/bmcCexTools.c
+abc-build/src/sat/bmc/bmcChain.c
 abc-build/src/sat/bmc/bmcEco.c
 abc-build/src/sat/bmc/bmcFault.c
 abc-build/src/sat/bmc/bmcICheck.c
@@ -1404,6 +1433,34 @@
 abc-build/src/sat/bsat/satTruth.h
 abc-build/src/sat/bsat/satUtil.c
 abc-build/src/sat/bsat/satVec.h
+abc-build/src/sat/bsat2/AbcApi.cpp
+abc-build/src/sat/bsat2/Alg.h
+abc-build/src/sat/bsat2/Alloc.h
+abc-build/src/sat/bsat2/Dimacs.h
+abc-build/src/sat/bsat2/Heap.h
+abc-build/src/sat/bsat2/IntTypes.h
+abc-build/src/sat/bsat2/LICENSE
+abc-build/src/sat/bsat2/MainSat.cpp
+abc-build/src/sat/bsat2/MainSimp.cpp
+abc-build/src/sat/bsat2/Map.h
+abc-build/src/sat/bsat2/module.make
+abc-build/src/sat/bsat2/Options.cpp
+abc-build/src/sat/bsat2/Options.h
+abc-build/src/sat/bsat2/ParseUtils.h
+abc-build/src/sat/bsat2/pstdint.h
+abc-build/src/sat/bsat2/Queue.h
+abc-build/src/sat/bsat2/README
+abc-build/src/sat/bsat2/ReleaseNotes-2.2.0.txt
+abc-build/src/sat/bsat2/SimpSolver.cpp
+abc-build/src/sat/bsat2/SimpSolver.h
+abc-build/src/sat/bsat2/Solver.cpp
+abc-build/src/sat/bsat2/Solver.h
+abc-build/src/sat/bsat2/SolverTypes.h
+abc-build/src/sat/bsat2/Sort.h
+abc-build/src/sat/bsat2/System.cpp
+abc-build/src/sat/bsat2/System.h
+abc-build/src/sat/bsat2/Vec.h
+abc-build/src/sat/bsat2/XAlloc.h
 abc-build/src/sat/cnf/cnf.h
 abc-build/src/sat/cnf/cnf_.c
 abc-build/src/sat/cnf/cnfCore.c
diff --git a/abc-build/abcexe.dsp b/abc-build/abcexe.dsp
--- a/abc-build/abcexe.dsp
+++ b/abc-build/abcexe.dsp
@@ -42,7 +42,7 @@
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "src" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D ABC_DLL=ABC_DLLEXPORT /D "_CRT_SECURE_NO_DEPRECATE" /FR /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "src" /D "WIN32" /D "WINDOWS" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D ABC_DLL=ABC_DLLEXPORT /D "_CRT_SECURE_NO_DEPRECATE" /D "ABC_USE_PTHREADS" /FR /YX /FD /c
 # ADD BASE RSC /l 0x409 /d "NDEBUG"
 # ADD RSC /l 0x409 /d "NDEBUG"
 BSC32=bscmake.exe
@@ -50,7 +50,7 @@
 # ADD BSC32 /nologo
 LINK32=link.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib lib\abcr.lib lib\x86\pthreadVC2.lib /nologo /subsystem:console /incremental:yes /debug /machine:I386 /out:"_TEST/abc.exe"
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib lib\x86\pthreadVC2.lib /nologo /subsystem:console /incremental:yes /debug /machine:I386 /out:"_TEST/abc.exe"
 # SUBTRACT LINK32 /profile
 
 !ELSEIF  "$(CFG)" == "abcexe - Win32 Debug"
@@ -67,7 +67,7 @@
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "src" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D ABC_DLL=ABC_DLLEXPORT /D "_CRT_SECURE_NO_DEPRECATE" /FR /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "src" /D "WIN32" /D "WINDOWS" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D ABC_DLL=ABC_DLLEXPORT /D "_CRT_SECURE_NO_DEPRECATE" /D "ABC_USE_PTHREADS" /FR /YX /FD /GZ /c
 # ADD BASE RSC /l 0x409 /d "_DEBUG"
 # ADD RSC /l 0x409 /d "_DEBUG"
 BSC32=bscmake.exe
@@ -75,7 +75,7 @@
 # ADD BSC32 /nologo
 LINK32=link.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib lib\abcd.lib lib\x86\pthreadVC2.lib /nologo /subsystem:console /debug /machine:I386 /out:"_TEST/abc.exe"
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib lib\x86\pthreadVC2.lib /nologo /subsystem:console /debug /machine:I386 /out:"_TEST/abc.exe"
 
 !ENDIF 
 
diff --git a/abc-build/abclib.dsp b/abc-build/abclib.dsp
--- a/abc-build/abclib.dsp
+++ b/abc-build/abclib.dsp
@@ -41,7 +41,7 @@
 # PROP Intermediate_Dir "ReleaseLib"
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "src" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D ABC_DLL=ABC_DLLEXPORT /D "_CRT_SECURE_NO_DEPRECATE" /FR /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "src" /D "WIN32" /D "WINDOWS" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D ABC_DLL=ABC_DLLEXPORT /D "_CRT_SECURE_NO_DEPRECATE" /D "ABC_USE_PTHREADS" /FR /YX /FD /c
 # ADD BASE RSC /l 0x409 /d "NDEBUG"
 # ADD RSC /l 0x409 /d "NDEBUG"
 BSC32=bscmake.exe
@@ -64,7 +64,7 @@
 # PROP Intermediate_Dir "DebugLib"
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "src" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D ABC_DLL=ABC_DLLEXPORT /D "_CRT_SECURE_NO_DEPRECATE" /FR /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "src" /D "WIN32" /D "WINDOWS" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D ABC_DLL=ABC_DLLEXPORT /D "_CRT_SECURE_NO_DEPRECATE" /D "ABC_USE_PTHREADS" /FR /YX /FD /GZ /c
 # ADD BASE RSC /l 0x409 /d "_DEBUG"
 # ADD RSC /l 0x409 /d "_DEBUG"
 BSC32=bscmake.exe
@@ -135,6 +135,10 @@
 # End Source File
 # Begin Source File
 
+SOURCE=.\src\base\abc\abcHieGia.c
+# End Source File
+# Begin Source File
+
 SOURCE=.\src\base\abc\abcHieNew.c
 # End Source File
 # Begin Source File
@@ -691,6 +695,10 @@
 # End Source File
 # Begin Source File
 
+SOURCE=.\src\base\main\mainReal.c
+# End Source File
+# Begin Source File
+
 SOURCE=.\src\base\main\mainUtils.c
 # End Source File
 # End Group
@@ -726,22 +734,6 @@
 SOURCE=.\src\base\test\test.c
 # End Source File
 # End Group
-# Begin Group "abc2"
-
-# PROP Default_Filter ""
-# End Group
-# Begin Group "abc2d"
-
-# PROP Default_Filter ""
-# End Group
-# Begin Group "pcm"
-
-# PROP Default_Filter ""
-# End Group
-# Begin Group "ply"
-
-# PROP Default_Filter ""
-# End Group
 # Begin Group "wlc"
 
 # PROP Default_Filter ""
@@ -755,6 +747,10 @@
 # End Source File
 # Begin Source File
 
+SOURCE=.\src\base\wlc\wlcAbs.c
+# End Source File
+# Begin Source File
+
 SOURCE=.\src\base\wlc\wlcBlast.c
 # End Source File
 # Begin Source File
@@ -767,6 +763,10 @@
 # End Source File
 # Begin Source File
 
+SOURCE=.\src\base\wlc\wlcReadSmt.c
+# End Source File
+# Begin Source File
+
 SOURCE=.\src\base\wlc\wlcReadVer.c
 # End Source File
 # Begin Source File
@@ -774,7 +774,79 @@
 SOURCE=.\src\base\wlc\wlcWriteVer.c
 # End Source File
 # End Group
+# Begin Group "cba"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\src\base\cba\cba.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\base\cba\cbaBlast.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\base\cba\cbaCba.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\base\cba\cbaCom.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\base\cba\cbaLib.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\base\cba\cbaNtk.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\base\cba\cbaPrs.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\base\cba\cbaPrsBuild.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\base\cba\cbaPrsTrans.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\base\cba\cbaPtr.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\base\cba\cbaPtrAbc.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\base\cba\cbaReadBlif.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\base\cba\cbaReadSmt.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\base\cba\cbaReadVer.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\base\cba\cbaWriteBlif.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\base\cba\cbaWriteSmt.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\base\cba\cbaWriteVer.c
+# End Source File
 # End Group
+# End Group
 # Begin Group "bdd"
 
 # PROP Default_Filter ""
@@ -1491,6 +1563,10 @@
 # End Source File
 # Begin Source File
 
+SOURCE=.\src\sat\bmc\bmcChain.c
+# End Source File
+# Begin Source File
+
 SOURCE=.\src\sat\bmc\bmcEco.c
 # End Source File
 # Begin Source File
@@ -1522,7 +1598,11 @@
 SOURCE=.\src\sat\bmc\bmcUnroll.c
 # End Source File
 # End Group
+# Begin Group "bsat2"
+
+# PROP Default_Filter ""
 # End Group
+# End Group
 # Begin Group "opt"
 
 # PROP Default_Filter ""
@@ -2795,6 +2875,10 @@
 # End Source File
 # Begin Source File
 
+SOURCE=.\src\misc\extra\extraUtilThresh.c
+# End Source File
+# Begin Source File
+
 SOURCE=.\src\misc\extra\extraUtilTruth.c
 # End Source File
 # Begin Source File
@@ -2991,6 +3075,10 @@
 # End Source File
 # Begin Source File
 
+SOURCE=.\src\misc\util\utilIsop.c
+# End Source File
+# Begin Source File
+
 SOURCE=.\src\misc\util\utilMem.c
 # End Source File
 # Begin Source File
@@ -3811,6 +3899,10 @@
 # End Source File
 # Begin Source File
 
+SOURCE=.\src\aig\gia\giaFadds.c
+# End Source File
+# Begin Source File
+
 SOURCE=.\src\aig\gia\giaFalse.c
 # End Source File
 # Begin Source File
@@ -3908,6 +4000,14 @@
 # Begin Source File
 
 SOURCE=.\src\aig\gia\giaPat.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\gia\giaPf.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\aig\gia\giaQbf.c
 # End Source File
 # Begin Source File
 
diff --git a/abc-build/galois-abcBridge.version b/abc-build/galois-abcBridge.version
--- a/abc-build/galois-abcBridge.version
+++ b/abc-build/galois-abcBridge.version
@@ -1,1 +1,1 @@
-0.12
+0.14
diff --git a/abc-build/src/aig/aig/aigMem.c b/abc-build/src/aig/aig/aigMem.c
--- a/abc-build/src/aig/aig/aigMem.c
+++ b/abc-build/src/aig/aig/aigMem.c
@@ -365,7 +365,11 @@
 ***********************************************************************/
 char * Aig_MmFlexEntryFetch( Aig_MmFlex_t * p, int nBytes )
 {
-    char * pTemp;
+    char * pTemp;
+#ifdef ABC_MEMALIGN
+    // extend size to max alignment
+    nBytes += (ABC_MEMALIGN - nBytes % ABC_MEMALIGN) % ABC_MEMALIGN;
+#endif
     // check if there are still free entries
     if ( p->pCurrent == NULL || p->pCurrent + nBytes > p->pEnd )
     { // need to allocate more entries
@@ -534,7 +538,11 @@
 char * Aig_MmStepEntryFetch( Aig_MmStep_t * p, int nBytes )
 {
     if ( nBytes == 0 )
-        return NULL;
+        return NULL;
+#ifdef ABC_MEMALIGN
+    // extend size to max alignment
+    nBytes += (ABC_MEMALIGN - nBytes % ABC_MEMALIGN) % ABC_MEMALIGN;
+#endif
     if ( nBytes > p->nMapSize )
     {
         if ( p->nChunks == p->nChunksAlloc )
@@ -564,6 +572,10 @@
 {
     if ( nBytes == 0 )
         return;
+#ifdef ABC_MEMALIGN
+    // extend size to max alignment
+    nBytes += (ABC_MEMALIGN - nBytes % ABC_MEMALIGN) % ABC_MEMALIGN;
+#endif
     if ( nBytes > p->nMapSize )
     {
 //        ABC_FREE( pEntry );
diff --git a/abc-build/src/aig/gia/gia.h b/abc-build/src/aig/gia/gia.h
--- a/abc-build/src/aig/gia/gia.h
+++ b/abc-build/src/aig/gia/gia.h
@@ -135,13 +135,15 @@
     Abc_Cex_t *    pCexComb;      // combinational counter-example
     Abc_Cex_t *    pCexSeq;       // sequential counter-example
     Vec_Ptr_t *    vSeqModelVec;  // sequential counter-examples
-    int *          pCopies;       // intermediate copies
+    Vec_Int_t      vCopies;       // intermediate copies
     Vec_Int_t *    vTruths;       // used for truth table computation
     Vec_Int_t *    vFlopClasses;  // classes of flops for retiming/merging/etc
     Vec_Int_t *    vGateClasses;  // classes of gates for abstraction
     Vec_Int_t *    vObjClasses;   // classes of objects for abstraction
     Vec_Int_t *    vInitClasses;  // classes of flops for retiming/merging/etc
+    Vec_Int_t *    vRegClasses;   // classes of registers for sequential synthesis
     Vec_Int_t *    vDoms;         // dominators
+    Vec_Int_t *    vBarBufs;      // barrier buffers
     unsigned char* pSwitching;    // switching activity for each object
     Gia_Plc_t *    pPlacement;    // placement of the objects
     Gia_Man_t *    pAigExtra;     // combinational logic of holes
@@ -188,7 +190,6 @@
     Vec_Int_t *    vStore;        // node storage  
 };
 
-
 
 typedef struct Gps_Par_t_ Gps_Par_t;
 struct Gps_Par_t_
@@ -246,6 +247,20 @@
     int            iOutFail;      // index of the failed output
 };
 
+typedef struct Gia_ManSim_t_ Gia_ManSim_t;
+struct Gia_ManSim_t_
+{
+    Gia_Man_t *    pAig;
+    Gia_ParSim_t * pPars; 
+    int            nWords;
+    Vec_Int_t *    vCis2Ids;
+    Vec_Int_t *    vConsts;
+    // simulation information
+    unsigned *     pDataSim;     // simulation data
+    unsigned *     pDataSimCis;  // simulation data for CIs
+    unsigned *     pDataSimCos;  // simulation data for COs
+};
+
 typedef struct Jf_Par_t_ Jf_Par_t; 
 struct Jf_Par_t_
 {
@@ -260,6 +275,7 @@
     int            nVerbLimit;
     int            DelayTarget;
     int            fAreaOnly;
+    int            fPinPerm;
     int            fOptEdge;
     int            fUseMux7;
     int            fPower;
@@ -375,6 +391,7 @@
 static inline int          Gia_ManXorNum( Gia_Man_t * p )      { return p->nXors;                                                          }
 static inline int          Gia_ManMuxNum( Gia_Man_t * p )      { return p->nMuxes;                                                         }
 static inline int          Gia_ManBufNum( Gia_Man_t * p )      { return p->nBufs;                                                          }
+static inline int          Gia_ManAndNotBufNum( Gia_Man_t * p ){ return Gia_ManAndNum(p) - Gia_ManBufNum(p);                               }
 static inline int          Gia_ManCandNum( Gia_Man_t * p )     { return Gia_ManCiNum(p) + Gia_ManAndNum(p);                                }
 static inline int          Gia_ManConstrNum( Gia_Man_t * p )   { return p->nConstrs;                                                       }
 static inline void         Gia_ManFlipVerbose( Gia_Man_t * p ) { p->fVerbose ^= 1;                                                         } 
@@ -408,7 +425,8 @@
 static inline int          Gia_ObjIsMuxId( Gia_Man_t * p, int iObj )           { return p->pMuxes && p->pMuxes[iObj] > 0;        } 
 static inline int          Gia_ObjIsMux( Gia_Man_t * p, Gia_Obj_t * pObj )     { return Gia_ObjIsMuxId( p, Gia_ObjId(p, pObj) ); } 
 static inline int          Gia_ObjIsAndReal( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Gia_ObjIsAnd(pObj) && pObj->iDiff0 > pObj->iDiff1 && !Gia_ObjIsMux(p, pObj); } 
-static inline int          Gia_ObjIsBuf( Gia_Obj_t * pObj )                    { return pObj->iDiff0 == pObj->iDiff1 && pObj->iDiff0 != GIA_NONE; } 
+static inline int          Gia_ObjIsBuf( Gia_Obj_t * pObj )                    { return pObj->iDiff0 == pObj->iDiff1 && pObj->iDiff0 != GIA_NONE && !pObj->fTerm;    } 
+static inline int          Gia_ObjIsAndNotBuf( Gia_Obj_t * pObj )              { return Gia_ObjIsAnd(pObj) && pObj->iDiff0 != pObj->iDiff1; } 
 static inline int          Gia_ObjIsCand( Gia_Obj_t * pObj )                   { return Gia_ObjIsAnd(pObj) || Gia_ObjIsCi(pObj); } 
 static inline int          Gia_ObjIsConst0( Gia_Obj_t * pObj )                 { return pObj->iDiff0 == GIA_NONE && pObj->iDiff1 == GIA_NONE;     } 
 static inline int          Gia_ManObjIsConst0( Gia_Man_t * p, Gia_Obj_t * pObj){ return pObj == p->pObjs;                        } 
@@ -465,11 +483,16 @@
 static inline int          Gia_ObjFanin1Copy( Gia_Obj_t * pObj )               { return Abc_LitNotCond( Gia_ObjFanin1(pObj)->Value, Gia_ObjFaninC1(pObj) );     }
 static inline int          Gia_ObjFanin2Copy( Gia_Man_t * p, Gia_Obj_t * pObj ){ return Abc_LitNotCond(Gia_ObjFanin2(p, pObj)->Value, Gia_ObjFaninC2(p, pObj)); }
 
-static inline int          Gia_ObjCopyF( Gia_Man_t * p, int f, Gia_Obj_t * pObj )               { return p->pCopies[Gia_ManObjNum(p) * f + Gia_ObjId(p,pObj)];  }
-static inline void         Gia_ObjSetCopyF( Gia_Man_t * p, int f, Gia_Obj_t * pObj, int iLit )  { p->pCopies[Gia_ManObjNum(p) * f + Gia_ObjId(p,pObj)] = iLit;  }
+static inline int          Gia_ObjCopyF( Gia_Man_t * p, int f, Gia_Obj_t * pObj )               { return Vec_IntEntry(&p->vCopies, Gia_ManObjNum(p) * f + Gia_ObjId(p,pObj));      }
+static inline void         Gia_ObjSetCopyF( Gia_Man_t * p, int f, Gia_Obj_t * pObj, int iLit )  { Vec_IntWriteEntry(&p->vCopies, Gia_ManObjNum(p) * f + Gia_ObjId(p,pObj), iLit);  }
+static inline int          Gia_ObjCopyArray( Gia_Man_t * p, int iObj )                          { return Vec_IntEntry(&p->vCopies, iObj);                                          }
+static inline void         Gia_ObjSetCopyArray( Gia_Man_t * p, int iObj, int iLit )             { Vec_IntWriteEntry(&p->vCopies, iObj, iLit);                                      }
+static inline void         Gia_ManCleanCopyArray( Gia_Man_t * p )                               { Vec_IntFill( &p->vCopies, Gia_ManObjNum(p), -1 );                                }
 
-static inline int          Gia_ObjFanin0CopyF( Gia_Man_t * p, int f, Gia_Obj_t * pObj )         { return Abc_LitNotCond(Gia_ObjCopyF(p, f, Gia_ObjFanin0(pObj)), Gia_ObjFaninC0(pObj));  }
-static inline int          Gia_ObjFanin1CopyF( Gia_Man_t * p, int f, Gia_Obj_t * pObj )         { return Abc_LitNotCond(Gia_ObjCopyF(p, f, Gia_ObjFanin1(pObj)), Gia_ObjFaninC1(pObj));  }
+static inline int          Gia_ObjFanin0CopyF( Gia_Man_t * p, int f, Gia_Obj_t * pObj )         { return Abc_LitNotCond(Gia_ObjCopyF(p, f, Gia_ObjFanin0(pObj)), Gia_ObjFaninC0(pObj));   }
+static inline int          Gia_ObjFanin1CopyF( Gia_Man_t * p, int f, Gia_Obj_t * pObj )         { return Abc_LitNotCond(Gia_ObjCopyF(p, f, Gia_ObjFanin1(pObj)), Gia_ObjFaninC1(pObj));   }
+static inline int          Gia_ObjFanin0CopyArray( Gia_Man_t * p, Gia_Obj_t * pObj )            { return Abc_LitNotCond(Gia_ObjCopyArray(p, Gia_ObjFaninId0p(p,pObj)), Gia_ObjFaninC0(pObj));  }
+static inline int          Gia_ObjFanin1CopyArray( Gia_Man_t * p, Gia_Obj_t * pObj )            { return Abc_LitNotCond(Gia_ObjCopyArray(p, Gia_ObjFaninId1p(p,pObj)), Gia_ObjFaninC1(pObj));  }
 
 static inline Gia_Obj_t *  Gia_ObjFromLit( Gia_Man_t * p, int iLit )           { return Gia_NotCond( Gia_ManObj(p, Abc_Lit2Var(iLit)), Abc_LitIsCompl(iLit) );  }
 static inline int          Gia_ObjToLit( Gia_Man_t * p, Gia_Obj_t * pObj )     { return Abc_Var2Lit( Gia_ObjId(p, Gia_Regular(pObj)), Gia_IsComplement(pObj) ); }
@@ -480,10 +503,11 @@
 static inline void         Gia_ObjSetLevelId( Gia_Man_t * p, int Id, int l )   { Vec_IntSetEntry(p->vLevels, Id, l);                        }
 static inline void         Gia_ObjSetLevel( Gia_Man_t * p, Gia_Obj_t * pObj, int l )  { Gia_ObjSetLevelId( p, Gia_ObjId(p,pObj), l );       }
 static inline void         Gia_ObjSetCoLevel( Gia_Man_t * p, Gia_Obj_t * pObj )  { assert( Gia_ObjIsCo(pObj)  ); Gia_ObjSetLevel( p, pObj, Gia_ObjLevel(p,Gia_ObjFanin0(pObj)) );                                                }
+static inline void         Gia_ObjSetBufLevel( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( Gia_ObjIsAnd(pObj) ); Gia_ObjSetLevel( p, pObj, Gia_ObjLevel(p,Gia_ObjFanin0(pObj)) );                                                }
 static inline void         Gia_ObjSetAndLevel( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( Gia_ObjIsAnd(pObj) ); Gia_ObjSetLevel( p, pObj, 1+Abc_MaxInt(Gia_ObjLevel(p,Gia_ObjFanin0(pObj)),Gia_ObjLevel(p,Gia_ObjFanin1(pObj))) ); }
 static inline void         Gia_ObjSetXorLevel( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( Gia_ObjIsXor(pObj) ); Gia_ObjSetLevel( p, pObj, 2+Abc_MaxInt(Gia_ObjLevel(p,Gia_ObjFanin0(pObj)),Gia_ObjLevel(p,Gia_ObjFanin1(pObj))) ); }
 static inline void         Gia_ObjSetMuxLevel( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( Gia_ObjIsMux(p,pObj) ); Gia_ObjSetLevel( p, pObj, 2+Abc_MaxInt( Abc_MaxInt(Gia_ObjLevel(p,Gia_ObjFanin0(pObj)),Gia_ObjLevel(p,Gia_ObjFanin1(pObj))), Gia_ObjLevel(p,Gia_ObjFanin2(p,pObj))) ); }
-static inline void         Gia_ObjSetGateLevel( Gia_Man_t * p, Gia_Obj_t * pObj ){ if ( Gia_ObjIsMux(p,pObj) ) Gia_ObjSetMuxLevel(p, pObj); else if ( Gia_ObjIsXor(pObj) ) Gia_ObjSetXorLevel(p, pObj); else if ( Gia_ObjIsAnd(pObj) ) Gia_ObjSetAndLevel(p, pObj); }
+static inline void         Gia_ObjSetGateLevel( Gia_Man_t * p, Gia_Obj_t * pObj ){ if ( Gia_ObjIsBuf(pObj) ) Gia_ObjSetBufLevel(p, pObj); else if ( Gia_ObjIsMux(p,pObj) ) Gia_ObjSetMuxLevel(p, pObj); else if ( Gia_ObjIsXor(pObj) ) Gia_ObjSetXorLevel(p, pObj); else if ( Gia_ObjIsAnd(pObj) ) Gia_ObjSetAndLevel(p, pObj); }
 
 static inline int          Gia_ObjHasNumId( Gia_Man_t * p, int Id )                { return Vec_IntEntry(p->vTtNums, Id) > -ABC_INFINITY;     }
 static inline int          Gia_ObjNumId( Gia_Man_t * p, int Id )                   { return Vec_IntEntry(p->vTtNums, Id);                     }
@@ -701,7 +725,14 @@
     int iTemp0 = Gia_ManAppendAnd( p, Abc_LitNot(iCtrl), iData0 );
     int iTemp1 = Gia_ManAppendAnd( p, iCtrl, iData1 );
     return Abc_LitNotCond( Gia_ManAppendAnd( p, Abc_LitNot(iTemp0), Abc_LitNot(iTemp1) ), 1 );
-}
+}
+static inline int Gia_ManAppendMaj( Gia_Man_t * p, int iData0, int iData1, int iData2 )  
+{ 
+    int iTemp0 = Gia_ManAppendOr( p, iData1, iData2 );
+    int iTemp1 = Gia_ManAppendAnd( p, iData0, iTemp0 );
+    int iTemp2 = Gia_ManAppendAnd( p, iData1, iData2 );
+    return Gia_ManAppendOr( p, iTemp1, iTemp2 );
+}
 static inline int Gia_ManAppendXor( Gia_Man_t * p, int iLit0, int iLit1 )  
 { 
     return Gia_ManAppendMux( p, iLit0, Abc_LitNot(iLit1), iLit1 );
@@ -923,10 +954,13 @@
 static inline int         Gia_ObjLutSize( Gia_Man_t * p, int Id )           { return Vec_IntEntry(p->vMapping, Vec_IntEntry(p->vMapping, Id));              }
 static inline int *       Gia_ObjLutFanins( Gia_Man_t * p, int Id )         { return Vec_IntEntryP(p->vMapping, Vec_IntEntry(p->vMapping, Id)) + 1;         }
 static inline int         Gia_ObjLutFanin( Gia_Man_t * p, int Id, int i )   { return Gia_ObjLutFanins(p, Id)[i];                                            }
-static inline int         Gia_ObjLutIsMux( Gia_Man_t * p, int Id )          { return (int)(Gia_ObjLutFanins(p, Id)[Gia_ObjLutSize(p, Id)] == -Id);          }
+static inline int         Gia_ObjLutMuxId( Gia_Man_t * p, int Id )          { return Gia_ObjLutFanins(p, Id)[Gia_ObjLutSize(p, Id)];                        }
+static inline int         Gia_ObjLutIsMux( Gia_Man_t * p, int Id )          { return (int)(Gia_ObjLutMuxId(p, Id) < 0);                                     }
 
 static inline int         Gia_ManHasCellMapping( Gia_Man_t * p )            { return p->vCellMapping != NULL;                                               }
 static inline int         Gia_ObjIsCell( Gia_Man_t * p, int iLit )          { return Vec_IntEntry(p->vCellMapping, iLit) != 0;                              }
+static inline int         Gia_ObjIsCellInv( Gia_Man_t * p, int iLit )       { return Vec_IntEntry(p->vCellMapping, iLit) == -1;                             }
+static inline int         Gia_ObjIsCellBuf( Gia_Man_t * p, int iLit )       { return Vec_IntEntry(p->vCellMapping, iLit) == -2;                             }
 static inline int         Gia_ObjCellSize( Gia_Man_t * p, int iLit )        { return Vec_IntEntry(p->vCellMapping, Vec_IntEntry(p->vCellMapping, iLit));    }
 static inline int *       Gia_ObjCellFanins( Gia_Man_t * p, int iLit )      { return Vec_IntEntryP(p->vCellMapping, Vec_IntEntry(p->vCellMapping, iLit))+1; }
 static inline int         Gia_ObjCellFanin( Gia_Man_t * p, int iLit, int i ){ return Gia_ObjCellFanins(p, iLit)[i];                                         }
@@ -962,6 +996,10 @@
     for ( i = p->nObjs - 1; (i >= 0) && ((pObj) = Gia_ManObj(p, i)); i-- )
 #define Gia_ManForEachObjReverse1( p, pObj, i )                         \
     for ( i = p->nObjs - 1; (i > 0) && ((pObj) = Gia_ManObj(p, i)); i-- )
+#define Gia_ManForEachBuf( p, pObj, i )                                 \
+    for ( i = Gia_ManBufNum(p) ? 0 : p->nObjs; (i < p->nObjs) && ((pObj) = Gia_ManObj(p, i)); i++ )      if ( !Gia_ObjIsBuf(pObj) ) {} else
+#define Gia_ManForEachBufId( p, i )                                     \
+    for ( i = 0; (i < p->nObjs); i++ )                                     if ( !Gia_ObjIsBuf(Gia_ManObj(p, i)) ) {} else
 #define Gia_ManForEachAnd( p, pObj, i )                                 \
     for ( i = 0; (i < p->nObjs) && ((pObj) = Gia_ManObj(p, i)); i++ )      if ( !Gia_ObjIsAnd(pObj) ) {} else
 #define Gia_ManForEachAndId( p, i )                                     \
@@ -1062,6 +1100,7 @@
 extern Gia_Man_t *         Gia_ManDupOrderDfsReverse( Gia_Man_t * p );
 extern Gia_Man_t *         Gia_ManDupOutputGroup( Gia_Man_t * p, int iOutStart, int iOutStop );
 extern Gia_Man_t *         Gia_ManDupOutputVec( Gia_Man_t * p, Vec_Int_t * vOutPres );
+extern Gia_Man_t *         Gia_ManDupSelectedOutputs( Gia_Man_t * p, Vec_Int_t * vOutsLeft );
 extern Gia_Man_t *         Gia_ManDupOrderAiger( Gia_Man_t * p );
 extern Gia_Man_t *         Gia_ManDupLastPis( Gia_Man_t * p, int nLastPis );
 extern Gia_Man_t *         Gia_ManDupFlip( Gia_Man_t * p, int * pInitState );
@@ -1099,6 +1138,7 @@
 extern Gia_Man_t *         Gia_ManDupZeroUndc( Gia_Man_t * p, char * pInit, int fVerbose );
 extern Gia_Man_t *         Gia_ManMiter2( Gia_Man_t * p, char * pInit, int fVerbose );
 extern Gia_Man_t *         Gia_ManTransformMiter( Gia_Man_t * p );
+extern Gia_Man_t *         Gia_ManTransformToDual( Gia_Man_t * p );
 extern Gia_Man_t *         Gia_ManChoiceMiter( Vec_Ptr_t * vGias );
 extern Gia_Man_t *         Gia_ManDupWithConstraints( Gia_Man_t * p, Vec_Int_t * vPoTypes );
 extern Gia_Man_t *         Gia_ManDupCones( Gia_Man_t * p, int * pPos, int nPos, int fTrimPis );
@@ -1133,7 +1173,7 @@
 extern int                 Gia_ManCountChoices( Gia_Man_t * p );
 extern int                 Gia_ManFilterEquivsForSpeculation( Gia_Man_t * pGia, char * pName1, char * pName2, int fLatchA, int fLatchB );
 extern int                 Gia_ManFilterEquivsUsingParts( Gia_Man_t * pGia, char * pName1, char * pName2 );
-extern void                Gia_ManFilterEquivsUsingLatches( Gia_Man_t * pGia, int fFlopsOnly, int fFlopsWith );
+extern void                Gia_ManFilterEquivsUsingLatches( Gia_Man_t * pGia, int fFlopsOnly, int fFlopsWith, int fUseRiDrivers );
 /*=== giaFanout.c =========================================================*/
 extern void                Gia_ObjAddFanout( Gia_Man_t * p, Gia_Obj_t * pObj, Gia_Obj_t * pFanout );
 extern void                Gia_ObjRemoveFanout( Gia_Man_t * p, Gia_Obj_t * pObj, Gia_Obj_t * pFanout );
@@ -1168,6 +1208,7 @@
 extern int                 Gia_ManHashOr( Gia_Man_t * p, int iLit0, int iLit1 ); 
 extern int                 Gia_ManHashXor( Gia_Man_t * p, int iLit0, int iLit1 ); 
 extern int                 Gia_ManHashMux( Gia_Man_t * p, int iCtrl, int iData1, int iData0 );
+extern int                 Gia_ManHashMaj( Gia_Man_t * p, int iData0, int iData1, int iData2 );
 extern int                 Gia_ManHashAndTry( Gia_Man_t * p, int iLit0, int iLit1 );
 extern Gia_Man_t *         Gia_ManRehash( Gia_Man_t * p, int fAddStrash );
 extern void                Gia_ManHashProfile( Gia_Man_t * p );
@@ -1271,7 +1312,13 @@
 extern int *               Gia_SortFloats( float * pArray, int * pPerm, int nSize );
 /*=== giaSim.c ============================================================*/
 extern void                Gia_ManSimSetDefaultParams( Gia_ParSim_t * p );
-extern int                 Gia_ManSimSimulate( Gia_Man_t * pAig, Gia_ParSim_t * pPars );
+extern int                 Gia_ManSimSimulate( Gia_Man_t * pAig, Gia_ParSim_t * pPars );
+extern unsigned *          Gia_SimDataExt( Gia_ManSim_t * p, int i );
+extern unsigned *          Gia_SimDataCiExt( Gia_ManSim_t * p, int i );
+extern unsigned *          Gia_SimDataCoExt( Gia_ManSim_t * p, int i );
+extern void                Gia_ManSimInfoInit( Gia_ManSim_t * p );
+extern void                Gia_ManSimInfoTransfer( Gia_ManSim_t * p );
+extern void                Gia_ManSimulateRound( Gia_ManSim_t * p );
 /*=== giaSpeedup.c ============================================================*/
 extern float               Gia_ManDelayTraceLut( Gia_Man_t * p );
 extern float               Gia_ManDelayTraceLutPrint( Gia_Man_t * p, int fVerbose );
@@ -1280,7 +1327,9 @@
 extern void                Gia_ManStgPrint( FILE * pFile, Vec_Int_t * vLines, int nIns, int nOuts, int nStates );
 extern Gia_Man_t *         Gia_ManStgRead( char * pFileName, int kHot, int fVerbose );
 /*=== giaSweep.c ============================================================*/
-extern Gia_Man_t *         Gia_ManFraigSweep( Gia_Man_t * p, void * pPars );
+extern Gia_Man_t *         Gia_ManFraigSweepSimple( Gia_Man_t * p, void * pPars );
+extern Gia_Man_t *         Gia_ManSweepWithBoxes( Gia_Man_t * p, void * pParsC, void * pParsS, int fConst, int fEquiv, int fVerbose );
+extern void                Gia_ManCheckIntegrityWithBoxes( Gia_Man_t * p );
 /*=== giaSweeper.c ============================================================*/
 extern Gia_Man_t *         Gia_SweeperStart( Gia_Man_t * p );
 extern void                Gia_SweeperStop( Gia_Man_t * p );
@@ -1311,14 +1360,25 @@
 extern Vec_Int_t *         Gia_ManComputeSwitchProbs( Gia_Man_t * pGia, int nFrames, int nPref, int fProbOne );
 extern Vec_Flt_t *         Gia_ManPrintOutputProb( Gia_Man_t * p );
 /*=== giaTim.c ===========================================================*/
+extern int                 Gia_ManBoxNum( Gia_Man_t * p );
+extern int                 Gia_ManRegBoxNum( Gia_Man_t * p );
+extern int                 Gia_ManNonRegBoxNum( Gia_Man_t * p );
+extern int                 Gia_ManBoxCiNum( Gia_Man_t * p );
+extern int                 Gia_ManBoxCoNum( Gia_Man_t * p );
+extern int                 Gia_ManClockDomainNum( Gia_Man_t * p );
+extern int                 Gia_ManIsSeqWithBoxes( Gia_Man_t * p );
+extern int                 Gia_ManIsNormalized( Gia_Man_t * p );
 extern Gia_Man_t *         Gia_ManDupNormalize( Gia_Man_t * p );
 extern Gia_Man_t *         Gia_ManDupUnnormalize( Gia_Man_t * p );
-extern Gia_Man_t *         Gia_ManDupCollapse( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t * vBoxPres );
+extern Gia_Man_t *         Gia_ManDupUnshuffleInputs( Gia_Man_t * p );
 extern int                 Gia_ManLevelWithBoxes( Gia_Man_t * p );
 extern int                 Gia_ManLutLevelWithBoxes( Gia_Man_t * p );
-extern int                 Gia_ManVerifyWithBoxes( Gia_Man_t * pGia, void * pParsInit );
 extern void *              Gia_ManUpdateTimMan( Gia_Man_t * p, Vec_Int_t * vBoxPres );
+extern void *              Gia_ManUpdateTimMan2( Gia_Man_t * p, Vec_Int_t * vBoxesLeft, int nTermsDiff );
 extern Gia_Man_t *         Gia_ManUpdateExtraAig( void * pTime, Gia_Man_t * pAig, Vec_Int_t * vBoxPres );
+extern Gia_Man_t *         Gia_ManUpdateExtraAig2( void * pTime, Gia_Man_t * pAig, Vec_Int_t * vBoxesLeft );
+extern Gia_Man_t *         Gia_ManDupCollapse( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t * vBoxPres, int fSeq );
+extern int                 Gia_ManVerifyWithBoxes( Gia_Man_t * pGia, int nBTLimit, int nTimeLim, int fSeq, int fVerbose, char * pFileSpec );
 /*=== giaTruth.c ===========================================================*/
 extern word                Gia_ObjComputeTruthTable6Lut( Gia_Man_t * p, int iObj, Vec_Wrd_t * vTemp );
 extern word                Gia_ObjComputeTruthTable6( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vSupp, Vec_Wrd_t * vTruths );
@@ -1362,7 +1422,6 @@
 extern void                Gia_ManCreateRefs( Gia_Man_t * p );
 extern int *               Gia_ManCreateMuxRefs( Gia_Man_t * p );
 extern int                 Gia_ManCrossCut( Gia_Man_t * p, int fReverse );
-extern int                 Gia_ManIsNormalized( Gia_Man_t * p );
 extern Vec_Int_t *         Gia_ManCollectPoIds( Gia_Man_t * p );
 extern int                 Gia_ObjIsMuxType( Gia_Obj_t * pNode );
 extern int                 Gia_ObjRecognizeExor( Gia_Obj_t * pObj, Gia_Obj_t ** ppFan0, Gia_Obj_t ** ppFan1 );
diff --git a/abc-build/src/aig/gia/giaAiger.c b/abc-build/src/aig/gia/giaAiger.c
--- a/abc-build/src/aig/gia/giaAiger.c
+++ b/abc-build/src/aig/gia/giaAiger.c
@@ -294,7 +294,12 @@
         iNode1 = Abc_LitNotCond( Vec_IntEntry(vNodes, uLit1 >> 1), uLit1 & 1 );
         assert( Vec_IntSize(vNodes) == i + 1 + nInputs + nLatches );
         if ( fSkipStrash )
-            Vec_IntPush( vNodes, Gia_ManAppendAnd(pNew, iNode0, iNode1) );
+        {
+            if ( iNode0 == iNode1 )
+                Vec_IntPush( vNodes, Gia_ManAppendBuf(pNew, iNode0) );
+            else
+                Vec_IntPush( vNodes, Gia_ManAppendAnd(pNew, iNode0, iNode1) );
+        }
         else
             Vec_IntPush( vNodes, Gia_ManHashAnd(pNew, iNode0, iNode1) );
     }
@@ -369,7 +374,7 @@
 
     // read signal names if they are of the special type
     pCur = pSymbols;
-    if ( *pCur != 'c' )
+    if ( pCur < (unsigned char *)pContents + nFileSize && *pCur != 'c' )
     {
         int fBreakUsed = 0;
         unsigned char * pCurOld = pCur;
@@ -652,6 +657,17 @@
                 pNew->pPlacement = pPlacement;
                 if ( fVerbose ) printf( "Finished reading extension \"p\".\n" );
             }
+            // read register classes
+            else if ( *pCur == 'r' )
+            {
+                int i, nRegs;
+                pCur++;
+                nRegs = Gia_AigerReadInt(pCur)/4;                       pCur += 4;
+                pNew->vRegClasses = Vec_IntAlloc( nRegs );
+                for ( i = 0; i < nRegs; i++ )
+                    Vec_IntPush( pNew->vRegClasses, Gia_AigerReadInt(pCur) ), pCur += 4;
+                if ( fVerbose ) printf( "Finished reading extension \"r\".\n" );
+            }
             // read choices
             else if ( *pCur == 'q' )
             {
@@ -742,9 +758,8 @@
     {
 //        Tim_ManPrint( (Tim_Man_t *)pNew->pManTime );
         if ( Abc_FrameReadLibBox() == NULL )
-            printf( "Cannot create TIM manager because box library is not available.\n" );
-        else
-            Tim_ManCreate( (Tim_Man_t *)pNew->pManTime, Abc_FrameReadLibBox(), pNew->vInArrs, pNew->vOutReqs );
+            printf( "Warning: Creating unit-delay box delay tables because box library is not available.\n" );
+        Tim_ManCreate( (Tim_Man_t *)pNew->pManTime, Abc_FrameReadLibBox(), pNew->vInArrs, pNew->vOutReqs );
     }
     Vec_FltFreeP( &pNew->vInArrs );
     Vec_FltFreeP( &pNew->vOutReqs );
@@ -1016,7 +1031,6 @@
     int i, nBufferSize, Pos;
     unsigned char * pBuffer;
     unsigned uLit0, uLit1, uLit;
-//    assert( Gia_ManIsNormalized(pInit) );
     assert( pInit->nXors == 0 && pInit->nMuxes == 0 );
 
     if ( Gia_ManCoNum(pInit) == 0 )
@@ -1090,7 +1104,7 @@
         uLit  = Abc_Var2Lit( i, 0 );
         uLit0 = Gia_ObjFaninLit0( pObj, i );
         uLit1 = Gia_ObjFaninLit1( pObj, i );
-        assert( uLit0 < uLit1 );
+        assert( Gia_ManBufNum(p) || uLit0 < uLit1 );
         Pos = Gia_AigerWriteUnsignedBuffer( pBuffer, Pos, uLit  - uLit1 );
         Pos = Gia_AigerWriteUnsignedBuffer( pBuffer, Pos, uLit1 - uLit0 );
         if ( Pos > nBufferSize - 10 )
@@ -1190,7 +1204,7 @@
         fprintf( pFile, "f" );
         Gia_FileWriteBufferSize( pFile, 4*Gia_ManRegNum(p) );
         assert( Vec_IntSize(p->vFlopClasses) == Gia_ManRegNum(p) );
-        fwrite( Vec_IntArray(p->vFlopClasses), 1, 4*Gia_ManRegNum(p), pFile );
+        fwrite( Vec_IntArray(p->vFlopClasses), 1, 4*Gia_ManRegNum(p), pFile );
     }
     // write gate classes
     if ( p->vGateClasses )
@@ -1240,6 +1254,15 @@
         fprintf( pFile, "p" );
         Gia_FileWriteBufferSize( pFile, 4*Gia_ManObjNum(p) );
         fwrite( p->pPlacement, 1, 4*Gia_ManObjNum(p), pFile );
+    }
+    // write register classes
+    if ( p->vRegClasses )
+    {
+        int i;
+        fprintf( pFile, "r" );
+        Gia_FileWriteBufferSize( pFile, 4*Vec_IntSize(p->vRegClasses) );
+        for ( i = 0; i < Vec_IntSize(p->vRegClasses); i++ )
+            Gia_FileWriteBufferSize( pFile, Vec_IntEntry(p->vRegClasses, i) );
     }
     // write choices
     if ( Gia_ManHasChoices(p) )
diff --git a/abc-build/src/aig/gia/giaBalAig.c b/abc-build/src/aig/gia/giaBalAig.c
--- a/abc-build/src/aig/gia/giaBalAig.c
+++ b/abc-build/src/aig/gia/giaBalAig.c
@@ -227,6 +227,7 @@
 }
 int Gia_ManBalanceGate( Gia_Man_t * pNew, Gia_Obj_t * pObj, Vec_Int_t * vSuper, int * pLits, int nLits )
 {
+    assert( !Gia_ObjIsBuf(pObj) );
     Vec_IntClear( vSuper );
     if ( nLits == 1 )
         Vec_IntPush( vSuper, pLits[0] );
@@ -280,6 +281,7 @@
     if ( ~pObj->Value )
         return;
     assert( Gia_ObjIsAnd(pObj) );
+    assert( !Gia_ObjIsBuf(pObj) );
     // handle MUX
     if ( Gia_ObjIsMux(p, pObj) )
     {
@@ -329,6 +331,12 @@
         pObj->Value = Gia_ManAppendCi( pNew );
     // create internal nodes
     Gia_ManHashStart( pNew );
+    Gia_ManForEachBuf( p, pObj, i )
+    {
+        Gia_ManBalance_rec( pNew, p, Gia_ObjFanin0(pObj) );
+        pObj->Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(pObj) );
+        Gia_ObjSetGateLevel( pNew, Gia_ManObj(pNew, Abc_Lit2Var(pObj->Value)) );
+    }
     Gia_ManForEachCo( p, pObj, i )
     {
         Gia_ManBalance_rec( pNew, p, Gia_ObjFanin0(pObj) );
@@ -428,6 +436,11 @@
     pObj = Gia_ManObj(p->pGia, Id);
     if ( Gia_ObjIsCi(pObj) )
         return;
+    if ( Gia_ObjIsBuf(pObj) )
+    {
+        Dam_ManCollectSets_rec( p, Gia_ObjFaninId0(pObj, Id) );
+        return;
+    }
     if ( Gia_ObjIsMux(p->pGia, pObj) )
     {
         if ( pObj->fMark0 )
@@ -714,12 +727,18 @@
     }
     // create internal nodes
     Gia_ManHashStart( pNew );
+    Gia_ManForEachBuf( p, pObj, i )
+    {
+        Dam_ManMultiAig_rec( pMan, pNew, p, Gia_ObjFanin0(pObj) );
+        pObj->Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(pObj) );
+        Gia_ObjSetGateLevel( pNew, Gia_ManObj(pNew, Abc_Lit2Var(pObj->Value)) );
+    }
     Gia_ManForEachCo( p, pObj, i )
     {
         Dam_ManMultiAig_rec( pMan, pNew, p, Gia_ObjFanin0(pObj) );
         pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
     }
-    assert( Gia_ManObjNum(pNew) <= Gia_ManObjNum(p) );
+//    assert( Gia_ManObjNum(pNew) <= Gia_ManObjNum(p) );
     Gia_ManHashStop( pNew );
     Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
     // perform cleanup
diff --git a/abc-build/src/aig/gia/giaClp.c b/abc-build/src/aig/gia/giaClp.c
--- a/abc-build/src/aig/gia/giaClp.c
+++ b/abc-build/src/aig/gia/giaClp.c
@@ -31,13 +31,48 @@
 extern int Abc_ConvertZddToSop( DdManager * dd, DdNode * zCover, char * pSop, int nFanins, Vec_Str_t * vCube, int fPhase );
 extern int Abc_CountZddCubes( DdManager * dd, DdNode * zCover );
 extern int Abc_NtkDeriveFlatGiaSop( Gia_Man_t * pGia, int * gFanins, char * pSop );
-extern Vec_Ptr_t * Abc_NodeGetFakeNames( int nNames );
 extern int Gia_ManFactorNode( Gia_Man_t * p, char * pSop, Vec_Int_t * vLeaves );
 
 ////////////////////////////////////////////////////////////////////////
 ///                     FUNCTION DEFINITIONS                         ///
-////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
 
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Vec_Ptr_t * Gia_GetFakeNames( int nNames )
+{
+    Vec_Ptr_t * vNames;
+    char Buffer[5];
+    int i;
+
+    vNames = Vec_PtrAlloc( nNames );
+    for ( i = 0; i < nNames; i++ )
+    {
+        if ( nNames < 26 )
+        {
+            Buffer[0] = 'a' + i;
+            Buffer[1] = 0;
+        }
+        else
+        {
+            Buffer[0] = 'a' + i%26;
+            Buffer[1] = '0' + i/26;
+            Buffer[2] = 0;
+        }
+        Vec_PtrPush( vNames, Extra_UtilStrsav(Buffer) );
+    }
+    return vNames;
+}
+
 /**Function*************************************************************
 
   Synopsis    []
@@ -338,8 +373,8 @@
     Dsd_Decompose( pManDsd, (DdNode **)Vec_PtrArray(vFuncs), Vec_PtrSize(vFuncs) );
     if ( fVerbose )
     {
-        Vec_Ptr_t * vNamesCi = Abc_NodeGetFakeNames( Gia_ManCiNum(p) );
-        Vec_Ptr_t * vNamesCo = Abc_NodeGetFakeNames( Gia_ManCoNum(p) );
+        Vec_Ptr_t * vNamesCi = Gia_GetFakeNames( Gia_ManCiNum(p) );
+        Vec_Ptr_t * vNamesCo = Gia_GetFakeNames( Gia_ManCoNum(p) );
         char ** ppNamesCi = (char **)Vec_PtrArray( vNamesCi );
         char ** ppNamesCo = (char **)Vec_PtrArray( vNamesCo );
         Dsd_TreePrint( stdout, pManDsd, ppNamesCi, ppNamesCo, 0, -1 );
diff --git a/abc-build/src/aig/gia/giaDup.c b/abc-build/src/aig/gia/giaDup.c
--- a/abc-build/src/aig/gia/giaDup.c
+++ b/abc-build/src/aig/gia/giaDup.c
@@ -251,6 +251,38 @@
             pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
     return pNew;
 }
+
+/**Function*************************************************************
+
+  Synopsis    [Duplicates AIG while putting objects in the DFS order.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManDupSelectedOutputs( Gia_Man_t * p, Vec_Int_t * vOutsLeft )
+{
+    Gia_Man_t * pNew;
+    Gia_Obj_t * pObj;
+    int i, iOut;
+    assert( Gia_ManRegNum(p) == 0 );
+    assert( Gia_ManPoNum(p) >= Vec_IntSize(vOutsLeft) );
+    Gia_ManFillValue( p );
+    pNew = Gia_ManStart( Gia_ManObjNum(p) );
+    pNew->pName = Abc_UtilStrsav( p->pName );
+    pNew->pSpec = Abc_UtilStrsav( p->pSpec );
+    Gia_ManConst0(p)->Value = 0;
+    Gia_ManForEachPi( p, pObj, i )
+        pObj->Value = Gia_ManAppendCi(pNew);
+    Vec_IntForEachEntry( vOutsLeft, iOut, i )
+        Gia_ManDupOrderDfs_rec( pNew, p, Gia_ObjFanin0(Gia_ManPo(p, iOut)) );
+    Vec_IntForEachEntry( vOutsLeft, iOut, i )
+        Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(Gia_ManPo(p, iOut)) );
+    return pNew;
+}
 
 /**Function*************************************************************
 
@@ -530,7 +562,9 @@
     Gia_ManConst0(p)->Value = 0;
     Gia_ManForEachObj1( p, pObj, i )
     {
-        if ( Gia_ObjIsAnd(pObj) )
+        if ( Gia_ObjIsBuf(pObj) )
+            pObj->Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(pObj) );
+        else if ( Gia_ObjIsAnd(pObj) )
         {
             pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
             if ( Gia_ObjSibl(p, Gia_ObjId(p, pObj)) )
@@ -957,11 +991,14 @@
     Gia_ManForEachObj1( p, pObj, i )
     {
         if ( pObj->fMark0 )
-        {
+        {
+            assert( !Gia_ObjIsBuf(pObj) );
             pObj->fMark0 = 0;
             continue;
         }
-        if ( Gia_ObjIsAnd(pObj) )
+        if ( Gia_ObjIsBuf(pObj) )
+            pObj->Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(pObj) );
+        else if ( Gia_ObjIsAnd(pObj) )
         {
             if ( Gia_ObjIsXor(pObj) )
                 pObj->Value = Gia_ManAppendXorReal( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
@@ -997,9 +1034,10 @@
                 continue;
             pRepr = Gia_ObjReprObj( p, i );
             if ( pRepr == NULL )
-                continue;
+                continue;
             if ( !~pRepr->Value )
                 continue;
+            assert( !Gia_ObjIsBuf(pObj) );
             if ( Abc_Lit2Var(pObj->Value) != Abc_Lit2Var(pRepr->Value) )
                 Gia_ObjSetRepr( pNew, Abc_Lit2Var(pObj->Value), Abc_Lit2Var(pRepr->Value) ); 
         }
@@ -1018,6 +1056,7 @@
                 continue;
             if ( !~pSibl->Value )
                 continue;
+            assert( !Gia_ObjIsBuf(pObj) );
             assert( Abc_Lit2Var(pObj->Value) > Abc_Lit2Var(pSibl->Value) );
             pNew->pSibls[Abc_Lit2Var(pObj->Value)] = Abc_Lit2Var(pSibl->Value);
         }
@@ -2311,6 +2350,31 @@
     Gia_ManStop( pTemp );
     return pNew;
 }
+Gia_Man_t * Gia_ManTransformToDual( Gia_Man_t * p )
+{
+    Gia_Man_t * pNew;
+    Gia_Obj_t * pObj;
+    int i;
+    pNew = Gia_ManStart( Gia_ManObjNum(p) );
+    pNew->pName = Abc_UtilStrsav( p->pName );
+    pNew->pSpec = Abc_UtilStrsav( p->pSpec );
+    Gia_ManConst0(p)->Value = 0;
+    Gia_ManHashAlloc( pNew );
+    Gia_ManForEachCi( p, pObj, i )
+        pObj->Value = Gia_ManAppendCi( pNew );
+    Gia_ManForEachAnd( p, pObj, i )
+        pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+    Gia_ManForEachPo( p, pObj, i )
+    {
+        Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+        Gia_ManAppendCo( pNew, 0 );
+    }
+    Gia_ManForEachRi( p, pObj, i )
+        pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+    Gia_ManHashStop( pNew );
+    Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+    return pNew;
+}
 
 /**Function*************************************************************
 
diff --git a/abc-build/src/aig/gia/giaEnable.c b/abc-build/src/aig/gia/giaEnable.c
--- a/abc-build/src/aig/gia/giaEnable.c
+++ b/abc-build/src/aig/gia/giaEnable.c
@@ -361,9 +361,8 @@
 {
     Gia_Man_t * pNew;
     Gia_Obj_t * pObj, * pObjRi, * pObjRo;
-    int f, i;
-    ABC_FREE( p->pCopies );
-    p->pCopies = ABC_FALLOC( int, nFrames * Gia_ManObjNum(p) );
+    int f, i;
+    Vec_IntFill( &p->vCopies, nFrames * Gia_ManObjNum(p), -1 );
     pNew = Gia_ManStart( nFrames * Gia_ManObjNum(p) );
     pNew->pName = Abc_UtilStrsav( p->pName );
     pNew->pSpec = Abc_UtilStrsav( p->pSpec );
@@ -412,8 +411,8 @@
     vCofSigs = Gia_ManDetectSeqSignalsWithFanout( p, nFanMax, fVerbose );
     vCofSigs = Gia_ManTransferFrames( p, pFrames, nFrames, pAig, vTemp = vCofSigs );
     Vec_IntFree( vTemp );
-    Gia_ManStop( pFrames );
-    ABC_FREE( p->pCopies );
+    Gia_ManStop( pFrames );
+    Vec_IntErase( &p->vCopies );
     // cofactor all these variables
     pNew = Gia_ManDupCofAllInt( pAig, vCofSigs, fVerbose );
     Vec_IntFree( vCofSigs );
diff --git a/abc-build/src/aig/gia/giaEquiv.c b/abc-build/src/aig/gia/giaEquiv.c
--- a/abc-build/src/aig/gia/giaEquiv.c
+++ b/abc-build/src/aig/gia/giaEquiv.c
@@ -1016,8 +1016,8 @@
         return NULL;
     }
 */
-    assert( pInit->nRegs == Gia_ManRegNum(p) && pInit->nPis == 0 );
-    p->pCopies = ABC_FALLOC( int, nFrames * Gia_ManObjNum(p) );
+    assert( pInit->nRegs == Gia_ManRegNum(p) && pInit->nPis == 0 );
+    Vec_IntFill( &p->vCopies, nFrames * Gia_ManObjNum(p), -1 );
     vXorLits = Vec_IntAlloc( 1000 );
     Gia_ManSetPhase( p );
     if ( fDualOut )
@@ -1052,7 +1052,7 @@
 //        Abc_Print( 1, "Speculatively reduced model has no primary outputs.\n" );
         Gia_ManAppendCo( pNew, 0 );
     }
-    ABC_FREE( p->pCopies );
+    Vec_IntErase( &p->vCopies );
     Vec_IntFree( vXorLits );
     Gia_ManHashStop( pNew );
     pNew = Gia_ManCleanup( pTemp = pNew );
@@ -2144,21 +2144,32 @@
   SeeAlso     []
 
 ***********************************************************************/
-void Gia_ManFilterEquivsUsingLatches( Gia_Man_t * pGia, int fFlopsOnly, int fFlopsWith )
+void Gia_ManFilterEquivsUsingLatches( Gia_Man_t * pGia, int fFlopsOnly, int fFlopsWith, int fUseRiDrivers )
 {
-    Vec_Int_t * vNodes;
-    Gia_Obj_t * pObj;
+    Gia_Obj_t * pObjR;
+    Vec_Int_t * vNodes, * vFfIds;
     int i, k, iObj, iNext, iPrev, iRepr;
     int iLitsOld = 0, iLitsNew = 0;
     assert( fFlopsOnly ^ fFlopsWith );
-    vNodes = Vec_IntAlloc( 100 );
-    // remove all noo-flop constants
+    vNodes = Vec_IntAlloc( 100 );
+    // select nodes "flop" node IDs
+    vFfIds = Vec_IntStart( Gia_ManObjNum(pGia) );
+    if ( fUseRiDrivers )
+    {
+        Gia_ManForEachRi( pGia, pObjR, i )
+            Vec_IntWriteEntry( vFfIds, Gia_ObjFaninId0p(pGia, pObjR), 1 );
+    }
+    else
+    {
+        Gia_ManForEachRo( pGia, pObjR, i )
+            Vec_IntWriteEntry( vFfIds, Gia_ObjId(pGia, pObjR), 1 );
+    }
+    // remove all non-flop constants
     Gia_ManForEachConst( pGia, i )
     {
         iLitsOld++;
-        pObj = Gia_ManObj( pGia, i );
         assert( pGia->pNexts[i] == 0 );
-        if ( !Gia_ObjIsRo(pGia, pObj) )
+        if ( !Vec_IntEntry(vFfIds, i) )
             Gia_ObjUnsetRepr( pGia, i );
         else
             iLitsNew++;
@@ -2171,8 +2182,7 @@
             Vec_IntClear( vNodes );
             Gia_ClassForEachObj( pGia, i, iObj )
             {
-                pObj = Gia_ManObj( pGia, iObj );
-                if ( Gia_ObjIsRo(pGia, pObj) )
+                if ( Vec_IntEntry(vFfIds, iObj) )
                     Vec_IntPush( vNodes, iObj );
                 iLitsOld++;
             }
@@ -2207,8 +2217,7 @@
             int fSeenFlop = 0;
             Gia_ClassForEachObj( pGia, i, iObj )
             {
-                pObj = Gia_ManObj( pGia, iObj );
-                if ( Gia_ObjIsRo(pGia, pObj) )
+                if ( Vec_IntEntry(vFfIds, iObj) )
                     fSeenFlop = 1;
                 iLitsOld++;
                 iLitsNew++;
@@ -2229,7 +2238,8 @@
             assert( !Gia_ObjIsHead(pGia, i) );
         }
     }
-    Vec_IntFree( vNodes );
+    Vec_IntFree( vNodes );
+    Vec_IntFree( vFfIds );
     Abc_Print( 1, "The number of literals: Before = %d. After = %d.\n", iLitsOld, iLitsNew );
 }
 
diff --git a/abc-build/src/aig/gia/giaEra2.c b/abc-build/src/aig/gia/giaEra2.c
--- a/abc-build/src/aig/gia/giaEra2.c
+++ b/abc-build/src/aig/gia/giaEra2.c
@@ -50,6 +50,13 @@
     unsigned       fMark    :  1;  // user mark
 };
 
+typedef union Gia_PtrAreInt_t_ Gia_PtrAreInt_t;
+union Gia_PtrAreInt_t_
+{
+    Gia_PtrAre_t   iGia;
+    unsigned       iInt;
+};
+
 // tree nodes
 typedef struct Gia_ObjAre_t_ Gia_ObjAre_t;
 struct Gia_ObjAre_t_
@@ -118,8 +125,8 @@
     int            timeCube;       // cube checking time 
 }; 
 
-static inline Gia_PtrAre_t    Gia_Int2Ptr( unsigned n )                               { return *(Gia_PtrAre_t *)(&n);                            }
-static inline unsigned        Gia_Ptr2Int( Gia_PtrAre_t n )                           { return (*(int *)(&n)) & 0x7fffffff;                      }
+static inline Gia_PtrAre_t    Gia_Int2Ptr( unsigned n )                               { Gia_PtrAreInt_t g; g.iInt = n; return g.iGia;            }
+static inline unsigned        Gia_Ptr2Int( Gia_PtrAre_t n )                           { Gia_PtrAreInt_t g; g.iGia = n; return g.iInt & 0x7fffffff; }
 
 static inline int             Gia_ObjHasBranch0( Gia_ObjAre_t * q )                   { return !q->nStas0 && (q->F[0].nPage || q->F[0].nItem);   }
 static inline int             Gia_ObjHasBranch1( Gia_ObjAre_t * q )                   { return !q->nStas1 && (q->F[1].nPage || q->F[1].nItem);   }
diff --git a/abc-build/src/aig/gia/giaFadds.c b/abc-build/src/aig/gia/giaFadds.c
new file mode 100644
--- /dev/null
+++ b/abc-build/src/aig/gia/giaFadds.c
@@ -0,0 +1,1104 @@
+/**CFile****************************************************************
+
+  FileName    [giaFadds.c]
+
+  SystemName  [ABC: Logic synthesis and verification system.]
+
+  PackageName [Scalable AIG package.]
+
+  Synopsis    [Extraction of full-adders.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - June 20, 2005.]
+
+  Revision    [$Id: giaFadds.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+#include "misc/vec/vecWec.h"
+#include "misc/tim/tim.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+#define Dtc_ForEachCut( pList, pCut, i ) for ( i = 0, pCut = pList + 1; i < pList[0]; i++, pCut += pCut[0] + 1 )
+#define Dtc_ForEachFadd( vFadds, i )     for ( i = 0; i < Vec_IntSize(vFadds)/5; i++ )
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    [Derive GIA with boxes containing adder-chains.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Gia_ManIllustrateBoxes( Gia_Man_t * p )
+{
+    Tim_Man_t * pManTime = (Tim_Man_t *)p->pManTime;
+    int nBoxes = Tim_ManBoxNum( pManTime );
+    int i, k, curCi, curCo, nBoxIns, nBoxOuts;
+    Gia_Obj_t * pObj;
+    // walk through the boxes
+    curCi = Tim_ManPiNum(pManTime);
+    curCo = 0;
+    for ( i = 0; i < nBoxes; i++ )
+    {
+        nBoxIns = Tim_ManBoxInputNum(pManTime, i);
+        nBoxOuts = Tim_ManBoxOutputNum(pManTime, i);
+        printf( "Box %4d  [%d x %d] :   ", i, nBoxIns, nBoxOuts );
+        printf( "Input obj IDs = " );
+        for ( k = 0; k < nBoxIns; k++ )
+        {
+            pObj = Gia_ManCo( p, curCo + k );
+            printf( "%d ", Gia_ObjId(p, pObj) );
+        }
+        printf( "  Output obj IDs = " );
+        for ( k = 0; k < nBoxOuts; k++ )
+        {
+            pObj = Gia_ManCi( p, curCi + k );
+            printf( "%d ", Gia_ObjId(p, pObj) );
+        }
+        curCo += nBoxIns;
+        curCi += nBoxOuts;
+        printf( "\n" );
+    }
+    curCo += Tim_ManPoNum(pManTime);
+    // verify counts
+    assert( curCi == Gia_ManCiNum(p) );
+    assert( curCo == Gia_ManCoNum(p) );
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Detecting FADDs in the AIG.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Dtc_ManCutMergeOne( int * pCut0, int * pCut1, int * pCut )
+{
+    int i, k;
+    for ( k = 0; k <= pCut1[0]; k++ )
+        pCut[k] = pCut1[k];
+    for ( i = 1; i <= pCut0[0]; i++ )
+    {
+        for ( k = 1; k <= pCut1[0]; k++ )
+            if ( pCut0[i] == pCut1[k] )
+                break;
+        if ( k <= pCut1[0] )
+            continue;
+        if ( pCut[0] == 3 )
+            return 0;
+        pCut[1+pCut[0]++] = pCut0[i];
+    }
+    assert( pCut[0] == 2 || pCut[0] == 3 );
+    if ( pCut[1] > pCut[2] )
+        ABC_SWAP( int, pCut[1], pCut[2] );
+    assert( pCut[1] < pCut[2] );
+    if ( pCut[0] == 2 )
+        return 1;
+    if ( pCut[2] > pCut[3] )
+        ABC_SWAP( int, pCut[2], pCut[3] );
+    if ( pCut[1] > pCut[2] )
+        ABC_SWAP( int, pCut[1], pCut[2] );
+    assert( pCut[1] < pCut[2] );
+    assert( pCut[2] < pCut[3] );
+    return 1;
+}
+int Dtc_ManCutCheckEqual( Vec_Int_t * vCuts, int * pCutNew )
+{
+    int * pList = Vec_IntArray( vCuts );
+    int i, k, * pCut;
+    Dtc_ForEachCut( pList, pCut, i )
+    {
+        for ( k = 0; k <= pCut[0]; k++ )
+            if ( pCut[k] != pCutNew[k] )
+                break;
+        if ( k > pCut[0] )
+            return 1;
+    }
+    return 0;
+}
+int Dtc_ObjComputeTruth_rec( Gia_Obj_t * pObj )
+{
+    int Truth0, Truth1;
+    if ( pObj->Value )
+        return pObj->Value;
+    assert( Gia_ObjIsAnd(pObj) );
+    Truth0 = Dtc_ObjComputeTruth_rec( Gia_ObjFanin0(pObj) );
+    Truth1 = Dtc_ObjComputeTruth_rec( Gia_ObjFanin1(pObj) );
+    return (pObj->Value = (Gia_ObjFaninC0(pObj) ? ~Truth0 : Truth0) & (Gia_ObjFaninC1(pObj) ? ~Truth1 : Truth1));
+}
+void Dtc_ObjCleanTruth_rec( Gia_Obj_t * pObj )
+{
+    if ( !pObj->Value )
+        return;
+    pObj->Value = 0;
+    if ( !Gia_ObjIsAnd(pObj) )
+        return;
+    Dtc_ObjCleanTruth_rec( Gia_ObjFanin0(pObj) );
+    Dtc_ObjCleanTruth_rec( Gia_ObjFanin1(pObj) );
+}
+int Dtc_ObjComputeTruth( Gia_Man_t * p, int iObj, int * pCut, int * pTruth )
+{
+    unsigned Truth, Truths[3] = { 0xAA, 0xCC, 0xF0 }; int i;
+    for ( i = 1; i <= pCut[0]; i++ )
+        Gia_ManObj(p, pCut[i])->Value = Truths[i-1];
+    Truth = 0xFF & Dtc_ObjComputeTruth_rec( Gia_ManObj(p, iObj) );
+    Dtc_ObjCleanTruth_rec( Gia_ManObj(p, iObj) );
+    if ( pTruth ) 
+        *pTruth = Truth;
+    if ( Truth == 0x96 || Truth == 0x69 )
+        return 1;
+    if ( Truth == 0xE8 || Truth == 0xD4 || Truth == 0xB2 || Truth == 0x71 ||
+         Truth == 0x17 || Truth == 0x2B || Truth == 0x4D || Truth == 0x8E )
+        return 2;
+    return 0;
+}
+void Dtc_ManCutMerge( Gia_Man_t * p, int iObj, int * pList0, int * pList1, Vec_Int_t * vCuts, Vec_Int_t * vCutsXor, Vec_Int_t * vCutsMaj )
+{
+    Vec_Int_t * vTemp;
+    int i, k, c, Type, * pCut0, * pCut1, pCut[4];
+    Vec_IntFill( vCuts, 2, 1 );
+    Vec_IntPush( vCuts, iObj );
+    Dtc_ForEachCut( pList0, pCut0, i )
+    Dtc_ForEachCut( pList1, pCut1, k )
+    {
+        if ( !Dtc_ManCutMergeOne(pCut0, pCut1, pCut) )
+            continue;
+        if ( Dtc_ManCutCheckEqual(vCuts, pCut) )
+            continue;
+        Vec_IntAddToEntry( vCuts, 0, 1 );  
+        for ( c = 0; c <= pCut[0]; c++ )
+            Vec_IntPush( vCuts, pCut[c] );
+        if ( pCut[0] != 3 )
+            continue;
+        Type = Dtc_ObjComputeTruth( p, iObj, pCut, NULL );
+        if ( Type == 0 )
+            continue;
+        vTemp = Type == 1 ? vCutsXor : vCutsMaj;
+        for ( c = 1; c <= pCut[0]; c++ )
+            Vec_IntPush( vTemp, pCut[c] );
+        Vec_IntPush( vTemp, iObj );
+    }
+}
+void Dtc_ManComputeCuts( Gia_Man_t * p, Vec_Int_t ** pvCutsXor, Vec_Int_t ** pvCutsMaj, int fVerbose )
+{
+    Gia_Obj_t * pObj; 
+    int * pList0, * pList1, i, nCuts = 0;
+    Vec_Int_t * vTemp = Vec_IntAlloc( 1000 );
+    Vec_Int_t * vCutsXor = Vec_IntAlloc( Gia_ManAndNum(p) );
+    Vec_Int_t * vCutsMaj = Vec_IntAlloc( Gia_ManAndNum(p) );
+    Vec_Int_t * vCuts = Vec_IntAlloc( 30 * Gia_ManAndNum(p) );
+    Vec_IntFill( vCuts, Gia_ManObjNum(p), 0 );
+    Gia_ManCleanValue( p );
+    Gia_ManForEachCi( p, pObj, i )
+    {
+        Vec_IntWriteEntry( vCuts, Gia_ObjId(p, pObj), Vec_IntSize(vCuts) );
+        Vec_IntPush( vCuts, 1 );
+        Vec_IntPush( vCuts, 1 );
+        Vec_IntPush( vCuts, Gia_ObjId(p, pObj) );
+    }
+    Gia_ManForEachAnd( p, pObj, i )
+    {
+        pList0 = Vec_IntEntryP( vCuts, Vec_IntEntry(vCuts, Gia_ObjFaninId0(pObj, i)) );
+        pList1 = Vec_IntEntryP( vCuts, Vec_IntEntry(vCuts, Gia_ObjFaninId1(pObj, i)) );
+        Dtc_ManCutMerge( p, i, pList0, pList1, vTemp, vCutsXor, vCutsMaj );
+        Vec_IntWriteEntry( vCuts, i, Vec_IntSize(vCuts) );
+        Vec_IntAppend( vCuts, vTemp );
+        nCuts += Vec_IntEntry( vTemp, 0 );
+    }
+    if ( fVerbose )
+        printf( "Nodes = %d.  Cuts = %d.  Cuts/Node = %.2f.  Ints/Node = %.2f.\n", 
+            Gia_ManAndNum(p), nCuts, 1.0*nCuts/Gia_ManAndNum(p), 1.0*Vec_IntSize(vCuts)/Gia_ManAndNum(p) );
+    Vec_IntFree( vTemp );
+    Vec_IntFree( vCuts );
+    *pvCutsXor = vCutsXor;
+    *pvCutsMaj = vCutsMaj;
+}
+Vec_Int_t * Dtc_ManFindCommonCuts( Gia_Man_t * p, Vec_Int_t * vCutsXor, Vec_Int_t * vCutsMaj )
+{
+    int * pCuts0 = Vec_IntArray(vCutsXor);
+    int * pCuts1 = Vec_IntArray(vCutsMaj);
+    int * pLimit0 = Vec_IntLimit(vCutsXor);
+    int * pLimit1 = Vec_IntLimit(vCutsMaj);   int i;
+    Vec_Int_t * vFadds = Vec_IntAlloc( 1000 );
+    assert( Vec_IntSize(vCutsXor) % 4 == 0 );
+    assert( Vec_IntSize(vCutsMaj) % 4 == 0 );
+    while ( pCuts0 < pLimit0 && pCuts1 < pLimit1 )
+    {
+        for ( i = 0; i < 3; i++ )
+            if ( pCuts0[i] != pCuts1[i] )
+                break;
+        if ( i == 3 )
+        {
+            for ( i = 0; i < 4; i++ )
+                Vec_IntPush( vFadds, pCuts0[i] );
+            Vec_IntPush( vFadds, pCuts1[3] );
+            pCuts0 += 4;
+            pCuts1 += 4;
+        }
+        else if ( pCuts0[i] < pCuts1[i] )
+            pCuts0 += 4;
+        else if ( pCuts0[i] > pCuts1[i] )
+            pCuts1 += 4;
+    }
+    assert( Vec_IntSize(vFadds) % 5 == 0 );
+    return vFadds;
+}
+void Dtc_ManPrintFadds( Vec_Int_t * vFadds )
+{
+    int i;
+    Dtc_ForEachFadd( vFadds, i )
+    {
+        printf( "%6d : ", i );
+        printf( "%6d ", Vec_IntEntry(vFadds, 5*i+0) );
+        printf( "%6d ", Vec_IntEntry(vFadds, 5*i+1) );
+        printf( "%6d ", Vec_IntEntry(vFadds, 5*i+2) );
+        printf( " ->  " );
+        printf( "%6d ", Vec_IntEntry(vFadds, 5*i+3) );
+        printf( "%6d ", Vec_IntEntry(vFadds, 5*i+4) );
+        printf( "\n" );
+    }
+}
+int Dtc_ManCompare( int * pCut0, int * pCut1 )
+{
+    if ( pCut0[0] < pCut1[0] ) return -1;
+    if ( pCut0[0] > pCut1[0] ) return  1;
+    if ( pCut0[1] < pCut1[1] ) return -1;
+    if ( pCut0[1] > pCut1[1] ) return  1;
+    if ( pCut0[2] < pCut1[2] ) return -1;
+    if ( pCut0[2] > pCut1[2] ) return  1;
+    return 0;
+}
+int Dtc_ManCompare2( int * pCut0, int * pCut1 )
+{
+    if ( pCut0[4] < pCut1[4] ) return -1;
+    if ( pCut0[4] > pCut1[4] ) return  1;
+    return 0;
+}
+// returns array of 5-tuples containing inputs/sum/cout of each full adder
+Vec_Int_t * Gia_ManDetectFullAdders( Gia_Man_t * p, int fVerbose )
+{
+    Vec_Int_t * vCutsXor, * vCutsMaj, * vFadds;
+    Dtc_ManComputeCuts( p, &vCutsXor, &vCutsMaj, fVerbose );
+    qsort( Vec_IntArray(vCutsXor), Vec_IntSize(vCutsXor)/4, 16, (int (*)(const void *, const void *))Dtc_ManCompare );
+    qsort( Vec_IntArray(vCutsMaj), Vec_IntSize(vCutsMaj)/4, 16, (int (*)(const void *, const void *))Dtc_ManCompare );
+    vFadds = Dtc_ManFindCommonCuts( p, vCutsXor, vCutsMaj );
+    qsort( Vec_IntArray(vFadds), Vec_IntSize(vFadds)/5, 20, (int (*)(const void *, const void *))Dtc_ManCompare2 );
+    if ( fVerbose )
+        printf( "XOR3 cuts = %d.  MAJ cuts = %d.  Full-adders = %d.\n", Vec_IntSize(vCutsXor)/4, Vec_IntSize(vCutsMaj)/4, Vec_IntSize(vFadds)/5 );
+    //Dtc_ManPrintFadds( vFadds );
+    Vec_IntFree( vCutsXor );
+    Vec_IntFree( vCutsMaj );
+    return vFadds;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Map each MAJ into the topmost MAJ of its chain.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+// maps MAJ nodes into FADD indexes
+Vec_Int_t * Gia_ManCreateMap( Gia_Man_t * p, Vec_Int_t * vFadds )
+{
+    Vec_Int_t * vMap = Vec_IntStartFull( Gia_ManObjNum(p) );  int i;
+    Dtc_ForEachFadd( vFadds, i )
+        Vec_IntWriteEntry( vMap, Vec_IntEntry(vFadds, 5*i+4), i );
+    return vMap;
+}
+// find chain length (for each MAJ, how many FADDs are rooted in its first input)
+int Gia_ManFindChains_rec( Gia_Man_t * p, int iMaj, Vec_Int_t * vFadds, Vec_Int_t * vMap, Vec_Int_t * vLength )
+{
+    assert( Vec_IntEntry(vMap, iMaj) >= 0 ); // MAJ
+    if ( Vec_IntEntry(vLength, iMaj) >= 0 )
+        return Vec_IntEntry(vLength, iMaj);
+    assert( Gia_ObjIsAnd(Gia_ManObj(p, iMaj)) );
+    {
+        int iFadd = Vec_IntEntry( vMap, iMaj );
+        int iXor0 = Vec_IntEntry( vFadds, 5*iFadd+0 );
+        int iXor1 = Vec_IntEntry( vFadds, 5*iFadd+1 );
+        int iXor2 = Vec_IntEntry( vFadds, 5*iFadd+2 );
+        int iLen0 = Vec_IntEntry( vMap, iXor0 ) == -1 ? 0 : Gia_ManFindChains_rec( p, iXor0, vFadds, vMap, vLength );
+        int iLen1 = Vec_IntEntry( vMap, iXor1 ) == -1 ? 0 : Gia_ManFindChains_rec( p, iXor1, vFadds, vMap, vLength );
+        int iLen2 = Vec_IntEntry( vMap, iXor2 ) == -1 ? 0 : Gia_ManFindChains_rec( p, iXor2, vFadds, vMap, vLength );
+        int iLen = Abc_MaxInt( iLen0, Abc_MaxInt(iLen1, iLen2) );
+        if ( iLen0 < iLen )
+        {
+            if ( iLen == iLen1 )
+            {
+                ABC_SWAP( int, Vec_IntArray(vFadds)[5*iFadd+0], Vec_IntArray(vFadds)[5*iFadd+1] );
+            }
+            else if ( iLen == iLen2 )
+            {
+                ABC_SWAP( int, Vec_IntArray(vFadds)[5*iFadd+0], Vec_IntArray(vFadds)[5*iFadd+2] );
+            }
+        }
+        Vec_IntWriteEntry( vLength, iMaj, iLen + 1 );
+        return iLen + 1;
+    }
+}
+// for each FADD find the longest chain and reorder its inputs
+void Gia_ManFindChains( Gia_Man_t * p, Vec_Int_t * vFadds, Vec_Int_t * vMap )
+{
+    int i;
+    // for each FADD find the longest chain rooted in it
+    Vec_Int_t * vLength = Vec_IntStartFull( Gia_ManObjNum(p) );
+    Dtc_ForEachFadd( vFadds, i )
+        Gia_ManFindChains_rec( p, Vec_IntEntry(vFadds, 5*i+4), vFadds, vMap, vLength );
+    Vec_IntFree( vLength );
+}
+// collect one carry-chain
+void Gia_ManCollectOneChain( Gia_Man_t * p, Vec_Int_t * vFadds, int iFaddTop, Vec_Int_t * vMap, Vec_Int_t * vChain )
+{
+    int iFadd;
+    Vec_IntClear( vChain );
+    for ( iFadd = iFaddTop; iFadd >= 0 && 
+          !Gia_ObjIsTravIdCurrentId(p, Vec_IntEntry(vFadds, 5*iFadd+3)) && 
+          !Gia_ObjIsTravIdCurrentId(p, Vec_IntEntry(vFadds, 5*iFadd+4)); 
+          iFadd = Vec_IntEntry(vMap, Vec_IntEntry(vFadds, 5*iFadd+0)) )
+          {
+                Vec_IntPush( vChain, iFadd );
+          }
+    Vec_IntReverseOrder( vChain );
+}
+void Gia_ManMarkWithTravId_rec( Gia_Man_t * p, int Id )
+{
+    Gia_Obj_t * pObj;
+    if ( Gia_ObjIsTravIdCurrentId(p, Id) )
+        return;
+    Gia_ObjSetTravIdCurrentId(p, Id);
+    pObj = Gia_ManObj( p, Id );
+    if ( Gia_ObjIsAnd(pObj) )
+        Gia_ManMarkWithTravId_rec( p, Gia_ObjFaninId0(pObj, Id) );
+    if ( Gia_ObjIsAnd(pObj) )
+        Gia_ManMarkWithTravId_rec( p, Gia_ObjFaninId1(pObj, Id) );
+}
+// returns mapping of each MAJ into the topmost elements of its chain
+Vec_Wec_t * Gia_ManCollectTopmost( Gia_Man_t * p, Vec_Int_t * vFadds, Vec_Int_t * vMap, int nFaddMin )
+{
+    int i, j, iFadd;
+    Vec_Int_t * vChain  = Vec_IntAlloc( 100 );
+    Vec_Wec_t * vChains = Vec_WecAlloc( Vec_IntSize(vFadds)/5 );
+    // erase elements appearing as FADD inputs
+    Vec_Bit_t * vMarksTop = Vec_BitStart( Vec_IntSize(vFadds)/5 );
+    Dtc_ForEachFadd( vFadds, i )
+        if ( (iFadd = Vec_IntEntry(vMap, Vec_IntEntry(vFadds, 5*i+0))) >= 0 )
+            Vec_BitWriteEntry( vMarksTop, iFadd, 1 );
+    // compress the remaining ones
+    Gia_ManIncrementTravId( p );
+    Dtc_ForEachFadd( vFadds, i )
+    {
+        if ( Vec_BitEntry(vMarksTop, i) )
+            continue;
+        Gia_ManCollectOneChain( p, vFadds, i, vMap, vChain );
+        if ( Vec_IntSize(vChain) < nFaddMin )
+            continue;
+        Vec_IntAppend( Vec_WecPushLevel(vChains), vChain );
+        Vec_IntForEachEntry( vChain, iFadd, j )
+        {
+            assert( !Gia_ObjIsTravIdCurrentId(p, Vec_IntEntry(vFadds, 5*iFadd+3)) );
+            assert( !Gia_ObjIsTravIdCurrentId(p, Vec_IntEntry(vFadds, 5*iFadd+4)) );
+            Gia_ManMarkWithTravId_rec( p, Vec_IntEntry(vFadds, 5*iFadd+3) );
+            Gia_ManMarkWithTravId_rec( p, Vec_IntEntry(vFadds, 5*iFadd+4) );
+        }
+    }
+    // cleanup
+    Vec_BitFree( vMarksTop );
+    Vec_IntFree( vChain );
+    return vChains;
+}
+// prints chains beginning in majority nodes contained in vTops
+void Gia_ManPrintChains( Gia_Man_t * p, Vec_Int_t * vFadds, Vec_Int_t * vMap, Vec_Wec_t * vChains )
+{
+    Vec_Int_t * vChain;
+    int i, k, iFadd, Count = 0;
+    Vec_WecForEachLevel( vChains, vChain, i )
+    {
+        Count += Vec_IntSize(vChain);
+        if ( i < 10 )
+        {
+            printf( "Chain %4d : %4d    ", i, Vec_IntSize(vChain) );
+            Vec_IntForEachEntry( vChain, iFadd, k )
+            {
+                printf( "%d(%d) ", iFadd, Vec_IntEntry(vFadds, 5*iFadd+4) );
+                if ( k != Vec_IntSize(vChain) - 1 )
+                    printf( "-> " );
+                if ( k > 6 )
+                {
+                    printf( "..." );
+                    break;
+                }
+            }
+            printf( "\n" );
+        }
+        else if ( i == 10 )
+            printf( "...\n" );
+
+    }
+    printf( "Total chains = %d. Total full-adders = %d.\n", Vec_WecSize(vChains), Count );
+}
+// map SUM bits and topmost MAJ into topmost FADD number
+Vec_Int_t * Gia_ManFindMapping( Gia_Man_t * p, Vec_Int_t * vFadds, Vec_Int_t * vMap, Vec_Wec_t * vChains )
+{
+    Vec_Int_t * vChain;
+    int i, k, iFadd = -1;
+    Vec_Int_t * vMap2Chain = Vec_IntStartFull( Gia_ManObjNum(p) );
+    Vec_WecForEachLevel( vChains, vChain, i )
+    {
+        assert( Vec_IntSize(vChain) > 0 );
+        Vec_IntForEachEntry( vChain, iFadd, k )
+        {
+            //printf( "Chain %d: setting SUM %d (obj %d)\n", i, k, Vec_IntEntry(vFadds, 5*iFadd+3) );
+            assert( Vec_IntEntry(vMap2Chain, Vec_IntEntry(vFadds, 5*iFadd+3)) == -1 );
+            Vec_IntWriteEntry( vMap2Chain, Vec_IntEntry(vFadds, 5*iFadd+3), i );
+        }
+        //printf( "Chain %d: setting CARRY (obj %d)\n", i, Vec_IntEntry(vFadds, 5*iFadd+4) );
+        assert( Vec_IntEntry(vMap2Chain, Vec_IntEntry(vFadds, 5*iFadd+4)) == -1 );
+        Vec_IntWriteEntry( vMap2Chain, Vec_IntEntry(vFadds, 5*iFadd+4), i );
+    }
+    return vMap2Chain;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Derive GIA with boxes containing adder-chains.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Vec_Int_t * Gia_ManCollectTruthTables( Gia_Man_t * p, Vec_Int_t * vFadds )
+{
+    int i, k, Type, Truth, pCut[4] = {3};
+    Vec_Int_t * vTruths = Vec_IntAlloc( 2*Vec_IntSize(vFadds)/5 );
+    Gia_ManCleanValue( p );
+    Dtc_ForEachFadd( vFadds, i )
+    {
+        for ( k = 0; k < 3; k++ )
+            pCut[k+1] = Vec_IntEntry( vFadds, 5*i+k );
+        Type = Dtc_ObjComputeTruth( p, Vec_IntEntry(vFadds, 5*i+3), pCut, &Truth );
+        assert( Type == 1 );
+        Vec_IntPush( vTruths, Truth );
+        Type = Dtc_ObjComputeTruth( p, Vec_IntEntry(vFadds, 5*i+4), pCut, &Truth );
+        assert( Type == 2 );
+        Vec_IntPush( vTruths, Truth );
+    }
+    return vTruths;
+}
+float * Gia_ManGenerateDelayTableFloat( int nIns, int nOuts )
+{
+    int i, Total = nIns * nOuts;
+    float * pDelayTable = ABC_ALLOC( float, Total + 3 );
+    pDelayTable[0] = 0;
+    pDelayTable[1] = nIns;
+    pDelayTable[2] = nOuts;
+    for ( i = 0; i < Total; i++ )
+        pDelayTable[i+3] = 1;
+    pDelayTable[i+3 - nIns] = -ABC_INFINITY;
+    return pDelayTable;
+}
+Tim_Man_t * Gia_ManGenerateTim( int nPis, int nPos, int nBoxes, int nIns, int nOuts )
+{
+    Tim_Man_t * pMan;
+    int i, curPi, curPo;
+    Vec_Ptr_t * vDelayTables = Vec_PtrAlloc( 1 );
+    Vec_PtrPush( vDelayTables, Gia_ManGenerateDelayTableFloat(nIns, nOuts) );
+    pMan = Tim_ManStart( nPis + nOuts * nBoxes, nPos + nIns * nBoxes );
+    Tim_ManSetDelayTables( pMan, vDelayTables );
+    curPi = nPis;
+    curPo = 0;
+    for ( i = 0; i < nBoxes; i++ )
+    {
+        Tim_ManCreateBox( pMan, curPo, nIns, curPi, nOuts, 0 );
+        curPi += nOuts;
+        curPo += nIns;
+    }
+    curPo += nPos;
+    assert( curPi == Tim_ManCiNum(pMan) );
+    assert( curPo == Tim_ManCoNum(pMan) );
+    //Tim_ManPrint( pMan );
+    return pMan;
+}
+Gia_Man_t * Gia_ManGenerateExtraAig( int nBoxes, int nIns, int nOuts )
+{
+    Gia_Man_t * pNew = Gia_ManStart( nBoxes * 20 );
+    int i, k, pInLits[16], pOutLits[16];
+    assert( nIns < 16 && nOuts < 16 );
+    for ( i = 0; i < nIns; i++ )
+        pInLits[i] = Gia_ManAppendCi( pNew );
+    pOutLits[0] = Gia_ManAppendXor( pNew, Gia_ManAppendXor(pNew, pInLits[0], pInLits[1]), pInLits[2] );
+    pOutLits[1] = Gia_ManAppendMaj( pNew, pInLits[0], pInLits[1], pInLits[2] );
+    for ( i = 0; i < nBoxes; i++ )
+        for ( k = 0; k < nOuts; k++ )
+            Gia_ManAppendCo( pNew, pOutLits[k] );
+    return pNew;
+}
+void Gia_ManDupFadd( Gia_Man_t * pNew, Gia_Man_t * p, Vec_Int_t * vChain, Vec_Int_t * vFadds, Vec_Int_t * vMap, Vec_Wec_t * vChains, Vec_Int_t * vMap2Chain, Vec_Int_t * vTruths )
+{
+    extern void Gia_ManDupWithFaddBoxes_rec( Gia_Man_t * pNew, Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vFadds, Vec_Int_t * vMap, Vec_Wec_t * vChains, Vec_Int_t * vMap2Chain, Vec_Int_t * vTruths );
+    int i, k, iFadd, iCiLit, pLits[3];
+    Gia_Obj_t * pObj;
+    // construct FADD inputs
+    Vec_IntForEachEntry( vChain, iFadd, i )
+        for ( k = 0; k < 3; k++ )
+        {
+            if ( i && !k ) continue;
+            pObj = Gia_ManObj( p, Vec_IntEntry(vFadds, 5*iFadd+k) );
+            Gia_ManDupWithFaddBoxes_rec( pNew, p, pObj, vFadds, vMap, vChains, vMap2Chain, vTruths );
+        }
+    // construct boxes
+    iCiLit = 0;
+    Vec_IntForEachEntry( vChain, iFadd, i )
+    {
+        int iXorTruth = Vec_IntEntry( vTruths, 2*iFadd+0 );
+        int iMajTruth = Vec_IntEntry( vTruths, 2*iFadd+1 );
+        for ( k = 0; k < 3; k++ )
+        {
+            pObj = Gia_ManObj( p, Vec_IntEntry(vFadds, 5*iFadd+k) );
+            pLits[k] = (!k && iCiLit) ? iCiLit : pObj->Value;
+            assert( pLits[k] >= 0 );
+        }
+        // normalize truth table
+        //    if ( Truth == 0xE8 || Truth == 0xD4 || Truth == 0xB2 || Truth == 0x71 ||
+        //         Truth == 0x17 || Truth == 0x2B || Truth == 0x4D || Truth == 0x8E )
+        if ( iMajTruth == 0x4D )
+            pLits[0] = Abc_LitNot(pLits[0]), iMajTruth = 0x8E, iXorTruth = 0xFF & ~iXorTruth;
+        else if ( iMajTruth == 0xD4 )
+            pLits[0] = Abc_LitNot(pLits[0]), iMajTruth = 0xE8, iXorTruth = 0xFF & ~iXorTruth;
+        else if ( iMajTruth == 0x2B )
+            pLits[1] = Abc_LitNot(pLits[1]), iMajTruth = 0x8E, iXorTruth = 0xFF & ~iXorTruth;
+        else if ( iMajTruth == 0xB2 )
+            pLits[1] = Abc_LitNot(pLits[1]), iMajTruth = 0xE8, iXorTruth = 0xFF & ~iXorTruth;
+        if ( iMajTruth == 0x8E )
+            pLits[2] = Abc_LitNot(pLits[2]), iMajTruth = 0xE8, iXorTruth = 0xFF & ~iXorTruth;
+        else if ( iMajTruth == 0x71 )
+            pLits[2] = Abc_LitNot(pLits[2]), iMajTruth = 0x17, iXorTruth = 0xFF & ~iXorTruth;
+        else assert( iMajTruth == 0xE8 || iMajTruth == 0x17 );
+        // normalize carry-in
+        if ( Abc_LitIsCompl(pLits[0]) )
+        {
+            for ( k = 0; k < 3; k++ )
+                pLits[k] = Abc_LitNot(pLits[k]);
+            iXorTruth = 0xFF & ~iXorTruth;
+            iMajTruth = 0xFF & ~iMajTruth;
+        }
+        // add COs
+        assert( !Abc_LitIsCompl(pLits[0]) );
+        for ( k = 0; k < 3; k++ )
+            Gia_ManAppendCo( pNew, pLits[k] );
+        // create CI
+        assert( iXorTruth == 0x96 || iXorTruth == 0x69 );
+        pObj = Gia_ManObj( p, Vec_IntEntry(vFadds, 5*iFadd+3) );
+        pObj->Value = Abc_LitNotCond( Gia_ManAppendCi(pNew), (int)(iXorTruth == 0x69) );
+        // create CI
+        assert( iMajTruth == 0xE8 || iMajTruth == 0x17 );
+        iCiLit = Abc_LitNotCond( Gia_ManAppendCi(pNew), (int)(iMajTruth == 0x17) );
+    }   
+    // assign carry out
+    assert( iFadd == Vec_IntEntryLast(vChain) );
+    pObj = Gia_ManObj( p, Vec_IntEntry(vFadds, 5*iFadd+4) );
+    pObj->Value = iCiLit;
+}
+void Gia_ManDupWithFaddBoxes_rec( Gia_Man_t * pNew, Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vFadds, Vec_Int_t * vMap, Vec_Wec_t * vChains, Vec_Int_t * vMap2Chain, Vec_Int_t * vTruths )
+{
+    int iChain;
+    if ( ~pObj->Value )
+        return;
+    assert( Gia_ObjIsAnd(pObj) );
+    iChain = Vec_IntEntry( vMap2Chain, Gia_ObjId(p, pObj) );
+/*
+    assert( iChain == -1 );
+    if ( iChain >= 0 )
+    {
+        Gia_ManDupFadd( pNew, p, Vec_WecEntry(vChains, iChain), vFadds, vMap, vChains, vMap2Chain, vTruths );
+        assert( ~pObj->Value );
+        return;
+    }
+*/
+    Gia_ManDupWithFaddBoxes_rec( pNew, p, Gia_ObjFanin0(pObj), vFadds, vMap, vChains, vMap2Chain, vTruths );
+    Gia_ManDupWithFaddBoxes_rec( pNew, p, Gia_ObjFanin1(pObj), vFadds, vMap, vChains, vMap2Chain, vTruths );
+    pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+}
+Gia_Man_t * Gia_ManDupWithNaturalBoxes( Gia_Man_t * p, int nFaddMin, int fVerbose )
+{
+    abctime clk = Abc_Clock();
+    Gia_Man_t * pNew;//, * pTemp;
+    Vec_Int_t * vFadds, * vMap, * vMap2Chain, * vTruths, * vChain;
+    Vec_Wec_t * vChains;
+    Gia_Obj_t * pObj;  
+    int i, nBoxes;
+    if ( Gia_ManBoxNum(p) > 0 )
+    {
+        printf( "Currently natural carry-chains cannot be detected when boxes are present.\n" );
+        return NULL;
+    }
+    assert( Gia_ManBoxNum(p) == 0 );
+
+    // detect FADDs
+    vFadds = Gia_ManDetectFullAdders( p, fVerbose );
+    assert( Vec_IntSize(vFadds) % 5 == 0 );
+    // map MAJ into its FADD
+    vMap = Gia_ManCreateMap( p, vFadds );
+    // for each FADD, find the longest chain and reorder its inputs
+    Gia_ManFindChains( p, vFadds, vMap );
+    // returns the set of topmost MAJ nodes
+    vChains = Gia_ManCollectTopmost( p, vFadds, vMap, nFaddMin );
+    if ( fVerbose )
+        Gia_ManPrintChains( p, vFadds, vMap, vChains );
+    if ( Vec_WecSize(vChains) == 0 )
+    {
+        Vec_IntFree( vFadds );
+        Vec_IntFree( vMap );
+        Vec_WecFree( vChains );
+        return Gia_ManDup( p );
+    }
+    // returns mapping of each MAJ into the topmost elements of its chain
+    vMap2Chain = Gia_ManFindMapping( p, vFadds, vMap, vChains );
+    // compute truth tables for FADDs
+    vTruths = Gia_ManCollectTruthTables( p, vFadds );
+    if ( fVerbose )
+        Abc_PrintTime( 1, "Carry-chain detection time", Abc_Clock() - clk );
+
+    // duplicate
+    clk = Abc_Clock();
+    Gia_ManFillValue( p );
+    pNew = Gia_ManStart( Gia_ManObjNum(p) );
+    pNew->pName = Abc_UtilStrsav( p->pName );
+    pNew->pSpec = Abc_UtilStrsav( p->pSpec );
+    Gia_ManConst0(p)->Value = 0;
+    Gia_ManForEachCi( p, pObj, i )
+        pObj->Value = Gia_ManAppendCi( pNew );
+    Vec_WecForEachLevel( vChains, vChain, i )
+        Gia_ManDupFadd( pNew, p, vChain, vFadds, vMap, vChains, vMap2Chain, vTruths );
+    Gia_ManForEachCo( p, pObj, i )
+        Gia_ManDupWithFaddBoxes_rec( pNew, p, Gia_ObjFanin0(pObj), vFadds, vMap, vChains, vMap2Chain, vTruths );
+    Gia_ManForEachCo( p, pObj, i )
+        Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+    Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+    if ( Gia_ManRegNum(p) )
+    {
+        if ( fVerbose )
+            printf( "Warning: Sequential design is coverted into combinational one by adding white boxes.\n" );
+        pNew->nRegs = 0;
+    }
+    assert( !Gia_ManHasDangling(pNew) );
+
+    // cleanup
+    Vec_IntFree( vFadds );
+    Vec_IntFree( vMap );
+    Vec_WecFree( vChains );
+    Vec_IntFree( vMap2Chain );
+    Vec_IntFree( vTruths );
+    
+    // other information
+    nBoxes = (Gia_ManCiNum(pNew) - Gia_ManCiNum(p)) / 2;
+    assert( nBoxes == (Gia_ManCoNum(pNew) - Gia_ManCoNum(p)) / 3 );
+    pNew->pManTime  = Gia_ManGenerateTim( Gia_ManCiNum(p), Gia_ManCoNum(p), nBoxes, 3, 2 );
+    pNew->pAigExtra = Gia_ManGenerateExtraAig( nBoxes, 3, 2 );
+/*
+    // normalize
+    pNew = Gia_ManDupNormalize( pTemp = pNew );
+    pNew->pManTime  = pTemp->pManTime;  pTemp->pManTime  = NULL;
+    pNew->pAigExtra = pTemp->pAigExtra; pTemp->pAigExtra = NULL;
+    Gia_ManStop( pTemp );
+*/
+    //pNew = Gia_ManDupCollapse( pTemp = pNew, pNew->pAigExtra, NULL );
+    //Gia_ManStop( pTemp );
+
+    //Gia_ManIllustrateBoxes( pNew );
+    if ( fVerbose )
+        Abc_PrintTime( 1, "AIG with boxes construction time", Abc_Clock() - clk );
+    return pNew;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Converting AIG with annotated carry-chains into AIG with boxes.]
+
+  Description [Assumes that annotations are pObj->fMark0 or pObj->fMark1.
+  Only one of these can be set to 1.  If fMark0 (fMark1) is set to 1, 
+  the first (second) input of an AND-gate is chained.]
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Gia_ObjFanin0CopyCarry( Vec_Int_t * vCarries, Gia_Obj_t * pObj, int Id )
+{
+    if ( vCarries == NULL || Vec_IntEntry(vCarries, Gia_ObjFaninId0(pObj, Id)) == -1 )
+        return Gia_ObjFanin0Copy(pObj);
+    return Abc_LitNotCond( Vec_IntEntry(vCarries, Gia_ObjFaninId0(pObj, Id)), Gia_ObjFaninC0(pObj) );
+}
+int Gia_ObjFanin1CopyCarry( Vec_Int_t * vCarries, Gia_Obj_t * pObj, int Id )
+{
+    if ( vCarries == NULL || Vec_IntEntry(vCarries, Gia_ObjFaninId1(pObj, Id)) == -1 )
+        return Gia_ObjFanin1Copy(pObj);
+    return Abc_LitNotCond( Vec_IntEntry(vCarries, Gia_ObjFaninId1(pObj, Id)), Gia_ObjFaninC1(pObj) );
+}
+Gia_Man_t * Gia_ManDupWithArtificalFaddBoxes( Gia_Man_t * p, int fUseFanout )
+{
+    Gia_Man_t * pNew;
+    Gia_Obj_t * pObj;  
+    int nBoxes = Gia_ManBoxNum(p);
+    int i, nRealPis, nRealPos;
+    Vec_Int_t * vCarries = NULL;
+    // make sure two chains do not overlap
+    Gia_ManCleanPhase( p );
+    Gia_ManForEachCi( p, pObj, i )
+        assert( !pObj->fMark0 && !pObj->fMark1 );
+    Gia_ManForEachCo( p, pObj, i )
+        assert( !pObj->fMark0 && !pObj->fMark1 );
+    Gia_ManForEachAnd( p, pObj, i )
+    {
+        assert( !pObj->fMark0 || !pObj->fMark1 );
+        if ( pObj->fMark0 )
+        {
+            assert( Gia_ObjFanin0(pObj)->fPhase == 0 );
+            Gia_ObjFanin0(pObj)->fPhase = 1;
+        }
+        if ( pObj->fMark1 )
+        {
+            assert( Gia_ObjFanin1(pObj)->fPhase == 0 );
+            Gia_ObjFanin1(pObj)->fPhase = 1;
+        }
+    }
+    // create mapping for carry-chains
+    if ( !fUseFanout )
+        vCarries = Vec_IntStartFull( Gia_ManObjNum(p) );
+    // create references and discount carries
+    if ( vCarries )
+    {
+        Gia_ManCreateRefs( p );
+        Gia_ManForEachAnd( p, pObj, i )
+            if ( pObj->fMark0 )
+                Gia_ObjRefFanin0Dec( p, pObj );
+            else if ( pObj->fMark1 )
+                Gia_ObjRefFanin1Dec( p, pObj );
+    }
+    // if AIG already has (natural) FADD boxes, it should not un-normalized
+    Gia_ManFillValue( p );
+    pNew = Gia_ManStart( Gia_ManObjNum(p) );
+    pNew->pName = Abc_UtilStrsav( p->pName );
+    pNew->pSpec = Abc_UtilStrsav( p->pSpec );
+    Gia_ManConst0(p)->Value = 0;
+    Gia_ManForEachObj1( p, pObj, i )
+    {
+        if ( Gia_ObjIsCi(pObj) )
+            pObj->Value = Gia_ManAppendCi( pNew );
+        else if ( Gia_ObjIsCo(pObj) )
+            pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+        else if ( !pObj->fMark0 && !pObj->fMark1 ) // AND-gate
+            pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+        else // AND-gate with chain
+        {
+            int iCiLit, iOtherLit, iLit0, iLit1, iLit2;
+            assert( pObj->fMark0 != pObj->fMark1 );
+            iCiLit    = pObj->fMark0 ? Gia_ObjFanin0CopyCarry(vCarries, pObj, i) : Gia_ObjFanin1CopyCarry(vCarries, pObj, i);
+            iOtherLit = pObj->fMark0 ? Gia_ObjFanin1Copy(pObj) : Gia_ObjFanin0Copy(pObj);
+            assert( iCiLit >= 0 && iOtherLit >= 0 );
+            iLit0 = Abc_LitNotCond( iCiLit,    Abc_LitIsCompl(iCiLit) );
+            iLit1 = Abc_LitNotCond( iOtherLit, Abc_LitIsCompl(iCiLit) );
+            iLit2 = Abc_LitNotCond( 0,         Abc_LitIsCompl(iCiLit) );
+            // add COs
+            assert( !Abc_LitIsCompl(iLit0) );
+            Gia_ManAppendCo( pNew, iLit0 );
+            Gia_ManAppendCo( pNew, iLit1 );
+            Gia_ManAppendCo( pNew, iLit2 );
+            // add CI (unused sum bit)
+            Gia_ManAppendCi(pNew);
+            // add CI (carry bit)
+            pObj->Value = Abc_LitNotCond( Gia_ManAppendCi(pNew), Abc_LitIsCompl(iCiLit) );
+            if ( vCarries && pObj->fPhase )
+            {
+                Vec_IntWriteEntry( vCarries, i, pObj->Value );
+                if ( Gia_ObjRefNum(p, pObj) > 0 )
+                    pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+            }
+            nBoxes++;
+        }
+    }
+    Gia_ManCleanPhase( p );
+    Vec_IntFreeP( &vCarries );
+    ABC_FREE( p->pRefs );
+    assert( !Gia_ManHasDangling(pNew) );
+    // other information
+//    nBoxes += (Gia_ManCiNum(pNew) - Gia_ManCiNum(p)) / 2;
+//    assert( nBoxes == Gia_ManBoxNum(p) + (Gia_ManCoNum(pNew) - Gia_ManCoNum(p)) / 3 );
+    nRealPis = Gia_ManBoxNum(p) ? Tim_ManPiNum((Tim_Man_t *)p->pManTime) : Gia_ManCiNum(p);
+    nRealPos = Gia_ManBoxNum(p) ? Tim_ManPoNum((Tim_Man_t *)p->pManTime) : Gia_ManCoNum(p);
+    pNew->pManTime  = Gia_ManGenerateTim( nRealPis, nRealPos, nBoxes, 3, 2 );
+    pNew->pAigExtra = Gia_ManGenerateExtraAig( nBoxes, 3, 2 );
+    // optionally normalize the AIG
+    return pNew;
+}
+Gia_Man_t * Gia_ManDupWithArtificalFaddBoxesTest( Gia_Man_t * p )
+{
+    Gia_Man_t * pNew;
+    Gia_Obj_t * pObj;
+    int i;
+    // label some and-gates
+    Gia_ManCleanMark01( p );
+    Gia_ManForEachAnd( p, pObj, i )
+    {
+        pObj->fMark0 = i % 5;
+        pObj->fMark1 = i % 7;
+        if ( pObj->fMark0 && pObj->fMark1 )
+            pObj->fMark0 = pObj->fMark1 = 0;
+    }
+
+    // output new AIG
+    pNew = Gia_ManDupWithArtificalFaddBoxes( p, 0 );
+    Gia_ManCleanMark01( p );
+    return pNew;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Adds artificial carry chains to the manager.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+// computes AIG delay information when boxes are used
+int Gia_ManFindAnnotatedDelay( Gia_Man_t * p, int DelayC, int * pnBoxes, int fIgnoreBoxDelays )
+{
+    Gia_Obj_t * pObj;
+    int nRealPis = Gia_ManBoxNum(p) ? Tim_ManPiNum((Tim_Man_t *)p->pManTime) : Gia_ManCiNum(p);
+    int * pDelays = Vec_IntArray(p->vLevels);
+    int i, k, iBox, iBoxOutId, Delay, Delay0, Delay1, DelayMax = 0, nBoxes = 0;
+    Vec_IntFill( p->vLevels, Gia_ManObjNum(p), 0 );
+    Gia_ManForEachObj1( p, pObj, i )
+    {
+        if ( Gia_ObjIsCi(pObj) )
+        {
+            if ( fIgnoreBoxDelays )
+                continue;
+            // check if it is real PI
+            iBoxOutId = Gia_ObjCioId(pObj) - nRealPis;
+            if ( iBoxOutId < 0 )
+                continue;
+            // if it is a box output, find box number
+            iBox = iBoxOutId / 2;
+            assert( iBox < Gia_ManBoxNum(p) );
+            // check find the maximum delay of the box inputs
+            Delay = 0;
+            for ( k = 0; k < 3; k++ )
+            {
+                int Id = Gia_ObjId( p, Gia_ManCo(p, iBox*3+k) );
+                assert( Id < i );
+                Delay = Abc_MaxInt( Delay, pDelays[Id] );
+            }
+            // consider outputs
+            if ( iBoxOutId & 1 ) // carry output
+                Delay += DelayC;
+            else // sum output
+                Delay += 100;
+            pDelays[i] = Delay;
+            continue;
+        }
+        if ( Gia_ObjIsCo(pObj) )
+        {
+            pDelays[i] = pDelays[Gia_ObjFaninId0(pObj, i)];
+            DelayMax = Abc_MaxInt( DelayMax, pDelays[i] );
+            continue;
+        }
+        assert( !pObj->fMark0 || !pObj->fMark1 );
+        Delay0 = pDelays[Gia_ObjFaninId0(pObj, i)];
+        Delay1 = pDelays[Gia_ObjFaninId1(pObj, i)];
+        if ( pObj->fMark0 )
+        {
+            Delay = Abc_MaxInt( Delay0 + DelayC, Delay1 + 100 );
+            nBoxes++;
+        }
+        else if ( pObj->fMark1 )
+        {
+            Delay = Abc_MaxInt( Delay1 + DelayC, Delay0 + 100 );
+            nBoxes++;
+        }
+        else
+            Delay = Abc_MaxInt( Delay0 + 100, Delay1 + 100 );
+        pDelays[i] = Delay;
+    }
+    if ( pnBoxes )
+        *pnBoxes = nBoxes;
+    return DelayMax;
+}
+// check if the object is already used in some chain
+static inline int Gia_ObjIsUsed( Gia_Obj_t * pObj )
+{
+    return pObj->fMark0 || pObj->fMark1 || pObj->fPhase;
+}
+// finds internal node that can begin a new chain
+int Gia_ManFindChainStart( Gia_Man_t * p )
+{
+    Gia_Obj_t * pObj;
+    int * pDelays = Vec_IntArray(p->vLevels);
+    int i, iMax = -1, DelayMax = 0;
+    Gia_ManForEachAnd( p, pObj, i )
+    {
+        if ( Gia_ObjIsUsed(pObj) )
+            continue;
+        if ( DelayMax > pDelays[i] )
+            continue;
+        DelayMax = pDelays[i];
+        iMax = i;
+    }
+    return iMax;
+}
+// finds a sequence of internal nodes that creates a new chain
+int Gia_ManFindPath( Gia_Man_t * p, int DelayC, int nPathMin, int nPathMax, Vec_Int_t * vPath )
+{
+    Gia_Obj_t * pObj, * pFanin0, * pFanin1;
+    int * pDelays = Vec_IntArray(p->vLevels);
+    int i, iLit, iMax = Gia_ManFindChainStart( p );
+    if ( iMax == -1 )
+        return -1;
+    Vec_IntClear( vPath );
+    pObj = Gia_ManObj(p, iMax);
+    assert( Gia_ObjIsAnd(pObj) );
+    while ( Gia_ObjIsAnd(pObj) )
+    {
+        assert( !Gia_ObjIsUsed(pObj) );
+        pFanin0 = Gia_ObjFanin0(pObj);
+        pFanin1 = Gia_ObjFanin1(pObj);
+        if ( Gia_ObjIsUsed(pFanin0) && Gia_ObjIsUsed(pFanin1) )
+            break;
+        if ( Gia_ObjIsUsed(pFanin0) )
+        {
+            Vec_IntPush( vPath, Abc_Var2Lit(Gia_ObjId(p, pObj), 1) );
+            pObj = pFanin1;
+        }
+        else if ( Gia_ObjIsUsed(pFanin1) )
+        {
+            Vec_IntPush( vPath, Abc_Var2Lit(Gia_ObjId(p, pObj), 0) );
+            pObj = pFanin0;
+        }
+        else
+        {
+            if ( pDelays[Gia_ObjId(p, pFanin1)] > pDelays[Gia_ObjId(p, pFanin0)] )
+            {
+                Vec_IntPush( vPath, Abc_Var2Lit(Gia_ObjId(p, pObj), 1) );
+                pObj = pFanin1;
+            }
+            else
+            {
+                Vec_IntPush( vPath, Abc_Var2Lit(Gia_ObjId(p, pObj), 0) );
+                pObj = pFanin0;
+            }
+        }
+    }
+    if ( Vec_IntSize(vPath) < nPathMin )
+    {
+        Gia_ManObj(p, iMax)->fPhase = 1;
+        return 0;
+    }
+    // label nodes
+    if ( Vec_IntSize(vPath) > nPathMax )
+        Vec_IntShrink( vPath, nPathMax );
+    Vec_IntForEachEntry( vPath, iLit, i )
+    {
+        pObj = Gia_ManObj( p, Abc_Lit2Var(iLit) );
+        if ( Abc_LitIsCompl(iLit) )
+        {
+            assert( pObj->fMark1 == 0 );
+            pObj->fMark1 = 1;
+            assert( Gia_ObjFanin1(pObj)->fPhase == 0 );
+            Gia_ObjFanin1(pObj)->fPhase = 1;
+        }
+        else
+        {
+            assert( pObj->fMark0 == 0 );
+            pObj->fMark0 = 1;
+            assert( Gia_ObjFanin0(pObj)->fPhase == 0 );
+            Gia_ObjFanin0(pObj)->fPhase = 1;
+        }
+    }
+    return Vec_IntSize(vPath);
+}
+// iteratively create the given number of chains
+int Gia_ManIteratePaths( Gia_Man_t * p, int DelayC, int nPathMin, int nPathMax, int nPathLimit, int fIgnoreBoxDelays, int fVerbose )
+{
+    Gia_Obj_t * pObj;
+    Vec_Int_t * vPath = Vec_IntAlloc( 100 );
+    int i, RetValue, nBoxes, MaxDelay, nPaths = 0;
+    assert( p->vLevels == NULL );
+    p->vLevels = Vec_IntStart( Gia_ManObjNum(p) );
+    Gia_ManCleanMark01( p );
+    Gia_ManCleanPhase( p );
+    Gia_ManForEachCi( p, pObj, i )
+        pObj->fPhase = 1;
+    if ( fVerbose )
+        printf( "Running path detection: BoxDelay = %d, PathMin = %d, PathMax = %d, PathLimit = %d.\n", DelayC, nPathMin, nPathMax, nPathLimit );
+    for ( i = 0; i < nPathLimit; i++ )
+    {
+        MaxDelay = Gia_ManFindAnnotatedDelay( p, DelayC, &nBoxes, fIgnoreBoxDelays );
+        RetValue = Gia_ManFindPath( p, DelayC, nPathMin, nPathMax, vPath );
+        if ( RetValue == -1 )
+            break;
+        nPaths += (RetValue > 0);
+        if ( fVerbose )
+            printf( "Iter %5d : Paths = %2d. Boxes = %2d. Total boxes = %6d.  Max delay = %5d.\n", i, nPaths, RetValue, nBoxes, MaxDelay );
+    }
+    Vec_IntFree( vPath );
+    Vec_IntFreeP( &p->vLevels );
+    Gia_ManCleanPhase( p );
+    return 1;
+}
+// annotate artificial chains and then put them into boxes
+Gia_Man_t * Gia_ManDupWithArtificialBoxes( Gia_Man_t * p, int DelayC, int nPathMin, int nPathMax, int nPathLimit, int fUseFanout, int fIgnoreBoxDelays, int fVerbose )
+{
+    Gia_Man_t * pNew;
+/*
+    if ( Gia_ManBoxNum(p) > 0 )
+    {
+        printf( "Currently artifical carry-chains cannot be detected when natural ones are present.\n" );
+        return NULL;
+    }
+*/
+    Gia_ManIteratePaths( p, DelayC, nPathMin, nPathMax, nPathLimit, fIgnoreBoxDelays, fVerbose );
+    pNew = Gia_ManDupWithArtificalFaddBoxes( p, fUseFanout );
+    Gia_ManCleanMark01( p );
+    return pNew;
+}
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/abc-build/src/aig/gia/giaFx.c b/abc-build/src/aig/gia/giaFx.c
--- a/abc-build/src/aig/gia/giaFx.c
+++ b/abc-build/src/aig/gia/giaFx.c
@@ -96,6 +96,20 @@
         iSum = Abc_LitNot(iSum);
     return iSum;
 }
+int Gia_ManFactorGraph( Gia_Man_t * p, Dec_Graph_t * pFForm, Vec_Int_t * vLeaves )
+{
+    Dec_Node_t * pFFNode;
+    int i, Lit;
+    // assign fanins
+    Dec_GraphForEachLeaf( pFForm, pFFNode, i )
+    {
+        assert( Vec_IntEntry(vLeaves, i) >= 0 );
+        pFFNode->iFunc = Vec_IntEntry(vLeaves, i);
+    }
+    // perform strashing
+    Lit = Gia_ManGraphToAig( p, pFForm );
+    return Lit;
+}
 int Gia_ManFactorNode( Gia_Man_t * p, char * pSop, Vec_Int_t * vLeaves )
 {
     if ( Kit_PlaGetVarNum(pSop) == 0 )
@@ -103,18 +117,8 @@
     assert( Kit_PlaGetVarNum(pSop) == Vec_IntSize(vLeaves) );
     if ( Kit_PlaGetVarNum(pSop) > 2 && Kit_PlaGetCubeNum(pSop) > 1 )
     {
-        Dec_Graph_t * pFForm;
-        Dec_Node_t * pFFNode;
-        int i, Lit;
-        pFForm = Dec_Factor( pSop );
-        // assign fanins
-        Dec_GraphForEachLeaf( pFForm, pFFNode, i )
-        {
-            assert( Vec_IntEntry(vLeaves, i) >= 0 );
-            pFFNode->iFunc = Vec_IntEntry(vLeaves, i);
-        }
-        // perform strashing
-        Lit = Gia_ManGraphToAig( p, pFForm );
+        Dec_Graph_t * pFForm = Dec_Factor( pSop );
+        int Lit = Gia_ManFactorGraph( p, pFForm, vLeaves );
         Dec_GraphFree( pFForm );
         return Lit;
     }
@@ -324,6 +328,7 @@
     pNew = Gia_ManStart( Gia_ManObjNum(p) );
     pNew->pName = Abc_UtilStrsav( p->pName );
     pNew->pSpec = Abc_UtilStrsav( p->pSpec );
+    pNew->vLevels = Vec_IntStart( 6*Gia_ManObjNum(p)/5 + 100 );
     Gia_ManHashStart( pNew );
     // create primary inputs
     vMap = Vec_IntStartFull( Vec_IntSize(vOrder) );
diff --git a/abc-build/src/aig/gia/giaHash.c b/abc-build/src/aig/gia/giaHash.c
--- a/abc-build/src/aig/gia/giaHash.c
+++ b/abc-build/src/aig/gia/giaHash.c
@@ -182,7 +182,7 @@
         assert( *pPlace != 0 );
         Counter++;
     }
-    Counter2 = Gia_ManAndNum(p);
+    Counter2 = Gia_ManAndNum(p) - Gia_ManBufNum(p);
     assert( Counter == Counter2 );
     ABC_FREE( pHTableOld );
 //    if ( p->fVerbose )
@@ -685,6 +685,25 @@
     iTemp1 = Gia_ManHashAnd( p, iCtrl, iData1 );
     return Abc_LitNotCond( Gia_ManHashAnd( p, Abc_LitNot(iTemp0), Abc_LitNot(iTemp1) ), !fCompl );
 }
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Gia_ManHashMaj( Gia_Man_t * p, int iData0, int iData1, int iData2 )  
+{ 
+    int iTemp0 = Gia_ManHashOr( p, iData1, iData2 );
+    int iTemp1 = Gia_ManHashAnd( p, iData0, iTemp0 );
+    int iTemp2 = Gia_ManHashAnd( p, iData1, iData2 );
+    return Gia_ManHashOr( p, iTemp1, iTemp2 );
+}
 
 /**Function*************************************************************
 
@@ -710,6 +729,9 @@
     Gia_ManConst0(p)->Value = 0;
     Gia_ManForEachObj( p, pObj, i )
     {
+        //if ( Gia_ObjIsBuf(pObj) )
+        //    pObj->Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(pObj) );
+        //else 
         if ( Gia_ObjIsAnd(pObj) )
             pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
         else if ( Gia_ObjIsCi(pObj) )
diff --git a/abc-build/src/aig/gia/giaIf.c b/abc-build/src/aig/gia/giaIf.c
--- a/abc-build/src/aig/gia/giaIf.c
+++ b/abc-build/src/aig/gia/giaIf.c
@@ -366,29 +366,52 @@
     pFanins[1] = Gia_ObjId(p, Gia_Regular(pData1));
     pFanins[2] = Gia_ObjId(p, Gia_Regular(pData0));
 }
-int Gia_ManCountDupLut6( Gia_Man_t * p )
+int Gia_ManCountDupLut( Gia_Man_t * p )
 {
-    int i, nCountDup = 0, nCountPis = 0, nCountMux = 0;
+    Gia_Obj_t * pObj, * pFanin;
+    int i, pFanins[3], nCountDup = 0, nCountPis = 0, nCountMux = 0;
     Gia_ManCleanMark01( p );
     Gia_ManForEachLut( p, i )
-        if ( Gia_ObjLutSize(p, i) == 3 && Gia_ObjLutIsMux(p, i) )
+        if ( Gia_ObjLutIsMux(p, i) )
         {
-            Gia_Obj_t * pFanin;
-            int pFanins[3];
-            Gia_ManPrintGetMuxFanins( p, Gia_ManObj(p, i), pFanins );
-            Gia_ManObj(p, i)->fMark1 = 1;
+            pObj = Gia_ManObj( p, i );
+            pObj->fMark1 = 1;
+            if ( Gia_ObjLutSize(p, i) == 3 )
+            {
+                Gia_ManPrintGetMuxFanins( p, pObj, pFanins );
 
-            pFanin = Gia_ManObj(p, pFanins[1]);
-            nCountPis += Gia_ObjIsCi(pFanin);
-            nCountDup += pFanin->fMark0;
-            nCountMux += pFanin->fMark1;
-            pFanin->fMark0 = 1;
+                pFanin = Gia_ManObj(p, pFanins[1]);
+                nCountPis += Gia_ObjIsCi(pFanin);
+                nCountDup += pFanin->fMark0;
+                nCountMux += pFanin->fMark1;
+                pFanin->fMark0 = 1;
 
-            pFanin = Gia_ManObj(p, pFanins[2]);
-            nCountPis += Gia_ObjIsCi(pFanin);
-            nCountDup += pFanin->fMark0;
-            nCountMux += pFanin->fMark1;
-            pFanin->fMark0 = 1;
+                pFanin = Gia_ManObj(p, pFanins[2]);
+                nCountPis += Gia_ObjIsCi(pFanin);
+                nCountDup += pFanin->fMark0;
+                nCountMux += pFanin->fMark1;
+                pFanin->fMark0 = 1;
+            }
+            else if ( Gia_ObjLutSize(p, i) == 2 )
+            {
+                pFanin = Gia_ObjFanin0(pObj);
+                if ( pFanin->fMark0 || pFanin->fMark1 )
+                {
+                    pFanin = Gia_ObjFanin1(pObj);
+                    nCountPis += Gia_ObjIsCi(pFanin);
+                    nCountDup += pFanin->fMark0;
+                    nCountMux += pFanin->fMark1;
+                    pFanin->fMark0 = 1;
+                }
+                else
+                {
+                    nCountPis += Gia_ObjIsCi(pFanin);
+                    nCountDup += pFanin->fMark0;
+                    nCountMux += pFanin->fMark1;
+                    pFanin->fMark0 = 1;
+                }
+            }
+            else assert( 0 );
         }
     Gia_ManCleanMark01( p );
     if ( nCountDup + nCountPis + nCountMux )
@@ -401,22 +424,31 @@
 {
     Gia_Obj_t * pObj;
     int * pLevels;
-    int i, k, iFan, nLutSize = 0, nLuts = 0, nFanins = 0, LevelMax = 0, Ave = 0, nMuxF7 = 0;
+    int i, k, iFan, nLutSize = 0, nLuts = 0, nFanins = 0, LevelMax = 0, Ave = 0, nMuxF = 0;
     if ( !Gia_ManHasMapping(p) )
         return;
     pLevels = ABC_CALLOC( int, Gia_ManObjNum(p) );
     Gia_ManForEachLut( p, i )
     {
-        if ( Gia_ObjLutSize(p, i) == 3 && Gia_ObjLutIsMux(p, i) )
+        if ( Gia_ObjLutIsMux(p, i) )
         {
             int pFanins[3];
-            Gia_ManPrintGetMuxFanins( p, Gia_ManObj(p, i), pFanins );
-            pLevels[i] = Abc_MaxInt( pLevels[i], pLevels[pFanins[0]]+1 );
-            pLevels[i] = Abc_MaxInt( pLevels[i], pLevels[pFanins[1]] );
-            pLevels[i] = Abc_MaxInt( pLevels[i], pLevels[pFanins[2]] );
+            if ( Gia_ObjLutSize(p, i) == 3 )
+            {
+                Gia_ManPrintGetMuxFanins( p, Gia_ManObj(p, i), pFanins );
+                pLevels[i] = Abc_MaxInt( pLevels[i], pLevels[pFanins[0]]+1 );
+                pLevels[i] = Abc_MaxInt( pLevels[i], pLevels[pFanins[1]] );
+                pLevels[i] = Abc_MaxInt( pLevels[i], pLevels[pFanins[2]] );
+            }
+            else if ( Gia_ObjLutSize(p, i) == 2 )
+            {
+                pObj = Gia_ManObj( p, i );
+                pLevels[i] = Abc_MaxInt( pLevels[i], pLevels[Gia_ObjFaninId0(pObj, i)] );
+                pLevels[i] = Abc_MaxInt( pLevels[i], pLevels[Gia_ObjFaninId1(pObj, i)] );
+            }
             LevelMax = Abc_MaxInt( LevelMax, pLevels[i] );
-            nMuxF7++;
             nFanins++;
+            nMuxF++;
             continue;
         }
         nLuts++;
@@ -437,8 +469,8 @@
     Abc_Print( 1, "Mapping (K=%d)  :  ", nLutSize );
     SetConsoleTextAttribute( hConsole, 14 ); // yellow
     Abc_Print( 1, "lut =%7d  ",  nLuts );
-    if ( nMuxF7 )
-    Abc_Print( 1, "mux =%7d  ",  nMuxF7 );
+    if ( nMuxF )
+    Abc_Print( 1, "muxF =%7d  ",  nMuxF );
     SetConsoleTextAttribute( hConsole, 10 ); // green
     Abc_Print( 1, "edge =%8d  ", nFanins );
     SetConsoleTextAttribute( hConsole, 12 ); // red
@@ -464,9 +496,10 @@
     Abc_Print( 1, "\n" );
 #endif
 
-    if ( nMuxF7 )
-        Gia_ManCountDupLut6( p );
+    if ( nMuxF )
+        Gia_ManCountDupLut( p );
 
+    return;
     if ( pDumpFile )
     {
         static char FileNameOld[1000] = {0};
@@ -477,11 +510,18 @@
             sprintf( FileNameOld, "%s", p->pName );
             fprintf( pTable, "\n" );
             fprintf( pTable, "%s  ", p->pName );
-            fprintf( pTable, "%d ", Gia_ManCiNum(p) );
-            fprintf( pTable, "%d ", Gia_ManCoNum(p) );
-            fprintf( pTable, "%d  ", Gia_ManAndNum(p) );
+//            fprintf( pTable, "%d ", Gia_ManCiNum(p) );
+//            fprintf( pTable, "%d ", Gia_ManCoNum(p) );
+//            fprintf( pTable, "%d  ", Gia_ManAndNum(p) );
+            fprintf( pTable, "%d ", Gia_ManPiNum(p) - Gia_ManBoxCiNum(p) - Gia_ManRegBoxNum(p) );
+            fprintf( pTable, "%d ", Gia_ManPoNum(p) - Gia_ManBoxCoNum(p) - Gia_ManRegBoxNum(p) );
+            fprintf( pTable, "%d ", Gia_ManClockDomainNum(p) );
+
+            fprintf( pTable, " " );
             fprintf( pTable, "%d ", nLuts           );
             fprintf( pTable, "%d ", LevelMax        );
+            fprintf( pTable, "%d ", Gia_ManRegBoxNum(p) );
+            fprintf( pTable, "%d ", Gia_ManNonRegBoxNum(p) );
             clk = Abc_Clock();
         }
         else
@@ -489,6 +529,8 @@
             fprintf( pTable, " " );
             fprintf( pTable, "%d ", nLuts           );
             fprintf( pTable, "%d ", LevelMax        );
+            fprintf( pTable, "%d ", Gia_ManRegBoxNum(p) );
+            fprintf( pTable, "%d ", Gia_ManNonRegBoxNum(p) );
             fprintf( pTable, "%.2f", 1.0*(Abc_Clock() - clk)/CLOCKS_PER_SEC );
             clk = Abc_Clock();
         }
@@ -1425,22 +1467,221 @@
   SeeAlso     []
 
 ***********************************************************************/
+int Gia_ManFromIfLogicFindCell( If_Man_t * pIfMan, Gia_Man_t * pNew, Gia_Man_t * pTemp, If_Cut_t * pCutBest, sat_solver * pSat, Vec_Int_t * vPiVars, Vec_Int_t * vPoVars, Ifn_Ntk_t * pNtkCell, int nLutMax, Vec_Int_t * vLeaves, Vec_Int_t * vLits, Vec_Int_t * vCover, Vec_Int_t * vMapping, Vec_Int_t * vMapping2, Vec_Int_t * vPacking )
+{
+    int iLit;
+    if ( Vec_IntSize(vLeaves) <= nLutMax )
+        iLit = Gia_ManFromIfLogicCreateLut( pNew, If_CutTruthW(pIfMan, pCutBest), vLeaves, vCover, vMapping, vMapping2 );
+    else
+    {
+        Gia_Obj_t * pObj;
+        int i, Id, iLitTemp;
+        // extract variable permutation
+        char * pCutPerm = If_CutDsdPerm( pIfMan, pCutBest ); // DSD input -> cut input
+        word Perm = If_DsdManGetFuncPerm( pIfMan->pIfDsdMan, If_CutDsdLit(pIfMan, pCutBest) ); // cell input -> DSD input
+        assert( Perm > 0 );
+        // (extend storage for configuration bits)
+        // derive mapping from cell inputs into cut inputs
+        // retrieve config bits of the LUTs
+        // perform boolean matching
+        if ( !If_ManSatFindCofigBits( pSat, vPiVars, vPoVars, If_CutTruthW(pIfMan, pCutBest), Vec_IntSize(vLeaves), Perm, Ifn_NtkInputNum(pNtkCell), vLits ) )
+        {
+            printf( "Boolean matching does not exist.\n" );
+            return -1;
+        }
+        // use config bits to generate the network
+        iLit = If_ManSatDeriveGiaFromBits( pTemp, pNtkCell, vLits, vCover );
+        // copy GIA back into the manager
+        Vec_IntFillExtra( &pTemp->vCopies, Gia_ManObjNum(pTemp), -1 );
+        Gia_ObjSetCopyArray( pTemp, 0, 0 );
+        Vec_IntForEachEntry( vLeaves, iLitTemp, i )
+            Gia_ObjSetCopyArray( pTemp, Gia_ManCiIdToId(pTemp, i), iLitTemp );
+        // collect nodes
+        Gia_ManIncrementTravId( pTemp );
+        Id = Abc_Lit2Var( iLit );
+        Gia_ManCollectAnds( pTemp, &Id, 1, vCover );
+        Vec_IntPrint( vCover );
+        Gia_ManForEachObjVec( vCover, pTemp, pObj, i )
+            Gia_ObjPrint( pTemp, pObj );
+        // copy GIA
+        Gia_ManForEachObjVec( vCover, pTemp, pObj, i )
+        {
+            iLit = Gia_ManAppendAnd( pNew, Gia_ObjFanin0CopyArray(pTemp, pObj), Gia_ObjFanin1CopyArray(pTemp, pObj) );
+            Gia_ObjSetCopyArray( pTemp, Gia_ObjId(pTemp, pObj), iLit );
+        }
+        iLit = Abc_LitNotCond( Gia_ObjCopyArray(pTemp, Id), Abc_LitIsCompl(iLit) );
+    }
+    // write packing
+    if ( !Gia_ObjIsCi(Gia_ManObj(pNew, Abc_Lit2Var(iLit))) && iLit > 1 )
+    {
+        Vec_IntPush( vPacking, 1 );
+        Vec_IntPush( vPacking, Abc_Lit2Var(iLit) );
+        Vec_IntAddToEntry( vPacking, 0, 1 );
+    }
+    return iLit;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Converts IF into GIA manager.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Gia_ManFromIfLogicCofVars( Gia_Man_t * pNew, If_Man_t * pIfMan, If_Cut_t * pCutBest, Vec_Int_t * vLeaves, Vec_Int_t * vLeaves2, Vec_Int_t * vCover, Vec_Int_t * vMapping, Vec_Int_t * vMapping2 )
+{
+    word pTruthCof[128], * pTruth = If_CutTruthW(pIfMan, pCutBest);
+    int pVarsNew[16], nVarsNew, iLitCofs[3]; 
+    int nLeaves = pCutBest->nLeaves;
+    int nWords  = Abc_Truth6WordNum(nLeaves);
+    int truthId = Abc_Lit2Var(pCutBest->iCutFunc);
+    int c, iVar = Vec_StrEntry(pIfMan->vTtVars[nLeaves], truthId), iTemp, iTopLit;
+    int k, RetValue = -1;
+    assert( iVar >= 0 && iVar < nLeaves && pIfMan->pPars->nLutSize <= 13 );
+    for ( c = 0; c < 2; c++ )
+    {
+        for ( k = 0; k < nLeaves; k++ )
+            pVarsNew[k] = k;
+        if ( c )
+            Abc_TtCofactor1p( pTruthCof, pTruth, nWords, iVar );
+        else
+            Abc_TtCofactor0p( pTruthCof, pTruth, nWords, iVar );
+        nVarsNew = Abc_TtMinBase( pTruthCof, pVarsNew, pCutBest->nLeaves, Abc_MaxInt(6, pCutBest->nLeaves) );
+        // derive LUT
+        Vec_IntClear( vLeaves2 );
+        for ( k = 0; k < nVarsNew; k++ )
+            Vec_IntPush( vLeaves2, Vec_IntEntry(vLeaves, pVarsNew[k]) );
+        iLitCofs[c] = Kit_TruthToGia( pNew, (unsigned *)pTruthCof, nVarsNew, vCover, vLeaves2, 0 );
+        if ( nVarsNew < 2 )
+            continue;
+        // create mapping
+        assert( Gia_ObjIsAnd(Gia_ManObj(pNew, Abc_Lit2Var(iLitCofs[c]))) );
+        Vec_IntSetEntry( vMapping, Abc_Lit2Var(iLitCofs[c]), Vec_IntSize(vMapping2) );
+        Vec_IntPush( vMapping2, Vec_IntSize(vLeaves2) );
+        Vec_IntForEachEntry( vLeaves2, iTemp, k )
+            Vec_IntPush( vMapping2, Abc_Lit2Var(iTemp) );
+        Vec_IntPush( vMapping2, Abc_Lit2Var(iLitCofs[c]) );
+    }
+    iLitCofs[2]  = Vec_IntEntry(vLeaves, iVar);
+    // derive MUX
+    if ( iLitCofs[0] > 1 && iLitCofs[1] > 1 )
+    {
+        pTruthCof[0] = ABC_CONST(0xCACACACACACACACA);
+        Vec_IntClear( vLeaves2 );
+        Vec_IntPush( vLeaves2, iLitCofs[0] );
+        Vec_IntPush( vLeaves2, iLitCofs[1] );
+        Vec_IntPush( vLeaves2, iLitCofs[2] );
+        RetValue = Kit_TruthToGia( pNew, (unsigned *)pTruthCof, Vec_IntSize(vLeaves2), vCover, vLeaves2, 0 );
+        iTopLit = RetValue;
+    }
+    else
+    {
+        assert( iLitCofs[0] > 1 || iLitCofs[1] > 1 );
+        // collect leaves
+        Vec_IntClear( vLeaves2 );
+        for ( k = 0; k < 3; k++ )
+            if ( iLitCofs[k] > 1 )
+                Vec_IntPush( vLeaves2, iLitCofs[k] );
+        assert( Vec_IntSize(vLeaves2) == 2 );
+        // consider three possibilities
+        if ( iLitCofs[0] == 0 )
+            RetValue = Gia_ManAppendAnd( pNew, iLitCofs[2], iLitCofs[1] );
+        else if ( iLitCofs[0] == 1 )
+            RetValue = Gia_ManAppendOr( pNew, Abc_LitNot(iLitCofs[2]), iLitCofs[1] );
+        else if ( iLitCofs[1] == 0 )
+            RetValue = Gia_ManAppendAnd( pNew, Abc_LitNot(iLitCofs[2]), iLitCofs[0] );
+        else if ( iLitCofs[1] == 1 )
+            RetValue = Gia_ManAppendOr( pNew, iLitCofs[2], iLitCofs[0] );
+        else assert( 0 );
+        iTopLit = iLitCofs[2];
+    }
+    // create mapping
+    Vec_IntSetEntry( vMapping, Abc_Lit2Var(RetValue), Vec_IntSize(vMapping2) );
+    Vec_IntPush( vMapping2, Vec_IntSize(vLeaves2) );
+    Vec_IntForEachEntry( vLeaves2, iTemp, k )
+        Vec_IntPush( vMapping2, Abc_Lit2Var(iTemp) );
+    Vec_IntPush( vMapping2, -Abc_Lit2Var(iTopLit) );
+    RetValue = Abc_LitNotCond( RetValue, pCutBest->fCompl );
+    return RetValue;
+}
+int Gia_ManFromIfLogicAndVars( Gia_Man_t * pNew, If_Man_t * pIfMan, If_Cut_t * pCutBest, Vec_Int_t * vLeaves, Vec_Int_t * vLeaves2, Vec_Int_t * vCover, Vec_Int_t * vMapping, Vec_Int_t * vMapping2 )
+{
+    word pFunc[64], uTruth[2];
+    int nLeaves = pCutBest->nLeaves;
+    int truthId = Abc_Lit2Var(pCutBest->iCutFunc);
+    int c, k, Mask = Vec_IntEntry(pIfMan->vTtDecs[nLeaves], truthId);
+    int MaskOne[2] = { Mask & 0xFFFF, (Mask >> 16) & 0x3FFF };
+    int iLitCofs[2], iTemp, fOrDec = (Mask >> 30) & 1, RetValue = -1; 
+    assert( Mask > 0 && nLeaves <= 2 * (pIfMan->pPars->nLutSize/2) && pIfMan->pPars->nLutSize <= 13 );
+    Abc_TtCopy( pFunc, If_CutTruthWR(pIfMan, pCutBest), pIfMan->nTruth6Words[nLeaves], fOrDec );
+    Abc_TtDeriveBiDec( pFunc, nLeaves, MaskOne[0], MaskOne[1], pIfMan->pPars->nLutSize/2, &uTruth[0], &uTruth[1] );
+    uTruth[0] = fOrDec ? ~uTruth[0] : uTruth[0];
+    uTruth[1] = fOrDec ? ~uTruth[1] : uTruth[1];
+    for ( c = 0; c < 2; c++ )
+    {
+        Vec_IntClear( vLeaves2 );
+        for ( k = 0; k < nLeaves; k++ )
+            if ( (MaskOne[c] >> k) & 1 )
+                Vec_IntPush( vLeaves2, Vec_IntEntry(vLeaves, k) );
+        assert( Vec_IntSize(vLeaves2) >= 1 );
+        iLitCofs[c] = Kit_TruthToGia( pNew, (unsigned *)&uTruth[c], Vec_IntSize(vLeaves2), vCover, vLeaves2, 0 );
+        if ( Vec_IntSize(vLeaves2) == 1 )
+            continue;
+        // create mapping
+        assert( Gia_ObjIsAnd(Gia_ManObj(pNew, Abc_Lit2Var(iLitCofs[c]))) );
+        Vec_IntSetEntry( vMapping, Abc_Lit2Var(iLitCofs[c]), Vec_IntSize(vMapping2) );
+        Vec_IntPush( vMapping2, Vec_IntSize(vLeaves2) );
+        Vec_IntForEachEntry( vLeaves2, iTemp, k )
+            Vec_IntPush( vMapping2, Abc_Lit2Var(iTemp) );
+        Vec_IntPush( vMapping2, Abc_Lit2Var(iLitCofs[c]) );
+    }
+    iLitCofs[0] = Abc_LitNotCond( iLitCofs[0], fOrDec );
+    iLitCofs[1] = Abc_LitNotCond( iLitCofs[1], fOrDec );
+    RetValue = Gia_ManAppendAnd( pNew, iLitCofs[0], iLitCofs[1] );
+    RetValue = Abc_LitNotCond( RetValue, fOrDec ^ Abc_LitIsCompl(pCutBest->iCutFunc) );
+    // create mapping
+    Vec_IntSetEntry( vMapping, Abc_Lit2Var(RetValue), Vec_IntSize(vMapping2) );
+    Vec_IntPush( vMapping2, 2 );
+    Vec_IntPush( vMapping2, Abc_Lit2Var(iLitCofs[0]) );
+    Vec_IntPush( vMapping2, Abc_Lit2Var(iLitCofs[1]) );
+    Vec_IntPush( vMapping2, -Abc_Lit2Var(RetValue) );
+    RetValue = Abc_LitNotCond( RetValue, pCutBest->fCompl );
+    return RetValue;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Converts IF into GIA manager.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
 Gia_Man_t * Gia_ManFromIfLogic( If_Man_t * pIfMan )
 {
-    Gia_Man_t * pNew;
+    Gia_Man_t * pNew, * pHashed = NULL;
     If_Cut_t * pCutBest;
     If_Obj_t * pIfObj, * pIfLeaf;
     Vec_Int_t * vMapping, * vMapping2, * vPacking = NULL;
     Vec_Int_t * vLeaves, * vLeaves2, * vCover, * vLits;
+    Vec_Int_t * vPiVars = NULL, * vPoVars = NULL;
     sat_solver * pSat = NULL;
-    int i, k, Entry;
+    Ifn_Ntk_t * pNtkCell = NULL;
+    int i, k, nLutMax = -1, Entry;
     assert( !pIfMan->pPars->fDeriveLuts || pIfMan->pPars->fTruth );
 //    if ( pIfMan->pPars->fEnableCheck07 )
 //        pIfMan->pPars->fDeriveLuts = 0;
     // start mapping and packing
     vMapping  = Vec_IntStart( If_ManObjNum(pIfMan) );
     vMapping2 = Vec_IntStart( 1 );
-    if ( pIfMan->pPars->fDeriveLuts && (pIfMan->pPars->pLutStruct || pIfMan->pPars->fEnableCheck75 || pIfMan->pPars->fEnableCheck75u || pIfMan->pPars->fEnableCheck07) )
+    if ( pIfMan->pPars->fDeriveLuts && (pIfMan->pPars->pLutStruct || pIfMan->pPars->fEnableCheck75 || pIfMan->pPars->fEnableCheck75u || pIfMan->pPars->fEnableCheck07 || pIfMan->pPars->fUseDsdTune) )
     {
         vPacking = Vec_IntAlloc( 1000 );
         Vec_IntPush( vPacking, 0 );
@@ -1461,7 +1702,10 @@
         {
             pCutBest = If_ObjCutBest( pIfObj );
             // perform sorting of cut leaves by delay, so that the slowest pin drives the fastest input of the LUT
-            if ( !pIfMan->pPars->fUseTtPerm && !pIfMan->pPars->fDelayOpt && !pIfMan->pPars->fDelayOptLut && !pIfMan->pPars->fDsdBalance && !pIfMan->pPars->pLutStruct && !pIfMan->pPars->fUserRecLib && !pIfMan->pPars->nGateSize && !pIfMan->pPars->fEnableCheck75 && !pIfMan->pPars->fEnableCheck75u && !pIfMan->pPars->fEnableCheck07 )
+            if ( !pIfMan->pPars->fUseTtPerm && !pIfMan->pPars->fDelayOpt && !pIfMan->pPars->fDelayOptLut && !pIfMan->pPars->fDsdBalance && 
+                 !pIfMan->pPars->pLutStruct && !pIfMan->pPars->fUserRecLib && !pIfMan->pPars->nGateSize && !pIfMan->pPars->fEnableCheck75 && 
+                 !pIfMan->pPars->fEnableCheck75u && !pIfMan->pPars->fEnableCheck07 && !pIfMan->pPars->fUseDsdTune && 
+                 !pIfMan->pPars->fUseCofVars && !pIfMan->pPars->fUseAndVars )
                 If_CutRotatePins( pIfMan, pCutBest );
             // collect leaves of the best cut
             Vec_IntClear( vLeaves );
@@ -1478,6 +1722,38 @@
                     pIfObj->iCopy = Gia_ManFromIfLogicCreateLut( pNew, If_CutTruthW(pIfMan, pCutBest), vLeaves, vCover, vMapping, vMapping2 );
                 pIfObj->iCopy = Abc_LitNotCond( pIfObj->iCopy, pCutBest->fCompl );
             }
+            else if ( pIfMan->pPars->fUseDsd && pIfMan->pPars->fUseDsdTune && pIfMan->pPars->fDeriveLuts )
+            {
+                if ( pSat == NULL )
+                {
+                    pSat = (sat_solver *)If_ManSatBuildFromCell( If_DsdManGetCellStr(pIfMan->pIfDsdMan), &vPiVars, &vPoVars, &pNtkCell );
+                    nLutMax = Ifn_NtkLutSizeMax( pNtkCell );
+                    pHashed = Gia_ManStart( 10000 );
+                    Vec_IntFillExtra( &pHashed->vCopies, 10000, -1 );
+                    for ( k = 0; k < pIfMan->pPars->nLutSize; k++ )
+                        Gia_ManAppendCi( pHashed );
+                    Gia_ManHashAlloc( pHashed );
+                }
+                pIfObj->iCopy = Gia_ManFromIfLogicFindCell( pIfMan, pNew, pHashed, pCutBest, pSat, vPiVars, vPoVars, pNtkCell, nLutMax, vLeaves, vLits, vCover, vMapping, vMapping2, vPacking );
+                pIfObj->iCopy = Abc_LitNotCond( pIfObj->iCopy, pCutBest->fCompl );
+            }
+            else if ( pIfMan->pPars->fUseAndVars && pIfMan->pPars->fUseCofVars && pIfMan->pPars->fDeriveLuts && (int)pCutBest->nLeaves > pIfMan->pPars->nLutSize/2 )
+            {
+                int truthId = Abc_Lit2Var(pCutBest->iCutFunc);
+                int Mask = Vec_IntEntry(pIfMan->vTtDecs[pCutBest->nLeaves], truthId);
+                if ( Mask )
+                    pIfObj->iCopy = Gia_ManFromIfLogicAndVars( pNew, pIfMan, pCutBest, vLeaves, vLeaves2, vCover, vMapping, vMapping2 );
+                else
+                    pIfObj->iCopy = Gia_ManFromIfLogicCofVars( pNew, pIfMan, pCutBest, vLeaves, vLeaves2, vCover, vMapping, vMapping2 );
+            }
+            else if ( pIfMan->pPars->fUseAndVars && pIfMan->pPars->fDeriveLuts && (int)pCutBest->nLeaves > pIfMan->pPars->nLutSize/2 )
+            {
+                pIfObj->iCopy = Gia_ManFromIfLogicAndVars( pNew, pIfMan, pCutBest, vLeaves, vLeaves2, vCover, vMapping, vMapping2 );
+            }
+            else if ( pIfMan->pPars->fUseCofVars && pIfMan->pPars->fDeriveLuts && (int)pCutBest->nLeaves > pIfMan->pPars->nLutSize/2 )
+            {
+                pIfObj->iCopy = Gia_ManFromIfLogicCofVars( pNew, pIfMan, pCutBest, vLeaves, vLeaves2, vCover, vMapping, vMapping2 );
+            }
             else if ( (pIfMan->pPars->fDeriveLuts && pIfMan->pPars->fTruth) || pIfMan->pPars->fUseDsd || pIfMan->pPars->fUseTtPerm )
             {
                 word * pTruth = If_CutTruthW(pIfMan, pCutBest);
@@ -1520,8 +1796,14 @@
     Vec_IntFree( vCover );
     Vec_IntFree( vLeaves );
     Vec_IntFree( vLeaves2 );
-    if ( pSat != NULL )
+    Vec_IntFreeP( &vPiVars );
+    Vec_IntFreeP( &vPoVars );
+    if ( pNtkCell )
+        ABC_FREE( pNtkCell );
+    if ( pSat )
         sat_solver_delete(pSat);
+    if ( pHashed )
+        Gia_ManStop( pHashed );
 //    printf( "Mapping array size:  IfMan = %d. Gia = %d. Increase = %.2f\n", 
 //        If_ManObjNum(pIfMan), Gia_ManObjNum(pNew), 1.0 * Gia_ManObjNum(pNew) / If_ManObjNum(pIfMan) );
     // finish mapping 
@@ -1546,6 +1828,19 @@
         Gia_ManForEachCo( pNew, pObj, i )
            assert( !Gia_ObjIsAnd(Gia_ObjFanin0(pObj)) || Gia_ObjIsLut(pNew, Gia_ObjFaninId0p(pNew, pObj)) );
     }
+    // verify that internal nodes have mapping
+    {
+        Gia_Obj_t * pFanin;
+        Gia_ManForEachLut( pNew, i )
+            Gia_LutForEachFaninObj( pNew, i, pFanin, k )
+                assert( !Gia_ObjIsAnd(pFanin) || Gia_ObjIsLut(pNew, Gia_ObjId(pNew, pFanin)) );
+    }
+    // verify that CIs have no mapping
+    {
+        Gia_Obj_t * pObj;
+        Gia_ManForEachCi( pNew, pObj, i )
+           assert( !Gia_ObjIsLut(pNew, Gia_ObjId(pNew, pObj)) );
+    }
     return pNew;
 }
 
@@ -1567,7 +1862,7 @@
     if ( Gia_ObjIsTravIdCurrent(p, pObj) )
         return 1;
     Gia_ObjSetTravIdCurrent(p, pObj);
-    if ( !Gia_ObjIsAnd(pObj) )
+    if ( !Gia_ObjIsAndNotBuf(pObj) )
         return 1;
     if ( !Gia_ObjIsLut(p, Gia_ObjId(p, pObj)) )
     {
@@ -1586,10 +1881,23 @@
     int i, Result = 1;
     assert( Gia_ManHasMapping(p) );
     Gia_ManIncrementTravId( p );
+    Gia_ManForEachBuf( p, pObj, i )
+    {
+        pFanin = Gia_ObjFanin0(pObj);
+        if ( !Gia_ObjIsAndNotBuf(pFanin) )
+            continue;
+        if ( !Gia_ObjIsLut(p, Gia_ObjId(p, pFanin)) )
+        {
+            Abc_Print( -1, "Gia_ManMappingVerify: CO driver %d does not have mapping.\n", Gia_ObjId(p, pFanin) );
+            Result = 0;
+            continue;
+        }
+        Result &= Gia_ManMappingVerify_rec( p, pFanin );
+    }
     Gia_ManForEachCo( p, pObj, i )
     {
         pFanin = Gia_ObjFanin0(pObj);
-        if ( !Gia_ObjIsAnd(pFanin) )
+        if ( !Gia_ObjIsAndNotBuf(pFanin) )
             continue;
         if ( !Gia_ObjIsLut(p, Gia_ObjId(p, pFanin)) )
         {
@@ -1633,7 +1941,8 @@
         Vec_IntPush( p->vMapping, Gia_ObjLutSize(pGia, i) );
         Gia_LutForEachFanin( pGia, i, iFan, k )
             Vec_IntPush( p->vMapping, Abc_Lit2Var(Gia_ObjValue(Gia_ManObj(pGia, iFan))) );
-        Vec_IntPush( p->vMapping, Gia_ObjLutIsMux(pGia, i) ? -Gia_ObjId(p, pObj) : Gia_ObjId(p, pObj) );
+        iFan = Abc_Lit2Var( Gia_ObjValue(Gia_ManObj(pGia, Abc_AbsInt(Gia_ObjLutMuxId(pGia, i)))) );
+        Vec_IntPush( p->vMapping, Gia_ObjLutIsMux(pGia, i) ? -iFan : iFan );
     }
     Gia_ManMappingVerify( p );
 }
@@ -1675,9 +1984,10 @@
 {
     if ( pGia->pManTime == NULL || p == pGia )
         return;
-    p->pManTime   = pGia->pManTime;   pGia->pManTime   = NULL;
-    p->pAigExtra  = pGia->pAigExtra;  pGia->pAigExtra  = NULL;
-    p->nAnd2Delay = pGia->nAnd2Delay; pGia->nAnd2Delay = 0;
+    p->pManTime    = pGia->pManTime;    pGia->pManTime    = NULL;
+    p->pAigExtra   = pGia->pAigExtra;   pGia->pAigExtra   = NULL;
+    p->vRegClasses = pGia->vRegClasses; pGia->vRegClasses = NULL;
+    p->nAnd2Delay  = pGia->nAnd2Delay;  pGia->nAnd2Delay  = 0;
 }
 
 /**Function*************************************************************
@@ -1898,6 +2208,7 @@
     printf( "LUT7 = %d  NonDec = %d (%.2f %%)    ", LutCount[7], LutNDecomp[7], 100.0 * LutNDecomp[7]/Abc_MaxInt(LutCount[7], 1) );
     printf( "\n" );
 }
+
 
 ////////////////////////////////////////////////////////////////////////
 ///                       END OF FILE                                ///
diff --git a/abc-build/src/aig/gia/giaJf.c b/abc-build/src/aig/gia/giaJf.c
--- a/abc-build/src/aig/gia/giaJf.c
+++ b/abc-build/src/aig/gia/giaJf.c
@@ -1589,6 +1589,7 @@
     pNew = Gia_ManStart( Gia_ManObjNum(p->pGia) );
     pNew->pName = Abc_UtilStrsav( p->pGia->pName );
     pNew->pSpec = Abc_UtilStrsav( p->pGia->pSpec );
+    pNew->vLevels = Vec_IntStart( 6*Gia_ManObjNum(p->pGia)/5 + 100 );
     // map primary inputs
     Vec_IntWriteEntry( vCopies, 0, 0 );
     Gia_ManForEachCi( p->pGia, pObj, i )
@@ -1713,6 +1714,7 @@
 {
     Gia_Man_t * pNew = pGia;
     Jf_Man_t * p; int i;
+    assert( !Gia_ManBufNum(pGia) );
     assert( !pPars->fCutMin || !pPars->fFuncDsd || pPars->nLutSize <= 6 );
     if ( pPars->fGenCnf )
         pPars->fCutMin = 1, pPars->fFuncDsd = 1, pPars->fOptEdge = 0;
diff --git a/abc-build/src/aig/gia/giaKf.c b/abc-build/src/aig/gia/giaKf.c
--- a/abc-build/src/aig/gia/giaKf.c
+++ b/abc-build/src/aig/gia/giaKf.c
@@ -38,6 +38,13 @@
 ///                        DECLARATIONS                              ///
 ////////////////////////////////////////////////////////////////////////
 
+#ifndef ABC_USE_PTHREADS
+
+void Kf_ManSetDefaultPars( Jf_Par_t * pPars ) {}
+Gia_Man_t * Kf_ManPerformMapping( Gia_Man_t * pGia, Jf_Par_t * pPars ) { return NULL; }
+
+#else // pthreads are used
+
 #define KF_LEAF_MAX  16
 #define KF_CUT_MAX   32
 #define KF_PROC_MAX  32
@@ -1332,6 +1339,7 @@
 ///                       END OF FILE                                ///
 ////////////////////////////////////////////////////////////////////////
 
+#endif // pthreads are used
 
 ABC_NAMESPACE_IMPL_END
 
diff --git a/abc-build/src/aig/gia/giaLf.c b/abc-build/src/aig/gia/giaLf.c
--- a/abc-build/src/aig/gia/giaLf.c
+++ b/abc-build/src/aig/gia/giaLf.c
@@ -8,53 +8,2283 @@
 
   Synopsis    [Cut computation.]
 
-  Author      [Alan Mishchenko]
-  
-  Affiliation [UC Berkeley]
-
-  Date        [Ver. 1.0. Started - June 20, 2005.]
-
-  Revision    [$Id: giaLf.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "gia.h"
-#include "misc/vec/vecSet.h"
-
-ABC_NAMESPACE_IMPL_START
-
-////////////////////////////////////////////////////////////////////////
-///                        DECLARATIONS                              ///
-////////////////////////////////////////////////////////////////////////
-
-
-////////////////////////////////////////////////////////////////////////
-///                     FUNCTION DEFINITIONS                         ///
-////////////////////////////////////////////////////////////////////////
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-               
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-void Lf_ManSetDefaultPars( Jf_Par_t * pPars )
-{
-    Jf_ManSetDefaultPars( pPars );
-}
-Gia_Man_t * Lf_ManPerformMapping( Gia_Man_t * pGia, Jf_Par_t * pPars )
-{
-    return Jf_ManPerformMapping( pGia, pPars );
-}
-Gia_Man_t * Gia_ManPerformLfMapping( Gia_Man_t * p, Jf_Par_t * pPars, int fNormalized )
-{
-    return NULL;
+  Author      [Alan Mishchenko]`
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - June 20, 2005.]
+
+  Revision    [$Id: giaLf.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+#include "misc/tim/tim.h"
+#include "misc/vec/vecSet.h"
+#include "misc/vec/vecMem.h"
+#include "misc/util/utilTruth.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+#define LF_LEAF_MAX   12
+#define LF_CUT_MAX    32
+#define LF_LOG_PAGE   12
+#define LF_NO_LEAF   255
+#define LF_CUT_WORDS (4+LF_LEAF_MAX/2)
+#define LF_TT_WORDS  ((LF_LEAF_MAX > 6) ? 1 << (LF_LEAF_MAX-6) : 1)
+
+typedef struct Lf_Cut_t_ Lf_Cut_t; 
+struct Lf_Cut_t_
+{
+    word            Sign;            // signature
+    int             Delay;           // delay
+    float           Flow;            // flow 
+    int             iFunc;           // functionality
+    unsigned        Cost      : 22;  // misc cut cost
+    unsigned        fLate     :  1;  // fails timing
+    unsigned        fMux7     :  1;  // specialized cut
+    unsigned        nLeaves   :  8;  // the number of leaves
+    int             pLeaves[0];      // leaves
+};
+typedef struct Lf_Plc_t_ Lf_Plc_t; 
+struct Lf_Plc_t_
+{
+    unsigned        fUsed    :  1;   // the cut is used
+    unsigned        Handle   : 31;   // the cut handle
+};
+typedef struct Lf_Bst_t_ Lf_Bst_t; 
+struct Lf_Bst_t_
+{
+    int             Delay[3];        // delay
+    float           Flow[3];         // flow 
+    Lf_Plc_t        Cut[2];          // cut info
+};
+typedef struct Lf_Mem_t_ Lf_Mem_t; 
+struct Lf_Mem_t_
+{
+    int             LogPage;         // log size of memory page
+    int             MaskPage;        // page mask
+    int             nCutWords;       // cut size in words
+    int             iCur;            // writing position 
+    Vec_Ptr_t       vPages;          // memory pages
+    Vec_Ptr_t *     vFree;           // free pages 
+};
+typedef struct Lf_Man_t_ Lf_Man_t; 
+struct Lf_Man_t_
+{
+    // user data
+    Gia_Man_t *     pGia;            // manager
+    Jf_Par_t *      pPars;           // parameters
+    // cut data
+    int             nCutWords;       // cut size in words
+    int             nSetWords;       // set size in words
+    Lf_Bst_t *      pObjBests;       // best cuts
+    Vec_Ptr_t       vMemSets;        // memory for cutsets
+    Vec_Int_t       vFreeSets;       // free cutsets
+    Vec_Mem_t *     vTtMem;          // truth tables
+    Vec_Ptr_t       vFreePages;      // free memory pages
+    Lf_Mem_t        vStoreOld;       // previous cuts
+    Lf_Mem_t        vStoreNew;       // current cuts
+    // mapper data
+    Vec_Int_t       vOffsets;        // offsets
+    Vec_Int_t       vRequired;       // required times
+    Vec_Int_t       vCutSets;        // cutsets (pObj->Value stores cut refs)
+    Vec_Flt_t       vFlowRefs;       // flow refs
+    Vec_Int_t       vMapRefs;        // mapping refs
+    Vec_Flt_t       vSwitches;       // switching activity
+    Vec_Int_t       vCiArrivals;     // arrival times of the CIs
+    // statistics
+    abctime         clkStart;        // starting time
+    double          CutCount[4];     // cut counts
+    double          Switches;        // switching activity
+    int             nFrontMax;       // frontier
+    int             nCoDrivers;      // CO drivers
+    int             nInverters;      // inverters
+    int             nTimeFails;      // timing fails
+    int             Iter;            // mapping iteration
+    int             fUseEla;         // use exact local area
+    int             nCutMux;         // non-trivial MUX cuts
+    int             nCutEqual;       // equal two cuts
+    int             nCutCounts[LF_LEAF_MAX+1];
+};
+
+static inline void        Lf_CutCopy( Lf_Cut_t * p, Lf_Cut_t * q, int n ) { memcpy(p, q, sizeof(word) * n);                                         }
+static inline Lf_Cut_t *  Lf_CutNext( Lf_Cut_t * p, int n )               { return (Lf_Cut_t *)((word *)p + n);                                     }
+static inline word *      Lf_CutTruth( Lf_Man_t * p, Lf_Cut_t * pCut )    { return Vec_MemReadEntry(p->vTtMem, Abc_Lit2Var(pCut->iFunc));           }
+
+static inline int         Lf_ObjOff( Lf_Man_t * p, int i )                { return Vec_IntEntry(&p->vOffsets, i);                                   }
+static inline int         Lf_ObjRequired( Lf_Man_t * p, int i )           { return Vec_IntEntry(&p->vRequired, i);                                  }
+static inline void        Lf_ObjSetRequired( Lf_Man_t * p, int i, int t ) { Vec_IntDowndateEntry(&p->vRequired, i, t);                              }
+static inline Lf_Bst_t *  Lf_ObjReadBest( Lf_Man_t * p, int i )           { return p->pObjBests + Lf_ObjOff(p,i);                                   }
+static inline float       Lf_ObjFlowRefs( Lf_Man_t * p, int i )           { return Vec_FltEntry(&p->vFlowRefs, Lf_ObjOff(p,i));                     }
+static inline int         Lf_ObjMapRefNum( Lf_Man_t * p, int i )          { return Vec_IntEntry(&p->vMapRefs, Lf_ObjOff(p,i));                      }
+static inline int         Lf_ObjMapRefInc( Lf_Man_t * p, int i )          { return (*Vec_IntEntryP(&p->vMapRefs, Lf_ObjOff(p,i)))++;                }
+static inline int         Lf_ObjMapRefDec( Lf_Man_t * p, int i )          { return --(*Vec_IntEntryP(&p->vMapRefs, Lf_ObjOff(p,i)));                }
+static inline float       Lf_ObjSwitches( Lf_Man_t * p, int i )           { return Vec_FltEntry(&p->vSwitches, i);                                  }
+static inline int         Lf_BestDiffCuts( Lf_Bst_t * p )                 { return p->Cut[0].Handle != p->Cut[1].Handle;                            }
+static inline int         Lf_BestIsMapped( Lf_Bst_t * p )                 { return (int)(p->Cut[0].fUsed ^ p->Cut[1].fUsed);                        }
+static inline int         Lf_BestIndex( Lf_Bst_t * p )                    { return p->Cut[1].fUsed;                                                 }
+static inline int         Lf_BestCutIndex( Lf_Bst_t * p )                 { if (p->Cut[0].fUsed) return 0; if (p->Cut[1].fUsed) return 1; return 2; }
+
+#define Lf_CutSetForEachCut( nWords, pCutSet, pCut, i, nCuts )  for ( i = 0, pCut = pCutSet; i < nCuts; pCut = Lf_CutNext(pCut, nWords), i++ ) 
+#define Lf_CutForEachVar( pCut, Var, i )                        for ( i = 0; i < (int)pCut->nLeaves && (Var = pCut->pLeaves[i]); i++ ) if ( Lf_ObjOff(p, Var) < 0 ) {} else
+
+extern int Kit_TruthToGia( Gia_Man_t * pMan, unsigned * pTruth, int nVars, Vec_Int_t * vMemory, Vec_Int_t * vLeaves, int fHash );
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline void Lf_ObjSetCiArrival( Lf_Man_t * p, int iCi, int Time )
+{
+    Vec_IntWriteEntry( &p->vCiArrivals, iCi, Time );
+}
+static inline int Lf_ObjCiArrival( Lf_Man_t * p, int iCi )
+{
+    return Vec_IntEntry( &p->vCiArrivals, iCi );
+}
+int Lf_ObjArrival_rec( Lf_Man_t * p, Gia_Obj_t * pDriver )
+{
+    if ( Gia_ObjIsBuf(pDriver) )
+        return Lf_ObjArrival_rec( p, Gia_ObjFanin0(pDriver) );
+    if ( Gia_ObjIsAnd(pDriver) )
+        return Lf_ObjReadBest(p, Gia_ObjId(p->pGia, pDriver))->Delay[0];
+    if ( Gia_ObjIsCi(pDriver) )
+        return Lf_ObjCiArrival(p, Gia_ObjCioId(pDriver));
+    return 0;
+}
+static inline int Lf_ObjCoArrival( Lf_Man_t * p, int iCo )
+{
+    Gia_Obj_t * pObj = Gia_ManCo(p->pGia, iCo);
+    Gia_Obj_t * pDriver = Gia_ObjFanin0(pObj);
+    return Lf_ObjArrival_rec( p, pDriver );
+//    if ( Gia_ObjIsAnd(pDriver) )
+//        return Lf_ObjReadBest(p, Gia_ObjId(p->pGia, pDriver))->Delay[0];
+//    if ( Gia_ObjIsCi(pDriver) )
+//        return Lf_ObjCiArrival(p, Gia_ObjCioId(pDriver));
+//    return 0;
+}
+int Lf_ObjCoArrival2_rec( Lf_Man_t * p, Gia_Obj_t * pDriver )
+{
+    if ( Gia_ObjIsBuf(pDriver) )
+        return Lf_ObjCoArrival2_rec( p, Gia_ObjFanin0(pDriver) );
+    if ( Gia_ObjIsAnd(pDriver) )
+    {
+        Lf_Bst_t * pBest = Lf_ObjReadBest(p, Gia_ObjId(p->pGia, pDriver));
+        int Index = Lf_BestCutIndex( pBest );
+        assert( Index < 2 || Gia_ObjIsMux(p->pGia, pDriver) );
+        return pBest->Delay[Index];
+    }
+    if ( Gia_ObjIsCi(pDriver) )
+        return Lf_ObjCiArrival(p, Gia_ObjCioId(pDriver));
+    return 0;
+}
+static inline int Lf_ObjCoArrival2( Lf_Man_t * p, int iCo )
+{
+    Gia_Obj_t * pObj = Gia_ManCo(p->pGia, iCo);
+    Gia_Obj_t * pDriver = Gia_ObjFanin0(pObj);
+    return Lf_ObjCoArrival2_rec( p, pDriver );
+//    if ( Gia_ObjIsAnd(pDriver) )
+//    {
+//        Lf_Bst_t * pBest = Lf_ObjReadBest(p, Gia_ObjId(p->pGia, pDriver));
+//        int Index = Lf_BestCutIndex( pBest );
+//        assert( Index < 2 || Gia_ObjIsMux(p->pGia, pDriver) );
+//        return pBest->Delay[Index];
+//    }
+//    if ( Gia_ObjIsCi(pDriver) )
+//        return Lf_ObjCiArrival(p, Gia_ObjCioId(pDriver));
+//    return 0;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Lf_ManComputeCrossCut( Gia_Man_t * p )
+{
+    Gia_Obj_t * pObj;
+    int i, nCutMax = 0, nCutCur = 0;
+    assert( p->pMuxes == NULL );
+    Gia_ManForEachObj( p, pObj, i )
+        pObj->Value = 0;
+    Gia_ManForEachAnd( p, pObj, i )
+    {
+        if ( Gia_ObjIsAnd(Gia_ObjFanin0(pObj)) )
+            Gia_ObjFanin0(pObj)->Value++;
+        if ( Gia_ObjIsAnd(Gia_ObjFanin1(pObj)) )
+            Gia_ObjFanin1(pObj)->Value++;
+    }
+    Gia_ManForEachAnd( p, pObj, i )
+    {
+        if ( pObj->Value )
+            nCutCur++;
+        if ( nCutMax < nCutCur )
+            nCutMax = nCutCur;
+        if ( Gia_ObjIsAnd(Gia_ObjFanin0(pObj)) && --Gia_ObjFanin0(pObj)->Value == 0 )
+            nCutCur--;
+        if ( Gia_ObjIsAnd(Gia_ObjFanin1(pObj)) && --Gia_ObjFanin1(pObj)->Value == 0 )
+            nCutCur--;
+    }
+    assert( nCutCur == 0 );
+    if ( nCutCur )
+        printf( "Cutset is not 0\n" );
+    Gia_ManForEachObj( p, pObj, i )
+        assert( pObj->Value == 0 );
+    printf( "CutMax = %d\n", nCutMax );
+    return nCutMax;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Detect MUX truth tables.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Lf_ManTtIsMux( word t )
+{
+    static unsigned s_Muxes[24] = {
+        (~0xAAAAAAAA & ~0xCCCCCCCC) | ( 0xAAAAAAAA & ~0xF0F0F0F0),
+        (~0xAAAAAAAA & ~0xCCCCCCCC) | ( 0xAAAAAAAA &  0xF0F0F0F0),
+        (~0xAAAAAAAA &  0xCCCCCCCC) | ( 0xAAAAAAAA & ~0xF0F0F0F0),
+        (~0xAAAAAAAA &  0xCCCCCCCC) | ( 0xAAAAAAAA &  0xF0F0F0F0),
+        ( 0xAAAAAAAA & ~0xCCCCCCCC) | (~0xAAAAAAAA & ~0xF0F0F0F0),
+        ( 0xAAAAAAAA & ~0xCCCCCCCC) | (~0xAAAAAAAA &  0xF0F0F0F0),
+        ( 0xAAAAAAAA &  0xCCCCCCCC) | (~0xAAAAAAAA & ~0xF0F0F0F0),
+        ( 0xAAAAAAAA &  0xCCCCCCCC) | (~0xAAAAAAAA &  0xF0F0F0F0),
+
+        (~0xCCCCCCCC & ~0xAAAAAAAA) | ( 0xCCCCCCCC & ~0xF0F0F0F0),
+        (~0xCCCCCCCC & ~0xAAAAAAAA) | ( 0xCCCCCCCC &  0xF0F0F0F0),
+        (~0xCCCCCCCC &  0xAAAAAAAA) | ( 0xCCCCCCCC & ~0xF0F0F0F0),
+        (~0xCCCCCCCC &  0xAAAAAAAA) | ( 0xCCCCCCCC &  0xF0F0F0F0),
+        ( 0xCCCCCCCC & ~0xAAAAAAAA) | (~0xCCCCCCCC & ~0xF0F0F0F0),
+        ( 0xCCCCCCCC & ~0xAAAAAAAA) | (~0xCCCCCCCC &  0xF0F0F0F0),
+        ( 0xCCCCCCCC &  0xAAAAAAAA) | (~0xCCCCCCCC & ~0xF0F0F0F0),
+        ( 0xCCCCCCCC &  0xAAAAAAAA) | (~0xCCCCCCCC &  0xF0F0F0F0),
+
+        (~0xF0F0F0F0 & ~0xCCCCCCCC) | ( 0xF0F0F0F0 & ~0xAAAAAAAA),
+        (~0xF0F0F0F0 & ~0xCCCCCCCC) | ( 0xF0F0F0F0 &  0xAAAAAAAA),
+        (~0xF0F0F0F0 &  0xCCCCCCCC) | ( 0xF0F0F0F0 & ~0xAAAAAAAA),
+        (~0xF0F0F0F0 &  0xCCCCCCCC) | ( 0xF0F0F0F0 &  0xAAAAAAAA),
+        ( 0xF0F0F0F0 & ~0xCCCCCCCC) | (~0xF0F0F0F0 & ~0xAAAAAAAA),
+        ( 0xF0F0F0F0 & ~0xCCCCCCCC) | (~0xF0F0F0F0 &  0xAAAAAAAA),
+        ( 0xF0F0F0F0 &  0xCCCCCCCC) | (~0xF0F0F0F0 & ~0xAAAAAAAA),
+        ( 0xF0F0F0F0 &  0xCCCCCCCC) | (~0xF0F0F0F0 &  0xAAAAAAAA)
+    };
+    int i;
+    for ( i = 0; i < 24; i++ )
+        if ( ((unsigned)t) == s_Muxes[i] )
+            return 1;
+    return 0;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Count the number of unique drivers and invertors.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Lf_ManAnalyzeCoDrivers( Gia_Man_t * p, int * pnDrivers, int * pnInverts )
+{
+    Gia_Obj_t * pObj;
+    int i, Entry, nDrivers, nInverts;
+    Vec_Int_t * vMarks = Vec_IntStart( Gia_ManObjNum(p) );
+    nDrivers = nInverts = 0;
+    Gia_ManForEachCo( p, pObj, i )
+        *Vec_IntEntryP( vMarks, Gia_ObjFaninId0p(p, pObj) ) |= Gia_ObjFaninC0(pObj) ? 2 : 1;
+    Vec_IntForEachEntry( vMarks, Entry, i )
+        nDrivers += (int)(Entry != 0), nInverts += (int)(Entry == 3);
+    Vec_IntFree( vMarks );
+    *pnDrivers = nDrivers;
+    *pnInverts = nInverts;
+}
+void Lf_ManComputeSwitching( Gia_Man_t * p, Vec_Flt_t * vSwitches )
+{
+//    abctime clk = Abc_Clock();
+    Vec_Flt_t * vSwitching = (Vec_Flt_t *)Gia_ManComputeSwitchProbs( p, 48, 16, 0 );
+    assert( Vec_FltCap(vSwitches) == 0 );
+    *vSwitches = *vSwitching;
+    ABC_FREE( vSwitching );
+//    Abc_PrintTime( 1, "Computing switching activity", Abc_Clock() - clk );
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Lf_CutCreateUnit( Lf_Cut_t * p, int i )
+{
+    p->fLate = 0;
+    p->fMux7 = 0;
+    p->iFunc = 2;
+    p->nLeaves = 1;
+    p->pLeaves[0] = i;
+    p->Sign = ((word)1) << (i & 0x3F);
+    return 1;
+}
+static inline Lf_Cut_t * Lf_ManFetchSet( Lf_Man_t * p, int i )
+{
+    int uMaskPage = (1 << LF_LOG_PAGE) - 1;
+    Gia_Obj_t * pObj = Gia_ManObj( p->pGia, i );
+    int iOffSet = Vec_IntEntry( &p->vOffsets, i );
+    int Entry = Vec_IntEntry( &p->vCutSets, iOffSet );
+    assert( Gia_ObjIsAndNotBuf(pObj) );
+    assert( pObj->Value > 0 );
+    if ( Entry == -1 ) // first visit
+    {
+        if ( Vec_IntSize(&p->vFreeSets) == 0 ) // add new
+        {
+            Lf_Cut_t * pCut = (Lf_Cut_t *)ABC_CALLOC( word, p->nSetWords * (1 << LF_LOG_PAGE) );
+            int uMaskShift = Vec_PtrSize(&p->vMemSets) << LF_LOG_PAGE;
+            Vec_PtrPush( &p->vMemSets, pCut );
+            for ( Entry = uMaskPage; Entry >= 0; Entry-- )
+            {
+                Vec_IntPush( &p->vFreeSets, uMaskShift | Entry );
+                pCut[Entry].nLeaves   = LF_NO_LEAF;
+            }
+        }
+        Entry = Vec_IntPop( &p->vFreeSets );
+        Vec_IntWriteEntry( &p->vCutSets, iOffSet, Entry );
+        p->nFrontMax = Abc_MaxInt( p->nFrontMax, Entry + 1 );
+    }
+    else if ( --pObj->Value == 0 )
+    {
+        Vec_IntPush( &p->vFreeSets, Entry );
+        Vec_IntWriteEntry( &p->vCutSets, iOffSet, -1 );
+    }
+    return (Lf_Cut_t *)((word *)Vec_PtrEntry(&p->vMemSets, Entry >> LF_LOG_PAGE) + p->nSetWords * (Entry & uMaskPage));
+}
+static inline int Lf_ManPrepareSet( Lf_Man_t * p, int iObj, int Index, Lf_Cut_t ** ppCutSet )
+{
+    static word CutTemp[3][LF_CUT_WORDS];
+    if ( Vec_IntEntry(&p->vOffsets, iObj) == -1 )
+        return Lf_CutCreateUnit( (*ppCutSet = (Lf_Cut_t *)CutTemp[Index]), iObj );
+    {
+        Lf_Cut_t * pCut; 
+        int i, nCutNum = p->pPars->nCutNum;
+        *ppCutSet = Lf_ManFetchSet(p, iObj);
+        Lf_CutSetForEachCut( p->nCutWords, *ppCutSet, pCut, i, nCutNum )
+            if ( pCut->nLeaves == LF_NO_LEAF )
+                return i;
+        return i;
+    }
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Cut manipulation.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline word Lf_CutGetSign( Lf_Cut_t * pCut )
+{
+    word Sign = 0; int i; 
+    for ( i = 0; i < (int)pCut->nLeaves; i++ )
+        Sign |= ((word)1) << (pCut->pLeaves[i] & 0x3F);
+    return Sign;
+}
+static inline int Lf_CutCountBits( word i )
+{
+    i = i - ((i >> 1) & 0x5555555555555555);
+    i = (i & 0x3333333333333333) + ((i >> 2) & 0x3333333333333333);
+    i = ((i + (i >> 4)) & 0x0F0F0F0F0F0F0F0F);
+    return (i*(0x0101010101010101))>>56;
+}
+static inline int Lf_CutEqual( Lf_Cut_t * pCut0, Lf_Cut_t * pCut1 )
+{
+    int i;
+    if ( pCut0->iFunc != pCut1->iFunc )
+        return 0;
+    if ( pCut0->nLeaves != pCut1->nLeaves )
+        return 0;
+    for ( i = 0; i < (int)pCut0->nLeaves; i++ )
+        if ( pCut0->pLeaves[i] != pCut1->pLeaves[i] )
+            return 0;
+    return 1;
+}
+static inline float Lf_CutSwitches( Lf_Man_t * p, Lf_Cut_t * pCut )
+{
+    float Switches = 0; int i; 
+    for ( i = 0; i < (int)pCut->nLeaves; i++ )
+        Switches += Lf_ObjSwitches(p, pCut->pLeaves[i]);
+//printf( "%.2f ", Switches );
+    return Switches;
+}
+static inline void Lf_CutPrint( Lf_Man_t * p, Lf_Cut_t * pCut )
+{
+    int i, nDigits = Abc_Base10Log(Gia_ManObjNum(p->pGia)); 
+    printf( "%d  {", pCut->nLeaves );
+    for ( i = 0; i < (int)pCut->nLeaves; i++ )
+        printf( " %*d", nDigits, pCut->pLeaves[i] );
+    for ( ; i < (int)p->pPars->nLutSize; i++ )
+        printf( " %*s", nDigits, " " );
+    printf( "  }   Late = %d  D = %4d  A = %9.4f  F = %6d\n", 
+        pCut->fLate, pCut->Delay, pCut->Flow, pCut->iFunc );
+}
+static inline float Lf_CutArea( Lf_Man_t * p, Lf_Cut_t * pCut )
+{
+    if ( pCut->nLeaves < 2 || pCut->fMux7 )
+        return 0;
+    if ( p->pPars->fPower )
+        return 1.0 * pCut->nLeaves + Lf_CutSwitches( p, pCut );
+    if ( p->pPars->fOptEdge )
+        return pCut->nLeaves + p->pPars->nAreaTuner;
+    return 1;
+}
+static inline int Lf_CutIsMux( Lf_Man_t * p, Lf_Cut_t * pCut, Gia_Obj_t * pMux )
+{
+    int i, Id;
+    if ( pCut->nLeaves != 3 )
+        return 0;
+    assert( Gia_ObjIsMux(p->pGia, pMux) );
+    if ( Gia_ObjIsCi(Gia_ObjFanin0(pMux)) || Gia_ObjIsCi(Gia_ObjFanin1(pMux)) )
+        return 0;
+    Id = Gia_ObjFaninId0p( p->pGia, pMux );
+    for ( i = 0; i < 3; i++ )
+        if ( pCut->pLeaves[i] == Id )
+            break;
+    if ( i == 3 ) 
+        return 0;
+    Id = Gia_ObjFaninId1p( p->pGia, pMux );
+    for ( i = 0; i < 3; i++ )
+        if ( pCut->pLeaves[i] == Id )
+            break;
+    if ( i == 3 ) 
+        return 0;
+    Id = Gia_ObjFaninId2p( p->pGia, pMux );
+    for ( i = 0; i < 3; i++ )
+        if ( pCut->pLeaves[i] == Id )
+            break;
+    if ( i == 3 ) 
+        return 0;
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Cut packing.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline void Lf_MemAlloc( Lf_Mem_t * p, int LogPage, Vec_Ptr_t * vFree, int nCutWords )
+{
+    memset( p, 0, sizeof(Lf_Mem_t) );
+    p->LogPage   = LogPage;
+    p->MaskPage  = (1 << LogPage) - 1;
+    p->nCutWords = nCutWords;
+    p->vFree     = vFree;
+}
+static inline int Lf_MemSaveCut( Lf_Mem_t * p, Lf_Cut_t * pCut, int iObj )
+{
+    unsigned char * pPlace;
+    int i, iPlace, Prev = iObj, iCur = p->iCur;
+    assert( !pCut->fMux7 );
+    if ( Vec_PtrSize(&p->vPages) == (p->iCur >> p->LogPage) )
+        Vec_PtrPush( &p->vPages, Vec_PtrSize(p->vFree) ? Vec_PtrPop(p->vFree) : ABC_ALLOC(char,p->MaskPage+1) );
+    assert( p->MaskPage - (p->iCur & p->MaskPage) >= 4 * (LF_LEAF_MAX + 2) );
+    iPlace = iCur & p->MaskPage;
+    pPlace = (unsigned char *)Vec_PtrEntry(&p->vPages, p->iCur >> p->LogPage);
+    iPlace = Gia_AigerWriteUnsignedBuffer( pPlace, iPlace, pCut->nLeaves );
+    for ( i = pCut->nLeaves - 1; i >= 0; i-- )
+        iPlace = Gia_AigerWriteUnsignedBuffer( pPlace, iPlace, Prev - pCut->pLeaves[i] ), Prev = pCut->pLeaves[i];
+    assert( pCut->nLeaves >= 2 || pCut->iFunc <= 3 );
+    if ( pCut->iFunc >= 0 )
+        iPlace = Gia_AigerWriteUnsignedBuffer( pPlace, iPlace, pCut->iFunc );
+    if ( p->MaskPage - (iPlace & p->MaskPage) < 4 * (LF_LEAF_MAX + 2) )
+        p->iCur = ((p->iCur >> p->LogPage) + 1) << p->LogPage;
+    else
+        p->iCur = (p->iCur & ~p->MaskPage) | iPlace;
+    return iCur;
+}
+static inline Lf_Cut_t * Lf_MemLoadCut( Lf_Mem_t * p, int iCur, int iObj, Lf_Cut_t * pCut, int fTruth, int fRecycle )
+{
+    unsigned char * pPlace;  
+    int i, Prev = iObj, Page = iCur >> p->LogPage;
+    assert( Page < Vec_PtrSize(&p->vPages) );
+    pPlace = (unsigned char *)Vec_PtrEntry(&p->vPages, Page) + (iCur & p->MaskPage);
+    pCut->nLeaves = Gia_AigerReadUnsigned(&pPlace);
+    assert( pCut->nLeaves <= LF_LEAF_MAX );
+    for ( i = pCut->nLeaves - 1; i >= 0; i-- )
+        pCut->pLeaves[i] = Prev - Gia_AigerReadUnsigned(&pPlace), Prev = pCut->pLeaves[i];
+    pCut->iFunc = fTruth ? Gia_AigerReadUnsigned(&pPlace) : -1;
+    assert( pCut->nLeaves >= 2 || pCut->iFunc <= 3 );
+    if ( fRecycle && Page && Vec_PtrEntry(&p->vPages, Page-1) )
+    {
+        Vec_PtrPush( p->vFree, Vec_PtrEntry(&p->vPages, Page-1) );
+        Vec_PtrWriteEntry( &p->vPages, Page-1, NULL );
+    }
+    pCut->Sign = fRecycle ? Lf_CutGetSign(pCut) : 0;
+    pCut->fMux7 = 0;
+    return pCut;
+}
+static inline void Lf_MemRecycle( Lf_Mem_t * p )
+{
+    void * pPlace; int i;
+    Vec_PtrForEachEntry( void *, &p->vPages, pPlace, i )
+        if ( pPlace )
+            Vec_PtrPush( p->vFree, pPlace );
+    Vec_PtrClear( &p->vPages );
+    p->iCur = 0;
+}
+static inline Lf_Cut_t * Lf_MemLoadMuxCut( Lf_Man_t * p, int iObj, Lf_Cut_t * pCut )
+{
+    Gia_Obj_t * pMux = Gia_ManObj( p->pGia, iObj );
+    assert( Gia_ObjIsMux(p->pGia, pMux) );
+    pCut->iFunc = p->pPars->fCutMin ? 4 : -1;
+    pCut->pLeaves[0] = Gia_ObjFaninId0( pMux, iObj );
+    pCut->pLeaves[1] = Gia_ObjFaninId1( pMux, iObj );
+    pCut->pLeaves[2] = Gia_ObjFaninId2( p->pGia, iObj );
+    pCut->nLeaves = 3;
+    pCut->fMux7 = 1;
+    return pCut;
+}
+static inline Lf_Cut_t * Lf_ObjCutMux( Lf_Man_t * p, int i )
+{
+    static word CutSet[LF_CUT_WORDS];
+    return Lf_MemLoadMuxCut( p, i, (Lf_Cut_t *)CutSet );
+}
+static inline Lf_Cut_t * Lf_ObjCutBest( Lf_Man_t * p, int i )
+{
+    static word CutSet[LF_CUT_WORDS];
+    Lf_Bst_t * pBest = Lf_ObjReadBest( p, i );
+    Lf_Cut_t * pCut = (Lf_Cut_t *)CutSet;
+    int Index = Lf_BestCutIndex( pBest );
+    pCut->Delay = pBest->Delay[Index];
+    pCut->Flow  = pBest->Flow[Index];
+    if ( Index == 2 )
+        return Lf_MemLoadMuxCut( p, i, pCut );
+    return Lf_MemLoadCut( &p->vStoreOld, pBest->Cut[Index].Handle, i, pCut, p->pPars->fCutMin, 0 );
+}
+static inline Lf_Cut_t * Lf_ObjCutBestNew( Lf_Man_t * p, int i, Lf_Cut_t * pCut )
+{
+    Lf_Bst_t * pBest = Lf_ObjReadBest( p, i );
+    int Index = Lf_BestCutIndex( pBest );
+    pCut->Delay = pBest->Delay[Index];
+    pCut->Flow  = pBest->Flow[Index];
+    if ( Index == 2 )
+        return Lf_MemLoadMuxCut( p, i, pCut );
+    return Lf_MemLoadCut( &p->vStoreNew, pBest->Cut[Index].Handle, i, pCut, 0, 0 );
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Check correctness of cuts.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Lf_CutCheck( Lf_Cut_t * pBase, Lf_Cut_t * pCut ) // check if pCut is contained in pBase
+{
+    int nSizeB = pBase->nLeaves;
+    int nSizeC = pCut->nLeaves;
+    int i, * pB = pBase->pLeaves;
+    int k, * pC = pCut->pLeaves;
+    for ( i = 0; i < nSizeC; i++ )
+    {
+        for ( k = 0; k < nSizeB; k++ )
+            if ( pC[i] == pB[k] )
+                break;
+        if ( k == nSizeB )
+            return 0;
+    }
+    return 1;
+}
+static inline int Lf_SetCheckArray( Lf_Cut_t ** ppCuts, int nCuts )
+{
+    Lf_Cut_t * pCut0, * pCut1; 
+    int i, k, m, n, Value;
+    assert( nCuts > 0 );
+    for ( i = 0; i < nCuts; i++ )
+    {
+        pCut0 = ppCuts[i];
+        assert( !pCut0->fMux7 );
+        assert( pCut0->nLeaves < LF_LEAF_MAX );
+        assert( pCut0->Sign == Lf_CutGetSign(pCut0) );
+        // check duplicates
+        for ( m = 0; m < (int)pCut0->nLeaves; m++ )
+        for ( n = m + 1; n < (int)pCut0->nLeaves; n++ )
+            assert( pCut0->pLeaves[m] < pCut0->pLeaves[n] );
+        // check pairs
+        for ( k = 0; k < nCuts; k++ )
+        {
+            pCut1 = ppCuts[k];
+            if ( pCut0 == pCut1 )
+                continue;
+            // check containments
+            Value = Lf_CutCheck( pCut0, pCut1 );
+            assert( Value == 0 );
+        }
+    }
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Lf_CutMergeOrder( Lf_Cut_t * pCut0, Lf_Cut_t * pCut1, Lf_Cut_t * pCut, int nLutSize )
+{ 
+    int nSize0   = pCut0->nLeaves;
+    int nSize1   = pCut1->nLeaves;
+    int i, * pC0 = pCut0->pLeaves;
+    int k, * pC1 = pCut1->pLeaves;
+    int c, * pC  = pCut->pLeaves;
+    // the case of the largest cut sizes
+    if ( nSize0 == nLutSize && nSize1 == nLutSize )
+    {
+        for ( i = 0; i < nSize0; i++ )
+        {
+            if ( pC0[i] != pC1[i] )  return 0;
+            pC[i] = pC0[i];
+        }
+        pCut->nLeaves = nLutSize;
+        pCut->iFunc = -1;
+        pCut->Sign = pCut0->Sign | pCut1->Sign;
+        return 1;
+    }
+    // compare two cuts with different numbers
+    i = k = c = 0;
+    if ( nSize0 == 0 ) goto FlushCut1;
+    if ( nSize1 == 0 ) goto FlushCut0;
+    while ( 1 )
+    {
+        if ( c == nLutSize ) return 0;
+        if ( pC0[i] < pC1[k] )
+        {
+            pC[c++] = pC0[i++];
+            if ( i >= nSize0 ) goto FlushCut1;
+        }
+        else if ( pC0[i] > pC1[k] )
+        {
+            pC[c++] = pC1[k++];
+            if ( k >= nSize1 ) goto FlushCut0;
+        }
+        else
+        {
+            pC[c++] = pC0[i++]; k++;
+            if ( i >= nSize0 ) goto FlushCut1;
+            if ( k >= nSize1 ) goto FlushCut0;
+        }
+    }
+
+FlushCut0:
+    if ( c + nSize0 > nLutSize + i ) return 0;
+    while ( i < nSize0 )
+        pC[c++] = pC0[i++];
+    pCut->nLeaves = c;
+    pCut->iFunc = -1;
+    pCut->fMux7 = 0;
+    pCut->Sign = pCut0->Sign | pCut1->Sign;
+    return 1;
+
+FlushCut1:
+    if ( c + nSize1 > nLutSize + k ) return 0;
+    while ( k < nSize1 )
+        pC[c++] = pC1[k++];
+    pCut->nLeaves = c;
+    pCut->iFunc = -1;
+    pCut->fMux7 = 0;
+    pCut->Sign = pCut0->Sign | pCut1->Sign;
+    return 1;
+}
+static inline int Lf_CutMergeOrder2( Lf_Cut_t * pCut0, Lf_Cut_t * pCut1, Lf_Cut_t * pCut, int nLutSize )
+{ 
+    int x0, i0 = 0, nSize0 = pCut0->nLeaves, * pC0 = pCut0->pLeaves;
+    int x1, i1 = 0, nSize1 = pCut1->nLeaves, * pC1 = pCut1->pLeaves;
+    int xMin, c = 0, * pC  = pCut->pLeaves;
+    while ( 1 )
+    {
+        x0 = (i0 == nSize0) ? ABC_INFINITY : pC0[i0];
+        x1 = (i1 == nSize1) ? ABC_INFINITY : pC1[i1];
+        xMin = Abc_MinInt(x0, x1);
+        if ( xMin == ABC_INFINITY ) break;
+        if ( c == nLutSize ) return 0;
+        pC[c++] = xMin;
+        if (x0 == xMin) i0++;
+        if (x1 == xMin) i1++;
+    }
+    pCut->nLeaves = c;
+    pCut->iFunc = -1;
+    pCut->fMux7 = 0;
+    pCut->Sign = pCut0->Sign | pCut1->Sign;
+    return 1;
+}
+static inline int Lf_CutMergeOrderMux( Lf_Cut_t * pCut0, Lf_Cut_t * pCut1, Lf_Cut_t * pCut2, Lf_Cut_t * pCut, int nLutSize )
+{ 
+    int x0, i0 = 0, nSize0 = pCut0->nLeaves, * pC0 = pCut0->pLeaves;
+    int x1, i1 = 0, nSize1 = pCut1->nLeaves, * pC1 = pCut1->pLeaves;
+    int x2, i2 = 0, nSize2 = pCut2->nLeaves, * pC2 = pCut2->pLeaves;
+    int xMin, c = 0, * pC  = pCut->pLeaves;
+    while ( 1 )
+    {
+        x0 = (i0 == nSize0) ? ABC_INFINITY : pC0[i0];
+        x1 = (i1 == nSize1) ? ABC_INFINITY : pC1[i1];
+        x2 = (i2 == nSize2) ? ABC_INFINITY : pC2[i2];
+        xMin = Abc_MinInt( Abc_MinInt(x0, x1), x2 );
+        if ( xMin == ABC_INFINITY ) break;
+        if ( c == nLutSize ) return 0;
+        pC[c++] = xMin;
+        if (x0 == xMin) i0++;
+        if (x1 == xMin) i1++;
+        if (x2 == xMin) i2++;
+    }
+    pCut->nLeaves = c;
+    pCut->iFunc = -1;
+    pCut->fMux7 = 0;
+    pCut->Sign = pCut0->Sign | pCut1->Sign | pCut2->Sign;
+    return 1;
+}
+
+static inline int Lf_SetCutIsContainedOrder( Lf_Cut_t * pBase, Lf_Cut_t * pCut ) // check if pCut is contained in pBase
+{
+    int i, nSizeB = pBase->nLeaves;
+    int k, nSizeC = pCut->nLeaves;
+    if ( nSizeB == nSizeC )
+    {
+        for ( i = 0; i < nSizeB; i++ )
+            if ( pBase->pLeaves[i] != pCut->pLeaves[i] )
+                return 0;
+        return 1;
+    }
+    assert( nSizeB > nSizeC ); 
+    if ( nSizeC == 0 )
+        return 1;
+    for ( i = k = 0; i < nSizeB; i++ )
+    {
+        if ( pBase->pLeaves[i] > pCut->pLeaves[k] )
+            return 0;
+        if ( pBase->pLeaves[i] == pCut->pLeaves[k] )
+        {
+            if ( ++k == nSizeC )
+                return 1;
+        }
+    }
+    return 0;
+}
+static inline int Lf_SetLastCutIsContained( Lf_Cut_t ** pCuts, int nCuts )
+{
+    int i;
+    for ( i = 0; i < nCuts; i++ )
+        if ( pCuts[i]->nLeaves <= pCuts[nCuts]->nLeaves && (pCuts[i]->Sign & pCuts[nCuts]->Sign) == pCuts[i]->Sign && Lf_SetCutIsContainedOrder(pCuts[nCuts], pCuts[i]) )
+            return 1;
+    return 0;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Lf_CutCompareDelay( Lf_Cut_t * pCut0, Lf_Cut_t * pCut1 )
+{
+    if ( pCut0->Delay   < pCut1->Delay   )  return -1;
+    if ( pCut0->Delay   > pCut1->Delay   )  return  1;
+    if ( pCut0->nLeaves < pCut1->nLeaves )  return -1;
+    if ( pCut0->nLeaves > pCut1->nLeaves )  return  1;
+    if ( pCut0->Flow    < pCut1->Flow    )  return -1;
+    if ( pCut0->Flow    > pCut1->Flow    )  return  1;
+    return 0;
+}
+static inline int Lf_CutCompareArea( Lf_Cut_t * pCut0, Lf_Cut_t * pCut1 )
+{
+    if ( pCut0->fLate   < pCut1->fLate   )  return -1;
+    if ( pCut0->fLate   > pCut1->fLate   )  return  1;
+    if ( pCut0->Flow    < pCut1->Flow    )  return -1;
+    if ( pCut0->Flow    > pCut1->Flow    )  return  1;
+    if ( pCut0->Delay   < pCut1->Delay   )  return -1;
+    if ( pCut0->Delay   > pCut1->Delay   )  return  1;
+    if ( pCut0->nLeaves < pCut1->nLeaves )  return -1;
+    if ( pCut0->nLeaves > pCut1->nLeaves )  return  1;
+    return 0;
+}
+static inline int Lf_SetLastCutContainsArea( Lf_Cut_t ** pCuts, int nCuts )
+{
+    int i, k, fChanges = 0;
+    for ( i = 1; i < nCuts; i++ )
+        if ( pCuts[nCuts]->nLeaves < pCuts[i]->nLeaves && (pCuts[nCuts]->Sign & pCuts[i]->Sign) == pCuts[nCuts]->Sign && Lf_SetCutIsContainedOrder(pCuts[i], pCuts[nCuts]) )
+            pCuts[i]->nLeaves = LF_NO_LEAF, fChanges = 1;
+    if ( !fChanges )
+        return nCuts;
+    for ( i = k = 1; i <= nCuts; i++ )
+    {
+        if ( pCuts[i]->nLeaves == LF_NO_LEAF )
+            continue;
+        if ( k < i )
+            ABC_SWAP( Lf_Cut_t *, pCuts[k], pCuts[i] );
+        k++;
+    }
+    return k - 1;
+}
+static inline void Lf_SetSortByArea( Lf_Cut_t ** pCuts, int nCuts )
+{
+    int i;
+    for ( i = nCuts; i > 1; i-- )
+    {
+        if ( Lf_CutCompareArea(pCuts[i - 1], pCuts[i]) < 0 )//!= 1 )
+            return;
+        ABC_SWAP( Lf_Cut_t *, pCuts[i - 1], pCuts[i] );
+    }
+}
+static inline int Lf_SetAddCut( Lf_Cut_t ** pCuts, int nCuts, int nCutNum )
+{
+    if ( nCuts == 0 )
+        return 1;
+    nCuts = Lf_SetLastCutContainsArea(pCuts, nCuts);
+    assert( nCuts >= 1 );
+    if ( Lf_CutCompareDelay(pCuts[0], pCuts[nCuts]) == 1 ) // new cut is better for delay
+    {
+        ABC_SWAP( Lf_Cut_t *, pCuts[0], pCuts[nCuts] );
+        // if old cut (now cut number nCuts) is contained - remove it
+        if ( pCuts[0]->nLeaves < pCuts[nCuts]->nLeaves && (pCuts[0]->Sign & pCuts[nCuts]->Sign) == pCuts[0]->Sign && Lf_SetCutIsContainedOrder(pCuts[nCuts], pCuts[0]) )
+            return nCuts;
+    }
+    // sort area cuts by area
+    Lf_SetSortByArea( pCuts, nCuts );
+    // add new cut if there is room
+    return Abc_MinInt( nCuts + 1, nCutNum - 1 );
+}
+static inline void Lf_SetSortBySize( Lf_Cut_t ** pCutsR, int nCutsR )
+{
+    int i, j, best_i;
+    for ( i = 1; i < nCutsR-1; i++ )
+    {
+        best_i = i;
+        for ( j = i+1; j < nCutsR; j++ )
+            if ( pCutsR[j]->nLeaves > pCutsR[best_i]->nLeaves )
+                best_i = j;
+        ABC_SWAP( Lf_Cut_t *, pCutsR[i], pCutsR[best_i] );
+    }
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Check if truth table has non-const-cof cofactoring variable.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Lf_ManFindCofVar( word * pTruth, int nWords, int nVars )
+{
+    word uTruthCof[LF_TT_WORDS]; int iVar;
+    for ( iVar = 0; iVar < nVars; iVar++ )
+    {
+        Abc_TtCofactor0p( uTruthCof, pTruth, nWords, iVar );
+        if ( Abc_TtSupportSize(uTruthCof, nVars) < 2 )
+            continue;
+        Abc_TtCofactor1p( uTruthCof, pTruth, nWords, iVar );
+        if ( Abc_TtSupportSize(uTruthCof, nVars) < 2 )
+            continue;
+        return iVar;
+    }
+    return -1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Lf_CutComputeTruth6( Lf_Man_t * p, Lf_Cut_t * pCut0, Lf_Cut_t * pCut1, int fCompl0, int fCompl1, Lf_Cut_t * pCutR, int fIsXor )
+{
+//    extern int Mf_ManTruthCanonicize( word * t, int nVars );
+    int nOldSupp = pCutR->nLeaves, truthId, fCompl; word t;
+    word t0 = *Lf_CutTruth(p, pCut0);
+    word t1 = *Lf_CutTruth(p, pCut1);
+    if ( Abc_LitIsCompl(pCut0->iFunc) ^ fCompl0 ) t0 = ~t0;
+    if ( Abc_LitIsCompl(pCut1->iFunc) ^ fCompl1 ) t1 = ~t1;
+    t0 = Abc_Tt6Expand( t0, pCut0->pLeaves, pCut0->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
+    t1 = Abc_Tt6Expand( t1, pCut1->pLeaves, pCut1->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
+    t =  fIsXor ? t0 ^ t1 : t0 & t1;
+    if ( (fCompl = (int)(t & 1)) ) t = ~t;
+    pCutR->nLeaves = Abc_Tt6MinBase( &t, pCutR->pLeaves, pCutR->nLeaves );
+    assert( (int)(t & 1) == 0 );
+    truthId        = Vec_MemHashInsert(p->vTtMem, &t);
+    pCutR->iFunc   = Abc_Var2Lit( truthId, fCompl );
+//    p->nCutMux += Lf_ManTtIsMux( t );
+    assert( (int)pCutR->nLeaves <= nOldSupp );
+//    Mf_ManTruthCanonicize( &t, pCutR->nLeaves );
+    return (int)pCutR->nLeaves < nOldSupp;
+}
+static inline int Lf_CutComputeTruth( Lf_Man_t * p, Lf_Cut_t * pCut0, Lf_Cut_t * pCut1, int fCompl0, int fCompl1, Lf_Cut_t * pCutR, int fIsXor )
+{
+    if ( p->pPars->nLutSize <= 6 )
+        return Lf_CutComputeTruth6( p, pCut0, pCut1, fCompl0, fCompl1, pCutR, fIsXor );
+    {
+    word uTruth[LF_TT_WORDS], uTruth0[LF_TT_WORDS], uTruth1[LF_TT_WORDS];
+    int nOldSupp   = pCutR->nLeaves, truthId;
+    int LutSize    = p->pPars->nLutSize, fCompl;
+    int nWords     = Abc_Truth6WordNum(LutSize);
+    word * pTruth0 = Lf_CutTruth(p, pCut0);
+    word * pTruth1 = Lf_CutTruth(p, pCut1);
+    Abc_TtCopy( uTruth0, pTruth0, nWords, Abc_LitIsCompl(pCut0->iFunc) ^ fCompl0 );
+    Abc_TtCopy( uTruth1, pTruth1, nWords, Abc_LitIsCompl(pCut1->iFunc) ^ fCompl1 );
+    Abc_TtExpand( uTruth0, LutSize, pCut0->pLeaves, pCut0->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
+    Abc_TtExpand( uTruth1, LutSize, pCut1->pLeaves, pCut1->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
+    if ( fIsXor )
+        Abc_TtXor( uTruth, uTruth0, uTruth1, nWords, (fCompl = (int)((uTruth0[0] ^ uTruth1[0]) & 1)) );
+    else
+        Abc_TtAnd( uTruth, uTruth0, uTruth1, nWords, (fCompl = (int)((uTruth0[0] & uTruth1[0]) & 1)) );
+    pCutR->nLeaves = Abc_TtMinBase( uTruth, pCutR->pLeaves, pCutR->nLeaves, LutSize );
+    assert( (uTruth[0] & 1) == 0 );
+//Kit_DsdPrintFromTruth( uTruth, pCutR->nLeaves ), printf("\n" ), printf("\n" );
+    truthId        = Vec_MemHashInsert(p->vTtMem, uTruth);
+    pCutR->iFunc   = Abc_Var2Lit( truthId, fCompl );
+    assert( (int)pCutR->nLeaves <= nOldSupp );
+    return (int)pCutR->nLeaves < nOldSupp;
+    }
+}
+static inline int Lf_CutComputeTruthMux6( Lf_Man_t * p, Lf_Cut_t * pCut0, Lf_Cut_t * pCut1, Lf_Cut_t * pCutC, int fCompl0, int fCompl1, int fComplC, Lf_Cut_t * pCutR )
+{
+    int nOldSupp = pCutR->nLeaves, truthId, fCompl; word t;
+    word t0 = *Lf_CutTruth(p, pCut0);
+    word t1 = *Lf_CutTruth(p, pCut1);
+    word tC = *Lf_CutTruth(p, pCutC);
+    if ( Abc_LitIsCompl(pCut0->iFunc) ^ fCompl0 ) t0 = ~t0;
+    if ( Abc_LitIsCompl(pCut1->iFunc) ^ fCompl1 ) t1 = ~t1;
+    if ( Abc_LitIsCompl(pCutC->iFunc) ^ fComplC ) tC = ~tC;
+    t0 = Abc_Tt6Expand( t0, pCut0->pLeaves, pCut0->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
+    t1 = Abc_Tt6Expand( t1, pCut1->pLeaves, pCut1->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
+    tC = Abc_Tt6Expand( tC, pCutC->pLeaves, pCutC->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
+    t = (tC & t1) | (~tC & t0);
+    if ( (fCompl = (int)(t & 1)) ) t = ~t;
+    pCutR->nLeaves = Abc_Tt6MinBase( &t, pCutR->pLeaves, pCutR->nLeaves );
+    assert( (int)(t & 1) == 0 );
+    truthId        = Vec_MemHashInsert(p->vTtMem, &t);
+    pCutR->iFunc   = Abc_Var2Lit( truthId, fCompl );
+    assert( (int)pCutR->nLeaves <= nOldSupp );
+    return (int)pCutR->nLeaves < nOldSupp;
+}
+static inline int Lf_CutComputeTruthMux( Lf_Man_t * p, Lf_Cut_t * pCut0, Lf_Cut_t * pCut1, Lf_Cut_t * pCutC, int fCompl0, int fCompl1, int fComplC, Lf_Cut_t * pCutR )
+{
+    if ( p->pPars->nLutSize <= 6 )
+        return Lf_CutComputeTruthMux6( p, pCut0, pCut1, pCutC, fCompl0, fCompl1, fComplC, pCutR );
+    {
+    word uTruth[LF_TT_WORDS], uTruth0[LF_TT_WORDS], uTruth1[LF_TT_WORDS], uTruthC[LF_TT_WORDS];
+    int nOldSupp   = pCutR->nLeaves, truthId;
+    int LutSize    = p->pPars->nLutSize, fCompl;
+    int nWords     = Abc_Truth6WordNum(LutSize);
+    word * pTruth0 = Lf_CutTruth(p, pCut0);
+    word * pTruth1 = Lf_CutTruth(p, pCut1);
+    word * pTruthC = Lf_CutTruth(p, pCutC);
+    Abc_TtCopy( uTruth0, pTruth0, nWords, Abc_LitIsCompl(pCut0->iFunc) ^ fCompl0 );
+    Abc_TtCopy( uTruth1, pTruth1, nWords, Abc_LitIsCompl(pCut1->iFunc) ^ fCompl1 );
+    Abc_TtCopy( uTruthC, pTruthC, nWords, Abc_LitIsCompl(pCutC->iFunc) ^ fComplC );
+    Abc_TtExpand( uTruth0, LutSize, pCut0->pLeaves, pCut0->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
+    Abc_TtExpand( uTruth1, LutSize, pCut1->pLeaves, pCut1->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
+    Abc_TtExpand( uTruthC, LutSize, pCutC->pLeaves, pCutC->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
+    Abc_TtMux( uTruth, uTruthC, uTruth1, uTruth0, nWords );
+    fCompl         = (int)(uTruth[0] & 1);
+    if ( fCompl ) Abc_TtNot( uTruth, nWords );
+    pCutR->nLeaves = Abc_TtMinBase( uTruth, pCutR->pLeaves, pCutR->nLeaves, LutSize );
+    assert( (uTruth[0] & 1) == 0 );
+    truthId        = Vec_MemHashInsert(p->vTtMem, uTruth);
+    pCutR->iFunc   = Abc_Var2Lit( truthId, fCompl );
+    assert( (int)pCutR->nLeaves <= nOldSupp );
+    return (int)pCutR->nLeaves < nOldSupp;
+    }
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Exact local area.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+float Lf_CutRef_rec( Lf_Man_t * p, Lf_Cut_t * pCut )
+{
+    word CutTemp[LF_CUT_WORDS] = {0};
+    float Count = Lf_CutArea(p, pCut);
+    int i, Var; 
+    Lf_CutForEachVar( pCut, Var, i )
+        if ( !Lf_ObjMapRefInc(p, Var) )
+            Count += Lf_CutRef_rec( p, Lf_ObjCutBestNew(p, Var, (Lf_Cut_t *)CutTemp) );
+    return Count;
+}
+float Lf_CutDeref_rec( Lf_Man_t * p, Lf_Cut_t * pCut )
+{
+    word CutTemp[LF_CUT_WORDS] = {0};
+    float Count = Lf_CutArea(p, pCut);
+    int i, Var; 
+    Lf_CutForEachVar( pCut, Var, i )
+        if ( !Lf_ObjMapRefDec(p, Var) )
+            Count += Lf_CutDeref_rec( p, Lf_ObjCutBestNew(p, Var, (Lf_Cut_t *)CutTemp) );
+    return Count;
+}
+static inline float Lf_CutAreaDerefed( Lf_Man_t * p, Lf_Cut_t * pCut )
+{
+    float Ela1 = Lf_CutRef_rec( p, pCut );
+    Lf_CutDeref_rec( p, pCut );
+//    float Ela2 = Lf_CutDeref_rec( p, pCut );
+//    assert( Ela1 == Ela2 );
+    return Ela1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int  Lf_CutRequired( Lf_Man_t * p, Lf_Cut_t * pCut )
+{
+    int i, Arr, Req, Arrival = 0, Required = 0;
+    for ( i = 0; i < (int)pCut->nLeaves; i++ )
+    {
+        if ( Lf_ObjOff(p, pCut->pLeaves[i]) < 0 )
+//            Arr = Lf_ObjCiArrival( p, Gia_ObjCioId(Gia_ManObj(p->pGia, pCut->pLeaves[i])) ); 
+            Arr = Lf_ObjArrival_rec( p, Gia_ManObj(p->pGia, pCut->pLeaves[i]) );
+        else
+            Arr = Lf_ObjReadBest(p, pCut->pLeaves[i])->Delay[0];
+        Arrival = Abc_MaxInt( Arrival, Arr );
+        Req = Lf_ObjRequired(p, pCut->pLeaves[i]);
+        if ( Req < ABC_INFINITY )
+            Required = Abc_MaxInt( Required, Req );
+    }
+    return Abc_MaxInt( Required + 2, Arrival + 1 ); 
+}
+static inline void Lf_CutParams( Lf_Man_t * p, Lf_Cut_t * pCut, int Required, float FlowRefs, Gia_Obj_t * pMux )
+{
+    Lf_Bst_t * pBest;
+    int i, Index, Delay;
+    assert( !pCut->fMux7 || Gia_ObjIsMux(p->pGia, pMux) );
+    pCut->fLate = 0;
+    pCut->Delay = 0;
+    pCut->Flow  = 0;
+    assert( pCut->nLeaves < LF_NO_LEAF );
+    for ( i = 0; i < (int)pCut->nLeaves; i++ )
+    {
+        if ( Lf_ObjOff(p, pCut->pLeaves[i]) < 0 )
+//            Delay = Lf_ObjCiArrival( p, Gia_ObjCioId(Gia_ManObj(p->pGia, pCut->pLeaves[i])) );   
+            Delay = Lf_ObjArrival_rec( p, Gia_ManObj(p->pGia, pCut->pLeaves[i]) );
+        else
+        {
+            pBest = Lf_ObjReadBest(p, pCut->pLeaves[i]);
+            assert( pBest->Delay[0] <= pBest->Delay[1] );
+            assert( pBest->Flow[0]  >= pBest->Flow[1]  );
+            if ( p->fUseEla )
+                Index = Lf_BestIndex(pBest);
+            else
+            {
+                Index = (int)(pBest->Delay[1] + 1 <= Required && Required != ABC_INFINITY);
+                pCut->Flow += pBest->Flow[Index];
+            }
+            Delay = pBest->Delay[Index];
+        }
+//        if ( pCut->fMux7 && pCut->pLeaves[i] == Gia_ObjFaninId2p(p->pGia, pMux) )
+//            Delay += 1;
+        pCut->Delay = Abc_MaxInt( pCut->Delay, Delay );
+    }
+    pCut->Delay += (int)(pCut->nLeaves > 1);// && !pCut->fMux7;
+    if ( pCut->Delay > Required )
+        pCut->fLate = 1;
+    if ( p->fUseEla )
+        pCut->Flow = Lf_CutAreaDerefed(p, pCut) / FlowRefs;
+    else
+        pCut->Flow = (pCut->Flow + Lf_CutArea(p, pCut)) / FlowRefs;
+}
+
+void Lf_ObjMergeOrder( Lf_Man_t * p, int iObj )
+{
+    word CutSet[LF_CUT_MAX][LF_CUT_WORDS] = {{0}};
+    Lf_Cut_t * pCutSet0, * pCutSet1, * pCutSet2, * pCut0, * pCut1, * pCut2;
+    Lf_Cut_t * pCutSet = (Lf_Cut_t *)CutSet, * pCutsR[LF_CUT_MAX];
+    Gia_Obj_t * pObj = Gia_ManObj(p->pGia, iObj);
+    Lf_Bst_t * pBest = Lf_ObjReadBest(p, iObj);
+    float FlowRefs = Lf_ObjFlowRefs(p, iObj);
+    int Required   = Lf_ObjRequired(p, iObj);
+    int nLutSize   = p->pPars->nLutSize;
+    int nCutNum    = p->pPars->nCutNum;
+    int nCutWords  = p->nCutWords;
+    int fComp0     = Gia_ObjFaninC0(pObj);
+    int fComp1     = Gia_ObjFaninC1(pObj);
+    int nCuts0     = Lf_ManPrepareSet( p, Gia_ObjFaninId0(pObj, iObj), 0, &pCutSet0 );
+    int nCuts1     = Lf_ManPrepareSet( p, Gia_ObjFaninId1(pObj, iObj), 1, &pCutSet1 );
+    int iSibl      = Gia_ObjSibl(p->pGia, iObj);
+    int i, k, n, iCutUsed, nCutsR = 0;
+    float Value1 = -1, Value2 = -1;
+    assert( !Gia_ObjIsBuf(pObj) );
+    Lf_CutSetForEachCut( nCutWords, pCutSet, pCut0, i, nCutNum )
+        pCutsR[i] = pCut0;
+    if ( p->Iter )
+    {
+        assert( nCutsR == 0 );
+        // load cuts
+        Lf_MemLoadCut( &p->vStoreOld, pBest->Cut[0].Handle, iObj, pCutsR[0], p->pPars->fCutMin, 1 );
+        if ( Lf_BestDiffCuts(pBest) )
+            Lf_MemLoadCut( &p->vStoreOld, pBest->Cut[1].Handle, iObj, pCutsR[1], p->pPars->fCutMin, 1 );
+        // deref the cut
+        if ( p->fUseEla && Lf_ObjMapRefNum(p, iObj) > 0 )
+            Value1 = Lf_CutDeref_rec( p, pCutsR[Lf_BestIndex(pBest)] );
+        // update required times
+        if ( Required == ABC_INFINITY )//&& !p->fUseEla )
+            Required = Lf_CutRequired( p, pCutsR[0] );
+        // compute parameters
+        Lf_CutParams( p, pCutsR[nCutsR++], Required, FlowRefs, pObj );
+        if ( Lf_BestDiffCuts(pBest) )
+        {
+            assert( nCutsR == 1 );
+            Lf_CutParams( p, pCutsR[nCutsR], Required, FlowRefs, pObj );
+            nCutsR = Lf_SetAddCut( pCutsR, nCutsR, nCutNum );
+        }
+        if ( pCutsR[0]->fLate )
+            p->nTimeFails++;
+    }
+    if ( iSibl )
+    {
+        Gia_Obj_t * pObjE = Gia_ObjSiblObj(p->pGia, iObj);
+        int fCompE = Gia_ObjPhase(pObj) ^ Gia_ObjPhase(pObjE);
+        int nCutsE = Lf_ManPrepareSet( p, iSibl, 2, &pCutSet2 );
+        Lf_CutSetForEachCut( nCutWords, pCutSet2, pCut2, n, nCutsE )
+        {
+            if ( pCut2->pLeaves[0] == iSibl )
+                continue;
+            Lf_CutCopy( pCutsR[nCutsR], pCut2, nCutWords );
+            if ( pCutsR[nCutsR]->iFunc >= 0 )
+                pCutsR[nCutsR]->iFunc = Abc_LitNotCond( pCutsR[nCutsR]->iFunc, fCompE );
+            Lf_CutParams( p, pCutsR[nCutsR], Required, FlowRefs, pObj );
+            nCutsR = Lf_SetAddCut( pCutsR, nCutsR, nCutNum );
+        }
+    }
+    if ( Gia_ObjIsMuxId(p->pGia, iObj) )
+    {
+        int fComp2 = Gia_ObjFaninC2(p->pGia, pObj);
+        int nCuts2 = Lf_ManPrepareSet( p, Gia_ObjFaninId2(p->pGia, iObj), 2, &pCutSet2 );
+        p->CutCount[0] += nCuts0 * nCuts1 * nCuts2;
+        Lf_CutSetForEachCut( nCutWords, pCutSet0, pCut0, i, nCuts0 )
+        Lf_CutSetForEachCut( nCutWords, pCutSet1, pCut1, k, nCuts1 )
+        Lf_CutSetForEachCut( nCutWords, pCutSet2, pCut2, n, nCuts2 )
+        {
+            if ( Lf_CutCountBits(pCut0->Sign | pCut1->Sign | pCut2->Sign) > nLutSize )
+                continue;
+            p->CutCount[1]++; 
+            if ( !Lf_CutMergeOrderMux(pCut0, pCut1, pCut2, pCutsR[nCutsR], nLutSize) )
+                continue;
+            if ( Lf_SetLastCutIsContained(pCutsR, nCutsR) )
+                continue;
+            p->CutCount[2]++;
+            if ( p->pPars->fCutMin && Lf_CutComputeTruthMux(p, pCut0, pCut1, pCut2, fComp0, fComp1, fComp2, pCutsR[nCutsR]) )
+                pCutsR[nCutsR]->Sign = Lf_CutGetSign(pCutsR[nCutsR]);
+            if ( p->pPars->nLutSizeMux && p->pPars->nLutSizeMux == (int)pCutsR[nCutsR]->nLeaves && 
+                Lf_ManFindCofVar(Lf_CutTruth(p,pCutsR[nCutsR]), Abc_Truth6WordNum(nLutSize), pCutsR[nCutsR]->nLeaves) == -1 )
+                continue;
+            Lf_CutParams( p, pCutsR[nCutsR], Required, FlowRefs, pObj );
+            nCutsR = Lf_SetAddCut( pCutsR, nCutsR, nCutNum );
+        }
+    }
+    else
+    {
+        int fIsXor = Gia_ObjIsXor(pObj);
+        p->CutCount[0] += nCuts0 * nCuts1;
+        Lf_CutSetForEachCut( nCutWords, pCutSet0, pCut0, i, nCuts0 )
+        Lf_CutSetForEachCut( nCutWords, pCutSet1, pCut1, k, nCuts1 )
+        {
+            if ( (int)(pCut0->nLeaves + pCut1->nLeaves) > nLutSize && Lf_CutCountBits(pCut0->Sign | pCut1->Sign) > nLutSize )
+                continue;
+            p->CutCount[1]++; 
+            if ( !Lf_CutMergeOrder(pCut0, pCut1, pCutsR[nCutsR], nLutSize) )
+                continue;
+            if ( Lf_SetLastCutIsContained(pCutsR, nCutsR) )
+                continue;
+            p->CutCount[2]++;
+            if ( p->pPars->fCutMin && Lf_CutComputeTruth(p, pCut0, pCut1, fComp0, fComp1, pCutsR[nCutsR], fIsXor) )
+                pCutsR[nCutsR]->Sign = Lf_CutGetSign(pCutsR[nCutsR]);
+            if ( p->pPars->nLutSizeMux && p->pPars->nLutSizeMux == (int)pCutsR[nCutsR]->nLeaves && 
+                Lf_ManFindCofVar(Lf_CutTruth(p,pCutsR[nCutsR]), Abc_Truth6WordNum(nLutSize), pCutsR[nCutsR]->nLeaves) == -1 )
+                continue;
+            Lf_CutParams( p, pCutsR[nCutsR], Required, FlowRefs, pObj );
+            nCutsR = Lf_SetAddCut( pCutsR, nCutsR, nCutNum );
+        }
+    }
+    // debug printout
+    if ( 0 )
+    {
+        printf( "*** Obj = %d  FlowRefs = %.2f  MapRefs = %2d  Required = %2d\n", iObj, FlowRefs, Lf_ObjMapRefNum(p, iObj), Required );
+        for ( i = 0; i < nCutsR; i++ )
+            Lf_CutPrint( p, pCutsR[i] );
+        printf( "\n" );
+    }
+    // verify
+    assert( nCutsR > 0 && nCutsR < nCutNum );
+//    assert( Lf_SetCheckArray(pCutsR, nCutsR) );
+    // delay cut
+    assert( nCutsR == 1 || pCutsR[0]->Delay <= pCutsR[1]->Delay );
+    pBest->Cut[0].fUsed = pBest->Cut[1].fUsed = 0;
+    pBest->Cut[0].Handle = pBest->Cut[1].Handle = Lf_MemSaveCut(&p->vStoreNew, pCutsR[0], iObj);
+    pBest->Delay[0] = pBest->Delay[1] = pCutsR[0]->Delay;
+    pBest->Flow[0] = pBest->Flow[1] = pCutsR[0]->Flow;
+    p->nCutCounts[pCutsR[0]->nLeaves]++;
+    p->CutCount[3] += nCutsR;
+    p->nCutEqual++;
+    // area cut
+    iCutUsed = 0;
+    if ( nCutsR > 1 && pCutsR[0]->Flow > pCutsR[1]->Flow )//&& !pCutsR[1]->fLate ) // can remove !fLate
+    {
+        pBest->Cut[1].Handle = Lf_MemSaveCut(&p->vStoreNew, pCutsR[1], iObj);
+        pBest->Delay[1] = pCutsR[1]->Delay;
+        pBest->Flow[1] = pCutsR[1]->Flow;
+        p->nCutCounts[pCutsR[1]->nLeaves]++;
+        p->nCutEqual--;
+        if ( !pCutsR[1]->fLate )
+            iCutUsed = 1;
+    }
+    // mux cut
+    if ( p->pPars->fUseMux7 && Gia_ObjIsMuxId(p->pGia, iObj) )
+    {
+        pCut2 = Lf_ObjCutMux( p, iObj );
+        Lf_CutParams( p, pCut2, Required, FlowRefs, pObj );
+        pBest->Delay[2] = pCut2->Delay;
+        pBest->Flow[2] = pCut2->Flow;
+        // update area value of the best area cut
+//        if ( !pCut2->fLate )
+//            pBest->Flow[1] = Abc_MinFloat( pBest->Flow[1], pBest->Flow[2] );
+    }
+    // reference resulting cut
+    if ( p->fUseEla )
+    {
+        pBest->Cut[iCutUsed].fUsed = 1;
+        if ( Lf_ObjMapRefNum(p, iObj) > 0 )
+            Value2 = Lf_CutRef_rec( p, pCutsR[iCutUsed] );
+//        if ( Value1 < Value2 )
+//            printf( "ELA degradated cost at node %d from %d to %d.\n", iObj, Value1, Value2 ), fflush(stdout);
+//        assert( Value1 >= Value2 );
+//        if ( Value1 != -1 )
+//            printf( "%.2f -> %.2f    ", Value1, Value2 );
+    }
+    if ( pObj->Value == 0 )
+        return;
+    // store the cutset
+    pCutSet = Lf_ManFetchSet(p, iObj);
+    Lf_CutSetForEachCut( nCutWords, pCutSet, pCut0, i, nCutNum )
+    {
+        assert( !pCut0->fMux7 );
+        if ( i < nCutsR )
+            Lf_CutCopy( pCut0, pCutsR[i], nCutWords );
+        else if ( i == nCutsR && pCutsR[0]->nLeaves > 1 && (nCutsR == 1 || pCutsR[1]->nLeaves > 1) )
+            Lf_CutCreateUnit( pCut0, iObj );
+        else
+            pCut0->nLeaves = LF_NO_LEAF;
+    }
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Computing delay/area.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline void Lf_ManSetFlowRefInc( Gia_Man_t * p, Vec_Flt_t * vRefs, Vec_Int_t * vOffsets, int i )
+{
+    if ( Gia_ObjIsAndNotBuf(Gia_ManObj(p, i)) )
+        Vec_FltAddToEntry( vRefs, Vec_IntEntry(vOffsets, i), 1 );
+}
+void Lf_ManSetFlowRefs( Gia_Man_t * p, Vec_Flt_t * vRefs, Vec_Int_t * vOffsets )
+{
+    int fDiscount = 1;
+    Gia_Obj_t * pObj, * pCtrl, * pData0, * pData1; 
+    int i, Id;
+    Vec_FltFill( vRefs, Gia_ManAndNotBufNum(p), 0 );
+    Gia_ManForEachAnd( p, pObj, i )
+    {
+        if ( Gia_ObjIsAndNotBuf(Gia_ObjFanin0(pObj)) )
+            Vec_FltAddToEntry( vRefs, Vec_IntEntry(vOffsets, Gia_ObjFaninId0(pObj, i)), 1 );
+        if ( Gia_ObjIsBuf(pObj) )
+            continue;
+        if ( Gia_ObjIsAndNotBuf(Gia_ObjFanin1(pObj)) )
+            Vec_FltAddToEntry( vRefs, Vec_IntEntry(vOffsets, Gia_ObjFaninId1(pObj, i)), 1 );
+        if ( p->pMuxes )
+        {
+            if ( Gia_ObjIsMuxId(p, i) && Gia_ObjIsAndNotBuf(Gia_ObjFanin2(p, pObj)) )
+                Vec_FltAddToEntry( vRefs, Vec_IntEntry(vOffsets, Gia_ObjFaninId2(p, i)), 1 );
+        }
+        else if ( fDiscount && Gia_ObjIsMuxType(pObj) ) // discount XOR/MUX
+        {
+            pCtrl  = Gia_Regular(Gia_ObjRecognizeMux(pObj, &pData1, &pData0));
+            pData0 = Gia_Regular(pData0);
+            pData1 = Gia_Regular(pData1);
+            if ( Gia_ObjIsAndNotBuf(pCtrl) )
+                Vec_FltAddToEntry( vRefs, Vec_IntEntry(vOffsets, Gia_ObjId(p, pCtrl)), -1 );
+            if ( pData0 == pData1 && Gia_ObjIsAndNotBuf(pData0) )
+                Vec_FltAddToEntry( vRefs, Vec_IntEntry(vOffsets, Gia_ObjId(p, pData0)), -1 );
+        }
+    }
+    Gia_ManForEachCoDriverId( p, Id, i )
+        if ( Gia_ObjIsAndNotBuf(Gia_ManObj(p, Id)) )
+            Vec_FltAddToEntry( vRefs, Vec_IntEntry(vOffsets, Id), 1 );
+    for ( i = 0; i < Vec_FltSize(vRefs); i++ )
+        Vec_FltUpdateEntry( vRefs, i, 1 );
+}
+void Lf_ManSetCutRefs( Lf_Man_t * p )
+{
+    Gia_Obj_t * pObj; int i;
+    if ( Vec_PtrSize(&p->vMemSets) * (1 << LF_LOG_PAGE) != Vec_IntSize(&p->vFreeSets) )
+        printf( "The number of used cutsets = %d.\n", Vec_PtrSize(&p->vMemSets) * (1 << LF_LOG_PAGE) - Vec_IntSize(&p->vFreeSets) );
+    Gia_ManForEachAnd( p->pGia, pObj, i )
+    {
+        assert( pObj->Value == 0 );
+        if ( Gia_ObjIsBuf(pObj) )
+            continue;
+        if ( Gia_ObjIsAndNotBuf(Gia_ObjFanin0(pObj)) )
+            Gia_ObjFanin0(pObj)->Value++;
+        if ( Gia_ObjIsAndNotBuf(Gia_ObjFanin1(pObj)) )
+            Gia_ObjFanin1(pObj)->Value++;
+        if ( Gia_ObjIsMuxId(p->pGia, i) && Gia_ObjIsAndNotBuf(Gia_ObjFanin2(p->pGia, pObj)) )
+            Gia_ObjFanin2(p->pGia, pObj)->Value++;
+        if ( Gia_ObjSibl(p->pGia, i) && Gia_ObjIsAndNotBuf(Gia_ObjSiblObj(p->pGia, i)) )
+            Gia_ObjSiblObj(p->pGia, i)->Value++;
+    }
+}
+
+static inline int Lf_ManSetMuxCut( Lf_Man_t * p, Lf_Bst_t * pBest, int iObj, int Required )
+{
+    Gia_Obj_t * pMux;
+    if ( !Gia_ObjIsMuxId(p->pGia, iObj) )
+        return 0;
+    if ( pBest->Delay[2] > Required )
+        return 0;
+    if ( pBest->Flow[2] > 1.1 * pBest->Flow[1] )
+        return 0;
+    pMux = Gia_ManObj(p->pGia, iObj);
+    if ( pMux->fMark0 || Gia_ObjFanin0(pMux)->fMark0 || Gia_ObjFanin1(pMux)->fMark0 )
+        return 0;
+    Gia_ObjFanin0(pMux)->fMark0 = 1;
+    Gia_ObjFanin1(pMux)->fMark0 = 1;
+    return 1;
+}
+void Lf_ManSetMapRefsOne( Lf_Man_t * p, int iObj )
+{
+    Lf_Cut_t * pCut;
+    Lf_Bst_t * pBest = Lf_ObjReadBest( p, iObj );
+    int k, Index, Required = Lf_ObjRequired( p, iObj );
+    assert( Lf_ObjMapRefNum(p, iObj) > 0 );
+    assert( !pBest->Cut[0].fUsed && !pBest->Cut[1].fUsed );
+    if ( !p->pPars->fUseMux7 || !Lf_ManSetMuxCut(p, pBest, iObj, Required) )
+    {
+        Index = (int)(Lf_BestDiffCuts(pBest) && pBest->Delay[1] <= Required);
+        pBest->Cut[Index].fUsed = 1;
+    }
+    pCut = Lf_ObjCutBest( p, iObj );
+    assert( !pCut->fMux7 || pCut->nLeaves == 3 );
+//    assert( pCut->Delay <= Required );
+    for ( k = 0; k < (int)pCut->nLeaves; k++ )
+    {
+//        if ( pCut->fMux7 && pCut->pLeaves[k] != Gia_ObjFaninId2(p->pGia, iObj) )
+//            Lf_ObjSetRequired( p, pCut->pLeaves[k], Required );
+//        else
+            Lf_ObjSetRequired( p, pCut->pLeaves[k], Required - 1 );
+        if ( Gia_ObjIsAndNotBuf(Gia_ManObj(p->pGia, pCut->pLeaves[k])) )
+            Lf_ObjMapRefInc( p, pCut->pLeaves[k] );
+    }
+    if ( pCut->fMux7 )
+    {
+        p->pPars->Mux7++;
+        p->pPars->Edge++;
+        return;
+    }
+    if ( Vec_FltSize(&p->vSwitches) )
+        p->Switches += Lf_CutSwitches(p, pCut);
+    p->pPars->Edge += pCut->nLeaves;
+    p->pPars->Area++;
+}
+int Lf_ManSetMapRefs( Lf_Man_t * p )
+{
+    float Coef = 1.0 / (1.0 + (p->Iter + 1) * (p->Iter + 1));
+    float * pFlowRefs; 
+    int * pMapRefs, i;
+    Gia_Obj_t * pObj;
+    // compute delay
+    int Delay = 0;
+    for ( i = 0; i < Gia_ManCoNum(p->pGia); i++ )
+        Delay = Abc_MaxInt( Delay, Lf_ObjCoArrival(p, i) );
+    // check delay target
+    if ( p->pPars->DelayTarget == -1 && p->pPars->nRelaxRatio )
+        p->pPars->DelayTarget = (int)((float)Delay * (100.0 + p->pPars->nRelaxRatio) / 100.0);
+    if ( p->pPars->DelayTarget != -1 )
+    {
+        if ( Delay < p->pPars->DelayTarget + 0.01 )
+            Delay = p->pPars->DelayTarget;
+        else if ( p->pPars->nRelaxRatio == 0 )
+            Abc_Print( 0, "Relaxing user-specified delay target from %d to %d.\n", p->pPars->DelayTarget, Delay );
+    } 
+    p->pPars->Delay = Delay;
+    // compute area/edges/required
+    p->pPars->Mux7 = p->pPars->Area = p->pPars->Edge = p->Switches = 0;
+    Vec_IntFill( &p->vMapRefs, Gia_ManAndNotBufNum(p->pGia), 0 );
+    Vec_IntFill( &p->vRequired, Gia_ManObjNum(p->pGia), ABC_INFINITY );
+    if ( p->pPars->fUseMux7 )
+    {
+        Gia_ManCleanMark0(p->pGia);
+        Gia_ManForEachCi( p->pGia, pObj, i )
+            pObj->fMark0 = 1;
+    }
+    if ( p->pGia->pManTime != NULL )
+    {
+        assert( Gia_ManBufNum(p->pGia) );
+        Tim_ManIncrementTravId( p->pGia->pManTime );
+        if ( p->pPars->fDoAverage )
+            for ( i = 0; i < Gia_ManCoNum(p->pGia); i++ )
+               Tim_ManSetCoRequired( p->pGia->pManTime, i, (int)(Lf_ObjCoArrival(p, i) * (100.0 + p->pPars->nRelaxRatio) / 100.0) );
+        else  
+            Tim_ManInitPoRequiredAll( p->pGia->pManTime, Delay );
+        Gia_ManForEachObjReverse1( p->pGia, pObj, i )
+        {
+            if ( Gia_ObjIsBuf(pObj) )
+                Lf_ObjSetRequired( p, Gia_ObjFaninId0(pObj, i), Lf_ObjRequired(p, i) );
+            else if ( Gia_ObjIsAnd(pObj) )
+            {
+                if ( Lf_ObjMapRefNum(p, i) )
+                    Lf_ManSetMapRefsOne( p, i );
+            }
+            else if ( Gia_ObjIsCi(pObj) )
+                Tim_ManSetCiRequired( p->pGia->pManTime, Gia_ObjCioId(pObj), Lf_ObjRequired(p, i) );
+            else if ( Gia_ObjIsCo(pObj) )
+            {
+                int iDriverId = Gia_ObjFaninId0(pObj, i);
+                int reqTime = Tim_ManGetCoRequired( p->pGia->pManTime, Gia_ObjCioId(pObj) );
+                Lf_ObjSetRequired( p, iDriverId, reqTime );
+                if ( Gia_ObjIsAndNotBuf(Gia_ObjFanin0(pObj)) )
+                    Lf_ObjMapRefInc( p, iDriverId );
+            }
+            else assert( 0 );
+        }
+    }
+    else
+    {
+        Gia_ManForEachCo( p->pGia, pObj, i )
+        {
+            int iDriverId = Gia_ObjFaninId0p(p->pGia, pObj);
+            int reqTime = p->pPars->fDoAverage ? (int)(Lf_ObjCoArrival(p, i) * (100.0 + p->pPars->nRelaxRatio) / 100.0) : Delay;
+            Lf_ObjSetRequired( p, iDriverId, reqTime );
+            if ( Gia_ObjIsAndNotBuf(Gia_ObjFanin0(pObj)) )
+                Lf_ObjMapRefInc( p, iDriverId );
+        }
+        Gia_ManForEachAndReverse( p->pGia, pObj, i )
+        {
+            if ( Gia_ObjIsBuf(pObj) )
+            {
+                Lf_ObjSetRequired( p, Gia_ObjFaninId0(pObj, i), Lf_ObjRequired(p, i) );
+                if ( Gia_ObjIsAndNotBuf(Gia_ObjFanin0(pObj)) )
+                    Lf_ObjMapRefInc( p, Gia_ObjFaninId0(pObj, i) );
+            }
+            else if ( Lf_ObjMapRefNum(p, i) )
+                Lf_ManSetMapRefsOne( p, i );
+        }
+    }
+    if ( p->pPars->fUseMux7 )
+        Gia_ManCleanMark0(p->pGia);
+    // blend references
+    assert( Vec_IntSize(&p->vMapRefs)  == Gia_ManAndNotBufNum(p->pGia) );
+    assert( Vec_FltSize(&p->vFlowRefs) == Gia_ManAndNotBufNum(p->pGia) );
+    pMapRefs  = Vec_IntArray(&p->vMapRefs);
+    pFlowRefs = Vec_FltArray(&p->vFlowRefs);
+    for ( i = 0; i < Vec_IntSize(&p->vMapRefs); i++ )
+        pFlowRefs[i] = Coef * pFlowRefs[i] + (1.0 - Coef) * Abc_MaxFloat(1, pMapRefs[i]);
+//        pFlowRefs[i] = 0.2 * pFlowRefs[i] + 0.8 * Abc_MaxFloat(1, pMapRefs[i]);
+    return p->pPars->Area;
+}
+
+void Lf_ManCountMapRefsOne( Lf_Man_t * p, int iObj )
+{
+    Lf_Bst_t * pBest = Lf_ObjReadBest( p, iObj );
+    Lf_Cut_t * pCut = Lf_ObjCutBest( p, iObj );
+    int k ,Required = Lf_ObjRequired( p, iObj );
+    assert( Lf_ObjMapRefNum(p, iObj) > 0 );
+    assert( Lf_BestIsMapped(pBest) );
+    assert( !pCut->fMux7 );
+//    assert( pCut->Delay <= Required );
+    for ( k = 0; k < (int)pCut->nLeaves; k++ )
+            Lf_ObjSetRequired( p, pCut->pLeaves[k], Required - 1 );
+    if ( Vec_FltSize(&p->vSwitches) )
+        p->Switches += Lf_CutSwitches(p, pCut);
+    p->pPars->Edge += pCut->nLeaves;
+    p->pPars->Area++;
+}
+void Lf_ManCountMapRefs( Lf_Man_t * p )
+{
+    // compute delay
+    Gia_Obj_t * pObj;
+    int i, Id, Delay = 0;
+    for ( i = 0; i < Gia_ManCoNum(p->pGia); i++ )
+        Delay = Abc_MaxInt( Delay, Lf_ObjCoArrival2(p, i) );
+    // check delay target
+    if ( p->pPars->DelayTarget == -1 && p->pPars->nRelaxRatio )
+        p->pPars->DelayTarget = (int)((float)Delay * (100.0 + p->pPars->nRelaxRatio) / 100.0);
+    if ( p->pPars->DelayTarget != -1 )
+    {
+        if ( Delay < p->pPars->DelayTarget + 0.01 )
+            Delay = p->pPars->DelayTarget;
+        else if ( p->pPars->nRelaxRatio == 0 )
+            Abc_Print( 0, "Relaxing user-specified delay target from %d to %d.\n", p->pPars->DelayTarget, Delay );
+    }
+    p->pPars->Delay = Delay;
+    // compute area/edges/required
+    p->pPars->Mux7 = p->pPars->Area = p->pPars->Edge = p->Switches = 0;
+    Vec_IntFill( &p->vRequired, Gia_ManObjNum(p->pGia), ABC_INFINITY );
+    if ( p->pPars->fUseMux7 )
+        Gia_ManCleanMark0(p->pGia);
+    if ( p->pGia->pManTime != NULL )
+    {
+        Tim_ManIncrementTravId( p->pGia->pManTime );
+        if ( p->pPars->fDoAverage )
+            for ( i = 0; i < Gia_ManCoNum(p->pGia); i++ )
+               Tim_ManSetCoRequired( p->pGia->pManTime, i, (int)(Lf_ObjCoArrival(p, i) * (100.0 + p->pPars->nRelaxRatio) / 100.0) );
+        else  
+            Tim_ManInitPoRequiredAll( p->pGia->pManTime, Delay );
+        Gia_ManForEachObjReverse1( p->pGia, pObj, i )
+        {
+            if ( Gia_ObjIsBuf(pObj) )
+                Lf_ObjSetRequired( p, Gia_ObjFaninId0(pObj, i), Lf_ObjRequired(p, i) );
+            else if ( Gia_ObjIsAnd(pObj) )
+            {
+                if ( Lf_ObjMapRefNum(p, i) )
+                    Lf_ManCountMapRefsOne( p, i );
+            }
+            else if ( Gia_ObjIsCi(pObj) )
+                Tim_ManSetCiRequired( p->pGia->pManTime, Gia_ObjCioId(pObj), Lf_ObjRequired(p, i) );
+            else if ( Gia_ObjIsCo(pObj) )
+            {
+                int reqTime = Tim_ManGetCoRequired( p->pGia->pManTime, Gia_ObjCioId(pObj) );
+                Lf_ObjSetRequired( p, Gia_ObjFaninId0(pObj, i), reqTime );
+            }
+            else assert( 0 );
+        }
+    }
+    else
+    {
+        Gia_ManForEachCoDriverId( p->pGia, Id, i )
+            Lf_ObjSetRequired( p, Id, p->pPars->fDoAverage ? (int)(Lf_ObjCoArrival(p, i) * (100.0 + p->pPars->nRelaxRatio) / 100.0) : Delay );
+        Gia_ManForEachAndReverse( p->pGia, pObj, i )
+            if ( Gia_ObjIsBuf(pObj) )
+                Lf_ObjSetRequired( p, Gia_ObjFaninId0(pObj, i), Lf_ObjRequired(p, i) );
+            else if ( Lf_ObjMapRefNum(p, i) )
+                Lf_ManCountMapRefsOne( p, i );
+    }
+    if ( p->pPars->fUseMux7 )
+        Gia_ManCleanMark0(p->pGia);
+}    
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Gia_Man_t * Lf_ManDeriveMapping( Lf_Man_t * p )
+{
+    Vec_Int_t * vMapping;
+    Lf_Cut_t * pCut;
+    int i, k;
+    assert( !p->pPars->fCutMin && p->pGia->vMapping == NULL );
+    vMapping = Vec_IntAlloc( Gia_ManObjNum(p->pGia) + (int)p->pPars->Edge + (int)p->pPars->Area * 2 );
+    Vec_IntFill( vMapping, Gia_ManObjNum(p->pGia), 0 );
+    Gia_ManForEachAndId( p->pGia, i )
+    {
+        if ( !Lf_ObjMapRefNum(p, i) )
+            continue;
+        assert( !Gia_ObjIsBuf(Gia_ManObj(p->pGia,i)) );
+        pCut = Lf_ObjCutBest( p, i );
+        assert( !pCut->fMux7 );
+        Vec_IntWriteEntry( vMapping, i, Vec_IntSize(vMapping) );
+        Vec_IntPush( vMapping, pCut->nLeaves );
+        for ( k = 0; k < (int)pCut->nLeaves; k++ )
+            Vec_IntPush( vMapping, pCut->pLeaves[k] );
+        Vec_IntPush( vMapping, i );
+    }
+    assert( Vec_IntCap(vMapping) == 16 || Vec_IntSize(vMapping) == Vec_IntCap(vMapping) );
+    p->pGia->vMapping = vMapping;
+    return p->pGia;
+}
+Gia_Man_t * Lf_ManDeriveMappingCoarse( Lf_Man_t * p )
+{
+    Gia_Man_t * pNew, * pGia = p->pGia;
+    Gia_Obj_t * pObj;
+    Lf_Cut_t * pCut;
+    int i, k;
+    assert( !p->pPars->fCutMin && pGia->pMuxes );
+    // create new manager
+    pNew = Gia_ManStart( Gia_ManObjNum(pGia) );
+    pNew->pName = Abc_UtilStrsav( pGia->pName );
+    pNew->pSpec = Abc_UtilStrsav( pGia->pSpec );
+    // start mapping
+    pNew->vMapping = Vec_IntAlloc( Gia_ManObjNum(pGia) + 2*Gia_ManXorNum(pGia) + 2*Gia_ManMuxNum(pGia) + (int)p->pPars->Edge + 2*(int)p->pPars->Area + 4*(int)p->pPars->Mux7 );
+    Vec_IntFill( pNew->vMapping, Gia_ManObjNum(pGia) + 2*Gia_ManXorNum(pGia) + 2*Gia_ManMuxNum(pGia), 0 );
+    // process objects
+    Gia_ManConst0(pGia)->Value = 0;
+    Gia_ManForEachObj1( pGia, pObj, i )
+    {
+        if ( Gia_ObjIsCi(pObj) )
+            { pObj->Value = Gia_ManAppendCi( pNew ); continue; }
+        if ( Gia_ObjIsCo(pObj) )
+            { pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) ); continue; }
+        if ( Gia_ObjIsBuf(pObj) )
+            { pObj->Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(pObj) ); continue; }
+        if ( Gia_ObjIsMuxId(pGia, i) )
+            pObj->Value = Gia_ManAppendMux( pNew, Gia_ObjFanin2Copy(pGia, pObj), Gia_ObjFanin1Copy(pObj), Gia_ObjFanin0Copy(pObj) );
+        else if ( Gia_ObjIsXor(pObj) )
+            pObj->Value = Gia_ManAppendXor( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+        else 
+            pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+        if ( !Lf_ObjMapRefNum(p, i) )
+            continue;
+        pCut = Lf_ObjCutBest( p, i );
+        Vec_IntWriteEntry( pNew->vMapping, Abc_Lit2Var(pObj->Value), Vec_IntSize(pNew->vMapping) );
+        Vec_IntPush( pNew->vMapping, pCut->nLeaves );
+        for ( k = 0; k < (int)pCut->nLeaves; k++ )
+            Vec_IntPush( pNew->vMapping, Abc_Lit2Var(Gia_ManObj(pGia, pCut->pLeaves[k])->Value) );
+        Vec_IntPush( pNew->vMapping, pCut->fMux7 ? -Abc_Lit2Var(pObj->Value) : Abc_Lit2Var(pObj->Value) );
+    }
+    Gia_ManSetRegNum( pNew, Gia_ManRegNum(pGia) );
+    assert( Vec_IntCap(pNew->vMapping) == 16 || Vec_IntSize(pNew->vMapping) == Vec_IntCap(pNew->vMapping) );
+    return pNew;
+}
+static inline int Lf_ManDerivePart( Lf_Man_t * p, Gia_Man_t * pNew, Vec_Int_t * vMapping, Vec_Int_t * vMapping2, Vec_Int_t * vCopies, Lf_Cut_t * pCut, Vec_Int_t * vLeaves, Vec_Int_t * vCover, Gia_Obj_t * pObj )
+{
+    word * pTruth;
+    int k, iLit, iTemp;
+    if ( p->pPars->nLutSizeMux && p->pPars->nLutSizeMux == (int)pCut->nLeaves )
+    {
+        word pTruthCof[LF_TT_WORDS], * pTruth = Lf_CutTruth( p, pCut );
+        int pVarsNew[LF_LEAF_MAX], nVarsNew, iLitCofs[2]; 
+        int LutSize   = p->pPars->nLutSize;
+        int nWords    = Abc_Truth6WordNum(LutSize);
+        int c, iVar   = Lf_ManFindCofVar( pTruth, nWords, pCut->nLeaves );
+        assert( iVar >= 0 && iVar < (int)pCut->nLeaves );
+        for ( c = 0; c < 2; c++ )
+        {
+            for ( k = 0; k < (int)pCut->nLeaves; k++ )
+                pVarsNew[k] = k;
+            if ( c )
+                Abc_TtCofactor1p( pTruthCof, pTruth, nWords, iVar );
+            else
+                Abc_TtCofactor0p( pTruthCof, pTruth, nWords, iVar );
+            nVarsNew = Abc_TtMinBase( pTruthCof, pVarsNew, pCut->nLeaves, LutSize );
+            assert( nVarsNew > 0 );
+            // derive LUT
+            Vec_IntClear( vLeaves );
+            for ( k = 0; k < nVarsNew; k++ )
+                Vec_IntPush( vLeaves, Vec_IntEntry(vCopies, pCut->pLeaves[pVarsNew[k]]) );
+            iLitCofs[c] = Kit_TruthToGia( pNew, (unsigned *)pTruthCof, nVarsNew, vCover, vLeaves, 0 );
+            // create mapping
+            Vec_IntSetEntry( vMapping, Abc_Lit2Var(iLitCofs[c]), Vec_IntSize(vMapping2) );
+            Vec_IntPush( vMapping2, Vec_IntSize(vLeaves) );
+            Vec_IntForEachEntry( vLeaves, iTemp, k )
+                Vec_IntPush( vMapping2, Abc_Lit2Var(iTemp) );
+            Vec_IntPush( vMapping2, Abc_Lit2Var(iLitCofs[c]) );
+        }
+        // derive MUX
+        pTruthCof[0] = ABC_CONST(0xCACACACACACACACA);
+        Vec_IntClear( vLeaves );
+        Vec_IntPush( vLeaves, iLitCofs[0] );
+        Vec_IntPush( vLeaves, iLitCofs[1] );
+        Vec_IntPush( vLeaves, Vec_IntEntry(vCopies, pCut->pLeaves[iVar]) );
+        iLit = Kit_TruthToGia( pNew, (unsigned *)pTruthCof, Vec_IntSize(vLeaves), vCover, vLeaves, 0 );
+        // create mapping
+        Vec_IntSetEntry( vMapping, Abc_Lit2Var(iLit), Vec_IntSize(vMapping2) );
+        Vec_IntPush( vMapping2, Vec_IntSize(vLeaves) );
+        Vec_IntForEachEntry( vLeaves, iTemp, k )
+            Vec_IntPush( vMapping2, Abc_Lit2Var(iTemp) );
+        Vec_IntPush( vMapping2, -Abc_Lit2Var(iLit) );
+        return iLit;
+    }
+    Vec_IntClear( vLeaves );
+    if ( pCut->fMux7 )
+    {
+        assert( pCut->nLeaves == 3 );
+        Vec_IntPush( vLeaves, Abc_LitNotCond(Vec_IntEntry(vCopies, pCut->pLeaves[0]), Gia_ObjFaninC0(pObj)) );
+        Vec_IntPush( vLeaves, Abc_LitNotCond(Vec_IntEntry(vCopies, pCut->pLeaves[1]), Gia_ObjFaninC1(pObj)) );
+        Vec_IntPush( vLeaves, Abc_LitNotCond(Vec_IntEntry(vCopies, pCut->pLeaves[2]), Gia_ObjFaninC2(p->pGia,pObj)) );
+    }
+    else
+    {
+        for ( k = 0; k < (int)pCut->nLeaves; k++ )
+            Vec_IntPush( vLeaves, Vec_IntEntry(vCopies, pCut->pLeaves[k]) );
+    }
+    pTruth = Lf_CutTruth( p, pCut );
+    iLit = Kit_TruthToGia( pNew, (unsigned *)pTruth, Vec_IntSize(vLeaves), vCover, vLeaves, 0 );
+    // create mapping
+    Vec_IntSetEntry( vMapping, Abc_Lit2Var(iLit), Vec_IntSize(vMapping2) );
+    Vec_IntPush( vMapping2, Vec_IntSize(vLeaves) );
+    Vec_IntForEachEntry( vLeaves, iTemp, k )
+        Vec_IntPush( vMapping2, Abc_Lit2Var(iTemp) );
+    Vec_IntPush( vMapping2, pCut->fMux7 ? -Abc_Lit2Var(iLit) : Abc_Lit2Var(iLit) );
+    return iLit;
+}
+Gia_Man_t * Lf_ManDeriveMappingGia( Lf_Man_t * p )
+{
+    Gia_Man_t * pNew; 
+    Gia_Obj_t * pObj; 
+    Vec_Int_t * vCopies   = Vec_IntStartFull( Gia_ManObjNum(p->pGia) );
+    Vec_Int_t * vMapping  = Vec_IntStart( 2*Gia_ManObjNum(p->pGia) + (int)p->pPars->Edge + 2*(int)p->pPars->Area + 4*(int)p->pPars->Mux7 );
+    Vec_Int_t * vMapping2 = Vec_IntStart( (int)p->pPars->Edge + 2*(int)p->pPars->Area + 1000 );
+    Vec_Int_t * vCover    = Vec_IntAlloc( 1 << 16 );
+    Vec_Int_t * vLeaves   = Vec_IntAlloc( 16 );
+    Lf_Cut_t * pCut;
+    int i, iLit; 
+    assert( p->pPars->fCutMin );
+    // create new manager
+    pNew = Gia_ManStart( Gia_ManObjNum(p->pGia) );
+    pNew->pName = Abc_UtilStrsav( p->pGia->pName );
+    pNew->pSpec = Abc_UtilStrsav( p->pGia->pSpec );
+    Vec_IntWriteEntry( vCopies, 0, 0 );
+    Gia_ManForEachObj1( p->pGia, pObj, i )
+    {
+        if ( Gia_ObjIsCi(pObj) )
+        {
+            Vec_IntWriteEntry( vCopies, i, Gia_ManAppendCi(pNew) );
+            continue;
+        }
+        if ( Gia_ObjIsCo(pObj) )
+        {
+            iLit = Vec_IntEntry( vCopies, Gia_ObjFaninId0p(p->pGia, pObj) );
+            iLit = Gia_ManAppendCo( pNew, Abc_LitNotCond(iLit, Gia_ObjFaninC0(pObj)) );
+            continue;
+        }
+        if ( Gia_ObjIsBuf(pObj) )
+        {
+            iLit = Vec_IntEntry( vCopies, Gia_ObjFaninId0p(p->pGia, pObj) );
+            iLit = Gia_ManAppendBuf( pNew, Abc_LitNotCond(iLit, Gia_ObjFaninC0(pObj)) );
+            Vec_IntWriteEntry( vCopies, i, iLit );
+            continue;
+        }
+        if ( !Lf_ObjMapRefNum(p, i) )
+            continue;
+        pCut = Lf_ObjCutBest( p, i );
+        assert( pCut->iFunc >= 0 );
+        if ( pCut->nLeaves == 0 )
+        {
+            assert( Abc_Lit2Var(pCut->iFunc) == 0 );
+            Vec_IntWriteEntry( vCopies, i, pCut->iFunc );
+            continue;
+        }
+        if ( pCut->nLeaves == 1 )
+        {
+            assert( Abc_Lit2Var(pCut->iFunc) == 1 );
+            iLit = Vec_IntEntry( vCopies, pCut->pLeaves[0] );
+            Vec_IntWriteEntry( vCopies, i, Abc_LitNotCond(iLit, Abc_LitIsCompl(pCut->iFunc)) );
+            continue;
+        }
+        iLit = Lf_ManDerivePart( p, pNew, vMapping, vMapping2, vCopies, pCut, vLeaves, vCover, pObj );
+        Vec_IntWriteEntry( vCopies, i, Abc_LitNotCond(iLit, Abc_LitIsCompl(pCut->iFunc)) );
+    }
+    Vec_IntFree( vCopies );
+    Vec_IntFree( vCover );
+    Vec_IntFree( vLeaves );
+    // finish mapping 
+    if ( Vec_IntSize(vMapping) > Gia_ManObjNum(pNew) )
+        Vec_IntShrink( vMapping, Gia_ManObjNum(pNew) );
+    else
+        Vec_IntFillExtra( vMapping, Gia_ManObjNum(pNew), 0 );
+    assert( Vec_IntSize(vMapping) == Gia_ManObjNum(pNew) );
+    Vec_IntForEachEntry( vMapping, iLit, i )
+        if ( iLit > 0 )
+            Vec_IntAddToEntry( vMapping, i, Gia_ManObjNum(pNew) );
+    Vec_IntAppend( vMapping, vMapping2 );
+    Vec_IntFree( vMapping2 );
+    // attach mapping and packing
+    assert( pNew->vMapping == NULL );
+    pNew->vMapping = vMapping;
+    Gia_ManSetRegNum( pNew, Gia_ManRegNum(p->pGia) );
+    return pNew;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Lf_Man_t * Lf_ManAlloc( Gia_Man_t * pGia, Jf_Par_t * pPars )
+{
+    Lf_Man_t * p; int i, k = 0;
+    assert( pPars->nCutNum > 1  && pPars->nCutNum <= LF_CUT_MAX );
+    assert( pPars->nLutSize > 1 && pPars->nLutSize <= LF_LEAF_MAX );
+    ABC_FREE( pGia->pRefs );
+    Vec_IntFreeP( &pGia->vMapping );
+    Gia_ManCleanValue( pGia );
+    if ( Gia_ManHasChoices(pGia) )
+        Gia_ManSetPhase(pGia);
+    p = ABC_CALLOC( Lf_Man_t, 1 );
+    Lf_ManAnalyzeCoDrivers( pGia, &p->nCoDrivers, &p->nInverters );
+    if ( pPars->fPower )
+        Lf_ManComputeSwitching( pGia, &p->vSwitches );
+    p->clkStart  = Abc_Clock();
+    p->pGia      = pGia;
+    p->pPars     = pPars;
+    p->nCutWords = (sizeof(Lf_Cut_t)/sizeof(int) + pPars->nLutSize + 1) >> 1;
+    p->nSetWords = p->nCutWords * pPars->nCutNum;
+    p->vTtMem    = pPars->fCutMin ? Vec_MemAllocForTT( pPars->nLutSize, 0 ) : NULL;
+    if ( pPars->fCutMin && pPars->fUseMux7 )
+        Vec_MemAddMuxTT( p->vTtMem, pPars->nLutSize );
+    p->pObjBests = ABC_CALLOC( Lf_Bst_t, Gia_ManAndNotBufNum(pGia) );
+    Vec_IntGrow( &p->vFreeSets, (1<<14) );
+    Vec_PtrGrow( &p->vFreePages, 256 );
+    Lf_MemAlloc( &p->vStoreOld, 16, &p->vFreePages, p->nCutWords );
+    Lf_MemAlloc( &p->vStoreNew, 16, &p->vFreePages, p->nCutWords );
+    Vec_IntFill( &p->vOffsets,  Gia_ManObjNum(pGia), -1 );
+    Vec_IntFill( &p->vRequired, Gia_ManObjNum(pGia), ABC_INFINITY );
+    Vec_IntFill( &p->vCutSets,  Gia_ManAndNotBufNum(pGia), -1 );
+    Vec_FltFill( &p->vFlowRefs, Gia_ManAndNotBufNum(pGia), 0 );
+    Vec_IntFill( &p->vMapRefs,  Gia_ManAndNotBufNum(pGia), 0 );
+    Vec_IntFill( &p->vCiArrivals, Gia_ManCiNum(pGia), 0 );
+    Gia_ManForEachAndId( pGia, i )
+        if ( !Gia_ObjIsBuf(Gia_ManObj(pGia, i)) )
+            Vec_IntWriteEntry( &p->vOffsets, i, k++ );
+    assert( k == Gia_ManAndNotBufNum(pGia) );
+    Lf_ManSetFlowRefs( pGia, &p->vFlowRefs, &p->vOffsets );
+    if ( pPars->pTimesArr )
+        for ( i = 0; i < Gia_ManPiNum(pGia); i++ )
+            Vec_IntWriteEntry( &p->vCiArrivals, i, pPars->pTimesArr[i] );
+    return p;
+}
+void Lf_ManFree( Lf_Man_t * p )
+{
+    ABC_FREE( p->pPars->pTimesArr );
+    ABC_FREE( p->pPars->pTimesReq );
+    if ( p->pPars->fCutMin )
+        Vec_MemHashFree( p->vTtMem );
+    if ( p->pPars->fCutMin )
+        Vec_MemFree( p->vTtMem );
+    Vec_PtrFreeData( &p->vMemSets );
+    Vec_PtrFreeData( &p->vFreePages );
+    Vec_PtrFreeData( &p->vStoreOld.vPages );
+    Vec_PtrFreeData( &p->vStoreNew.vPages );
+    ABC_FREE( p->vMemSets.pArray );
+    ABC_FREE( p->vFreePages.pArray );
+    ABC_FREE( p->vStoreOld.vPages.pArray );
+    ABC_FREE( p->vStoreNew.vPages.pArray );
+    ABC_FREE( p->vFreePages.pArray );
+    ABC_FREE( p->vFreeSets.pArray );
+    ABC_FREE( p->vOffsets.pArray );
+    ABC_FREE( p->vRequired.pArray );
+    ABC_FREE( p->vCutSets.pArray );
+    ABC_FREE( p->vFlowRefs.pArray );
+    ABC_FREE( p->vMapRefs.pArray );
+    ABC_FREE( p->vSwitches.pArray );
+    ABC_FREE( p->vCiArrivals.pArray );
+    ABC_FREE( p->pObjBests );
+    ABC_FREE( p );
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Lf_ManSetDefaultPars( Jf_Par_t * pPars )
+{
+    memset( pPars, 0, sizeof(Jf_Par_t) );
+    pPars->nLutSize     =  6;
+    pPars->nCutNum      =  8;
+    pPars->nProcNum     =  0;
+    pPars->nRounds      =  4;
+    pPars->nRoundsEla   =  1;
+    pPars->nRelaxRatio  =  0;
+    pPars->nCoarseLimit =  3;
+    pPars->nAreaTuner   =  1;
+    pPars->nVerbLimit   =  5;
+    pPars->DelayTarget  = -1;
+    pPars->fAreaOnly    =  0;
+    pPars->fOptEdge     =  1; 
+    pPars->fUseMux7     =  0;
+    pPars->fPower       =  0;
+    pPars->fCoarsen     =  1;
+    pPars->fCutMin      =  0;
+    pPars->fFuncDsd     =  0;
+    pPars->fGenCnf      =  0;
+    pPars->fPureAig     =  0;
+    pPars->fCutHashing  =  0;
+    pPars->fCutSimple   =  0;
+    pPars->fVerbose     =  0;
+    pPars->fVeryVerbose =  0;
+    pPars->nLutSizeMax  =  LF_LEAF_MAX;
+    pPars->nCutNumMax   =  LF_CUT_MAX;
+}
+void Lf_ManPrintStats( Lf_Man_t * p, char * pTitle )
+{
+    if ( !p->pPars->fVerbose )
+        return;
+    printf( "%s :  ", pTitle );
+    printf( "Level =%6lu   ",   p->pPars->Delay );
+    printf( "Area =%9lu   ",    p->pPars->Area );
+    printf( "Edge =%9lu   ",    p->pPars->Edge );
+    printf( "LUT =%9lu  ",      p->pPars->Area+p->nInverters );
+    if ( Vec_FltSize(&p->vSwitches) )
+        printf( "Swt =%8.1f  ", p->Switches );
+    if ( p->pPars->fUseMux7 )
+        printf( "Mux7 =%7lu  ", p->pPars->Mux7 );
+    Abc_PrintTime( 1, "Time", Abc_Clock() - p->clkStart );
+    fflush( stdout );
+}
+void Lf_ManPrintInit( Lf_Man_t * p )
+{
+    if ( !p->pPars->fVerbose )
+        return;
+    printf( "LutSize = %d  ", p->pPars->nLutSize );
+    printf( "CutNum = %d  ",  p->pPars->nCutNum );
+    printf( "Iter = %d  ",    p->pPars->nRounds + p->pPars->nRoundsEla );
+    if ( p->pPars->nRelaxRatio )
+    printf( "Ratio = %d  ",   p->pPars->nRelaxRatio );
+    printf( "Edge = %d  ",    p->pPars->fOptEdge );
+    if ( p->pPars->DelayTarget != -1 )
+    printf( "Delay = %d  ",   p->pPars->DelayTarget );
+    printf( "CutMin = %d  ",  p->pPars->fCutMin );
+    printf( "Coarse = %d  ",  p->pPars->fCoarsen );
+    printf( "Cut/Set = %d/%d Bytes", 8*p->nCutWords, 8*p->nSetWords );
+    printf( "\n" );
+    printf( "Computing cuts...\r" );
+    fflush( stdout );
+}
+void Lf_ManPrintQuit( Lf_Man_t * p, Gia_Man_t * pNew )
+{
+    float MemGia   = Gia_ManMemory(p->pGia) / (1<<20);
+    float MemMan   = 1.0 * sizeof(int) * (2 * Gia_ManObjNum(p->pGia) + 3 * Gia_ManAndNotBufNum(p->pGia)) / (1<<20); // offset, required, cutsets, maprefs, flowrefs
+    float MemCutsB = 1.0 * (p->vStoreOld.MaskPage + 1) * (Vec_PtrSize(&p->vFreePages) + Vec_PtrSize(&p->vStoreOld.vPages)) / (1<<20) + 1.0 * sizeof(Lf_Bst_t) * Gia_ManAndNotBufNum(p->pGia) / (1<<20);
+    float MemCutsF = 1.0 * sizeof(word) * p->nSetWords * (1<<LF_LOG_PAGE) * Vec_PtrSize(&p->vMemSets) / (1<<20);
+    float MemTt    = p->vTtMem ? Vec_MemMemory(p->vTtMem) / (1<<20) : 0;
+    float MemMap   = Vec_IntMemory(pNew->vMapping) / (1<<20);
+    if ( p->CutCount[0] == 0 )
+        p->CutCount[0] = 1;
+    if ( !p->pPars->fVerbose )
+        return;
+    printf( "CutPair = %.0f  ",         p->CutCount[0] );
+    printf( "Merge = %.0f (%.2f %%)  ", p->CutCount[1], 100.0*p->CutCount[1]/p->CutCount[0] );
+    printf( "Eval = %.0f (%.2f %%)  ",  p->CutCount[2], 100.0*p->CutCount[2]/p->CutCount[0] );
+    printf( "Cut = %.0f (%.2f %%)  ",   p->CutCount[3], 100.0*p->CutCount[3]/p->CutCount[0] );
+    printf( "\n" );
+    printf( "Gia = %.2f MB  ",          MemGia );
+    printf( "Man = %.2f MB  ",          MemMan ); 
+    printf( "Best = %.2f MB  ",         MemCutsB );
+    printf( "Front = %.2f MB   ",       MemCutsF );
+    printf( "Map = %.2f MB  ",          MemMap ); 
+    printf( "TT = %.2f MB  ",           MemTt ); 
+    printf( "Total = %.2f MB",          MemGia + MemMan + MemCutsB + MemCutsF + MemMap + MemTt ); 
+    printf( "\n" );
+    if ( 1 )
+    {
+        int i;
+        for ( i = 0; i <= p->pPars->nLutSize; i++ )
+            printf( "%d:%d  ", i, p->nCutCounts[i] );
+        printf( "Equal = %d (%.0f %%) ", p->nCutEqual, 100.0 * p->nCutEqual / p->Iter / Gia_ManAndNotBufNum(p->pGia) );
+        if ( p->vTtMem )
+            printf( "TT = %d (%.2f %%)  ", Vec_MemEntryNum(p->vTtMem), 100.0 * Vec_MemEntryNum(p->vTtMem) / p->CutCount[2] );
+        if ( p->pGia->pMuxes && p->nCutMux )
+            printf( "MuxTT = %d (%.0f %%) ", p->nCutMux, 100.0 * p->nCutMux / p->Iter / Gia_ManMuxNum(p->pGia) );
+        printf( "\n" );
+    }
+    printf( "CoDrvs = %d (%.2f %%)  ",  p->nCoDrivers, 100.0*p->nCoDrivers/Gia_ManCoNum(p->pGia) );
+    printf( "CoInvs = %d (%.2f %%)  ",  p->nInverters, 100.0*p->nInverters/Gia_ManCoNum(p->pGia) );
+    printf( "Front = %d (%.2f %%)  ",   p->nFrontMax,  100.0*p->nFrontMax/Gia_ManAndNum(p->pGia) );
+    printf( "TimeFails = %d   ",        p->nTimeFails );
+    Abc_PrintTime( 1, "Time",    Abc_Clock() - p->clkStart );
+    fflush( stdout );
+}
+void Lf_ManComputeMapping( Lf_Man_t * p )
+{
+    Gia_Obj_t * pObj;
+    int i, arrTime;
+    assert( p->vStoreNew.iCur == 0 );
+    Lf_ManSetCutRefs( p );
+    if ( p->pGia->pManTime != NULL )
+    {
+        assert( !Gia_ManBufNum(p->pGia) );
+        Tim_ManIncrementTravId( p->pGia->pManTime );
+        Gia_ManForEachObj1( p->pGia, pObj, i )
+        {
+            if ( Gia_ObjIsBuf(pObj) )
+                continue;
+            if ( Gia_ObjIsAnd(pObj) )
+                Lf_ObjMergeOrder( p, i );
+            else if ( Gia_ObjIsCi(pObj) )
+            {
+                arrTime = Tim_ManGetCiArrival( p->pGia->pManTime, Gia_ObjCioId(pObj) );
+                Lf_ObjSetCiArrival( p, Gia_ObjCioId(pObj), arrTime );
+            }
+            else if ( Gia_ObjIsCo(pObj) )
+            {
+                arrTime = Lf_ObjCoArrival( p, Gia_ObjCioId(pObj) );
+                Tim_ManSetCoArrival( p->pGia->pManTime, Gia_ObjCioId(pObj), arrTime );
+            }
+            else assert( 0 );
+        }
+//        Tim_ManPrint( p->pGia->pManTime );
+    }
+    else
+    {
+        Gia_ManForEachAnd( p->pGia, pObj, i )
+            if ( !Gia_ObjIsBuf(pObj) )
+                Lf_ObjMergeOrder( p, i );
+    }
+    Lf_MemRecycle( &p->vStoreOld );
+    ABC_SWAP( Lf_Mem_t, p->vStoreOld, p->vStoreNew );
+    if ( p->fUseEla )
+        Lf_ManCountMapRefs( p );
+    else
+        Lf_ManSetMapRefs( p );
+    Lf_ManPrintStats( p, p->fUseEla ? "Ela  " : (p->Iter ? "Area " : "Delay") );
+}
+Gia_Man_t * Lf_ManPerformMappingInt( Gia_Man_t * pGia, Jf_Par_t * pPars )
+{
+    int fUsePowerMode = 0;
+    Lf_Man_t * p;
+    Gia_Man_t * pNew, * pCls;
+    if ( pPars->fUseMux7 )
+        pPars->fCoarsen = 1, pPars->nRoundsEla = 0;
+    if ( Gia_ManHasChoices(pGia) || pPars->nLutSizeMux )
+        pPars->fCutMin = 1; 
+    if ( pPars->fCoarsen )
+    {
+        pCls = Gia_ManDupMuxes(pGia, pPars->nCoarseLimit);
+        pCls->pManTime = pGia->pManTime; pGia->pManTime = NULL;
+    }
+    else pCls = pGia;
+    p = Lf_ManAlloc( pCls, pPars );
+    if ( pPars->fVerbose && pPars->fCoarsen )
+    {
+        printf( "Initial " );  Gia_ManPrintMuxStats( pGia );  printf( "\n" );
+        printf( "Derived " );  Gia_ManPrintMuxStats( pCls );  printf( "\n" );
+    }
+    Lf_ManPrintInit( p );
+
+    // power mode
+    if ( fUsePowerMode && Vec_FltSize(&p->vSwitches) )
+        pPars->fPower = 0;
+
+    // perform mapping
+    for ( p->Iter = 0; p->Iter < p->pPars->nRounds; p->Iter++ )
+        Lf_ManComputeMapping( p );
+    p->fUseEla = 1;
+    for ( ; p->Iter < p->pPars->nRounds + pPars->nRoundsEla; p->Iter++ )
+        Lf_ManComputeMapping( p );
+
+    // power mode
+    if ( fUsePowerMode && Vec_FltSize(&p->vSwitches) )
+    {
+        pPars->fPower = 1;
+        for ( ; p->Iter < p->pPars->nRounds + pPars->nRoundsEla + 2; p->Iter++ )
+            Lf_ManComputeMapping( p );
+    }
+
+    if ( pPars->fVeryVerbose && pPars->fCutMin )
+        Vec_MemDumpTruthTables( p->vTtMem, Gia_ManName(p->pGia), pPars->nLutSize );
+    if ( pPars->fCutMin )
+        pNew = Lf_ManDeriveMappingGia( p );
+    else if ( pPars->fCoarsen )
+        pNew = Lf_ManDeriveMappingCoarse( p );
+    else
+        pNew = Lf_ManDeriveMapping( p );
+    Gia_ManMappingVerify( pNew );
+    Lf_ManPrintQuit( p, pNew );
+    Lf_ManFree( p );
+    if ( pCls != pGia )
+    {
+        pGia->pManTime = pCls->pManTime; pCls->pManTime = NULL;
+        Gia_ManStop( pCls );
+    }
+    return pNew;
+}
+Gia_Man_t * Lf_ManPerformMapping( Gia_Man_t * p, Jf_Par_t * pPars )
+{
+    Gia_Man_t * pNew;
+    if ( p->pManTime && Tim_ManBoxNum(p->pManTime) && Gia_ManIsNormalized(p) )
+    {
+        Tim_Man_t * pTimOld = (Tim_Man_t *)p->pManTime;
+        p->pManTime = Tim_ManDup( pTimOld, 1 );
+        pNew = Gia_ManDupUnnormalize( p );
+        if ( pNew == NULL )
+            return NULL;
+        Gia_ManTransferTiming( pNew, p );
+        p = pNew;
+        // mapping
+        pNew = Lf_ManPerformMappingInt( p, pPars );
+        if ( pNew != p )
+        {
+            Gia_ManTransferTiming( pNew, p );
+            Gia_ManStop( p );
+        }
+        // normalize
+        pNew = Gia_ManDupNormalize( p = pNew );
+        Gia_ManTransferMapping( pNew, p );
+//        Gia_ManTransferPacking( pNew, p );
+        Gia_ManTransferTiming( pNew, p );
+        Gia_ManStop( p ); // do not delete if the original one!
+        // cleanup
+        Tim_ManStop( (Tim_Man_t *)pNew->pManTime );
+        pNew->pManTime = pTimOld;
+        assert( Gia_ManIsNormalized(pNew) );
+    }
+    else 
+    {
+        // mapping
+        pNew = Lf_ManPerformMappingInt( p, pPars );
+        Gia_ManTransferTiming( pNew, p );
+    }
+    return pNew;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Interface of LUT mapping package.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     [] 
+
+***********************************************************************/
+Gia_Man_t * Gia_ManPerformLfMapping( Gia_Man_t * p, Jf_Par_t * pPars, int fNormalized )
+{
+    Gia_Man_t * pNew;
+    // reconstruct GIA according to the hierarchy manager
+    assert( pPars->pTimesArr == NULL );
+    assert( pPars->pTimesReq == NULL );
+    if ( p->pManTime )
+    {
+        if ( fNormalized )
+        {
+            pNew = Gia_ManDupUnnormalize( p );
+            if ( pNew == NULL )
+                return NULL;
+            Gia_ManTransferTiming( pNew, p );
+            p = pNew;
+            // set arrival and required times
+            pPars->pTimesArr = Tim_ManGetArrTimes( (Tim_Man_t *)p->pManTime );
+            pPars->pTimesReq = Tim_ManGetReqTimes( (Tim_Man_t *)p->pManTime );
+        }
+        else
+            p = Gia_ManDup( p );
+    }
+    else 
+        p = Gia_ManDup( p );
+    // perform mapping
+    pNew = Lf_ManPerformMappingInt( p, pPars );
+    if ( pNew != p )
+    {
+        // transfer name
+        ABC_FREE( pNew->pName );
+        ABC_FREE( pNew->pSpec );
+        pNew->pName = Abc_UtilStrsav( p->pName );
+        pNew->pSpec = Abc_UtilStrsav( p->pSpec );
+        Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+        // return the original (unmodified by the mapper) timing manager
+        Gia_ManTransferTiming( pNew, p );
+        Gia_ManStop( p );
+    }
+    // normalize and transfer mapping
+    pNew = Gia_ManDupNormalize( p = pNew );
+    Gia_ManTransferMapping( pNew, p );
+//    Gia_ManTransferPacking( pNew, p );
+    Gia_ManTransferTiming( pNew, p );
+    Gia_ManStop( p );
+    return pNew;
 }
 
 ////////////////////////////////////////////////////////////////////////
diff --git a/abc-build/src/aig/gia/giaMan.c b/abc-build/src/aig/gia/giaMan.c
--- a/abc-build/src/aig/gia/giaMan.c
+++ b/abc-build/src/aig/gia/giaMan.c
@@ -97,13 +97,16 @@
     Vec_IntFreeP( &p->vUserPiIds );
     Vec_IntFreeP( &p->vUserPoIds );
     Vec_IntFreeP( &p->vUserFfIds );
-    Vec_IntFreeP( &p->vFlopClasses );
+    Vec_IntFreeP( &p->vFlopClasses );
     Vec_IntFreeP( &p->vGateClasses );
     Vec_IntFreeP( &p->vObjClasses );
     Vec_IntFreeP( &p->vInitClasses );
+    Vec_IntFreeP( &p->vRegClasses );
     Vec_IntFreeP( &p->vDoms );
+    Vec_IntFreeP( &p->vBarBufs );
     Vec_IntFreeP( &p->vLevels );
-    Vec_IntFreeP( &p->vTruths );
+    Vec_IntFreeP( &p->vTruths );
+    Vec_IntErase( &p->vCopies );
     Vec_IntFreeP( &p->vTtNums );
     Vec_IntFreeP( &p->vTtNodes );
     Vec_WrdFreeP( &p->vTtMemory );
@@ -157,6 +160,7 @@
     Memory += sizeof(int) * Gia_ManCiNum(p);
     Memory += sizeof(int) * Gia_ManCoNum(p);
     Memory += sizeof(int) * p->nHTable * (p->pHTable != NULL);
+    Memory += sizeof(int) * Gia_ManObjNum(p) * (p->pRefs != NULL);
     return Memory;
 }
 
@@ -400,11 +404,15 @@
     if ( p->pName )
         Abc_Print( 1, "%s%-8s%s : ", "\033[1;37m", p->pName, "\033[0m" );  // bright
 #endif
-    Abc_Print( 1, "i/o =%7d/%7d", Gia_ManPiNum(p), Gia_ManPoNum(p) );
+    Abc_Print( 1, "i/o =%7d/%7d", 
+        Gia_ManPiNum(p) - Gia_ManBoxCiNum(p) - Gia_ManRegBoxNum(p), 
+        Gia_ManPoNum(p) - Gia_ManBoxCoNum(p) - Gia_ManRegBoxNum(p) );
     if ( Gia_ManConstrNum(p) )
         Abc_Print( 1, "(c=%d)", Gia_ManConstrNum(p) );
     if ( Gia_ManRegNum(p) )
         Abc_Print( 1, "  ff =%7d", Gia_ManRegNum(p) );
+    if ( Gia_ManRegBoxNum(p) )
+        Abc_Print( 1, "  boxff =%d(%d)", Gia_ManRegBoxNum(p), Gia_ManClockDomainNum(p) );
 
 #ifdef WIN32
     {
@@ -428,7 +436,9 @@
     if ( Gia_ManHasChoices(p) )
         Abc_Print( 1, "  ch =%5d", Gia_ManChoiceNum(p) );
 	if ( p->pManTime )
-		Abc_Print( 1, "  box = %d", Tim_ManBoxNum((Tim_Man_t *)p->pManTime) );
+		Abc_Print( 1, "  box = %d", Gia_ManNonRegBoxNum(p) );
+    if ( Gia_ManBufNum(p) )
+		Abc_Print( 1, "  buf = %d", Gia_ManBufNum(p) );
     if ( pPars && pPars->fMuxXor )
         printf( "\nXOR/MUX " ), Gia_ManPrintMuxStats( p );
     if ( pPars && pPars->fSwitch )
@@ -460,12 +470,27 @@
         Gia_ManPrintPlacement( p );
 //    if ( p->pManTime )
 //        Tim_ManPrintStats( (Tim_Man_t *)p->pManTime, p->nAnd2Delay );
-    // print register classes
     Gia_ManPrintFlopClasses( p );
     Gia_ManPrintGateClasses( p );
     Gia_ManPrintObjClasses( p );
+//    if ( p->vRegClasses )
+//    {
+//        printf( "The design has %d flops with the following class info: ", Vec_IntSize(p->vRegClasses) );
+//        Vec_IntPrint( p->vRegClasses );
+//    }
     if ( p->vInitClasses )
-        Gia_ManPrintInitClasses( p->vInitClasses );
+        Gia_ManPrintInitClasses( p->vInitClasses );
+    // check integrity of boxes
+    Gia_ManCheckIntegrityWithBoxes( p );
+/*
+    if ( Gia_ManRegBoxNum(p) )
+    {
+        int i, Limit = Vec_IntFindMax(p->vRegClasses);
+        for ( i = 1; i <= Limit; i++ )
+            printf( "%d ", Vec_IntCountEntry(p->vRegClasses, i) );
+        printf( "\n" );
+    }
+*/
     if ( pPars && pPars->fTents )
     {
 /*
diff --git a/abc-build/src/aig/gia/giaMf.c b/abc-build/src/aig/gia/giaMf.c
--- a/abc-build/src/aig/gia/giaMf.c
+++ b/abc-build/src/aig/gia/giaMf.c
@@ -23,6 +23,7 @@
 #include "misc/util/utilTruth.h"
 #include "misc/extra/extra.h"
 #include "sat/cnf/cnf.h"
+#include "opt/dau/dau.h"
 
 ABC_NAMESPACE_IMPL_START
 
@@ -96,7 +97,6 @@
 #define Mf_ObjForEachCut( pCuts, i, nCuts )     for ( i = 0, i < nCuts; i++ )
 
 extern int Kit_TruthToGia( Gia_Man_t * pMan, unsigned * pTruth, int nVars, Vec_Int_t * vMemory, Vec_Int_t * vLeaves, int fHash );
-extern void Dau_DsdPrintFromTruth( word * pTruth, int nVarsInit );
 
 ////////////////////////////////////////////////////////////////////////
 ///                     FUNCTION DEFINITIONS                         ///
@@ -1643,11 +1643,11 @@
 //    Cnf_DataPrint( (Cnf_Dat_t *)pGia->pData, 1 );
     return pGia->pData;
 }
-void Mf_ManDumpCnf( Gia_Man_t * p, char * pFileName, int nLutSize, int fVerbose )
+void Mf_ManDumpCnf( Gia_Man_t * p, char * pFileName, int nLutSize, int fCnfObjIds, int fAddOrCla, int fVerbose )
 {
     abctime clk = Abc_Clock();
     Cnf_Dat_t * pCnf;
-    pCnf = Mf_ManGenerateCnf( p, nLutSize, 0, 1, fVerbose );
+    pCnf = Mf_ManGenerateCnf( p, nLutSize, fCnfObjIds, fAddOrCla, fVerbose );
     Cnf_DataWriteIntoFile( pCnf, pFileName, 0, NULL, NULL );
 //    if ( fVerbose )
     {
diff --git a/abc-build/src/aig/gia/giaMfs.c b/abc-build/src/aig/gia/giaMfs.c
--- a/abc-build/src/aig/gia/giaMfs.c
+++ b/abc-build/src/aig/gia/giaMfs.c
@@ -19,22 +19,15 @@
 ***********************************************************************/
 
 #include "gia.h"
-#include "bool/kit/kit.h"
 #include "opt/sfm/sfm.h"
 #include "misc/tim/tim.h"
 
 ABC_NAMESPACE_IMPL_START
 
-
 ////////////////////////////////////////////////////////////////////////
 ///                        DECLARATIONS                              ///
 ////////////////////////////////////////////////////////////////////////
-
-static word s_ElemVar  = ABC_CONST(0xAAAAAAAAAAAAAAAA);
-static word s_ElemVar2 = ABC_CONST(0xCCCCCCCCCCCCCCCC);
 
-extern int Kit_TruthToGia( Gia_Man_t * pMan, unsigned * pTruth, int nVars, Vec_Int_t * vMemory, Vec_Int_t * vLeaves, int fHash );
-
 ////////////////////////////////////////////////////////////////////////
 ///                     FUNCTION DEFINITIONS                         ///
 ////////////////////////////////////////////////////////////////////////
@@ -50,204 +43,149 @@
   SeeAlso     []
 
 ***********************************************************************/
-void Gia_ManExtractMfs_rec( Gia_Man_t * p, int iObj, Vec_Int_t * vId2Mfs, Vec_Wec_t * vFanins, Vec_Str_t * vFixed, Vec_Wrd_t * vTruths, Vec_Wrd_t * vTruthsTemp )
-{
-    Vec_Int_t * vArray;
-    int i, Fanin;
-    Gia_Obj_t * pObj = Gia_ManObj( p, iObj );
-    assert( Gia_ObjIsLut(p, iObj) );
-    if ( !~pObj->Value )
-        return;
-    Gia_LutForEachFanin( p, iObj, Fanin, i )
-        Gia_ManExtractMfs_rec( p, Fanin, vId2Mfs, vFanins, vFixed, vTruths, vTruthsTemp );
-    pObj->Value = Vec_WecSize(vFanins);
-    vArray = Vec_WecPushLevel( vFanins );
-    Vec_IntGrow( vArray, Gia_ObjLutSize(p, iObj) );
-    Gia_LutForEachFanin( p, iObj, Fanin, i )
-        Vec_IntPush( vArray, Gia_ManObj(p, Fanin)->Value );
-    Vec_StrPush( vFixed, (char)0 );
-    Vec_WrdPush( vTruths, Gia_ObjComputeTruthTable6Lut(p, iObj, vTruthsTemp) );
-    Vec_IntWriteEntry( vId2Mfs, iObj, pObj->Value );
-}
-void Gia_ManExtractMfs_rec2( Gia_Man_t * p, int iObj, Vec_Int_t * vId2Mfs, Vec_Wec_t * vFanins, Vec_Str_t * vFixed, Vec_Wrd_t * vTruths )
+Sfm_Ntk_t * Gia_ManExtractMfs( Gia_Man_t * p )
 {
+    word uTruth, uTruths6[6] = {
+        ABC_CONST(0xAAAAAAAAAAAAAAAA),
+        ABC_CONST(0xCCCCCCCCCCCCCCCC),
+        ABC_CONST(0xF0F0F0F0F0F0F0F0),
+        ABC_CONST(0xFF00FF00FF00FF00),
+        ABC_CONST(0xFFFF0000FFFF0000),
+        ABC_CONST(0xFFFFFFFF00000000)
+    };
+    Gia_Obj_t * pObj, * pObjExtra;
+    Vec_Wec_t * vFanins; // mfs data
+    Vec_Str_t * vFixed;  // mfs data 
+    Vec_Str_t * vEmpty;  // mfs data
+    Vec_Wrd_t * vTruths; // mfs data
     Vec_Int_t * vArray;
-    Gia_Obj_t * pObj = Gia_ManObj( p, iObj );
-    if ( Gia_ObjIsTravIdCurrent(p, pObj) )
-        return;
-    Gia_ObjSetTravIdCurrent(p, pObj);
-    assert( Gia_ObjIsAnd(pObj) );
-    Gia_ManExtractMfs_rec2( p, Gia_ObjFaninId0(pObj, iObj), vId2Mfs, vFanins, vFixed, vTruths );
-    Gia_ManExtractMfs_rec2( p, Gia_ObjFaninId1(pObj, iObj), vId2Mfs, vFanins, vFixed, vTruths );
-    pObj->Value = Vec_WecSize(vFanins);
-    vArray = Vec_WecPushLevel( vFanins );
-    Vec_IntGrow( vArray, 2 );
-    Vec_IntPush( vArray, Gia_ObjFanin0(pObj)->Value );
-    Vec_IntPush( vArray, Gia_ObjFanin1(pObj)->Value );
-    Vec_StrPush( vFixed, (char)1 );
-    Vec_WrdPush( vTruths, (Gia_ObjFaninC0(pObj) ? ~s_ElemVar : s_ElemVar) & (Gia_ObjFaninC1(pObj) ? ~s_ElemVar2 : s_ElemVar2) );
-    Vec_IntWriteEntry( vId2Mfs, iObj, pObj->Value );
-}
-Sfm_Ntk_t * Gia_ManExtractMfs( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t ** pvId2Mfs )
-{
+    Vec_Int_t * vLeaves;
     Tim_Man_t * pManTime = (Tim_Man_t *)p->pManTime;
-    Vec_Int_t * vPoNodes;
-    Vec_Int_t * vId2Mfs;
-    Vec_Wec_t * vFanins;
-    Vec_Str_t * vFixed;
-    Vec_Wrd_t * vTruths, * vTruthsTemp;
-    Vec_Int_t * vArray;
-    Gia_Obj_t * pObj, * pObjBox;
-    int i, k, nRealPis, nRealPos, nPiNum, nPoNum, curCi, curCo;
-    assert( pManTime == NULL || Tim_ManCiNum(pManTime) == Gia_ManCiNum(p) );
-    assert( pManTime == NULL || Tim_ManCoNum(pManTime) == Gia_ManCoNum(p) );
-    // get the real number of PIs and POs
-    nRealPis = pManTime ? Tim_ManPiNum(pManTime) : Gia_ManCiNum(p);
-    nRealPos = pManTime ? Tim_ManPoNum(pManTime) : Gia_ManCoNum(p);
-    // create mapping from GIA into MFS
-    vId2Mfs  = Vec_IntStartFull( Gia_ManObjNum(p) );
-    // collect PO nodes
-    vPoNodes = Vec_IntAlloc( 1000 );
-    // create the arrays
-    vFanins  = Vec_WecAlloc( 1000 );
-    vFixed   = Vec_StrAlloc( 1000 );
-    vTruths  = Vec_WrdAlloc( 1000 );
-    vTruthsTemp = Vec_WrdStart( Gia_ManObjNum(p) );
-    // assign MFS ids to primary inputs
-    Gia_ManFillValue( p );
-    for ( i = 0; i < nRealPis; i++ )
-    {
-        pObj = Gia_ManPi( p, i );
-        pObj->Value = Vec_WecSize(vFanins);
-        Vec_WecPushLevel( vFanins );
-        Vec_StrPush( vFixed, (char)0 );
-        Vec_WrdPush( vTruths, (word)0 );
-        Vec_IntWriteEntry( vId2Mfs, Gia_ObjId(p, pObj), pObj->Value );
-    }
-    // assign MFS ids to black box outputs
-    curCi = nRealPis;
-    curCo = 0;
-    if ( pManTime )
-    for ( i = 0; i < Tim_ManBoxNum(pManTime); i++ )
+    int nBoxes   = Gia_ManBoxNum(p);
+    int nRealPis = nBoxes ? Tim_ManPiNum(pManTime) : Gia_ManPiNum(p);
+    int nRealPos = nBoxes ? Tim_ManPoNum(pManTime) : Gia_ManPoNum(p);
+    int i, j, k, curCi, curCo, nBoxIns, nBoxOuts;
+    int Id, iFan, nMfsVars, Counter = 0;
+    assert( !p->pAigExtra || Gia_ManPiNum(p->pAigExtra) <= 6 );
+    // prepare storage
+    nMfsVars = Gia_ManCiNum(p) + 1 + Gia_ManLutNum(p) + Gia_ManCoNum(p);
+    vFanins  = Vec_WecStart( nMfsVars );
+    vFixed   = Vec_StrStart( nMfsVars );
+    vEmpty   = Vec_StrStart( nMfsVars );
+    vTruths  = Vec_WrdStart( nMfsVars );
+    // set internal PIs
+    Gia_ManCleanCopyArray( p );
+    Gia_ManForEachCiId( p, Id, i )
+        Gia_ObjSetCopyArray( p, Id, Counter++ );
+    // set constant node
+    Vec_StrWriteEntry( vFixed, Counter, (char)1 );
+    Vec_WrdWriteEntry( vTruths, Counter, (word)0 );
+    Gia_ObjSetCopyArray( p, 0, Counter++ );
+    // set internal LUTs
+    vLeaves = Vec_IntAlloc( 6 );
+    Gia_ObjComputeTruthTableStart( p, 6 );
+    Gia_ManForEachLut( p, Id )
     {
-        if ( !Tim_ManBoxIsBlack(pManTime, i) )
+        Vec_IntClear( vLeaves );
+        vArray = Vec_WecEntry( vFanins, Counter );
+        Vec_IntGrow( vArray, Gia_ObjLutSize(p, Id) );
+        Gia_LutForEachFanin( p, Id, iFan, k )
         {
-            // collect POs
-            for ( k = 0; k < Tim_ManBoxInputNum(pManTime, i); k++ )
-            {
-                pObj = Gia_ManPo( p, curCo + k );
-                Vec_IntPush( vPoNodes, Gia_ObjId(p, pObj) );
-            }
-            // assign values to the PIs
-            for ( k = 0; k < Tim_ManBoxOutputNum(pManTime, i); k++ )
-            {
-                pObj = Gia_ManPi( p, curCi + k );
-                pObj->Value = Vec_WecSize(vFanins);
-                Vec_WecPushLevel( vFanins );
-                Vec_StrPush( vFixed, (char)1 );
-                Vec_WrdPush( vTruths, (word)0 );
-                Vec_IntWriteEntry( vId2Mfs, Gia_ObjId(p, pObj), pObj->Value );
-            }
+            assert( Gia_ObjCopyArray(p, iFan) >= 0 );
+            Vec_IntPush( vArray, Gia_ObjCopyArray(p, iFan) );
+            Vec_IntPush( vLeaves, iFan );
         }
-        curCo += Tim_ManBoxInputNum(pManTime, i);
-        curCi += Tim_ManBoxOutputNum(pManTime, i);
-    }
-    // collect POs
-//    for ( i = Tim_ManCoNum(pManTime) - Tim_ManPoNum(pManTime); i < Tim_ManCoNum(pManTime); i++ )
-    for ( i = Gia_ManCoNum(p) - nRealPos; i < Gia_ManCoNum(p); i++ )
-    {
-        pObj = Gia_ManPo( p, i );
-        Vec_IntPush( vPoNodes, Gia_ObjId(p, pObj) );
+        assert( Vec_IntSize(vLeaves) <= 6 );
+        assert( Vec_IntSize(vLeaves) == Gia_ObjLutSize(p, Id) );
+        uTruth = *Gia_ObjComputeTruthTableCut( p, Gia_ManObj(p, Id), vLeaves );
+        Vec_WrdWriteEntry( vTruths, Counter, uTruth );
+        Gia_ObjSetCopyArray( p, Id, Counter++ );
     }
-    curCo += nRealPos;
-    // verify counts
-    assert( curCi == Gia_ManPiNum(p) );
-    assert( curCo == Gia_ManPoNum(p) );
-    // remeber the end of PIs
-    nPiNum = Vec_WecSize(vFanins);
-    nPoNum = Vec_IntSize(vPoNodes);
-    // assign value to constant node
-    pObj = Gia_ManConst0(p);
-    Vec_IntWriteEntry( vId2Mfs, Gia_ObjId(p, pObj), Vec_WecSize(vFanins) );
-    pObj->Value = Vec_WecSize(vFanins);
-    Vec_WecPushLevel( vFanins );
-    Vec_StrPush( vFixed, (char)0 );
-    Vec_WrdPush( vTruths, (word)0 );
-    Vec_IntWriteEntry( vId2Mfs, Gia_ObjId(p, pObj), pObj->Value );
-    // create internal nodes
-    curCi = nRealPis;
-    curCo = 0;
-    if ( pManTime )
-    for ( i = 0; i < Tim_ManBoxNum(pManTime); i++ )
+    Gia_ObjComputeTruthTableStop( p );
+    // set all POs
+    Gia_ManForEachCo( p, pObj, i )
     {
-        // recursively add for box inputs
-        Gia_ManIncrementTravId( pBoxes );
-        for ( k = 0; k < Tim_ManBoxInputNum(pManTime, i); k++ )
+        iFan = Gia_ObjFaninId0p( p, pObj );
+        assert( Gia_ObjCopyArray(p, iFan) >= 0 );
+        vArray = Vec_WecEntry( vFanins, Counter );
+        Vec_IntFill( vArray, 1, Gia_ObjCopyArray(p, iFan) );
+        if ( i < Gia_ManCoNum(p) - nRealPos ) // internal PO
         {
-            // build logic
-            pObj = Gia_ManPo( p, curCo + k );
-            Gia_ManExtractMfs_rec( p, Gia_ObjFaninId0p(p, pObj), vId2Mfs, vFanins, vFixed, vTruths, vTruthsTemp );
-            // add buffer/inverter
-            pObj->Value = Vec_WecSize(vFanins);
-            vArray = Vec_WecPushLevel( vFanins );
-            Vec_IntGrow( vArray, 1 );
-            assert( !~Gia_ObjFanin0(pObj)->Value );
-            Vec_IntPush( vArray, Gia_ObjFanin0(pObj)->Value );
-            Vec_StrPush( vFixed, (char)0 );
-            Vec_WrdPush( vTruths, Gia_ObjFaninC0(pObj) ? ~s_ElemVar : s_ElemVar );
-            Vec_IntWriteEntry( vId2Mfs, Gia_ObjId(p, pObj), pObj->Value );
-            // transfer to the PI
-            pObjBox = Gia_ManPi( pBoxes, k );
-            pObjBox->Value = pObj->Value;
-            Gia_ObjSetTravIdCurrent( pBoxes, pObjBox );
+            Vec_StrWriteEntry( vFixed, Counter, (char)1 );
+            Vec_StrWriteEntry( vEmpty, Counter, (char)1 );
+            uTruth = Gia_ObjFaninC0(pObj) ? ~uTruths6[0]: uTruths6[0];
+            Vec_WrdWriteEntry( vTruths, Counter, uTruth );
         }
-        if ( !Tim_ManBoxIsBlack(pManTime, i) )
+        Gia_ObjSetCopyArray( p, Gia_ObjId(p, pObj), Counter++ );
+    }
+    assert( Counter == nMfsVars );
+    // add functions of the boxes
+    if ( p->pAigExtra )
+    {
+        Gia_ObjComputeTruthTableStart( p->pAigExtra, 6 );
+        curCi = nRealPis;
+        curCo = 0;
+        for ( k = 0; k < nBoxes; k++ )
         {
-            pObjBox = Gia_ManConst0(pBoxes);
-            pObjBox->Value = Vec_WecSize(vFanins);
-            Vec_WecPushLevel( vFanins );
-            Vec_StrPush( vFixed, (char)0 );
-            Vec_WrdPush( vTruths, (word)0 );
-            Gia_ObjSetTravIdCurrent( pBoxes, pObjBox );
-            // add internal nodes and transfer
-            for ( k = 0; k < Tim_ManBoxOutputNum(pManTime, i); k++ )
+            assert( !Tim_ManBoxIsBlack(pManTime, k) );
+            nBoxIns = Tim_ManBoxInputNum( pManTime, k );
+            nBoxOuts = Tim_ManBoxOutputNum( pManTime, k );
+            // collect truth table leaves
+            Vec_IntClear( vLeaves );
+            for ( i = 0; i < nBoxIns; i++ )
+                Vec_IntPush( vLeaves, Gia_ObjId(p->pAigExtra, Gia_ManCi(p->pAigExtra, i)) );
+            // iterate through box outputs
+            //printf( "Box %d:\n", k );
+            for ( j = 0; j < nBoxOuts; j++ )
             {
-                // build logic
-                pObjBox = Gia_ManPo( pBoxes, curCi - Tim_ManPiNum(pManTime) + k );
-                Gia_ManExtractMfs_rec2( pBoxes, Gia_ObjFaninId0p(pBoxes, pObjBox), vId2Mfs, vFanins, vFixed, vTruths );
-                // add buffer/inverter
-                vArray = Vec_WecPushLevel( vFanins );
-                Vec_IntGrow( vArray, 1 );
-                assert( !~Gia_ObjFanin0(pObjBox)->Value );
-                Vec_IntPush( vArray, Gia_ObjFanin0(pObjBox)->Value );
-                Vec_StrPush( vFixed, (char)1 );
-                Vec_WrdPush( vTruths, Gia_ObjFaninC0(pObjBox) ? ~s_ElemVar : s_ElemVar );
-                // transfer to the PI
-                pObj = Gia_ManPi( p, curCi + k );
-                pObj->Value = pObjBox->Value;
+                // CI corresponding to the box outputs
+                pObj = Gia_ManCi( p, curCi + j );
+                Counter = Gia_ObjCopyArray( p, Gia_ObjId(p, pObj) );
+                // box output in the extra manager
+                pObjExtra = Gia_ManCo( p->pAigExtra, curCi - nRealPis + j );
+                // compute truth table
+                if ( Gia_ObjFaninId0p(p->pAigExtra, pObjExtra) == 0 )
+                    uTruth = 0;
+                else if ( Gia_ObjIsCi(Gia_ObjFanin0(pObjExtra)) )
+                    uTruth = uTruths6[Gia_ObjCioId(Gia_ObjFanin0(pObjExtra))];
+                else
+                    uTruth = *Gia_ObjComputeTruthTableCut( p->pAigExtra, Gia_ObjFanin0(pObjExtra), vLeaves );
+                uTruth = Gia_ObjFaninC0(pObjExtra) ? ~uTruth : uTruth;
+                Vec_WrdWriteEntry( vTruths, Counter, uTruth );
+                //Dau_DsdPrintFromTruth( &uTruth, Vec_IntSize(vLeaves) );
+                // add box inputs (POs of the AIG) as fanins
+                vArray = Vec_WecEntry( vFanins, Counter );
+                Vec_IntGrow( vArray, nBoxIns );
+                for ( i = 0; i < nBoxIns; i++ )
+                {
+                    iFan = Gia_ObjId( p, Gia_ManCo(p, curCo + i) );
+                    assert( Gia_ObjCopyArray(p, iFan) >= 0 );
+                    Vec_IntPush( vArray, Gia_ObjCopyArray(p, iFan) );
+                }
+                Vec_StrWriteEntry( vFixed, Counter, (char)1 );
             }
+            // set internal POs pointing directly to internal PIs as no-delay
+            for ( i = 0; i < nBoxIns; i++ )
+            {
+                pObj = Gia_ManCo( p, curCo + i );
+                if ( !Gia_ObjIsCi( Gia_ObjFanin0(pObj) ) )
+                    continue;
+                Counter = Gia_ObjCopyArray( p, Gia_ObjFaninId0p(p, pObj) );
+                Vec_StrWriteEntry( vEmpty, Counter, (char)1 );
+            }
+            curCo += nBoxIns;
+            curCi += nBoxOuts;
         }
-        curCo += Tim_ManBoxInputNum(pManTime, i);
-        curCi += Tim_ManBoxOutputNum(pManTime, i);
-    }
-    // create POs with buffers
-    Gia_ManForEachObjVec( vPoNodes, p, pObj, i )
-    {
-        Gia_ManExtractMfs_rec( p, Gia_ObjFaninId0p(p, pObj), vId2Mfs, vFanins, vFixed, vTruths, vTruthsTemp );
-        pObj->Value = Vec_WecSize(vFanins);
-        // add buffer/inverter
-        vArray = Vec_WecPushLevel( vFanins );
-        Vec_IntGrow( vArray, 1 );
-        assert( !~Gia_ObjFanin0(pObj)->Value );
-        Vec_IntPush( vArray, Gia_ObjFanin0(pObj)->Value );
-        Vec_StrPush( vFixed, (char)0 );
-        Vec_WrdPush( vTruths, Gia_ObjFaninC0(pObj) ? ~s_ElemVar : s_ElemVar );
-        Vec_IntWriteEntry( vId2Mfs, Gia_ObjId(p, pObj), pObj->Value );
+        curCo += nRealPos;
+        Gia_ObjComputeTruthTableStop( p->pAigExtra );
+        // verify counts
+        assert( curCi == Gia_ManCiNum(p) );
+        assert( curCo == Gia_ManCoNum(p) );
+        assert( curCi - nRealPis == Gia_ManCoNum(p->pAigExtra) );
     }
-    Vec_IntFree( vPoNodes );
-    Vec_WrdFree( vTruthsTemp );
-    *pvId2Mfs = vId2Mfs;
-    return Sfm_NtkConstruct( vFanins, nPiNum, nPoNum, vFixed, NULL, vTruths );
+    // finalize 
+    Vec_IntFree( vLeaves );
+    return Sfm_NtkConstruct( vFanins, nRealPis, nRealPos, vFixed, vEmpty, vTruths );
 }
 
 /**Function*************************************************************
@@ -261,72 +199,165 @@
   SeeAlso     []
 
 ***********************************************************************/
-Gia_Man_t * Gia_ManInsertMfs( Gia_Man_t * p, Sfm_Ntk_t * pNtk, Vec_Int_t * vId2Mfs )
+Gia_Man_t * Gia_ManInsertMfs( Gia_Man_t * p, Sfm_Ntk_t * pNtk )
 {
-    Gia_Man_t * pNew;
-    Gia_Obj_t * pObj;
-    Vec_Int_t * vMfsTopo, * vMfs2New, * vArray, * vCover;
-    int i, k, Fanin, iMfsId, iLitNew;
-    word * pTruth;
-    // collect MFS nodes in the topo order
-    vMfsTopo = Sfm_NtkDfs( pNtk );
-    // create mapping from MFS to new GIA literals
-    vMfs2New = Vec_IntStartFull( Vec_IntCap(vMfsTopo) );
+    extern int Gia_ManFromIfLogicCreateLut( Gia_Man_t * pNew, word * pRes, Vec_Int_t * vLeaves, Vec_Int_t * vCover, Vec_Int_t * vMapping, Vec_Int_t * vMapping2 );
+    Gia_Man_t * pNew;  Gia_Obj_t * pObj;
+    Tim_Man_t * pManTime = (Tim_Man_t *)p->pManTime;
+    int nBoxes   = Gia_ManBoxNum(p);
+    int nRealPis = nBoxes ? Tim_ManPiNum(pManTime) : Gia_ManPiNum(p);
+    int nRealPos = nBoxes ? Tim_ManPoNum(pManTime) : Gia_ManPoNum(p);
+    int i, k, Id, curCi, curCo, nBoxIns, nBoxOuts, iLitNew, iMfsId, iGroup, Fanin;
+    int nMfsNodes = 1 + Gia_ManCiNum(p) + Gia_ManLutNum(p) + Gia_ManCoNum(p);
+    word * pTruth, uTruthVar = ABC_CONST(0xAAAAAAAAAAAAAAAA);
+    Vec_Wec_t * vGroups = Vec_WecStart( nBoxes );
+    Vec_Int_t * vMfs2Gia = Vec_IntStartFull( nMfsNodes );
+    Vec_Int_t * vGroupMap = Vec_IntStartFull( nMfsNodes );
+    Vec_Int_t * vMfsTopo, * vCover, * vBoxesLeft;
+    Vec_Int_t * vArray, * vLeaves;
+    Vec_Int_t * vMapping, * vMapping2;
+    // collect nodes
+    curCi = nRealPis;
+    curCo = 0;
+    for ( i = 0; i < nBoxes; i++ )
+    {
+        nBoxIns = Tim_ManBoxInputNum( pManTime, i );
+        nBoxOuts = Tim_ManBoxOutputNum( pManTime, i );
+        vArray = Vec_WecEntry( vGroups, i );
+        for ( k = 0; k < nBoxIns; k++ )
+        {
+            pObj = Gia_ManCo( p, curCo + k );
+            iMfsId = Gia_ObjCopyArray( p, Gia_ObjId(p, pObj) );
+            assert( iMfsId > 0 );
+            Vec_IntPush( vArray, iMfsId );
+            Vec_IntWriteEntry( vGroupMap, iMfsId, Abc_Var2Lit(i,0) );
+        }
+        for ( k = 0; k < nBoxOuts; k++ )
+        {
+            pObj = Gia_ManCi( p, curCi + k );
+            iMfsId = Gia_ObjCopyArray( p, Gia_ObjId(p, pObj) );
+            assert( iMfsId > 0 );
+            Vec_IntPush( vArray, iMfsId );
+            Vec_IntWriteEntry( vGroupMap, iMfsId, Abc_Var2Lit(i,1) );
+        }
+        curCo += nBoxIns;
+        curCi += nBoxOuts;
+    }
+    curCo += nRealPos;
+    assert( curCi == Gia_ManCiNum(p) );
+    assert( curCo == Gia_ManCoNum(p) );
+
+    // collect nodes in the given order
+    vBoxesLeft = Vec_IntAlloc( nBoxes );
+    vMfsTopo = Sfm_NtkDfs( pNtk, vGroups, vGroupMap, vBoxesLeft );
+    assert( Vec_IntSize(vBoxesLeft) <= nBoxes );
+    assert( Vec_IntSize(vMfsTopo) > 0 );
+
     // start new GIA
     pNew = Gia_ManStart( Gia_ManObjNum(p) );
     pNew->pName = Abc_UtilStrsav( p->pName );
     pNew->pSpec = Abc_UtilStrsav( p->pSpec );
+
+    // start mapping
+    vMapping  = Vec_IntStart( Gia_ManObjNum(p) );
+    vMapping2 = Vec_IntStart( 1 );
+    // create const LUT
+    Vec_IntWriteEntry( vMapping, 0, Vec_IntSize(vMapping2) );
+    Vec_IntPush( vMapping2, 0 );
+    Vec_IntPush( vMapping2, 0 );
+
+    // map constant
+    Vec_IntWriteEntry( vMfs2Gia, Gia_ObjCopyArray(p, 0), 0 );
     // map primary inputs
-    Gia_ManForEachCi( p, pObj, i )
-    {
-        iMfsId = Vec_IntEntry( vId2Mfs, Gia_ObjId(p, pObj) );
-        assert( iMfsId >= 0 );
-        Vec_IntWriteEntry( vMfs2New, iMfsId, Gia_ManAppendCi(pNew) );
-    }
+    Gia_ManForEachCiId( p, Id, i )
+        if ( i < nRealPis )
+            Vec_IntWriteEntry( vMfs2Gia, Gia_ObjCopyArray(p, Id), Gia_ManAppendCi(pNew) );
     // map internal nodes
+    vLeaves = Vec_IntAlloc( 6 );
     vCover = Vec_IntAlloc( 1 << 16 );
     Vec_IntForEachEntry( vMfsTopo, iMfsId, i )
     {
-        assert( Sfm_NodeReadUsed(pNtk, iMfsId) );
         pTruth = Sfm_NodeReadTruth( pNtk, iMfsId );
-        if ( pTruth[0] == 0 || ~pTruth[0] == 0 )
-        {
-            Vec_IntWriteEntry( vMfs2New, iMfsId, 0 );
-            continue;
-        }
+        iGroup = Vec_IntEntry( vGroupMap, iMfsId );
         vArray = Sfm_NodeReadFanins( pNtk, iMfsId ); // belongs to pNtk
+        Vec_IntClear( vLeaves );
         Vec_IntForEachEntry( vArray, Fanin, k )
         {
-            iLitNew = Vec_IntEntry( vMfs2New, Fanin );
-            assert( iLitNew >= 0 );
-            Vec_IntWriteEntry( vArray, k, iLitNew );            
+            iLitNew = Vec_IntEntry( vMfs2Gia, Fanin );  assert( iLitNew >= 0 );
+            Vec_IntPush( vLeaves, iLitNew );            
         }
-        // derive new function
-        iLitNew = Kit_TruthToGia( pNew, (unsigned *)pTruth, Vec_IntSize(vArray), vCover, vArray, 0 );
-        Vec_IntWriteEntry( vMfs2New, iMfsId, iLitNew );
+        if ( iGroup == -1 ) // internal node
+        {
+            assert( Sfm_NodeReadUsed(pNtk, iMfsId) );
+            iLitNew = Gia_ManFromIfLogicCreateLut( pNew, pTruth, vLeaves, vCover, vMapping, vMapping2 );
+        }
+        else if ( Abc_LitIsCompl(iGroup) ) // internal CI
+        {
+            //Dau_DsdPrintFromTruth( pTruth, Vec_IntSize(vLeaves) );
+            iLitNew = Gia_ManAppendCi( pNew );
+        }
+        else // internal CO
+        {
+            iLitNew = Gia_ManAppendCo( pNew, Abc_LitNotCond(Vec_IntEntry(vLeaves, 0), pTruth[0] == ~uTruthVar) );
+            //printf("Group = %d. po = %d\n", iGroup>>1, iMfsId );
+        }
+        Vec_IntWriteEntry( vMfs2Gia, iMfsId, iLitNew );
     }
     Vec_IntFree( vCover );
-    // map output nodes
+    Vec_IntFree( vLeaves );
+
+    // map primary outputs
     Gia_ManForEachCo( p, pObj, i )
     {
-        iMfsId = Vec_IntEntry( vId2Mfs, Gia_ObjId(p, pObj) );
-        assert( iMfsId >= 0 );
-        vArray = Sfm_NodeReadFanins( pNtk, iMfsId ); // belongs to pNtk
-        assert( Vec_IntSize(vArray) == 1 );
-        // get the fanin
-        iLitNew = Vec_IntEntry( vMfs2New, Vec_IntEntry(vArray, 0) );
+        if ( i < Gia_ManCoNum(p) - nRealPos ) // internal COs
+        {
+            iMfsId = Gia_ObjCopyArray( p, Gia_ObjId(p, pObj) );
+            iGroup = Vec_IntEntry( vGroupMap, iMfsId );
+            if ( Vec_IntFind(vMfsTopo, iGroup) >= 0 )
+            {
+                iLitNew = Vec_IntEntry( vMfs2Gia, iMfsId );
+                assert( iLitNew >= 0 );
+            }
+            continue;
+        }
+        iLitNew = Vec_IntEntry( vMfs2Gia, Gia_ObjCopyArray(p, Gia_ObjFaninId0p(p, pObj)) );
         assert( iLitNew >= 0 );
-        // create CO
-        pTruth = Sfm_NodeReadTruth( pNtk, iMfsId );
-        assert( pTruth[0] == s_ElemVar || ~pTruth[0] == s_ElemVar );
-        Gia_ManAppendCo( pNew, Abc_LitNotCond(iLitNew, (int)(pTruth[0] != s_ElemVar)) );
+        Gia_ManAppendCo( pNew, Abc_LitNotCond(iLitNew, Gia_ObjFaninC0(pObj)) );
     }
-    Vec_IntFree( vMfs2New );
+
+    // finish mapping 
+    if ( Vec_IntSize(vMapping) > Gia_ManObjNum(pNew) )
+        Vec_IntShrink( vMapping, Gia_ManObjNum(pNew) );
+    else
+        Vec_IntFillExtra( vMapping, Gia_ManObjNum(pNew), 0 );
+    assert( Vec_IntSize(vMapping) == Gia_ManObjNum(pNew) );
+    Vec_IntForEachEntry( vMapping, iLitNew, i )
+        if ( iLitNew > 0 )
+            Vec_IntAddToEntry( vMapping, i, Gia_ManObjNum(pNew) );
+    Vec_IntAppend( vMapping, vMapping2 );
+    Vec_IntFree( vMapping2 );
+    assert( pNew->vMapping == NULL );
+    pNew->vMapping = vMapping;
+
+    // create new timing manager and extra AIG
+    if ( pManTime )
+        pNew->pManTime = Gia_ManUpdateTimMan2( p, vBoxesLeft, 0 );
+    // update extra STG
+    if ( p->pAigExtra )
+        pNew->pAigExtra = Gia_ManUpdateExtraAig2( p->pManTime, p->pAigExtra, vBoxesLeft );
+    // duplicated flops
+    if ( p->vRegClasses )
+        pNew->vRegClasses = Vec_IntDup( p->vRegClasses );
+
+    // cleanup
+    Vec_WecFree( vGroups );
     Vec_IntFree( vMfsTopo );
+    Vec_IntFree( vGroupMap );
+    Vec_IntFree( vMfs2Gia );
+    Vec_IntFree( vBoxesLeft );
     return pNew;
 }
 
-
 /**Function*************************************************************
 
   Synopsis    []
@@ -341,7 +372,6 @@
 Gia_Man_t * Gia_ManPerformMfs( Gia_Man_t * p, Sfm_Par_t * pPars )
 {
     Sfm_Ntk_t * pNtk;
-    Vec_Int_t * vId2Mfs;
     Gia_Man_t * pNew;
     int nFaninMax, nNodes;
     assert( Gia_ManRegNum(p) == 0 );
@@ -359,32 +389,31 @@
         return NULL;
     }
     // collect information
-    pNtk = Gia_ManExtractMfs( p, p->pAigExtra, &vId2Mfs );
+    pNtk = Gia_ManExtractMfs( p );
     // perform optimization
     nNodes = Sfm_NtkPerform( pNtk, pPars );
-    // call the fast extract procedure
     if ( nNodes == 0 )
     {
         Abc_Print( 1, "The network is not changed by \"&mfs\".\n" );
         pNew = Gia_ManDup( p );
         pNew->vMapping = Vec_IntDup( p->vMapping );
+        Gia_ManTransferTiming( pNew, p );
     }
     else
     {
-        pNew = Gia_ManInsertMfs( p, pNtk, vId2Mfs );
+        pNew = Gia_ManInsertMfs( p, pNtk );
         if( pPars->fVerbose )
             Abc_Print( 1, "The network has %d nodes changed by \"&mfs\".\n", nNodes );
+        // check integrity
+        //Gia_ManCheckIntegrityWithBoxes( pNew );
     }
-    Vec_IntFree( vId2Mfs );
     Sfm_NtkFree( pNtk );
     return pNew;
 }
 
-
 ////////////////////////////////////////////////////////////////////////
 ///                       END OF FILE                                ///
 ////////////////////////////////////////////////////////////////////////
-
 
 ABC_NAMESPACE_IMPL_END
 
diff --git a/abc-build/src/aig/gia/giaMuxes.c b/abc-build/src/aig/gia/giaMuxes.c
--- a/abc-build/src/aig/gia/giaMuxes.c
+++ b/abc-build/src/aig/gia/giaMuxes.c
@@ -63,7 +63,7 @@
     int nAnds, nMuxes, nXors, nTotal;
     if ( p->pMuxes )
     {
-        nAnds  = Gia_ManAndNum(p)-Gia_ManXorNum(p)-Gia_ManMuxNum(p);
+        nAnds  = Gia_ManAndNotBufNum(p)-Gia_ManXorNum(p)-Gia_ManMuxNum(p);
         nXors  = Gia_ManXorNum(p);
         nMuxes = Gia_ManMuxNum(p);
         nTotal = nAnds + 3*nXors + 3*nMuxes;
@@ -71,14 +71,14 @@
     else 
     {
         Gia_ManCountMuxXor( p, &nMuxes, &nXors );
-        nAnds  = Gia_ManAndNum(p) - 3*nMuxes - 3*nXors;
-        nTotal = Gia_ManAndNum(p);
+        nAnds  = Gia_ManAndNotBufNum(p) - 3*nMuxes - 3*nXors;
+        nTotal = Gia_ManAndNotBufNum(p);
     }
     Abc_Print( 1, "stats:  " );
     Abc_Print( 1, "xor =%8d %6.2f %%   ", nXors,  300.0*nXors/nTotal );
     Abc_Print( 1, "mux =%8d %6.2f %%   ", nMuxes, 300.0*nMuxes/nTotal );
     Abc_Print( 1, "and =%8d %6.2f %%   ", nAnds,  100.0*nAnds/nTotal );
-    Abc_Print( 1, "obj =%8d  ", Gia_ManAndNum(p) );
+    Abc_Print( 1, "obj =%8d  ", Gia_ManAndNotBufNum(p) );
     fflush( stdout );
 }
 
@@ -117,6 +117,8 @@
             pObj->Value = Gia_ManAppendCi( pNew );
         else if ( Gia_ObjIsCo(pObj) )
             pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+        else if ( Gia_ObjIsBuf(pObj) )
+            pObj->Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(pObj) );
         else if ( !Gia_ObjIsMuxType(pObj) || Gia_ObjSibl(p, Gia_ObjFaninId0(pObj, i)) || Gia_ObjSibl(p, Gia_ObjFaninId1(pObj, i)) )
             pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
         else if ( Gia_ObjRecognizeExor(pObj, &pFan0, &pFan1) )
@@ -172,6 +174,8 @@
             pObj->Value = Gia_ManAppendCi( pNew );
         else if ( Gia_ObjIsCo(pObj) )
             pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+        else if ( Gia_ObjIsBuf(pObj) )
+            pObj->Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(pObj) );
         else if ( Gia_ObjIsMuxId(p, i) )
             pObj->Value = Gia_ManHashMux( pNew, Gia_ObjFanin2Copy(p, pObj), Gia_ObjFanin1Copy(pObj), Gia_ObjFanin0Copy(pObj) );
         else if ( Gia_ObjIsXor(pObj) )
diff --git a/abc-build/src/aig/gia/giaNf.c b/abc-build/src/aig/gia/giaNf.c
--- a/abc-build/src/aig/gia/giaNf.c
+++ b/abc-build/src/aig/gia/giaNf.c
@@ -6,47 +6,2134 @@
 
   PackageName [Scalable AIG package.]
 
-  Synopsis    [Technology mapper.]
-
-  Author      [Alan Mishchenko]
-  
-  Affiliation [UC Berkeley]
-
-  Date        [Ver. 1.0. Started - June 20, 2005.]
-
-  Revision    [$Id: giaNf.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "gia.h"
-
-ABC_NAMESPACE_IMPL_START
-
-////////////////////////////////////////////////////////////////////////
-///                        DECLARATIONS                              ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-///                     FUNCTION DEFINITIONS                         ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-               
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-void Nf_ManSetDefaultPars( Jf_Par_t * pPars )
-{
-}
-Gia_Man_t * Nf_ManPerformMapping( Gia_Man_t * pGia, Jf_Par_t * pPars )
-{
-    return Gia_ManDup( pGia );
+  Synopsis    [Standard-cell mapper.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - June 20, 2005.]
+
+  Revision    [$Id: giaNf.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include <float.h>
+#include "gia.h"
+#include "misc/st/st.h"
+#include "map/mio/mio.h"
+#include "misc/util/utilTruth.h"
+#include "misc/extra/extra.h"
+#include "base/main/main.h"
+#include "misc/vec/vecMem.h"
+#include "misc/vec/vecWec.h"
+#include "opt/dau/dau.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+#define NF_LEAF_MAX  6
+#define NF_CUT_MAX  32
+#define NF_NO_LEAF  31
+#define NF_INFINITY FLT_MAX
+
+typedef struct Nf_Cut_t_ Nf_Cut_t; 
+struct Nf_Cut_t_
+{
+    word            Sign;           // signature
+    int             Delay;          // delay
+    float           Flow;           // flow
+    unsigned        iFunc   : 26;   // function
+    unsigned        Useless :  1;   // function
+    unsigned        nLeaves :  5;   // leaf number (NF_NO_LEAF)
+    int             pLeaves[NF_LEAF_MAX+1]; // leaves
+};
+typedef struct Pf_Mat_t_ Pf_Mat_t; 
+struct Pf_Mat_t_
+{
+    unsigned        fCompl  :  8;   // complemented
+    unsigned        Phase   :  6;   // match phase
+    unsigned        Perm    : 18;   // match permutation
+};
+typedef struct Nf_Mat_t_ Nf_Mat_t; 
+struct Nf_Mat_t_
+{
+    unsigned        Gate    : 20;   // gate
+    unsigned        CutH    : 10;   // cut handle
+    unsigned        fCompl  :  1;   // complemented
+    unsigned        fBest   :  1;   // best cut
+    int             Conf;           // input literals
+    float           D;              // delay
+    float           A;              // area 
+};
+typedef struct Nf_Obj_t_ Nf_Obj_t; 
+struct Nf_Obj_t_
+{
+    Nf_Mat_t        M[2][2];         // del/area (2x)
+};
+typedef struct Nf_Man_t_ Nf_Man_t; 
+struct Nf_Man_t_
+{
+    // user data
+    Gia_Man_t *     pGia;           // derived manager
+    Jf_Par_t *      pPars;          // parameters
+    // matching
+    Vec_Mem_t *     vTtMem;         // truth tables
+    Vec_Wec_t *     vTt2Match;      // matches for truth tables
+    Mio_Cell_t *    pCells;         // library gates
+    int             nCells;         // library gate count
+    // cut data
+    Nf_Obj_t *      pNfObjs;        // best cuts
+    Vec_Ptr_t       vPages;         // cut memory
+    Vec_Int_t       vCutSets;       // cut offsets
+    Vec_Int_t       vMapRefs;       // mapping refs   (2x)
+    Vec_Flt_t       vFlowRefs;      // flow refs      (2x)
+    Vec_Flt_t       vRequired;      // required times (2x)
+    Vec_Flt_t       vCutFlows;      // temporary cut area
+    Vec_Int_t       vCutDelays;     // temporary cut delay
+    Vec_Int_t       vBackup;        // backup literals
+    Vec_Int_t       vBackup2;       // backup literals
+    int             iCur;           // current position
+    int             Iter;           // mapping iterations
+    int             fUseEla;        // use exact area
+    int             nInvs;          // the inverter count
+    float           InvDelay;       // inverter delay
+    float           InvArea;        // inverter area 
+    // statistics
+    abctime         clkStart;       // starting time
+    double          CutCount[6];    // cut counts
+    int             nCutUseAll;     // objects with useful cuts
+};
+
+static inline int         Pf_Mat2Int( Pf_Mat_t Mat )                                { union { int x; Pf_Mat_t y; } v; v.y = Mat; return v.x;           }
+static inline Pf_Mat_t    Pf_Int2Mat( int Int )                                     { union { int x; Pf_Mat_t y; } v; v.x = Int; return v.y;           }
+
+static inline Nf_Obj_t *  Nf_ManObj( Nf_Man_t * p, int i )                          { return p->pNfObjs + i;                                           }
+static inline Mio_Cell_t* Nf_ManCell( Nf_Man_t * p, int i )                         { return p->pCells + i;                                            }
+static inline int *       Nf_ManCutSet( Nf_Man_t * p, int i )                       { return (int *)Vec_PtrEntry(&p->vPages, i >> 16) + (i & 0xFFFF);  }
+static inline int         Nf_ObjCutSetId( Nf_Man_t * p, int i )                     { return Vec_IntEntry( &p->vCutSets, i );                          }
+static inline int *       Nf_ObjCutSet( Nf_Man_t * p, int i )                       { return Nf_ManCutSet(p, Nf_ObjCutSetId(p, i));                    }
+static inline int         Nf_ObjHasCuts( Nf_Man_t * p, int i )                      { return (int)(Vec_IntEntry(&p->vCutSets, i) > 0);                 }
+static inline int *       Nf_ObjCutBest( Nf_Man_t * p, int i )                      { return NULL;                                                     } 
+static inline int         Nf_ObjCutUseless( Nf_Man_t * p, int TruthId )             { return (int)(TruthId >= Vec_WecSize(p->vTt2Match));              } 
+
+static inline float       Nf_ObjCutFlow( Nf_Man_t * p, int i )                      { return Vec_FltEntry(&p->vCutFlows, i);                           } 
+static inline int         Nf_ObjCutDelay( Nf_Man_t * p, int i )                     { return Vec_IntEntry(&p->vCutDelays, i);                          } 
+static inline void        Nf_ObjSetCutFlow( Nf_Man_t * p, int i, float a )          { Vec_FltWriteEntry(&p->vCutFlows, i, a);                          } 
+static inline void        Nf_ObjSetCutDelay( Nf_Man_t * p, int i, int d )           { Vec_IntWriteEntry(&p->vCutDelays, i, d);                         } 
+
+static inline int         Nf_ObjMapRefNum( Nf_Man_t * p, int i, int c )             { return Vec_IntEntry(&p->vMapRefs, Abc_Var2Lit(i,c));             }
+static inline int         Nf_ObjMapRefInc( Nf_Man_t * p, int i, int c )             { return (*Vec_IntEntryP(&p->vMapRefs, Abc_Var2Lit(i,c)))++;       }
+static inline int         Nf_ObjMapRefDec( Nf_Man_t * p, int i, int c )             { return --(*Vec_IntEntryP(&p->vMapRefs, Abc_Var2Lit(i,c)));       }
+static inline float       Nf_ObjFlowRefs( Nf_Man_t * p, int i, int c )              { return Vec_FltEntry(&p->vFlowRefs, Abc_Var2Lit(i,c));            }
+static inline float       Nf_ObjRequired( Nf_Man_t * p, int i, int c )              { return Vec_FltEntry(&p->vRequired, Abc_Var2Lit(i,c));            }
+static inline void        Nf_ObjSetRequired(Nf_Man_t * p,int i, int c, float f)     { Vec_FltWriteEntry(&p->vRequired, Abc_Var2Lit(i,c), f);           }
+static inline void        Nf_ObjUpdateRequired(Nf_Man_t * p,int i, int c, float f)  { if (Nf_ObjRequired(p, i, c) > f) Nf_ObjSetRequired(p, i, c, f);  }
+
+static inline Nf_Mat_t *  Nf_ObjMatchD( Nf_Man_t * p, int i, int c )                { return &Nf_ManObj(p, i)->M[c][0];                                }
+static inline Nf_Mat_t *  Nf_ObjMatchA( Nf_Man_t * p, int i, int c )                { return &Nf_ManObj(p, i)->M[c][1];                                }
+
+static inline Nf_Mat_t *  Nf_ObjMatchBest( Nf_Man_t * p, int i, int c )             
+{
+    Nf_Mat_t * pD = Nf_ObjMatchD(p, i, c);
+    Nf_Mat_t * pA = Nf_ObjMatchA(p, i, c);
+    assert( pD->fBest != pA->fBest );
+    assert( Nf_ObjMapRefNum(p, i, c) > 0 );
+    if ( pA->fBest )
+        return pA;
+    if ( pD->fBest )
+        return pD;
+    return NULL;
+}
+
+static inline int         Nf_CutSize( int * pCut )                                  { return pCut[0] & NF_NO_LEAF;                                     }
+static inline int         Nf_CutFunc( int * pCut )                                  { return ((unsigned)pCut[0] >> 5);                                 }
+static inline int *       Nf_CutLeaves( int * pCut )                                { return pCut + 1;                                                 }
+static inline int         Nf_CutSetBoth( int n, int f )                             { return n | (f << 5);                                             }
+static inline int         Nf_CutIsTriv( int * pCut, int i )                         { return Nf_CutSize(pCut) == 1 && pCut[1] == i;                    } 
+static inline int         Nf_CutHandle( int * pCutSet, int * pCut )                 { assert( pCut > pCutSet ); return pCut - pCutSet;                 } 
+static inline int *       Nf_CutFromHandle( int * pCutSet, int h )                  { assert( h > 0 ); return pCutSet + h;                             }
+static inline int         Nf_CutConfLit( int Conf, int i )                          { return 15 & (Conf >> (i << 2));                                  }
+static inline int         Nf_CutConfVar( int Conf, int i )                          { return Abc_Lit2Var( Nf_CutConfLit(Conf, i) );                    }
+static inline int         Nf_CutConfC( int Conf, int i )                            { return Abc_LitIsCompl( Nf_CutConfLit(Conf, i) );                 }
+
+#define Nf_SetForEachCut( pList, pCut, i )         for ( i = 0, pCut = pList + 1; i < pList[0]; i++, pCut += Nf_CutSize(pCut) + 1 )
+#define Nf_CutForEachLit( pCut, Conf, iLit, i )    for ( i = 0; i < Nf_CutSize(pCut) && (iLit = Abc_Lit2LitV(Nf_CutLeaves(pCut), Nf_CutConfLit(Conf, i))); i++ )
+#define Nf_CutForEachVar( pCut, Conf, iVar, c, i ) for ( i = 0; i < Nf_CutSize(pCut) && (iVar = Nf_CutLeaves(pCut)[Nf_CutConfVar(Conf, i)]) && ((c = Nf_CutConfC(Conf, i)), 1); i++ )
+
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    [Sort inputs by delay.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Nf_StoCreateGateAdd( Nf_Man_t * pMan, word uTruth, int * pFans, int nFans, int CellId )
+{
+    Vec_Int_t * vArray;
+    Pf_Mat_t Mat = Pf_Int2Mat(0);
+    int i, GateId, Entry, fCompl = (int)(uTruth & 1);
+    word uFunc = fCompl ? ~uTruth : uTruth;
+    int iFunc = Vec_MemHashInsert( pMan->vTtMem, &uFunc );
+    if ( iFunc == Vec_WecSize(pMan->vTt2Match) )
+        Vec_WecPushLevel( pMan->vTt2Match );
+    vArray = Vec_WecEntry( pMan->vTt2Match, iFunc );
+    Mat.fCompl = fCompl;
+    assert( nFans < 7 );
+    for ( i = 0; i < nFans; i++ )
+    {
+        Mat.Perm  |= (unsigned)(Abc_Lit2Var(pFans[i]) << (3*i));
+        Mat.Phase |= (unsigned)(Abc_LitIsCompl(pFans[i]) << i);
+    }
+    if ( pMan->pPars->fPinPerm ) // use pin-permutation (slower but good for delay when pin-delays differ)
+    {
+        Vec_IntPush( vArray, CellId );
+        Vec_IntPush( vArray, Pf_Mat2Int(Mat) );
+        return;
+    }
+    // check if the same one exists
+    Vec_IntForEachEntryDouble( vArray, GateId, Entry, i )
+        if ( GateId == CellId && Pf_Int2Mat(Entry).Phase == Mat.Phase )
+            break;
+    if ( i == Vec_IntSize(vArray) )
+    {
+        Vec_IntPush( vArray, CellId );
+        Vec_IntPush( vArray, Pf_Mat2Int(Mat) );
+    }
+}
+void Nf_StoCreateGateMaches( Nf_Man_t * pMan, Mio_Cell_t * pCell, int ** pComp, int ** pPerm, int * pnPerms )
+{
+    int Perm[NF_LEAF_MAX], * Perm1, * Perm2;
+    int nPerms = pnPerms[pCell->nFanins];
+    int nMints = (1 << pCell->nFanins);
+    word tCur, tTemp1, tTemp2;
+    int i, p, c;
+    for ( i = 0; i < (int)pCell->nFanins; i++ )
+        Perm[i] = Abc_Var2Lit( i, 0 );
+    tCur = tTemp1 = pCell->uTruth;
+    for ( p = 0; p < nPerms; p++ )
+    {
+        tTemp2 = tCur;
+        for ( c = 0; c < nMints; c++ )
+        {
+            Nf_StoCreateGateAdd( pMan, tCur, Perm, pCell->nFanins, pCell->Id );
+            // update
+            tCur  = Abc_Tt6Flip( tCur, pComp[pCell->nFanins][c] );
+            Perm1 = Perm + pComp[pCell->nFanins][c];
+            *Perm1 = Abc_LitNot( *Perm1 );
+        }
+        assert( tTemp2 == tCur );
+        // update
+        tCur = Abc_Tt6SwapAdjacent( tCur, pPerm[pCell->nFanins][p] );
+        Perm1 = Perm + pPerm[pCell->nFanins][p];
+        Perm2 = Perm1 + 1;
+        ABC_SWAP( int, *Perm1, *Perm2 );
+    }
+    assert( tTemp1 == tCur );
+}
+void Nf_StoDeriveMatches( Nf_Man_t * p, int fVerbose )
+{
+//    abctime clk = Abc_Clock();
+    int * pComp[7];
+    int * pPerm[7];
+    int nPerms[7], i;
+    for ( i = 2; i <= 6; i++ )
+        pComp[i] = Extra_GreyCodeSchedule( i );
+    for ( i = 2; i <= 6; i++ )
+        pPerm[i] = Extra_PermSchedule( i );
+    for ( i = 2; i <= 6; i++ )
+        nPerms[i] = Extra_Factorial( i );
+    p->pCells = Mio_CollectRootsNewDefault( 6, &p->nCells, fVerbose );
+    for ( i = 4; i < p->nCells; i++ )
+        Nf_StoCreateGateMaches( p, p->pCells + i, pComp, pPerm, nPerms );
+    for ( i = 2; i <= 6; i++ )
+        ABC_FREE( pComp[i] );
+    for ( i = 2; i <= 6; i++ )
+        ABC_FREE( pPerm[i] );
+//    Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
+}
+void Nf_StoPrintOne( Nf_Man_t * p, int Count, int t, int i, int GateId, Pf_Mat_t Mat )
+{
+    Mio_Cell_t * pC = p->pCells + GateId;
+    word * pTruth = Vec_MemReadEntry(p->vTtMem, t);
+    int k, nSuppSize = Abc_TtSupportSize(pTruth, 6);
+    printf( "%6d : ", Count );
+    printf( "%6d : ", t );
+    printf( "%6d : ", i );
+    printf( "Gate %16s  ",   pC->pName );
+    printf( "Area =%8.2f  ", pC->Area );
+    printf( "In = %d   ",    pC->nFanins );
+    if ( Mat.fCompl )
+        printf( " compl " );
+    else
+        printf( "       " );
+    for ( k = 0; k < (int)pC->nFanins; k++ )
+    {
+        int fComplF = (Mat.Phase >> k) & 1;
+        int iFanin  = (Mat.Perm >> (3*k)) & 7;
+        printf( "%c", 'a' + iFanin - fComplF * ('a' - 'A') );
+    }
+    printf( "  " );
+    Dau_DsdPrintFromTruth( pTruth, nSuppSize );
+}
+void Nf_StoPrint( Nf_Man_t * p, int fVerbose )
+{
+    int t, i, GateId, Entry, Count = 0;
+    for ( t = 2; t < Vec_WecSize(p->vTt2Match); t++ )
+    {
+        Vec_Int_t * vArr = Vec_WecEntry( p->vTt2Match, t );
+        Vec_IntForEachEntryDouble( vArr, GateId, Entry, i )
+        {
+            Count++;
+            if ( !fVerbose )
+                continue;
+            //if ( t < 10 )
+            //    Nf_StoPrintOne( p, Count, t, i/2, GateId, Pf_Int2Mat(Entry) );
+        }
+    }
+    printf( "Gates = %d.  Truths = %d.  Matches = %d.\n", 
+        p->nCells, Vec_MemEntryNum(p->vTtMem), Count );
+}
+
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Nf_Man_t * Nf_StoCreate( Gia_Man_t * pGia, Jf_Par_t * pPars )
+{
+    extern void Mf_ManSetFlowRefs( Gia_Man_t * p, Vec_Int_t * vRefs );
+    Vec_Int_t * vFlowRefs;
+    Nf_Man_t * p;
+    int i, Entry;
+    assert( pPars->nCutNum > 1  && pPars->nCutNum <= NF_CUT_MAX );
+    assert( pPars->nLutSize > 1 && pPars->nLutSize <= NF_LEAF_MAX );
+    ABC_FREE( pGia->pRefs );
+    Vec_IntFreeP( &pGia->vCellMapping );
+    if ( Gia_ManHasChoices(pGia) )
+        Gia_ManSetPhase(pGia);
+    // create
+    p = ABC_CALLOC( Nf_Man_t, 1 );
+    p->clkStart = Abc_Clock();
+    p->pGia     = pGia;
+    p->pPars    = pPars;
+    p->pNfObjs  = ABC_CALLOC( Nf_Obj_t, Gia_ManObjNum(pGia) );
+    p->iCur     = 2;
+    // other
+    Vec_PtrGrow( &p->vPages, 256 );                                    // cut memory
+    Vec_IntFill( &p->vMapRefs,  2*Gia_ManObjNum(pGia), 0 );            // mapping refs   (2x)
+    Vec_FltFill( &p->vFlowRefs, 2*Gia_ManObjNum(pGia), 0 );            // flow refs      (2x)
+    Vec_FltFill( &p->vRequired, 2*Gia_ManObjNum(pGia), NF_INFINITY );  // required times (2x)
+    Vec_IntFill( &p->vCutSets,  Gia_ManObjNum(pGia), 0 );              // cut offsets
+    Vec_FltFill( &p->vCutFlows, Gia_ManObjNum(pGia), 0 );              // cut area
+    Vec_IntFill( &p->vCutDelays,Gia_ManObjNum(pGia), 0 );              // cut delay
+    Vec_IntGrow( &p->vBackup, 1000 );
+    Vec_IntGrow( &p->vBackup2, 1000 );
+    // references
+    vFlowRefs = Vec_IntAlloc(0);
+    Mf_ManSetFlowRefs( pGia, vFlowRefs );
+    Vec_IntForEachEntry( vFlowRefs, Entry, i )
+    {
+        Vec_FltWriteEntry( &p->vFlowRefs, 2*i,   /*0.5* */Entry );
+        Vec_FltWriteEntry( &p->vFlowRefs, 2*i+1, /*0.5* */Entry );
+    }
+    Vec_IntFree(vFlowRefs);
+    // matching
+    p->vTtMem    = Vec_MemAllocForTT( 6, 0 );          
+    p->vTt2Match = Vec_WecAlloc( 1000 ); 
+    Vec_WecPushLevel( p->vTt2Match );
+    Vec_WecPushLevel( p->vTt2Match );
+    assert( Vec_WecSize(p->vTt2Match) == Vec_MemEntryNum(p->vTtMem) );
+    Nf_StoDeriveMatches( p, 0 );//pPars->fVerbose );
+    p->InvDelay = p->pCells[3].Delays[0];
+    p->InvArea  = p->pCells[3].Area;
+    Nf_ObjMatchD(p, 0, 0)->Gate = 0;
+    Nf_ObjMatchD(p, 0, 1)->Gate = 1;
+    // prepare cuts
+    return p;
+}
+void Nf_StoDelete( Nf_Man_t * p )
+{
+    Vec_PtrFreeData( &p->vPages );
+    ABC_FREE( p->vPages.pArray );
+    ABC_FREE( p->vMapRefs.pArray );
+    ABC_FREE( p->vFlowRefs.pArray );
+    ABC_FREE( p->vRequired.pArray );
+    ABC_FREE( p->vCutSets.pArray );
+    ABC_FREE( p->vCutFlows.pArray );
+    ABC_FREE( p->vCutDelays.pArray );
+    ABC_FREE( p->vBackup.pArray );
+    ABC_FREE( p->vBackup2.pArray );
+    ABC_FREE( p->pNfObjs );
+    // matching
+    Vec_WecFree( p->vTt2Match );
+    Vec_MemHashFree( p->vTtMem );
+    Vec_MemFree( p->vTtMem );
+    ABC_FREE( p->pCells );
+    ABC_FREE( p );
+}
+
+
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Nf_CutComputeTruth6( Nf_Man_t * p, Nf_Cut_t * pCut0, Nf_Cut_t * pCut1, int fCompl0, int fCompl1, Nf_Cut_t * pCutR, int fIsXor )
+{
+//    extern int Nf_ManTruthCanonicize( word * t, int nVars );
+    int nOldSupp = pCutR->nLeaves, truthId, fCompl; word t;
+    word t0 = *Vec_MemReadEntry(p->vTtMem, Abc_Lit2Var(pCut0->iFunc));
+    word t1 = *Vec_MemReadEntry(p->vTtMem, Abc_Lit2Var(pCut1->iFunc));
+    if ( Abc_LitIsCompl(pCut0->iFunc) ^ fCompl0 ) t0 = ~t0;
+    if ( Abc_LitIsCompl(pCut1->iFunc) ^ fCompl1 ) t1 = ~t1;
+    t0 = Abc_Tt6Expand( t0, pCut0->pLeaves, pCut0->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
+    t1 = Abc_Tt6Expand( t1, pCut1->pLeaves, pCut1->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
+    t =  fIsXor ? t0 ^ t1 : t0 & t1;
+    if ( (fCompl = (int)(t & 1)) ) t = ~t;
+    pCutR->nLeaves = Abc_Tt6MinBase( &t, pCutR->pLeaves, pCutR->nLeaves );
+    assert( (int)(t & 1) == 0 );
+    truthId        = Vec_MemHashInsert(p->vTtMem, &t);
+    pCutR->iFunc   = Abc_Var2Lit( truthId, fCompl );
+    pCutR->Useless = Nf_ObjCutUseless( p, truthId );
+    assert( (int)pCutR->nLeaves <= nOldSupp );
+    return (int)pCutR->nLeaves < nOldSupp;
+}
+static inline int Nf_CutComputeTruthMux6( Nf_Man_t * p, Nf_Cut_t * pCut0, Nf_Cut_t * pCut1, Nf_Cut_t * pCutC, int fCompl0, int fCompl1, int fComplC, Nf_Cut_t * pCutR )
+{
+    int nOldSupp = pCutR->nLeaves, truthId, fCompl; word t;
+    word t0 = *Vec_MemReadEntry(p->vTtMem, Abc_Lit2Var(pCut0->iFunc));
+    word t1 = *Vec_MemReadEntry(p->vTtMem, Abc_Lit2Var(pCut1->iFunc));
+    word tC = *Vec_MemReadEntry(p->vTtMem, Abc_Lit2Var(pCutC->iFunc));
+    if ( Abc_LitIsCompl(pCut0->iFunc) ^ fCompl0 ) t0 = ~t0;
+    if ( Abc_LitIsCompl(pCut1->iFunc) ^ fCompl1 ) t1 = ~t1;
+    if ( Abc_LitIsCompl(pCutC->iFunc) ^ fComplC ) tC = ~tC;
+    t0 = Abc_Tt6Expand( t0, pCut0->pLeaves, pCut0->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
+    t1 = Abc_Tt6Expand( t1, pCut1->pLeaves, pCut1->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
+    tC = Abc_Tt6Expand( tC, pCutC->pLeaves, pCutC->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
+    t = (tC & t1) | (~tC & t0);
+    if ( (fCompl = (int)(t & 1)) ) t = ~t;
+    pCutR->nLeaves = Abc_Tt6MinBase( &t, pCutR->pLeaves, pCutR->nLeaves );
+    assert( (int)(t & 1) == 0 );
+    truthId        = Vec_MemHashInsert(p->vTtMem, &t);
+    pCutR->iFunc   = Abc_Var2Lit( truthId, fCompl );
+    pCutR->Useless = Nf_ObjCutUseless( p, truthId );
+    assert( (int)pCutR->nLeaves <= nOldSupp );
+    return (int)pCutR->nLeaves < nOldSupp;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Nf_CutCountBits( word i )
+{
+    i = i - ((i >> 1) & 0x5555555555555555);
+    i = (i & 0x3333333333333333) + ((i >> 2) & 0x3333333333333333);
+    i = ((i + (i >> 4)) & 0x0F0F0F0F0F0F0F0F);
+    return (i*(0x0101010101010101))>>56;
+}
+static inline word Nf_CutGetSign( int * pLeaves, int nLeaves )
+{
+    word Sign = 0; int i; 
+    for ( i = 0; i < nLeaves; i++ )
+        Sign |= ((word)1) << (pLeaves[i] & 0x3F);
+    return Sign;
+}
+static inline int Nf_CutCreateUnit( Nf_Cut_t * p, int i )
+{
+    p->Delay      = 0;
+    p->Flow       = 0;
+    p->iFunc      = 2;
+    p->nLeaves    = 1;
+    p->pLeaves[0] = i;
+    p->Sign       = ((word)1) << (i & 0x3F);
+    return 1;
+}
+static inline void Nf_Cutprintf( Nf_Man_t * p, Nf_Cut_t * pCut )
+{
+    int i, nDigits = Abc_Base10Log(Gia_ManObjNum(p->pGia)); 
+    printf( "%d  {", pCut->nLeaves );
+    for ( i = 0; i < (int)pCut->nLeaves; i++ )
+        printf( " %*d", nDigits, pCut->pLeaves[i] );
+    for ( ; i < (int)p->pPars->nLutSize; i++ )
+        printf( " %*s", nDigits, " " );
+    printf( "  }   Useless = %d. D = %4d  A = %9.4f  F = %6d  ", 
+        pCut->Useless, pCut->Delay, pCut->Flow, pCut->iFunc );
+    if ( p->vTtMem )
+        Dau_DsdPrintFromTruth( Vec_MemReadEntry(p->vTtMem, Abc_Lit2Var(pCut->iFunc)), pCut->nLeaves );
+    else
+        printf( "\n" );
+}
+static inline int Nf_ManPrepareCuts( Nf_Cut_t * pCuts, Nf_Man_t * p, int iObj, int fAddUnit )
+{
+    if ( Nf_ObjHasCuts(p, iObj) )
+    {
+        Nf_Cut_t * pMfCut = pCuts;
+        int i, * pCut, * pList = Nf_ObjCutSet(p, iObj);
+        Nf_SetForEachCut( pList, pCut, i )
+        {
+            pMfCut->Delay   = 0;
+            pMfCut->Flow    = 0;
+            pMfCut->iFunc   = Nf_CutFunc( pCut );
+            pMfCut->nLeaves = Nf_CutSize( pCut );
+            pMfCut->Sign    = Nf_CutGetSign( pCut+1, Nf_CutSize(pCut) );
+            pMfCut->Useless = Nf_ObjCutUseless( p, Abc_Lit2Var(pMfCut->iFunc) );
+            memcpy( pMfCut->pLeaves, pCut+1, sizeof(int) * Nf_CutSize(pCut) );
+            pMfCut++;
+        }
+        if ( fAddUnit && pCuts->nLeaves > 1 )
+            return pList[0] + Nf_CutCreateUnit( pMfCut, iObj );
+        return pList[0];
+    }
+    return Nf_CutCreateUnit( pCuts, iObj );
+}
+static inline int Nf_ManSaveCuts( Nf_Man_t * p, Nf_Cut_t ** pCuts, int nCuts, int fUseful )
+{
+    int i, * pPlace, iCur, nInts = 1, nCutsNew = 0;
+    for ( i = 0; i < nCuts; i++ )
+        if ( !fUseful || !pCuts[i]->Useless )
+            nInts += pCuts[i]->nLeaves + 1, nCutsNew++;
+    if ( (p->iCur & 0xFFFF) + nInts > 0xFFFF )
+        p->iCur = ((p->iCur >> 16) + 1) << 16;
+    if ( Vec_PtrSize(&p->vPages) == (p->iCur >> 16) )
+        Vec_PtrPush( &p->vPages, ABC_ALLOC(int, (1<<16)) );
+    iCur = p->iCur; p->iCur += nInts;
+    pPlace = Nf_ManCutSet( p, iCur );
+    *pPlace++ = nCutsNew;
+    for ( i = 0; i < nCuts; i++ )
+        if ( !fUseful || !pCuts[i]->Useless )
+        {
+            *pPlace++ = Nf_CutSetBoth( pCuts[i]->nLeaves, pCuts[i]->iFunc );
+            memcpy( pPlace, pCuts[i]->pLeaves, sizeof(int) * pCuts[i]->nLeaves );
+            pPlace += pCuts[i]->nLeaves;
+        }
+    return iCur;
+}
+static inline int Nf_ManCountUseful( Nf_Cut_t ** pCuts, int nCuts )
+{
+    int i, Count = 0;
+    for ( i = 0; i < nCuts; i++ )
+        Count += !pCuts[i]->Useless;
+    return Count;
+}
+static inline int Nf_ManCountMatches( Nf_Man_t * p, Nf_Cut_t ** pCuts, int nCuts )
+{
+    int i, Count = 0;
+    for ( i = 0; i < nCuts; i++ )
+        if ( !pCuts[i]->Useless )
+            Count += Vec_IntSize(Vec_WecEntry(p->vTt2Match, Abc_Lit2Var(pCuts[i]->iFunc))) / 2;
+    return Count;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Check correctness of cuts.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Nf_CutCheck( Nf_Cut_t * pBase, Nf_Cut_t * pCut ) // check if pCut is contained in pBase
+{
+    int nSizeB = pBase->nLeaves;
+    int nSizeC = pCut->nLeaves;
+    int i, * pB = pBase->pLeaves;
+    int k, * pC = pCut->pLeaves;
+    for ( i = 0; i < nSizeC; i++ )
+    {
+        for ( k = 0; k < nSizeB; k++ )
+            if ( pC[i] == pB[k] )
+                break;
+        if ( k == nSizeB )
+            return 0;
+    }
+    return 1;
+}
+static inline int Nf_SetCheckArray( Nf_Cut_t ** ppCuts, int nCuts )
+{
+    Nf_Cut_t * pCut0, * pCut1; 
+    int i, k, m, n, Value;
+    assert( nCuts > 0 );
+    for ( i = 0; i < nCuts; i++ )
+    {
+        pCut0 = ppCuts[i];
+        assert( pCut0->nLeaves <= NF_LEAF_MAX );
+        assert( pCut0->Sign == Nf_CutGetSign(pCut0->pLeaves, pCut0->nLeaves) );
+        // check duplicates
+        for ( m = 0; m < (int)pCut0->nLeaves; m++ )
+        for ( n = m + 1; n < (int)pCut0->nLeaves; n++ )
+            assert( pCut0->pLeaves[m] < pCut0->pLeaves[n] );
+        // check pairs
+        for ( k = 0; k < nCuts; k++ )
+        {
+            pCut1 = ppCuts[k];
+            if ( pCut0 == pCut1 )
+                continue;
+            // check containments
+            Value = Nf_CutCheck( pCut0, pCut1 );
+            assert( Value == 0 );
+        }
+    }
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Nf_CutMergeOrder( Nf_Cut_t * pCut0, Nf_Cut_t * pCut1, Nf_Cut_t * pCut, int nLutSize )
+{ 
+    int nSize0   = pCut0->nLeaves;
+    int nSize1   = pCut1->nLeaves;
+    int i, * pC0 = pCut0->pLeaves;
+    int k, * pC1 = pCut1->pLeaves;
+    int c, * pC  = pCut->pLeaves;
+    // the case of the largest cut sizes
+    if ( nSize0 == nLutSize && nSize1 == nLutSize )
+    {
+        for ( i = 0; i < nSize0; i++ )
+        {
+            if ( pC0[i] != pC1[i] )  return 0;
+            pC[i] = pC0[i];
+        }
+        pCut->nLeaves = nLutSize;
+        pCut->iFunc = -1;
+        pCut->Sign = pCut0->Sign | pCut1->Sign;
+        return 1;
+    }
+    // compare two cuts with different numbers
+    i = k = c = 0;
+    if ( nSize0 == 0 ) goto FlushCut1;
+    if ( nSize1 == 0 ) goto FlushCut0;
+    while ( 1 )
+    {
+        if ( c == nLutSize ) return 0;
+        if ( pC0[i] < pC1[k] )
+        {
+            pC[c++] = pC0[i++];
+            if ( i >= nSize0 ) goto FlushCut1;
+        }
+        else if ( pC0[i] > pC1[k] )
+        {
+            pC[c++] = pC1[k++];
+            if ( k >= nSize1 ) goto FlushCut0;
+        }
+        else
+        {
+            pC[c++] = pC0[i++]; k++;
+            if ( i >= nSize0 ) goto FlushCut1;
+            if ( k >= nSize1 ) goto FlushCut0;
+        }
+    }
+
+FlushCut0:
+    if ( c + nSize0 > nLutSize + i ) return 0;
+    while ( i < nSize0 )
+        pC[c++] = pC0[i++];
+    pCut->nLeaves = c;
+    pCut->iFunc = -1;
+    pCut->Sign = pCut0->Sign | pCut1->Sign;
+    return 1;
+
+FlushCut1:
+    if ( c + nSize1 > nLutSize + k ) return 0;
+    while ( k < nSize1 )
+        pC[c++] = pC1[k++];
+    pCut->nLeaves = c;
+    pCut->iFunc = -1;
+    pCut->Sign = pCut0->Sign | pCut1->Sign;
+    return 1;
+}
+static inline int Nf_CutMergeOrderMux( Nf_Cut_t * pCut0, Nf_Cut_t * pCut1, Nf_Cut_t * pCut2, Nf_Cut_t * pCut, int nLutSize )
+{ 
+    int x0, i0 = 0, nSize0 = pCut0->nLeaves, * pC0 = pCut0->pLeaves;
+    int x1, i1 = 0, nSize1 = pCut1->nLeaves, * pC1 = pCut1->pLeaves;
+    int x2, i2 = 0, nSize2 = pCut2->nLeaves, * pC2 = pCut2->pLeaves;
+    int xMin, c = 0, * pC  = pCut->pLeaves;
+    while ( 1 )
+    {
+        x0 = (i0 == nSize0) ? ABC_INFINITY : pC0[i0];
+        x1 = (i1 == nSize1) ? ABC_INFINITY : pC1[i1];
+        x2 = (i2 == nSize2) ? ABC_INFINITY : pC2[i2];
+        xMin = Abc_MinInt( Abc_MinInt(x0, x1), x2 );
+        if ( xMin == ABC_INFINITY ) break;
+        if ( c == nLutSize ) return 0;
+        pC[c++] = xMin;
+        if (x0 == xMin) i0++;
+        if (x1 == xMin) i1++;
+        if (x2 == xMin) i2++;
+    }
+    pCut->nLeaves = c;
+    pCut->iFunc = -1;
+    pCut->Sign = pCut0->Sign | pCut1->Sign | pCut2->Sign;
+    return 1;
+}
+static inline int Nf_SetCutIsContainedOrder( Nf_Cut_t * pBase, Nf_Cut_t * pCut ) // check if pCut is contained in pBase
+{
+    int i, nSizeB = pBase->nLeaves;
+    int k, nSizeC = pCut->nLeaves;
+    if ( nSizeB == nSizeC )
+    {
+        for ( i = 0; i < nSizeB; i++ )
+            if ( pBase->pLeaves[i] != pCut->pLeaves[i] )
+                return 0;
+        return 1;
+    }
+    assert( nSizeB > nSizeC ); 
+    if ( nSizeC == 0 )
+        return 1;
+    for ( i = k = 0; i < nSizeB; i++ )
+    {
+        if ( pBase->pLeaves[i] > pCut->pLeaves[k] )
+            return 0;
+        if ( pBase->pLeaves[i] == pCut->pLeaves[k] )
+        {
+            if ( ++k == nSizeC )
+                return 1;
+        }
+    }
+    return 0;
+}
+static inline int Nf_SetLastCutIsContained( Nf_Cut_t ** pCuts, int nCuts )
+{
+    int i;
+    for ( i = 0; i < nCuts; i++ )
+        if ( pCuts[i]->nLeaves <= pCuts[nCuts]->nLeaves && (pCuts[i]->Sign & pCuts[nCuts]->Sign) == pCuts[i]->Sign && Nf_SetCutIsContainedOrder(pCuts[nCuts], pCuts[i]) )
+            return 1;
+    return 0;
+}
+static inline int Nf_SetLastCutContainsArea( Nf_Cut_t ** pCuts, int nCuts )
+{
+    int i, k, fChanges = 0;
+    for ( i = 0; i < nCuts; i++ )
+        if ( pCuts[nCuts]->nLeaves < pCuts[i]->nLeaves && (pCuts[nCuts]->Sign & pCuts[i]->Sign) == pCuts[nCuts]->Sign && Nf_SetCutIsContainedOrder(pCuts[i], pCuts[nCuts]) )
+            pCuts[i]->nLeaves = NF_NO_LEAF, fChanges = 1;
+    if ( !fChanges )
+        return nCuts;
+    for ( i = k = 0; i <= nCuts; i++ )
+    {
+        if ( pCuts[i]->nLeaves == NF_NO_LEAF )
+            continue;
+        if ( k < i )
+            ABC_SWAP( Nf_Cut_t *, pCuts[k], pCuts[i] );
+        k++;
+    }
+    return k - 1;
+}
+static inline int Nf_CutCompareArea( Nf_Cut_t * pCut0, Nf_Cut_t * pCut1 )
+{
+    if ( pCut0->Useless < pCut1->Useless )  return -1;
+    if ( pCut0->Useless > pCut1->Useless )  return  1;
+    if ( pCut0->Flow    < pCut1->Flow    )  return -1;
+    if ( pCut0->Flow    > pCut1->Flow    )  return  1;
+    if ( pCut0->Delay   < pCut1->Delay   )  return -1;
+    if ( pCut0->Delay   > pCut1->Delay   )  return  1;
+    if ( pCut0->nLeaves < pCut1->nLeaves )  return -1;
+    if ( pCut0->nLeaves > pCut1->nLeaves )  return  1;
+    return 0;
+}
+static inline void Nf_SetSortByArea( Nf_Cut_t ** pCuts, int nCuts )
+{
+    int i;
+    for ( i = nCuts; i > 0; i-- )
+    {
+        if ( Nf_CutCompareArea(pCuts[i - 1], pCuts[i]) < 0 )//!= 1 )
+            return;
+        ABC_SWAP( Nf_Cut_t *, pCuts[i - 1], pCuts[i] );
+    }
+}
+static inline int Nf_SetAddCut( Nf_Cut_t ** pCuts, int nCuts, int nCutNum )
+{
+    if ( nCuts == 0 )
+        return 1;
+    nCuts = Nf_SetLastCutContainsArea(pCuts, nCuts);
+    Nf_SetSortByArea( pCuts, nCuts );
+    return Abc_MinInt( nCuts + 1, nCutNum - 1 );
+}
+static inline int Nf_CutArea( Nf_Man_t * p, int nLeaves )
+{
+    if ( nLeaves < 2 )
+        return 0;
+    return nLeaves + p->pPars->nAreaTuner;
+}
+static inline void Nf_CutParams( Nf_Man_t * p, Nf_Cut_t * pCut, float FlowRefs )
+{
+    int i, nLeaves = pCut->nLeaves; 
+    assert( nLeaves <= p->pPars->nLutSize );
+    pCut->Delay = 0;
+    pCut->Flow  = 0;
+    for ( i = 0; i < nLeaves; i++ )
+    {
+        pCut->Delay = Abc_MaxInt( pCut->Delay, Nf_ObjCutDelay(p, pCut->pLeaves[i]) );
+        pCut->Flow += Nf_ObjCutFlow(p, pCut->pLeaves[i]);
+    }
+    pCut->Delay += (int)(nLeaves > 1);
+    pCut->Flow = (pCut->Flow + Nf_CutArea(p, nLeaves)) / FlowRefs;
+}
+void Nf_ObjMergeOrder( Nf_Man_t * p, int iObj )
+{
+    Nf_Cut_t pCuts0[NF_CUT_MAX], pCuts1[NF_CUT_MAX], pCuts[NF_CUT_MAX], * pCutsR[NF_CUT_MAX];
+    Gia_Obj_t * pObj = Gia_ManObj(p->pGia, iObj);
+    //Nf_Obj_t * pBest = Nf_ManObj(p, iObj);
+    float dFlowRefs  = Nf_ObjFlowRefs(p, iObj, 0) + Nf_ObjFlowRefs(p, iObj, 1);
+    int nLutSize = p->pPars->nLutSize;
+    int nCutNum  = p->pPars->nCutNum;
+    int nCuts0   = Nf_ManPrepareCuts(pCuts0, p, Gia_ObjFaninId0(pObj, iObj), 1);
+    int nCuts1   = Nf_ManPrepareCuts(pCuts1, p, Gia_ObjFaninId1(pObj, iObj), 1);
+    int fComp0   = Gia_ObjFaninC0(pObj);
+    int fComp1   = Gia_ObjFaninC1(pObj);
+    int iSibl    = Gia_ObjSibl(p->pGia, iObj);
+    Nf_Cut_t * pCut0, * pCut1, * pCut0Lim = pCuts0 + nCuts0, * pCut1Lim = pCuts1 + nCuts1;
+    int i, nCutsUse, nCutsR = 0;
+    assert( !Gia_ObjIsBuf(pObj) );
+    for ( i = 0; i < nCutNum; i++ )
+        pCutsR[i] = pCuts + i;
+    if ( iSibl )
+    {
+        Nf_Cut_t pCuts2[NF_CUT_MAX];
+        Gia_Obj_t * pObjE = Gia_ObjSiblObj(p->pGia, iObj);
+        int fCompE = Gia_ObjPhase(pObj) ^ Gia_ObjPhase(pObjE);
+        int nCuts2 = Nf_ManPrepareCuts(pCuts2, p, iSibl, 0);
+        Nf_Cut_t * pCut2, * pCut2Lim = pCuts2 + nCuts2;
+        for ( pCut2 = pCuts2; pCut2 < pCut2Lim; pCut2++ )
+        {
+            *pCutsR[nCutsR] = *pCut2;
+            pCutsR[nCutsR]->iFunc = Abc_LitNotCond( pCutsR[nCutsR]->iFunc, fCompE );
+            Nf_CutParams( p, pCutsR[nCutsR], dFlowRefs );
+            nCutsR = Nf_SetAddCut( pCutsR, nCutsR, nCutNum );
+        }
+    }
+    if ( Gia_ObjIsMuxId(p->pGia, iObj) )
+    {
+        Nf_Cut_t pCuts2[NF_CUT_MAX];
+        int nCuts2  = Nf_ManPrepareCuts(pCuts2, p, Gia_ObjFaninId2(p->pGia, iObj), 1);
+        int fComp2  = Gia_ObjFaninC2(p->pGia, pObj);
+        Nf_Cut_t * pCut2, * pCut2Lim = pCuts2 + nCuts2;
+        p->CutCount[0] += nCuts0 * nCuts1 * nCuts2;
+        for ( pCut0 = pCuts0; pCut0 < pCut0Lim; pCut0++ )
+        for ( pCut1 = pCuts1; pCut1 < pCut1Lim; pCut1++ )
+        for ( pCut2 = pCuts2; pCut2 < pCut2Lim; pCut2++ )
+        {
+            if ( Nf_CutCountBits(pCut0->Sign | pCut1->Sign | pCut2->Sign) > nLutSize )
+                continue;
+            p->CutCount[1]++; 
+            if ( !Nf_CutMergeOrderMux(pCut0, pCut1, pCut2, pCutsR[nCutsR], nLutSize) )
+                continue;
+            if ( Nf_SetLastCutIsContained(pCutsR, nCutsR) )
+                continue;
+            p->CutCount[2]++;
+            if ( Nf_CutComputeTruthMux6(p, pCut0, pCut1, pCut2, fComp0, fComp1, fComp2, pCutsR[nCutsR]) )
+                pCutsR[nCutsR]->Sign = Nf_CutGetSign(pCutsR[nCutsR]->pLeaves, pCutsR[nCutsR]->nLeaves);
+            Nf_CutParams( p, pCutsR[nCutsR], dFlowRefs );
+            nCutsR = Nf_SetAddCut( pCutsR, nCutsR, nCutNum );
+        }
+    }
+    else
+    {
+        int fIsXor = Gia_ObjIsXor(pObj);
+        p->CutCount[0] += nCuts0 * nCuts1;
+        for ( pCut0 = pCuts0; pCut0 < pCut0Lim; pCut0++ )
+        for ( pCut1 = pCuts1; pCut1 < pCut1Lim; pCut1++ )
+        {
+            if ( (int)(pCut0->nLeaves + pCut1->nLeaves) > nLutSize && Nf_CutCountBits(pCut0->Sign | pCut1->Sign) > nLutSize )
+                continue;
+            p->CutCount[1]++; 
+            if ( !Nf_CutMergeOrder(pCut0, pCut1, pCutsR[nCutsR], nLutSize) )
+                continue;
+            if ( Nf_SetLastCutIsContained(pCutsR, nCutsR) )
+                continue;
+            p->CutCount[2]++;
+            if ( Nf_CutComputeTruth6(p, pCut0, pCut1, fComp0, fComp1, pCutsR[nCutsR], fIsXor) )
+                pCutsR[nCutsR]->Sign = Nf_CutGetSign(pCutsR[nCutsR]->pLeaves, pCutsR[nCutsR]->nLeaves);
+            Nf_CutParams( p, pCutsR[nCutsR], dFlowRefs );
+            nCutsR = Nf_SetAddCut( pCutsR, nCutsR, nCutNum );
+        }
+    }
+    // debug printout
+    if ( 0 )
+//    if ( iObj % 10000 == 0 )
+//    if ( iObj == 1090 )
+    {
+        printf( "*** Obj = %d  Useful = %d\n", iObj, Nf_ManCountUseful(pCutsR, nCutsR) );
+        for ( i = 0; i < nCutsR; i++ )
+            Nf_Cutprintf( p, pCutsR[i] );
+        printf( "\n" );
+    } 
+    // verify
+    assert( nCutsR > 0 && nCutsR < nCutNum );
+//    assert( Nf_SetCheckArray(pCutsR, nCutsR) );
+    // store the cutset
+    Nf_ObjSetCutFlow( p, iObj, pCutsR[0]->Flow );
+    Nf_ObjSetCutDelay( p, iObj, pCutsR[0]->Delay );
+    *Vec_IntEntryP(&p->vCutSets, iObj) = Nf_ManSaveCuts(p, pCutsR, nCutsR, 0);
+    p->CutCount[3] += nCutsR;
+    nCutsUse = Nf_ManCountUseful(pCutsR, nCutsR);
+    p->CutCount[4] += nCutsUse;
+    p->nCutUseAll  += nCutsUse == nCutsR;
+    p->CutCount[5] += Nf_ManCountMatches(p, pCutsR, nCutsR);
+}
+void Nf_ManComputeCuts( Nf_Man_t * p )
+{
+    Gia_Obj_t * pObj; int i, iFanin;
+    Gia_ManForEachAnd( p->pGia, pObj, i )
+        if ( Gia_ObjIsBuf(pObj) )
+        {
+            iFanin = Gia_ObjFaninId0(pObj, i);
+            Nf_ObjSetCutFlow( p, i,  Nf_ObjCutFlow(p, iFanin) );
+            Nf_ObjSetCutDelay( p, i, Nf_ObjCutDelay(p, iFanin) );
+        }
+        else
+            Nf_ObjMergeOrder( p, i );
+}
+
+
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Nf_ManPrintStats( Nf_Man_t * p, char * pTitle )
+{
+    if ( !p->pPars->fVerbose )
+        return;
+    printf( "%s :  ", pTitle );
+    printf( "Delay =%8.2f  ",  p->pPars->MapDelay );
+    printf( "Area =%12.2f  ",  p->pPars->MapArea );
+    printf( "Gate =%6d  ",    (int)p->pPars->Area );
+    printf( "Inv =%6d  ",     (int)p->nInvs );
+    printf( "Edge =%7d  ",    (int)p->pPars->Edge );
+    Abc_PrintTime( 1, "Time", Abc_Clock() - p->clkStart );
+    fflush( stdout );
+}
+void Nf_ManPrintInit( Nf_Man_t * p )
+{
+    int nChoices;
+    if ( !p->pPars->fVerbose )
+        return;
+    printf( "LutSize = %d  ", p->pPars->nLutSize );
+    printf( "CutNum = %d  ",  p->pPars->nCutNum );
+    printf( "Iter = %d  ",    p->pPars->nRounds );//+ p->pPars->nRoundsEla );
+    printf( "Coarse = %d   ", p->pPars->fCoarsen );
+    printf( "Cells = %d  ",   p->nCells );
+    printf( "Funcs = %d  ",   Vec_MemEntryNum(p->vTtMem) );
+    printf( "Matches = %d  ", Vec_WecSizeSize(p->vTt2Match)/2 );
+    nChoices = Gia_ManChoiceNum( p->pGia );
+    if ( nChoices )
+    printf( "Choices = %d  ", nChoices );
+    printf( "\n" );
+    printf( "Computing cuts...\r" );
+    fflush( stdout );
+}
+void Nf_ManPrintQuit( Nf_Man_t * p )
+{
+    float MemGia   = Gia_ManMemory(p->pGia) / (1<<20);
+    float MemMan   =(1.0 * sizeof(Nf_Obj_t) + 8.0 * sizeof(int)) * Gia_ManObjNum(p->pGia) / (1<<20);
+    float MemCuts  = 1.0 * sizeof(int) * (1 << 16) * Vec_PtrSize(&p->vPages) / (1<<20);
+    float MemTt    = p->vTtMem ? Vec_MemMemory(p->vTtMem) / (1<<20) : 0;
+    if ( p->CutCount[0] == 0 )
+        p->CutCount[0] = 1;
+    if ( !p->pPars->fVerbose )
+        return;
+    printf( "CutPair = %.0f  ",         p->CutCount[0] );
+    printf( "Merge = %.0f (%.1f)  ",    p->CutCount[1], 1.0*p->CutCount[1]/Gia_ManAndNum(p->pGia) );
+    printf( "Eval = %.0f (%.1f)  ",     p->CutCount[2], 1.0*p->CutCount[2]/Gia_ManAndNum(p->pGia) );
+    printf( "Cut = %.0f (%.1f)  ",      p->CutCount[3], 1.0*p->CutCount[3]/Gia_ManAndNum(p->pGia) );
+    printf( "Use = %.0f (%.1f)  ",      p->CutCount[4], 1.0*p->CutCount[4]/Gia_ManAndNum(p->pGia) );
+    printf( "Mat = %.0f (%.1f)  ",      p->CutCount[5], 1.0*p->CutCount[5]/Gia_ManAndNum(p->pGia) );
+//    printf( "Equ = %d (%.2f %%)  ",     p->nCutUseAll,  100.0*p->nCutUseAll /p->CutCount[0] );
+    printf( "\n" );
+    printf( "Gia = %.2f MB  ",          MemGia );
+    printf( "Man = %.2f MB  ",          MemMan ); 
+    printf( "Cut = %.2f MB   ",         MemCuts );
+    printf( "TT = %.2f MB  ",           MemTt ); 
+    printf( "Total = %.2f MB   ",       MemGia + MemMan + MemCuts + MemTt ); 
+//    printf( "\n" );
+    Abc_PrintTime( 1, "Time", Abc_Clock() - p->clkStart );
+    fflush( stdout );
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    [Technology mappping.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+float Nf_MatchDeref2_rec( Nf_Man_t * p, int i, int c, Nf_Mat_t * pM )
+{
+    int k, iVar, fCompl, * pCut;
+    float Area = 0;
+    if ( pM->fCompl )
+    {
+        assert( Nf_ObjMapRefNum(p, i, !c) > 0 );
+        if ( !Nf_ObjMapRefDec(p, i, !c) )
+            Area += Nf_MatchDeref2_rec( p, i, !c, Nf_ObjMatchBest(p, i, !c) );
+        return Area + p->InvArea;
+    }
+    if ( Nf_ObjCutSetId(p, i) == 0 )
+        return 0;
+    pCut = Nf_CutFromHandle( Nf_ObjCutSet(p, i), pM->CutH );
+    Nf_CutForEachVar( pCut, pM->Conf, iVar, fCompl, k )
+    {
+        assert( Nf_ObjMapRefNum(p, iVar, fCompl) > 0 );
+        if ( !Nf_ObjMapRefDec(p, iVar, fCompl) )
+            Area += Nf_MatchDeref2_rec( p, iVar, fCompl, Nf_ObjMatchBest(p, iVar, fCompl) );
+    }
+    return Area + Nf_ManCell(p, pM->Gate)->Area;
+}
+float Nf_MatchRef2_rec( Nf_Man_t * p, int i, int c, Nf_Mat_t * pM, Vec_Int_t * vBackup )
+{
+    int k, iVar, fCompl, * pCut;
+    float Area = 0;
+    if ( pM->fCompl )
+    {
+        if ( vBackup )
+            Vec_IntPush( vBackup, Abc_Var2Lit(i, !c) );
+        assert( Nf_ObjMapRefNum(p, i, !c) >= 0 );
+        if ( !Nf_ObjMapRefInc(p, i, !c) )
+            Area += Nf_MatchRef2_rec( p, i, !c, Nf_ObjMatchBest(p, i, !c), vBackup );
+        return Area + p->InvArea;
+    }
+    if ( Nf_ObjCutSetId(p, i) == 0 )
+        return 0;
+    pCut = Nf_CutFromHandle( Nf_ObjCutSet(p, i), pM->CutH );
+    Nf_CutForEachVar( pCut, pM->Conf, iVar, fCompl, k )
+    {
+        if ( vBackup )
+            Vec_IntPush( vBackup, Abc_Var2Lit(iVar, fCompl) );
+        assert( Nf_ObjMapRefNum(p, iVar, fCompl) >= 0 );
+        if ( !Nf_ObjMapRefInc(p, iVar, fCompl) )
+            Area += Nf_MatchRef2_rec( p, iVar, fCompl, Nf_ObjMatchBest(p, iVar, fCompl), vBackup );
+    }
+    return Area + Nf_ManCell(p, pM->Gate)->Area;
+}
+float Nf_MatchRef2Area( Nf_Man_t * p, int i, int c, Nf_Mat_t * pM )
+{
+    float Area;  int iLit, k; 
+    Vec_IntClear( &p->vBackup );
+    Area = Nf_MatchRef2_rec( p, i, c, pM, &p->vBackup );
+    Vec_IntForEachEntry( &p->vBackup, iLit, k )
+    {
+        assert( Nf_ObjMapRefNum(p, Abc_Lit2Var(iLit), Abc_LitIsCompl(iLit)) > 0 );
+        Nf_ObjMapRefDec( p, Abc_Lit2Var(iLit), Abc_LitIsCompl(iLit) );
+    }
+    return Area;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Nf_ManCutMatchPrint( Nf_Man_t * p, int iObj, int fCompl, Nf_Mat_t * pM )
+{
+    Mio_Cell_t * pCell;
+    int i, * pCut;
+    printf( "%5d %d : ", iObj, fCompl );
+    if ( pM->CutH == 0 )
+    {
+        printf( "Unassigned\n" );
+        return;
+    }
+    pCell = Nf_ManCell( p, pM->Gate );
+    pCut = Nf_CutFromHandle( Nf_ObjCutSet(p, iObj), pM->CutH );
+    printf( "D = %8.2f  ", pM->D );
+    printf( "A = %8.2f  ", pM->A );
+    printf( "C = %d ", pM->fCompl );
+//    printf( "B = %d ", pM->fBest );
+    printf( "  " );
+    printf( "Cut = {" );
+    for ( i = 0; i < (int)pCell->nFanins; i++ )
+        printf( "%5d ", Nf_CutLeaves(pCut)[i] );
+    for ( ; i < 6; i++ )
+        printf( "      " );
+    printf( "}  " );
+    printf( "%12s  ", pCell->pName );
+    printf( "%d  ", pCell->nFanins );
+    printf( "{" );
+    for ( i = 0; i < (int)pCell->nFanins; i++ )
+        printf( "%7.2f ", pCell->Delays[i] );
+    for ( ; i < 6; i++ )
+        printf( "        " );
+    printf( " }  " );
+    for ( i = 0; i < (int)pCell->nFanins; i++ )
+        printf( "%2d ", Nf_CutConfLit(pM->Conf, i) );
+    for ( ; i < 6; i++ )
+        printf( "   " );
+    Dau_DsdPrintFromTruth( &pCell->uTruth, pCell->nFanins );
+}
+void Nf_ManCutMatchOne( Nf_Man_t * p, int iObj, int * pCut, int * pCutSet )
+{
+    Nf_Obj_t * pBest = Nf_ManObj(p, iObj);
+    int * pFans      = Nf_CutLeaves(pCut);
+    int nFans        = Nf_CutSize(pCut);
+    int iFuncLit     = Nf_CutFunc(pCut);
+    int fComplExt    = Abc_LitIsCompl(iFuncLit);
+    float Epsilon    = p->pPars->Epsilon;
+    Vec_Int_t * vArr = Vec_WecEntry( p->vTt2Match, Abc_Lit2Var(iFuncLit) );
+    int i, k, c, Info, Offset, iFanin, fComplF;
+    float ArrivalD, ArrivalA;
+    Nf_Mat_t * pD, * pA;
+    // assign fanins matches
+    Nf_Obj_t * pBestF[NF_LEAF_MAX];
+    for ( i = 0; i < nFans; i++ )
+        pBestF[i] = Nf_ManObj( p, pFans[i] );
+    // special cases
+    if ( nFans == 0 )
+    {
+        int Const = (iFuncLit == 1);
+        assert( iFuncLit == 0 || iFuncLit == 1 );
+        for ( c = 0; c < 2; c++ )
+        { 
+            pD = Nf_ObjMatchD( p, iObj, c );
+            pA = Nf_ObjMatchA( p, iObj, c );
+            pD->D = pA->D = 0;
+            pD->A = pA->A = p->pCells[c ^ Const].Area;
+            pD->CutH = pA->CutH = Nf_CutHandle(pCutSet, pCut);
+            pD->Gate = pA->Gate = c ^ Const;
+            pD->Conf = pA->Conf = 0;
+        }
+        return;
+    }
+    if ( nFans == 1 )
+    {
+        int Const = (iFuncLit == 3);
+        assert( iFuncLit == 2 || iFuncLit == 3 );
+        for ( c = 0; c < 2; c++ )
+        { 
+            pD = Nf_ObjMatchD( p, iObj, c );
+            pA = Nf_ObjMatchA( p, iObj, c );
+            pD->D = pA->D = pBestF[0]->M[c ^ !Const][0].D + p->pCells[2 + (c ^ Const)].Delays[0];
+            pD->A = pA->A = pBestF[0]->M[c ^ !Const][0].A + p->pCells[2 + (c ^ Const)].Area;
+            pD->CutH = pA->CutH = Nf_CutHandle(pCutSet, pCut);
+            pD->Gate = pA->Gate = 2 + (c ^ Const);
+            pD->Conf = pA->Conf = 0;
+        }
+        return;
+    }
+    // consider matches of this function
+    Vec_IntForEachEntryDouble( vArr, Info, Offset, i )
+    {
+        Pf_Mat_t Mat   = Pf_Int2Mat(Offset);
+        Mio_Cell_t* pC = Nf_ManCell( p, Info );
+        int fCompl     = Mat.fCompl ^ fComplExt;
+        float Required = Nf_ObjRequired( p, iObj, fCompl );
+        Nf_Mat_t * pD  = &pBest->M[fCompl][0];
+        Nf_Mat_t * pA  = &pBest->M[fCompl][1];
+        float Area = pC->Area, Delay = 0;
+        assert( nFans == (int)pC->nFanins );
+        //char * pInfo   = Vec_StrEntryP( p->vMemStore, Offset );
+//        for ( k = 0; k < nFans; k++ )
+//            pInfo[k] = (char)Abc_Var2Lit( (Mat.Perm >> (3*k)) & 7, (Mat.Phase >> k) & 1 );
+        for ( k = 0; k < nFans; k++ )
+        {
+//            iFanin    = Abc_Lit2Var((int)pInfo[k]);
+//            fComplF   = Abc_LitIsCompl((int)pInfo[k]);
+            iFanin    = (Mat.Perm >> (3*k)) & 7;
+            fComplF   = (Mat.Phase >> k) & 1;
+            ArrivalD  = pBestF[k]->M[fComplF][0].D;
+            ArrivalA  = pBestF[k]->M[fComplF][1].D;
+            if ( ArrivalA + pC->Delays[iFanin] < Required + Epsilon && Required != NF_INFINITY )
+            {
+                Delay = Abc_MaxFloat( Delay, ArrivalA + pC->Delays[iFanin] );
+                Area += pBestF[k]->M[fComplF][1].A;
+            }
+            else 
+            {
+//                    assert( ArrivalD + pC->Delays[iFanin] < Required + Epsilon );
+                if ( pD->D < NF_INFINITY && pA->D < NF_INFINITY && ArrivalD + pC->Delays[iFanin] >= Required + Epsilon )
+                    break;
+                Delay = Abc_MaxFloat( Delay, ArrivalD + pC->Delays[iFanin] );
+                Area += pBestF[k]->M[fComplF][0].A;
+            }
+        }
+        if ( k < nFans )
+            continue;
+        // select best match
+        if ( pD->D > Delay )//+ Epsilon )
+        {
+            pD->D = Delay;
+            pD->A = Area;
+            pD->CutH = Nf_CutHandle(pCutSet, pCut);
+            pD->Gate = pC->Id;
+            pD->Conf = 0;
+            for ( k = 0; k < nFans; k++ )
+//                    pD->Conf |= ((int)pInfo[k] << (k << 2));
+//                pD->Conf |= (Abc_Var2Lit(k, Abc_LitIsCompl((int)pInfo[k])) << (Abc_Lit2Var((int)pInfo[k]) << 2));
+                pD->Conf |= (Abc_Var2Lit(k, (Mat.Phase >> k) & 1) << (((Mat.Perm >> (3*k)) & 7) << 2));
+        }
+        if ( pA->A > Area )//+ Epsilon )
+        {
+            pA->D = Delay;
+            pA->A = Area;
+            pA->CutH = Nf_CutHandle(pCutSet, pCut);
+            pA->Gate = pC->Id;
+            pA->Conf = 0;
+            for ( k = 0; k < nFans; k++ )
+//                    pA->Conf |= ((int)pInfo[k] << (k << 2));
+//                pA->Conf |= (Abc_Var2Lit(k, Abc_LitIsCompl((int)pInfo[k])) << (Abc_Lit2Var((int)pInfo[k]) << 2));
+                pA->Conf |= (Abc_Var2Lit(k, (Mat.Phase >> k) & 1) << (((Mat.Perm >> (3*k)) & 7) << 2));
+        }
+    }
+/*
+    Nf_ManCutMatchPrint( p, iObj, 0, &pBest->M[0][0] );
+    Nf_ManCutMatchPrint( p, iObj, 0, &pBest->M[0][1] );
+    Nf_ManCutMatchPrint( p, iObj, 1, &pBest->M[1][0] );
+    Nf_ManCutMatchPrint( p, iObj, 1, &pBest->M[1][1] );
+*/
+}
+static inline void Nf_ObjPrepareCi( Nf_Man_t * p, int iObj )
+{
+    Nf_Mat_t * pD = Nf_ObjMatchD( p, iObj, 1 );
+    Nf_Mat_t * pA = Nf_ObjMatchA( p, iObj, 1 );
+    pD->fCompl = 1;
+    pD->D = p->InvDelay;
+    pD->A = p->InvArea;
+    pA->fCompl = 1;
+    pA->D = p->InvDelay;
+    pA->A = p->InvArea;
+    Nf_ObjMatchD( p, iObj, 0 )->fBest = 1;
+    Nf_ObjMatchD( p, iObj, 1 )->fBest = 1;
+}
+static inline void Nf_ObjPrepareBuf( Nf_Man_t * p, Gia_Obj_t * pObj )
+{
+    // get fanin info
+    int iObj = Gia_ObjId( p->pGia, pObj );
+    int iFanin = Gia_ObjFaninId0( pObj, iObj );
+    Nf_Mat_t * pDf = Nf_ObjMatchD( p, iFanin, Gia_ObjFaninC0(pObj) );
+    //Nf_Mat_t * pAf = Nf_ObjMatchA( p, iFanin, Gia_ObjFaninC0(pObj) );
+    // set the direct phase
+    Nf_Mat_t * pDp = Nf_ObjMatchD( p, iObj, 0 );
+    Nf_Mat_t * pAp = Nf_ObjMatchA( p, iObj, 0 );
+    Nf_Mat_t * pDn = Nf_ObjMatchD( p, iObj, 1 );
+    Nf_Mat_t * pAn = Nf_ObjMatchA( p, iObj, 1 );
+    assert( Gia_ObjIsBuf(pObj) );
+    memset( Nf_ManObj(p, iObj), 0, sizeof(Nf_Obj_t) );
+    // set the direct phase
+    pDp->D = pAp->D = pDf->D;
+    pDp->A = pAp->A = pDf->A; // do not pass flow???
+    pDp->fBest = 1;
+    // set the inverted phase
+    pDn->D = pAn->D = pDf->D + p->InvDelay;
+    pDn->A = pAn->A = pDf->A + p->InvArea;
+    pDn->fCompl = pAn->fCompl = 1;
+    pDn->fBest = 1;
+}
+static inline float Nf_CutRequired( Nf_Man_t * p, Nf_Mat_t * pM, int * pCutSet )
+{
+    Mio_Cell_t * pCell = Nf_ManCell( p, pM->Gate );
+    int * pCut   = Nf_CutFromHandle( pCutSet, pM->CutH );
+    int * pFans  = Nf_CutLeaves(pCut);
+    int i, nFans = Nf_CutSize(pCut);
+    float Arrival = 0, Required = 0;
+    for ( i = 0; i < nFans; i++ )
+    {
+        int iLit   = Nf_CutConfLit( pM->Conf, i );
+        int iFanin = pFans[ Abc_Lit2Var(iLit) ];
+        int fCompl = Abc_LitIsCompl( iLit );
+        float Arr  = Nf_ManObj(p, iFanin)->M[fCompl][0].D + pCell->Delays[i];
+        float Req  = Nf_ObjRequired(p, iFanin, fCompl);
+        Arrival = Abc_MaxInt( Arrival, Arr );
+        if ( Req < NF_INFINITY )
+            Required = Abc_MaxInt( Required, Req + pCell->Delays[i] );
+    }
+    return Abc_MaxFloat( Required + 2*p->InvDelay, Arrival ); 
+}
+static inline void Nf_ObjComputeRequired( Nf_Man_t * p, int iObj )
+{
+    Nf_Obj_t * pBest = Nf_ManObj(p, iObj);
+    int c, * pCutSet = Nf_ObjCutSet( p, iObj );
+    for ( c = 0; c < 2; c++ )
+        if ( Nf_ObjRequired(p, iObj, c) == NF_INFINITY )
+            Nf_ObjSetRequired( p, iObj, c, Nf_CutRequired(p, &pBest->M[c][0], pCutSet) );
+}
+void Nf_ManCutMatch( Nf_Man_t * p, int iObj )
+{
+    Nf_Obj_t * pBest = Nf_ManObj(p, iObj);
+    Nf_Mat_t * pDp = &pBest->M[0][0];
+    Nf_Mat_t * pDn = &pBest->M[1][0];
+    Nf_Mat_t * pAp = &pBest->M[0][1];
+    Nf_Mat_t * pAn = &pBest->M[1][1];
+    float FlowRefP = Nf_ObjFlowRefs(p, iObj, 0);
+    float FlowRefN = Nf_ObjFlowRefs(p, iObj, 1);
+    float Epsilon  = p->pPars->Epsilon;
+    int i, Index, * pCut, * pCutSet = Nf_ObjCutSet( p, iObj );
+    float ValueBeg[2] = {0}, ValueEnd[2] = {0}, Required[2] = {0};
+    if ( p->Iter )
+    {
+        Nf_ObjComputeRequired( p, iObj );
+        Required[0] = Nf_ObjRequired( p, iObj, 0 );
+        Required[1] = Nf_ObjRequired( p, iObj, 1 );
+    }
+    if ( p->fUseEla && Nf_ObjMapRefNum(p, iObj, 0) > 0 )
+        ValueBeg[0] = Nf_MatchDeref2_rec( p, iObj, 0, Nf_ObjMatchBest(p, iObj, 0) );
+    if ( p->fUseEla && Nf_ObjMapRefNum(p, iObj, 1) > 0 )
+        ValueBeg[1] = Nf_MatchDeref2_rec( p, iObj, 1, Nf_ObjMatchBest(p, iObj, 1) );
+    memset( pBest, 0, sizeof(Nf_Obj_t) );
+    pDp->D = pDp->A = NF_INFINITY;
+    pDn->D = pDn->A = NF_INFINITY;
+    pAp->D = pAp->A = NF_INFINITY;
+    pAn->D = pAn->A = NF_INFINITY;
+    Nf_SetForEachCut( pCutSet, pCut, i )
+    {
+        if ( Abc_Lit2Var(Nf_CutFunc(pCut)) >= Vec_WecSize(p->vTt2Match) )
+            continue;
+        assert( !Nf_CutIsTriv(pCut, iObj) );
+        assert( Nf_CutSize(pCut) <= p->pPars->nLutSize );
+        assert( Abc_Lit2Var(Nf_CutFunc(pCut)) < Vec_WecSize(p->vTt2Match) );
+        Nf_ManCutMatchOne( p, iObj, pCut, pCutSet );
+    }
+
+/*
+    if ( 18687 == iObj )
+    {
+        printf( "Obj %6d (%f %f):\n", iObj, Required[0], Required[1] );
+        Nf_ManCutMatchPrint( p, iObj, 0, &pBest->M[0][0] );
+        Nf_ManCutMatchPrint( p, iObj, 0, &pBest->M[0][1] );
+        Nf_ManCutMatchPrint( p, iObj, 1, &pBest->M[1][0] );
+        Nf_ManCutMatchPrint( p, iObj, 1, &pBest->M[1][1] );
+        printf( "\n" );
+    }
+*/
+
+    // divide by ref count
+    pDp->A /= FlowRefP;
+    pAp->A /= FlowRefP;
+    pDn->A /= FlowRefN;
+    pAn->A /= FlowRefN;
+
+    // add the inverters
+    //assert( pDp->D < NF_INFINITY || pDn->D < NF_INFINITY );
+    if ( pDp->D > pDn->D + p->InvDelay + Epsilon )
+    {
+        *pDp = *pDn;
+        pDp->D += p->InvDelay;
+        pDp->A += p->InvArea;
+        pDp->fCompl = 1;
+        if ( pAp->D == NF_INFINITY )
+            *pAp = *pDp;
+        //printf( "Using inverter to improve delay at node %d in phase %d.\n", iObj, 1 );
+    }
+    else if ( pDn->D > pDp->D + p->InvDelay + Epsilon )
+    {
+        *pDn = *pDp;
+        pDn->D += p->InvDelay;
+        pDn->A += p->InvArea;
+        pDn->fCompl = 1;
+        if ( pAn->D == NF_INFINITY )
+            *pAn = *pDn;
+        //printf( "Using inverter to improve delay at node %d in phase %d.\n", iObj, 0 );
+    }
+    //assert( pAp->A < NF_INFINITY || pAn->A < NF_INFINITY );
+    // try replacing pos with neg
+    if ( pAp->D == NF_INFINITY || (pAp->A > pAn->A + p->InvArea + Epsilon && pAn->D + p->InvDelay + Epsilon < Required[1]) )
+    {
+        assert( p->Iter > 0 );
+        *pAp = *pAn;
+        pAp->D += p->InvDelay;
+        pAp->A += p->InvArea;
+        pAp->fCompl = 1;
+        if ( pDp->D == NF_INFINITY )
+            *pDp = *pAp;
+        //printf( "Using inverter to improve area at node %d in phase %d.\n", iObj, 1 );
+    }
+    // try replacing neg with pos
+    else if ( pAn->D == NF_INFINITY || (pAn->A > pAp->A + p->InvArea + Epsilon && pAp->D + p->InvDelay + Epsilon < Required[0]) )
+    {
+        assert( p->Iter > 0 );
+        *pAn = *pAp;
+        pAn->D += p->InvDelay;
+        pAn->A += p->InvArea;
+        pAn->fCompl = 1;
+        if ( pDn->D == NF_INFINITY )
+            *pDn = *pAn;
+        //printf( "Using inverter to improve area at node %d in phase %d.\n", iObj, 0 );
+    }
+
+    if ( pDp->D == NF_INFINITY )
+        printf( "Object %d has pDp unassigned.\n", iObj );
+    if ( pDn->D == NF_INFINITY )
+        printf( "Object %d has pDn unassigned.\n", iObj );
+    if ( pAp->D == NF_INFINITY )
+        printf( "Object %d has pAp unassigned.\n", iObj );
+    if ( pAn->D == NF_INFINITY )
+        printf( "Object %d has pAn unassigned.\n", iObj );
+
+    pDp->A = Abc_MinFloat( pDp->A, NF_INFINITY/1000000 );
+    pDn->A = Abc_MinFloat( pDn->A, NF_INFINITY/1000000 );
+    pAp->A = Abc_MinFloat( pAp->A, NF_INFINITY/1000000 );  
+    pAn->A = Abc_MinFloat( pAn->A, NF_INFINITY/1000000 );
+    
+    assert( pDp->D < NF_INFINITY );
+    assert( pDn->D < NF_INFINITY );
+    assert( pAp->D < NF_INFINITY );
+    assert( pAn->D < NF_INFINITY );
+
+    assert( pDp->A < NF_INFINITY );
+    assert( pDn->A < NF_INFINITY );
+    assert( pAp->A < NF_INFINITY );
+    assert( pAn->A < NF_INFINITY );
+
+    //printf( "%16f  %16f   %16f  %16f\n", pDp->A, pDn->A, pAp->A, pAn->A );
+//    assert ( pDp->A < 1000 );
+
+    if ( p->fUseEla )
+    {
+        // set the first good cut
+        Index = (pAp->D != NF_INFINITY && pAp->D < Nf_ObjRequired(p, iObj, 0) + Epsilon);
+        assert( !pDp->fBest && !pAp->fBest );
+        pBest->M[0][Index].fBest = 1;
+        assert( pDp->fBest != pAp->fBest );
+        // set the second good cut
+        Index = (pAn->D != NF_INFINITY && pAn->D < Nf_ObjRequired(p, iObj, 1) + Epsilon);
+        assert( !pDn->fBest && !pAn->fBest );
+        pBest->M[1][Index].fBest = 1;
+        assert( pDn->fBest != pAn->fBest );
+        // reference if needed
+        if ( Nf_ObjMapRefNum(p, iObj, 0) > 0 )
+            ValueEnd[0] = Nf_MatchRef2_rec( p, iObj, 0, Nf_ObjMatchBest(p, iObj, 0), NULL );
+        if ( Nf_ObjMapRefNum(p, iObj, 1) > 0 )
+            ValueEnd[1] = Nf_MatchRef2_rec( p, iObj, 1, Nf_ObjMatchBest(p, iObj, 1), NULL );
+//        assert( ValueBeg[0] > ValueEnd[0] - Epsilon );
+//        assert( ValueBeg[1] > ValueEnd[1] - Epsilon );
+    }
+}
+void Nf_ManComputeMapping( Nf_Man_t * p )
+{
+    Gia_Obj_t * pObj; int i;
+    Gia_ManForEachAnd( p->pGia, pObj, i )
+        if ( Gia_ObjIsBuf(pObj) )
+            Nf_ObjPrepareBuf( p, pObj );
+        else
+            Nf_ManCutMatch( p, i );
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Nf_ManSetMapRefsGate( Nf_Man_t * p, int iObj, float Required, Nf_Mat_t * pM )
+{
+    int k, iVar, fCompl;
+    Mio_Cell_t * pCell = Nf_ManCell( p, pM->Gate );
+    int * pCut = Nf_CutFromHandle( Nf_ObjCutSet(p, iObj), pM->CutH );
+    Nf_CutForEachVar( pCut, pM->Conf, iVar, fCompl, k )
+    {
+        Nf_ObjMapRefInc( p, iVar, fCompl );
+        Nf_ObjUpdateRequired( p, iVar, fCompl, Required - pCell->Delays[k] );
+    }
+    assert( Nf_CutSize(pCut) == (int)pCell->nFanins );
+    // update global stats
+    p->pPars->MapArea += pCell->Area;
+    p->pPars->Edge += Nf_CutSize(pCut);
+    p->pPars->Area++;
+    // update status of the gate
+    assert( pM->fBest == 0 );
+    pM->fBest = 1;
+}
+int Nf_ManSetMapRefs( Nf_Man_t * p )
+{
+    float Coef = 1.0 / (1.0 + (p->Iter + 1) * (p->Iter + 1));
+    float * pFlowRefs = Vec_FltArray( &p->vFlowRefs );
+    int * pMapRefs = Vec_IntArray( &p->vMapRefs );
+    float Epsilon = p->pPars->Epsilon;
+    int nLits = 2*Gia_ManObjNum(p->pGia);
+    int i, c, Id, nRefs[2];
+    Nf_Mat_t * pD, * pA, * pM;
+    Nf_Mat_t * pDs[2], * pAs[2], * pMs[2];
+    Gia_Obj_t * pObj;
+    float Required = 0, Requireds[2];
+    // check references
+    assert( !p->fUseEla );
+    memset( pMapRefs, 0, sizeof(int) * nLits );
+    Vec_FltFill( &p->vRequired, nLits, NF_INFINITY );
+//    for ( i = 0; i < Gia_ManObjNum(p->pGia); i++ )
+//        assert( !Nf_ObjMapRefNum(p, i, 0) && !Nf_ObjMapRefNum(p, i, 1) );
+    // compute delay
+    p->pPars->MapDelay = 0;
+    Gia_ManForEachCo( p->pGia, pObj, i )
+    {
+        Required = Nf_ObjMatchD( p, Gia_ObjFaninId0p(p->pGia, pObj), Gia_ObjFaninC0(pObj) )->D;
+        if ( Required == NF_INFINITY )
+        {
+            Nf_ManCutMatchPrint( p, Gia_ObjFaninId0p(p->pGia, pObj), Gia_ObjFaninC0(pObj), Nf_ObjMatchD( p, Gia_ObjFaninId0p(p->pGia, pObj), Gia_ObjFaninC0(pObj) ) );
+        }
+        p->pPars->MapDelay = Abc_MaxFloat( p->pPars->MapDelay, Required );
+    }
+    // check delay target
+    if ( p->pPars->MapDelayTarget == -1 && p->pPars->nRelaxRatio )
+        p->pPars->MapDelayTarget = (int)((float)p->pPars->MapDelay * (100.0 + p->pPars->nRelaxRatio) / 100.0);
+    if ( p->pPars->MapDelayTarget != -1 )
+    {
+        if ( p->pPars->MapDelay < p->pPars->MapDelayTarget + Epsilon )
+            p->pPars->MapDelay = p->pPars->MapDelayTarget;
+        else if ( p->pPars->nRelaxRatio == 0 )
+            Abc_Print( 0, "Relaxing user-specified delay target from %.2f to %.2f.\n", p->pPars->MapDelayTarget, p->pPars->MapDelay );
+    }
+    // set required times
+    Gia_ManForEachCo( p->pGia, pObj, i )
+    {
+        Required = Nf_ObjMatchD( p, Gia_ObjFaninId0p(p->pGia, pObj), Gia_ObjFaninC0(pObj) )->D;
+        Required = p->pPars->fDoAverage ? Required * (100.0 + p->pPars->nRelaxRatio) / 100.0 : p->pPars->MapDelay;
+        Nf_ObjUpdateRequired( p, Gia_ObjFaninId0p(p->pGia, pObj), Gia_ObjFaninC0(pObj), Required );
+        Nf_ObjMapRefInc( p, Gia_ObjFaninId0p(p->pGia, pObj), Gia_ObjFaninC0(pObj));
+    }
+    // compute area and edges
+    p->nInvs = 0;
+    p->pPars->MapArea = 0; 
+    p->pPars->Area = p->pPars->Edge = 0;
+    Gia_ManForEachAndReverse( p->pGia, pObj, i )
+    {
+        if ( Gia_ObjIsBuf(pObj) )
+        {
+            if ( Nf_ObjMapRefNum(p, i, 1) )
+            {
+                Nf_ObjMapRefInc( p, i, 0 );
+                Nf_ObjUpdateRequired( p, i, 0, Nf_ObjRequired(p, i, 1) - p->InvDelay );
+                p->pPars->MapArea += p->InvArea;
+                p->pPars->Edge++;
+                p->pPars->Area++;
+                p->nInvs++;
+            }
+            Nf_ObjUpdateRequired( p, Gia_ObjFaninId0(pObj, i), Gia_ObjFaninC0(pObj), Nf_ObjRequired(p, i, 0) );
+            Nf_ObjMapRefInc( p, Gia_ObjFaninId0(pObj, i), Gia_ObjFaninC0(pObj));
+            continue;
+        }
+        // skip if this node is not used
+        for ( c = 0; c < 2; c++ )
+        {
+            nRefs[c] = Nf_ObjMapRefNum(p, i, c);
+
+            //if ( Nf_ObjMatchD( p, i, c )->fCompl )
+            //    printf( "Match D of node %d has inv in phase %d.\n", i, c );
+            //if ( Nf_ObjMatchA( p, i, c )->fCompl )
+            //    printf( "Match A of node %d has inv in phase %d.\n", i, c );
+        }
+        if ( !nRefs[0] && !nRefs[1] )
+            continue;
+
+        // consider two cases
+        if ( nRefs[0] && nRefs[1] )
+        {
+            // find best matches for both phases
+            for ( c = 0; c < 2; c++ )
+            {
+                Requireds[c] = Nf_ObjRequired( p, i, c );
+                //assert( Requireds[c] < NF_INFINITY );
+                pDs[c] = Nf_ObjMatchD( p, i, c );
+                pAs[c] = Nf_ObjMatchA( p, i, c );
+                pMs[c] = (pAs[c]->D < Requireds[c] + Epsilon) ? pAs[c] : pDs[c];
+            }
+            // swap complemented matches
+            if ( pMs[0]->fCompl && pMs[1]->fCompl )
+            {
+                pMs[0]->fCompl = pMs[1]->fCompl = 0;
+                ABC_SWAP( Nf_Mat_t *, pMs[0], pMs[1] );
+            }
+            // check if intervers are involved
+            if ( !pMs[0]->fCompl && !pMs[1]->fCompl )
+            {
+                // no inverters
+                for ( c = 0; c < 2; c++ )
+                    Nf_ManSetMapRefsGate( p, i, Requireds[c], pMs[c] );
+            }
+            else 
+            {
+                // one interver
+                assert( !pMs[0]->fCompl || !pMs[1]->fCompl );
+                c = pMs[1]->fCompl;
+                assert( pMs[c]->fCompl && !pMs[!c]->fCompl );
+                //printf( "Using inverter at node %d in phase %d\n", i, c );
+
+                // update this phase phase
+                pM = pMs[c];
+                pM->fBest = 1;
+                Required = Requireds[c];
+
+                // update opposite phase
+                Nf_ObjMapRefInc( p, i, !c );
+                Nf_ObjUpdateRequired( p, i, !c, Required - p->InvDelay );
+
+                // select oppositve phase
+                Required = Nf_ObjRequired( p, i, !c );
+                //assert( Required < NF_INFINITY );
+                pD = Nf_ObjMatchD( p, i, !c );
+                pA = Nf_ObjMatchA( p, i, !c );
+                pM = (pA->D < Required + Epsilon) ? pA : pD;
+                assert( !pM->fCompl );
+
+                // account for the inverter
+                p->pPars->MapArea += p->InvArea;
+                p->pPars->Edge++;
+                p->pPars->Area++;
+                p->nInvs++;
+
+                // create gate
+                Nf_ManSetMapRefsGate( p, i, Required, pM );
+            }
+        }
+        else
+        {
+            c = (int)(nRefs[1] > 0);
+            assert( nRefs[c] && !nRefs[!c] );
+            // consider this phase
+            Required = Nf_ObjRequired( p, i, c );
+            //assert( Required < NF_INFINITY );
+            pD = Nf_ObjMatchD( p, i, c );
+            pA = Nf_ObjMatchA( p, i, c );
+            pM = (pA->D < Required + Epsilon) ? pA : pD;
+
+            if ( pM->fCompl ) // use inverter
+            {
+                p->nInvs++;
+                //printf( "Using inverter at node %d in phase %d\n", i, c );
+                pM->fBest = 1;
+                // update opposite phase
+                Nf_ObjMapRefInc( p, i, !c );
+                Nf_ObjUpdateRequired( p, i, !c, Required - p->InvDelay );
+                // select oppositve phase
+                Required = Nf_ObjRequired( p, i, !c );
+                //assert( Required < NF_INFINITY );
+                pD = Nf_ObjMatchD( p, i, !c );
+                pA = Nf_ObjMatchA( p, i, !c );
+                pM = (pA->D < Required + Epsilon) ? pA : pD;
+                assert( !pM->fCompl );
+
+                // account for the inverter
+                p->pPars->MapArea += p->InvArea;
+                p->pPars->Edge++;
+                p->pPars->Area++;
+            }
+
+            // create gate
+            Nf_ManSetMapRefsGate( p, i, Required, pM );
+        }
+
+
+        // the result of this:
+        // - only one phase can be implemented as inverter of the other phase
+        // - required times are propagated correctly
+        // - references are set correctly
+    }
+    Gia_ManForEachCiId( p->pGia, Id, i )
+        if ( Nf_ObjMapRefNum(p, Id, 1) )
+        {
+            Nf_ObjMapRefInc( p, Id, 0 );
+            Nf_ObjUpdateRequired( p, Id, 0, Required - p->InvDelay );
+            p->pPars->MapArea += p->InvArea;
+            p->pPars->Edge++;
+            p->pPars->Area++;
+            p->nInvs++;
+        }
+    // blend references
+    for ( i = 0; i < nLits; i++ )
+//        pFlowRefs[i] = Abc_MaxFloat(1.0, pMapRefs[i]);
+        pFlowRefs[i] = Abc_MaxFloat(1.0, Coef * pFlowRefs[i] + (1.0 - Coef) * Abc_MaxFloat(1, pMapRefs[i]));
+//        pFlowRefs[i] = 0.2 * pFlowRefs[i] + 0.8 * Abc_MaxFloat(1, pMapRefs[i]);
+//    memset( pMapRefs, 0, sizeof(int) * nLits );
+    return p->pPars->Area;
+}
+Gia_Man_t * Nf_ManDeriveMapping( Nf_Man_t * p )
+{
+    Vec_Int_t * vMapping;
+    Nf_Mat_t * pM;
+    int i, k, c, Id, iLit, * pCut;
+    assert( p->pGia->vCellMapping == NULL );
+    vMapping = Vec_IntAlloc( 2*Gia_ManObjNum(p->pGia) + (int)p->pPars->Edge + (int)p->pPars->Area * 2 );
+    Vec_IntFill( vMapping, 2*Gia_ManObjNum(p->pGia), 0 );
+    // create CI inverters
+    Gia_ManForEachCiId( p->pGia, Id, i )
+    if ( Nf_ObjMapRefNum(p, Id, 1) )
+        Vec_IntWriteEntry( vMapping, Abc_Var2Lit(Id, 1), -1 );
+    // create internal nodes
+    Gia_ManForEachAndId( p->pGia, i )
+    {
+        Gia_Obj_t * pObj = Gia_ManObj(p->pGia, i);
+        if ( Gia_ObjIsBuf(pObj) )
+        {
+            if ( Nf_ObjMapRefNum(p, i, 1) )
+                Vec_IntWriteEntry( vMapping, Abc_Var2Lit(i, 1), -1 );
+            Vec_IntWriteEntry( vMapping, Abc_Var2Lit(i, 0), -2 );
+            continue;
+        }
+        for ( c = 0; c < 2; c++ )
+        if ( Nf_ObjMapRefNum(p, i, c) )
+        {
+    //        printf( "Using %d %d\n", i, c );
+            pM = Nf_ObjMatchBest( p, i, c );
+            // remember inverter
+            if ( pM->fCompl )
+            {
+                Vec_IntWriteEntry( vMapping, Abc_Var2Lit(i, c), -1 );
+                continue;
+            }
+    //        Nf_ManCutMatchPrint( p, i, c, pM );
+            pCut = Nf_CutFromHandle( Nf_ObjCutSet(p, i), pM->CutH );
+            // create mapping
+            Vec_IntWriteEntry( vMapping, Abc_Var2Lit(i, c), Vec_IntSize(vMapping) );
+            Vec_IntPush( vMapping, Nf_CutSize(pCut) );
+            Nf_CutForEachLit( pCut, pM->Conf, iLit, k )
+                Vec_IntPush( vMapping, iLit );
+            Vec_IntPush( vMapping, pM->Gate );
+        }
+    }
+//    assert( Vec_IntCap(vMapping) == 16 || Vec_IntSize(vMapping) == Vec_IntCap(vMapping) );
+    p->pGia->vCellMapping = vMapping;
+    return p->pGia;
+}
+void Nf_ManUpdateStats( Nf_Man_t * p )
+{
+    Nf_Mat_t * pM;
+    Gia_Obj_t * pObj;
+    Mio_Cell_t * pCell;
+    int i, c, Id, * pCut;
+    p->pPars->MapDelay = 0;
+    Gia_ManForEachCo( p->pGia, pObj, i )
+    {
+        float Delay = Nf_ObjMatchD( p, Gia_ObjFaninId0p(p->pGia, pObj), Gia_ObjFaninC0(pObj) )->D;
+        p->pPars->MapDelay = Abc_MaxFloat( p->pPars->MapDelay, Delay );
+    }
+    p->pPars->MapArea = 0; 
+    p->pPars->Area = p->pPars->Edge = 0;
+    Gia_ManForEachAndId( p->pGia, i )
+    for ( c = 0; c < 2; c++ )
+    if ( Nf_ObjMapRefNum(p, i, c) )
+    {
+        pM = Nf_ObjMatchBest( p, i, c );
+        pCut = Nf_CutFromHandle( Nf_ObjCutSet(p, i), pM->CutH );
+        pCell = Nf_ManCell( p, pM->Gate );
+        assert( Nf_CutSize(pCut) == (int)pCell->nFanins );
+        p->pPars->MapArea += pCell->Area;
+        p->pPars->Edge += Nf_CutSize(pCut);
+        p->pPars->Area++;
+    }
+    Gia_ManForEachCiId( p->pGia, Id, i )
+        if ( Nf_ObjMapRefNum(p, Id, 1) )
+        {
+            p->pPars->MapArea += p->InvArea;
+            p->pPars->Edge++;
+            p->pPars->Area++;
+        }
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Technology mappping.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+
+/*
+static inline Nf_Mat_t *  Nf_ObjMatchBestReq( Nf_Man_t * p, int i, int c, float r ) 
+{ 
+    Nf_Mat_t * pD = Nf_ObjMatchD(p, i, c);
+    Nf_Mat_t * pA = Nf_ObjMatchA(p, i, c);
+    assert( !pD->fBest && !pA->fBest );
+    assert( Nf_ObjMapRefNum(p, i, c) == 0 );
+    if ( pA->D < r + p->pPars->Epsilon )
+        return pA;
+    return pD;
+}
+float Nf_MatchDeref_rec( Nf_Man_t * p, int i, int c, Nf_Mat_t * pM )
+{
+    int k, iVar, fCompl, * pCut;
+    float Area = 0;
+    int Value = pM->fBest;
+    pM->fBest = 0;
+    if ( pM->fCompl )
+    {
+        assert( Nf_ObjMapRefNum(p, i, !c) > 0 );
+        if ( !Nf_ObjMapRefDec(p, i, !c) )
+            Area += Nf_MatchDeref_rec( p, i, !c, Nf_ObjMatchBest(p, i, !c) );
+        return Area + p->InvArea;
+    }
+    if ( Nf_ObjCutSetId(p, i) == 0 )
+        return 0;
+    assert( Value == 1 );
+    pCut = Nf_CutFromHandle( Nf_ObjCutSet(p, i), pM->CutH );
+    Nf_CutForEachVar( pCut, pM->Conf, iVar, fCompl, k )
+    {
+        assert( Nf_ObjMapRefNum(p, iVar, fCompl) > 0 );
+        if ( !Nf_ObjMapRefDec(p, iVar, fCompl) )
+            Area += Nf_MatchDeref_rec( p, iVar, fCompl, Nf_ObjMatchBest(p, iVar, fCompl) );
+    }
+    return Area + Nf_ManCell(p, pM->Gate)->Area;
+}
+float Nf_MatchRef_rec( Nf_Man_t * p, int i, int c, Nf_Mat_t * pM, float Required, Vec_Int_t * vBackup )
+{
+    int k, iVar, fCompl, * pCut;
+    float ReqFanin, Area = 0;
+    assert( pM->fBest == 0 );
+    if ( vBackup == NULL )
+        pM->fBest = 1;
+    if ( pM->fCompl )
+    {
+        ReqFanin = Required - p->InvDelay;
+        if ( vBackup )
+            Vec_IntPush( vBackup, Abc_Var2Lit(i, !c) );
+        assert( Nf_ObjMapRefNum(p, i, !c) >= 0 );
+        if ( !Nf_ObjMapRefInc(p, i, !c) )
+            Area += Nf_MatchRef_rec( p, i, !c, Nf_ObjMatchBestReq(p, i, !c, ReqFanin), ReqFanin, vBackup );
+        return Area + p->InvArea;
+    }
+    if ( Nf_ObjCutSetId(p, i) == 0 )
+        return 0;
+    pCut = Nf_CutFromHandle( Nf_ObjCutSet(p, i), pM->CutH );
+    Nf_CutForEachVar( pCut, pM->Conf, iVar, fCompl, k )
+    {
+        ReqFanin = Required - Nf_ManCell(p, pM->Gate)->Delays[k];
+        if ( vBackup )
+            Vec_IntPush( vBackup, Abc_Var2Lit(iVar, fCompl) );
+        assert( Nf_ObjMapRefNum(p, iVar, fCompl) >= 0 );
+        if ( !Nf_ObjMapRefInc(p, iVar, fCompl) )
+            Area += Nf_MatchRef_rec( p, iVar, fCompl, Nf_ObjMatchBestReq(p, iVar, fCompl, ReqFanin), ReqFanin, vBackup );
+    }
+    return Area + Nf_ManCell(p, pM->Gate)->Area;
+}
+float Nf_MatchRefArea( Nf_Man_t * p, int i, int c, Nf_Mat_t * pM, float Required )
+{
+    float Area;  int iLit, k; 
+    Vec_IntClear( &p->vBackup );
+    Area = Nf_MatchRef_rec( p, i, c, pM, Required, &p->vBackup );
+    Vec_IntForEachEntry( &p->vBackup, iLit, k )
+    {
+        assert( Nf_ObjMapRefNum(p, Abc_Lit2Var(iLit), Abc_LitIsCompl(iLit)) > 0 );
+        Nf_ObjMapRefDec( p, Abc_Lit2Var(iLit), Abc_LitIsCompl(iLit) );
+    }
+    return Area;
+}
+void Nf_ManElaBestMatchOne( Nf_Man_t * p, int iObj, int c, int * pCut, int * pCutSet, Nf_Mat_t * pRes, float Required )
+{
+    Nf_Mat_t Mb, * pMb = &Mb;
+    Nf_Obj_t * pBest = Nf_ManObj(p, iObj);
+    int * pFans      = Nf_CutLeaves(pCut);
+    int nFans        = Nf_CutSize(pCut);
+    int iFuncLit     = Nf_CutFunc(pCut);
+    int fComplExt    = Abc_LitIsCompl(iFuncLit);
+    float Epsilon    = p->pPars->Epsilon;
+    Vec_Int_t * vArr = Vec_WecEntry( p->vTt2Match, Abc_Lit2Var(iFuncLit) );
+    int i, k, Info, Offset, iFanin, fComplF;
+    float ArrivalD, ArrivalA;
+    // assign fanins matches
+    Nf_Obj_t * pBestF[NF_LEAF_MAX];
+    for ( i = 0; i < nFans; i++ )
+        pBestF[i] = Nf_ManObj( p, pFans[i] );
+    // special cases
+    if ( nFans < 2 )
+    {
+        *pRes = *Nf_ObjMatchBestReq( p, iObj, c, Required );
+        return;
+    }
+    // consider matches of this function
+    memset( pMb, 0, sizeof(Nf_Mat_t) );
+    pMb->D = pMb->A = NF_INFINITY;
+    Vec_IntForEachEntryDouble( vArr, Info, Offset, i )
+    {
+        Mio_Cell_t* pC = Nf_ManCell( p, Info >> 8 );
+        int Type       = (Info >> 4) & 15;
+        int fCompl     = (Info & 1) ^ fComplExt;
+        char * pInfo   = Vec_StrEntryP( p->vMemStore, Offset );
+        Nf_Mat_t * pD  = &pBest->M[fCompl][0];
+        Nf_Mat_t * pA  = &pBest->M[fCompl][1];
+        assert( nFans == (int)pC->nFanins );
+        if ( fCompl != c )
+            continue;
+        if ( Type == NF_PRIME )
+        {
+            float Delay = 0;
+            for ( k = 0; k < nFans; k++ )
+            {
+                iFanin    = Abc_Lit2Var((int)pInfo[k]);
+                fComplF   = Abc_LitIsCompl((int)pInfo[k]);
+                ArrivalD  = pBestF[k]->M[fComplF][0].D;
+                ArrivalA  = pBestF[k]->M[fComplF][1].D;
+                if ( ArrivalA + pC->Delays[iFanin] < Required + Epsilon && Required != NF_INFINITY )
+                    Delay = Abc_MaxFloat( Delay, ArrivalA + pC->Delays[iFanin] );
+                else 
+                    Delay = Abc_MaxFloat( Delay, ArrivalD + pC->Delays[iFanin] );
+                if ( Delay > Required + Epsilon )
+                    break;
+            }
+            if ( k < nFans )
+                continue;
+            // create match
+            pMb->D = Delay;
+            pMb->A = -1;
+            pMb->CutH = Nf_CutHandle(pCutSet, pCut);
+            pMb->Gate = pC->Id;
+            pMb->Conf = 0;
+            for ( k = 0; k < nFans; k++ )
+//             pD->Conf |= ((int)pInfo[k] << (k << 2));
+                pMb->Conf |= (Abc_Var2Lit(k, Abc_LitIsCompl((int)pInfo[k])) << (Abc_Lit2Var((int)pInfo[k]) << 2));
+            // compute area
+            pMb->A = Nf_MatchRefArea( p, iObj, c, pMb, Required );
+            // compare
+            if ( pRes->A > pMb->A + Epsilon || (pRes->A == pMb->A && pRes->D > pMb->D + Epsilon) )
+                *pRes = *pMb;
+        }
+    }
+}
+void Nf_ManElaBestMatch( Nf_Man_t * p, int iObj, int c, Nf_Mat_t * pRes, float Required )
+{
+    int k, * pCut, * pCutSet = Nf_ObjCutSet( p, iObj );
+    memset( pRes, 0, sizeof(Nf_Mat_t) );
+    pRes->D = pRes->A = NF_INFINITY;
+    Nf_SetForEachCut( pCutSet, pCut, k )
+    {
+        if ( Abc_Lit2Var(Nf_CutFunc(pCut)) >= Vec_WecSize(p->vTt2Match) )
+            continue;
+        Nf_ManElaBestMatchOne( p, iObj, c, pCut, pCutSet, pRes, Required );
+    }
+}
+// the best match is stored in pA provided that it satisfies pA->D < req
+// area is never compared
+void Nf_ManComputeMappingEla( Nf_Man_t * p )
+{
+    Gia_Obj_t * pObj;
+    Mio_Cell_t * pCell;
+    Nf_Mat_t Mb, * pMb = &Mb, * pM;
+    float Epsilon = p->pPars->Epsilon;
+    float AreaBef, AreaAft, Required, MapArea;
+    int nLits = 2*Gia_ManObjNum(p->pGia);
+    int i, c, iVar, Id, fCompl, k, * pCut;
+    Vec_FltFill( &p->vRequired, nLits, NF_INFINITY );
+    // compute delay
+    p->pPars->MapDelay = 0;
+    Gia_ManForEachCo( p->pGia, pObj, i )
+    {
+        Required = Nf_ObjMatchD( p, Gia_ObjFaninId0p(p->pGia, pObj), Gia_ObjFaninC0(pObj) )->D;
+        p->pPars->MapDelay = Abc_MaxFloat( p->pPars->MapDelay, Required );
+    }
+    // check delay target
+    if ( p->pPars->MapDelayTarget == -1 && p->pPars->nRelaxRatio )
+        p->pPars->MapDelayTarget = (int)((float)p->pPars->MapDelay * (100.0 + p->pPars->nRelaxRatio) / 100.0);
+    if ( p->pPars->MapDelayTarget != -1 )
+    {
+        if ( p->pPars->MapDelay < p->pPars->MapDelayTarget + Epsilon )
+            p->pPars->MapDelay = p->pPars->MapDelayTarget;
+        else if ( p->pPars->nRelaxRatio == 0 )
+            Abc_Print( 0, "Relaxing user-specified delay target from %.2f to %.2f.\n", p->pPars->MapDelayTarget, p->pPars->MapDelay );
+    }
+    // set required times
+    Gia_ManForEachCo( p->pGia, pObj, i )
+    {
+        Required = Nf_ObjMatchD( p, Gia_ObjFaninId0p(p->pGia, pObj), Gia_ObjFaninC0(pObj) )->D;
+        Required = p->pPars->fDoAverage ? Required * (100.0 + p->pPars->nRelaxRatio) / 100.0 : p->pPars->MapDelay;
+        Nf_ObjUpdateRequired( p, Gia_ObjFaninId0p(p->pGia, pObj), Gia_ObjFaninC0(pObj), Required );
+        Nf_ObjMapRefInc( p, Gia_ObjFaninId0p(p->pGia, pObj), Gia_ObjFaninC0(pObj));
+    }
+    // compute area and edges
+    MapArea = p->pPars->MapArea;
+    p->pPars->MapArea = 0; 
+    p->pPars->Area = p->pPars->Edge = 0;
+    Gia_ManForEachAndReverseId( p->pGia, i )
+    for ( c = 0; c < 2; c++ )
+    if ( Nf_ObjMapRefNum(p, i, c) )
+    {
+        pM = Nf_ObjMatchBest( p, i, c );
+        Required = Nf_ObjRequired( p, i, c );
+        assert( pM->D < Required + Epsilon );
+        // try different cuts at this node and find best match
+        Vec_IntClear( &p->vBackup2 );
+        AreaBef = Nf_MatchDeref_rec( p, i, c, pM );
+        Nf_ManElaBestMatch( p, i, c, pMb, Required );
+        AreaAft = Nf_MatchRef_rec( p, i, c, pMb, Required, NULL );
+        assert( pMb->A == AreaAft );
+        assert( AreaBef + Epsilon > AreaAft );
+        MapArea += AreaAft - AreaBef;
+//        printf( "%8.2f %8.2f\n", AreaBef, AreaAft );
+        // set match
+        assert( pMb->D < Required + Epsilon );
+        assert( pMb->fBest == 0 );
+        *Nf_ObjMatchA(p, i, c) = *pMb;
+        assert( Nf_ObjMatchA(p, i, c) == Nf_ObjMatchBest( p, i, c ) );
+        // count status
+        pCell = Nf_ManCell( p, pMb->Gate );
+        pCut = Nf_CutFromHandle( Nf_ObjCutSet(p, i), pMb->CutH );
+        Nf_CutForEachVar( pCut, pMb->Conf, iVar, fCompl, k )
+            Nf_ObjUpdateRequired( p, iVar, fCompl, Required - pCell->Delays[k] );
+        p->pPars->MapArea += pCell->Area;
+        p->pPars->Edge += Nf_CutSize(pCut);
+        p->pPars->Area++;
+    }
+    Gia_ManForEachCiId( p->pGia, Id, i )
+        if ( Nf_ObjMapRefNum(p, Id, 1) )
+        {
+            Nf_ObjMapRefInc( p, Id, 0 );
+            Nf_ObjUpdateRequired( p, Id, 0, Required - p->InvDelay );
+            p->pPars->MapArea += p->InvArea;
+            p->pPars->Edge++;
+            p->pPars->Area++;
+        }
+//    Nf_ManUpdateStats( p );
+    if ( !(MapArea < p->pPars->MapArea + Epsilon && MapArea + Epsilon > p->pPars->MapArea) )
+        printf( "Mismatch:  Estimated = %.2f  Real = %.2f\n", MapArea, p->pPars->MapArea );
+//    assert( MapArea < p->pPars->MapArea + Epsilon && MapArea + Epsilon > p->pPars->MapArea );
+    Nf_ManPrintStats( p, "Ela  " );
+}
+*/
+
+/**Function*************************************************************
+
+  Synopsis    [Technology mappping.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Nf_ManSetDefaultPars( Jf_Par_t * pPars )
+{
+    memset( pPars, 0, sizeof(Jf_Par_t) );
+    pPars->nLutSize     =  6;
+    pPars->nCutNum      = 16;
+    pPars->nProcNum     =  0;
+    pPars->nRounds      =  3;
+    pPars->nRoundsEla   =  3;
+    pPars->nRelaxRatio  =  0;
+    pPars->nCoarseLimit =  3;
+    pPars->nAreaTuner   =  1;
+    pPars->nVerbLimit   =  5;
+    pPars->DelayTarget  = -1;
+    pPars->fAreaOnly    =  0;
+    pPars->fPinPerm     =  0;
+    pPars->fOptEdge     =  1; 
+    pPars->fCoarsen     =  0;
+    pPars->fCutMin      =  1;
+    pPars->fGenCnf      =  0;
+    pPars->fPureAig     =  0;
+    pPars->fVerbose     =  0;
+    pPars->fVeryVerbose =  0;
+    pPars->nLutSizeMax  =  NF_LEAF_MAX;
+    pPars->nCutNumMax   =  NF_CUT_MAX;
+    pPars->MapDelayTarget = -1;
+    pPars->Epsilon      = (float)0.01;
+}
+Gia_Man_t * Nf_ManPerformMapping( Gia_Man_t * pGia, Jf_Par_t * pPars )
+{
+    Gia_Man_t * pNew = NULL, * pCls;
+    Nf_Man_t * p; int i, Id;
+    if ( Gia_ManHasChoices(pGia) )
+        pPars->fCoarsen = 0; 
+    pCls = pPars->fCoarsen ? Gia_ManDupMuxes(pGia, pPars->nCoarseLimit) : pGia;
+    p = Nf_StoCreate( pCls, pPars );
+//    if ( pPars->fVeryVerbose )
+//        Nf_StoPrint( p, pPars->fVeryVerbose );
+    if ( pPars->fVerbose && pPars->fCoarsen )
+    {
+        printf( "Initial " );  Gia_ManPrintMuxStats( pGia );  printf( "\n" );
+        printf( "Derived " );  Gia_ManPrintMuxStats( pCls );  printf( "\n" );
+    }
+    Nf_ManPrintInit( p );
+    Nf_ManComputeCuts( p );
+    Nf_ManPrintQuit( p );
+    Gia_ManForEachCiId( p->pGia, Id, i )
+        Nf_ObjPrepareCi( p, Id );
+    for ( p->Iter = 0; p->Iter < p->pPars->nRounds; p->Iter++ )
+    {
+        Nf_ManComputeMapping( p );
+        Nf_ManSetMapRefs( p );
+        Nf_ManPrintStats( p, p->Iter ? "Area " : "Delay" );
+    }
+/*
+    p->fUseEla = 1;
+    for ( ; p->Iter < p->pPars->nRounds + pPars->nRoundsEla; p->Iter++ )
+    {
+        Nf_ManComputeMapping( p );
+        Nf_ManUpdateStats( p );
+        Nf_ManPrintStats( p, "Ela  " );
+    }
+*/
+    pNew = Nf_ManDeriveMapping( p );
+//    Gia_ManMappingVerify( pNew );
+    Nf_StoDelete( p );
+    if ( pCls != pGia )
+        Gia_ManStop( pCls );
+    if ( pNew == NULL )
+        return Gia_ManDup( pGia );
+    return pNew;
 }
 
 ////////////////////////////////////////////////////////////////////////
diff --git a/abc-build/src/aig/gia/giaPf.c b/abc-build/src/aig/gia/giaPf.c
new file mode 100644
--- /dev/null
+++ b/abc-build/src/aig/gia/giaPf.c
@@ -0,0 +1,1353 @@
+/**CFile****************************************************************
+
+  FileName    [giaNf.c]
+
+  SystemName  [ABC: Logic synthesis and verification system.]
+
+  PackageName [Scalable AIG package.]
+
+  Synopsis    [Standard-cell mapper.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - June 20, 2005.]
+
+  Revision    [$Id: giaNf.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include <float.h>
+#include "gia.h"
+#include "misc/st/st.h"
+#include "map/mio/mio.h"
+#include "misc/util/utilTruth.h"
+#include "misc/extra/extra.h"
+#include "base/main/main.h"
+#include "misc/vec/vecMem.h"
+#include "misc/vec/vecWec.h"
+#include "opt/dau/dau.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+#define PF_LEAF_MAX  6
+#define PF_CUT_MAX  32
+#define PF_NO_LEAF  31
+#define PF_INFINITY FLT_MAX
+
+typedef struct Pf_Cut_t_ Pf_Cut_t; 
+struct Pf_Cut_t_
+{
+    word            Sign;           // signature
+    int             Delay;          // delay
+    float           Flow;           // flow
+    unsigned        iFunc   : 26;   // function
+    unsigned        Useless :  1;   // function
+    unsigned        nLeaves :  5;   // leaf number (PF_NO_LEAF)
+    int             pLeaves[PF_LEAF_MAX+1]; // leaves
+};
+typedef struct Pf_Mat_t_ Pf_Mat_t; 
+struct Pf_Mat_t_
+{
+    unsigned        fCompl  :  8;   // complemented
+    unsigned        Phase   :  6;   // match phase
+    unsigned        Perm    : 18;   // match permutation
+};
+typedef struct Pf_Obj_t_ Pf_Obj_t; 
+struct Pf_Obj_t_
+{
+    float           Area;
+    unsigned        Gate    :  7;   // gate
+    unsigned        nLeaves :  3;   // fanin count  
+    unsigned        nRefs   : 22;   // ref count
+    int             pLeaves[6];     // leaf literals
+};
+typedef struct Pf_Man_t_ Pf_Man_t; 
+struct Pf_Man_t_
+{
+    // user data
+    Gia_Man_t *     pGia;           // derived manager
+    Jf_Par_t *      pPars;          // parameters
+    // matching
+    Vec_Mem_t *     vTtMem;         // truth tables
+    Vec_Wec_t *     vTt2Match;      // matches for truth tables
+    Mio_Cell_t *    pCells;         // library gates
+    int             nCells;         // library gate count
+    // cut data
+    Pf_Obj_t *      pPfObjs;        // best cuts
+    Vec_Ptr_t       vPages;         // cut memory
+    Vec_Int_t       vCutSets;       // cut offsets
+    Vec_Flt_t       vCutFlows;      // temporary cut area
+    Vec_Int_t       vCutDelays;     // temporary cut delay
+    int             iCur;           // current position
+    int             Iter;           // mapping iterations
+    int             fUseEla;        // use exact area
+    int             nInvs;          // the inverter count
+    float           InvDelay;       // inverter delay
+    float           InvArea;        // inverter area 
+    // statistics
+    abctime         clkStart;       // starting time
+    double          CutCount[6];    // cut counts
+    int             nCutUseAll;     // objects with useful cuts
+};
+
+static inline int         Pf_Mat2Int( Pf_Mat_t Mat )                                { union { int x; Pf_Mat_t y; } v; v.y = Mat; return v.x;           }
+static inline Pf_Mat_t    Pf_Int2Mat( int Int )                                     { union { int x; Pf_Mat_t y; } v; v.x = Int; return v.y;           }
+
+static inline Pf_Obj_t *  Pf_ManObj( Pf_Man_t * p, int i )                          { return p->pPfObjs + i;                                           }
+static inline Mio_Cell_t* Pf_ManCell( Pf_Man_t * p, int i )                         { return p->pCells + i;                                            }
+static inline int *       Pf_ManCutSet( Pf_Man_t * p, int i )                       { return (int *)Vec_PtrEntry(&p->vPages, i >> 16) + (i & 0xFFFF);  }
+static inline int         Pf_ObjCutSetId( Pf_Man_t * p, int i )                     { return Vec_IntEntry( &p->vCutSets, i );                          }
+static inline int *       Pf_ObjCutSet( Pf_Man_t * p, int i )                       { return Pf_ManCutSet(p, Pf_ObjCutSetId(p, i));                    }
+static inline int         Pf_ObjHasCuts( Pf_Man_t * p, int i )                      { return (int)(Vec_IntEntry(&p->vCutSets, i) > 0);                 }
+static inline int         Pf_ObjCutUseless( Pf_Man_t * p, int TruthId )             { return (int)(TruthId >= Vec_WecSize(p->vTt2Match));              } 
+
+static inline float       Pf_ObjCutFlow( Pf_Man_t * p, int i )                      { return Vec_FltEntry(&p->vCutFlows, i);                           } 
+static inline int         Pf_ObjCutDelay( Pf_Man_t * p, int i )                     { return Vec_IntEntry(&p->vCutDelays, i);                          } 
+static inline void        Pf_ObjSetCutFlow( Pf_Man_t * p, int i, float a )          { Vec_FltWriteEntry(&p->vCutFlows, i, a);                          } 
+static inline void        Pf_ObjSetCutDelay( Pf_Man_t * p, int i, int d )           { Vec_IntWriteEntry(&p->vCutDelays, i, d);                         } 
+
+static inline int         Pf_CutSize( int * pCut )                                  { return pCut[0] & PF_NO_LEAF;                                     }
+static inline int         Pf_CutFunc( int * pCut )                                  { return ((unsigned)pCut[0] >> 5);                                 }
+static inline int *       Pf_CutLeaves( int * pCut )                                { return pCut + 1;                                                 }
+static inline int         Pf_CutSetBoth( int n, int f )                             { return n | (f << 5);                                             }
+static inline int         Pf_CutIsTriv( int * pCut, int i )                         { return Pf_CutSize(pCut) == 1 && pCut[1] == i;                    } 
+static inline int         Pf_CutHandle( int * pCutSet, int * pCut )                 { assert( pCut > pCutSet ); return pCut - pCutSet;                 } 
+static inline int *       Pf_CutFromHandle( int * pCutSet, int h )                  { assert( h > 0 ); return pCutSet + h;                             }
+static inline int         Pf_CutConfLit( int Conf, int i )                          { return 15 & (Conf >> (i << 2));                                  }
+static inline int         Pf_CutConfVar( int Conf, int i )                          { return Abc_Lit2Var( Pf_CutConfLit(Conf, i) );                    }
+static inline int         Pf_CutConfC( int Conf, int i )                            { return Abc_LitIsCompl( Pf_CutConfLit(Conf, i) );                 }
+
+#define Pf_SetForEachCut( pList, pCut, i )         for ( i = 0, pCut = pList + 1; i < pList[0]; i++, pCut += Pf_CutSize(pCut) + 1 )
+#define Pf_ObjForEachCut( pCuts, i, nCuts )        for ( i = 0, i < nCuts; i++ )
+#define Pf_CutForEachLit( pCut, Conf, iLit, i )    for ( i = 0; i < Pf_CutSize(pCut) && (iLit = Abc_Lit2LitV(Pf_CutLeaves(pCut), Pf_CutConfLit(Conf, i))); i++ )
+#define Pf_CutForEachVar( pCut, Conf, iVar, c, i ) for ( i = 0; i < Pf_CutSize(pCut) && (iVar = Pf_CutLeaves(pCut)[Pf_CutConfVar(Conf, i)]) && ((c = Pf_CutConfC(Conf, i)), 1); i++ )
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Pf_StoCreateGateAdd( Pf_Man_t * pMan, word uTruth, int * pFans, int nFans, int CellId )
+{
+    Vec_Int_t * vArray;
+    Pf_Mat_t Mat = Pf_Int2Mat(0);
+    int i, GateId, Entry, fCompl = (int)(uTruth & 1);
+    word uFunc = fCompl ? ~uTruth : uTruth;
+    int iFunc = Vec_MemHashInsert( pMan->vTtMem, &uFunc );
+    if ( iFunc == Vec_WecSize(pMan->vTt2Match) )
+        Vec_WecPushLevel( pMan->vTt2Match );
+    vArray = Vec_WecEntry( pMan->vTt2Match, iFunc );
+    Mat.fCompl = fCompl;
+    assert( nFans < 7 );
+    for ( i = 0; i < nFans; i++ )
+    {
+        Mat.Perm  |= (unsigned)(Abc_Lit2Var(pFans[i]) << (3*i));
+        Mat.Phase |= (unsigned)(Abc_LitIsCompl(pFans[i]) << i);
+    }
+    // check if the same one exists
+    Vec_IntForEachEntryDouble( vArray, GateId, Entry, i )
+        if ( GateId == CellId && Pf_Int2Mat(Entry).Phase == Mat.Phase )
+            break;
+    if ( i == Vec_IntSize(vArray) )
+    {
+        Vec_IntPush( vArray, CellId );
+        Vec_IntPush( vArray, Pf_Mat2Int(Mat) );
+    }
+}
+void Pf_StoCreateGate( Pf_Man_t * pMan, Mio_Cell_t * pCell, int ** pComp, int ** pPerm, int * pnPerms )
+{
+    int Perm[PF_LEAF_MAX], * Perm1, * Perm2;
+    int nPerms = pnPerms[pCell->nFanins];
+    int nMints = (1 << pCell->nFanins);
+    word tCur, tTemp1, tTemp2;
+    int i, p, c;
+    for ( i = 0; i < (int)pCell->nFanins; i++ )
+        Perm[i] = Abc_Var2Lit( i, 0 );
+    tCur = tTemp1 = pCell->uTruth;
+    for ( p = 0; p < nPerms; p++ )
+    {
+        tTemp2 = tCur;
+        for ( c = 0; c < nMints; c++ )
+        {
+            Pf_StoCreateGateAdd( pMan, tCur, Perm, pCell->nFanins, pCell->Id );
+            // update
+            tCur  = Abc_Tt6Flip( tCur, pComp[pCell->nFanins][c] );
+            Perm1 = Perm + pComp[pCell->nFanins][c];
+            *Perm1 = Abc_LitNot( *Perm1 );
+        }
+        assert( tTemp2 == tCur );
+        // update
+        tCur = Abc_Tt6SwapAdjacent( tCur, pPerm[pCell->nFanins][p] );
+        Perm1 = Perm + pPerm[pCell->nFanins][p];
+        Perm2 = Perm1 + 1;
+        ABC_SWAP( int, *Perm1, *Perm2 );
+    }
+    assert( tTemp1 == tCur );
+}
+void Pf_StoDeriveMatches( Pf_Man_t * p, int fVerbose )
+{
+//    abctime clk = Abc_Clock();
+    int * pComp[7];
+    int * pPerm[7];
+    int nPerms[7], i;
+    for ( i = 2; i <= 6; i++ )
+        pComp[i] = Extra_GreyCodeSchedule( i );
+    for ( i = 2; i <= 6; i++ )
+        pPerm[i] = Extra_PermSchedule( i );
+    for ( i = 2; i <= 6; i++ )
+        nPerms[i] = Extra_Factorial( i );
+    p->pCells = Mio_CollectRootsNewDefault( 6, &p->nCells, fVerbose );
+    for ( i = 4; i < p->nCells; i++ )
+        Pf_StoCreateGate( p, p->pCells + i, pComp, pPerm, nPerms );
+    for ( i = 2; i <= 6; i++ )
+        ABC_FREE( pComp[i] );
+    for ( i = 2; i <= 6; i++ )
+        ABC_FREE( pPerm[i] );
+//    Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
+}
+void Pf_StoPrintOne( Pf_Man_t * p, int Count, int t, int i, int GateId, Pf_Mat_t Mat )
+{
+    Mio_Cell_t * pC = p->pCells + GateId;
+    word * pTruth = Vec_MemReadEntry(p->vTtMem, t);
+    int k, nSuppSize = Abc_TtSupportSize(pTruth, 6);
+    printf( "%6d : ", Count );
+    printf( "%6d : ", t );
+    printf( "%6d : ", i );
+    printf( "Gate %16s  ",   pC->pName );
+    printf( "Area =%8.2f  ", pC->Area );
+    printf( "In = %d   ",    pC->nFanins );
+    if ( Mat.fCompl )
+        printf( " compl " );
+    else
+        printf( "       " );
+    for ( k = 0; k < (int)pC->nFanins; k++ )
+    {
+        int fComplF = (Mat.Phase >> k) & 1;
+        int iFanin  = (Mat.Perm >> (3*k)) & 7;
+        printf( "%c", 'a' + iFanin - fComplF * ('a' - 'A') );
+    }
+    printf( "  " );
+    Dau_DsdPrintFromTruth( pTruth, nSuppSize );
+}
+void Pf_StoPrint( Pf_Man_t * p, int fVerbose )
+{
+    int t, i, GateId, Entry, Count = 0;
+    for ( t = 2; t < Vec_WecSize(p->vTt2Match); t++ )
+    {
+        Vec_Int_t * vArr = Vec_WecEntry( p->vTt2Match, t );
+        Vec_IntForEachEntryDouble( vArr, GateId, Entry, i )
+        {
+            Count++;
+            if ( !fVerbose )
+                continue;
+            if ( t < 10 )
+                Pf_StoPrintOne( p, Count, t, i/2, GateId, Pf_Int2Mat(Entry) );
+        }
+    }
+    printf( "Gates = %d.  Truths = %d.  Matches = %d.\n", 
+        p->nCells, Vec_MemEntryNum(p->vTtMem), Count );
+}
+/*
+void Pf_ManPrepareLibraryTest()
+{
+    int fVerbose = 0;
+    abctime clk = Abc_Clock();
+    Pf_Man_t * p;
+    p = Pf_StoCreate( NULL, NULL, fVerbose );
+    Pf_StoPrint( p, fVerbose );
+    Pf_StoDelete(p);
+    Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
+}
+*/
+
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Pf_Man_t * Pf_StoCreate( Gia_Man_t * pGia, Jf_Par_t * pPars )
+{
+    extern void Mf_ManSetFlowRefs( Gia_Man_t * p, Vec_Int_t * vRefs );
+    Pf_Man_t * p;
+    Vec_Int_t * vFlowRefs;
+    assert( pPars->nCutNum > 1  && pPars->nCutNum <= PF_CUT_MAX );
+    assert( pPars->nLutSize > 1 && pPars->nLutSize <= PF_LEAF_MAX );
+    ABC_FREE( pGia->pRefs );
+    Vec_IntFreeP( &pGia->vCellMapping );
+    if ( Gia_ManHasChoices(pGia) )
+        Gia_ManSetPhase(pGia);
+    // create references
+    ABC_FREE( pGia->pRefs );
+    vFlowRefs = Vec_IntAlloc(0);
+    Mf_ManSetFlowRefs( pGia, vFlowRefs );
+    pGia->pRefs= Vec_IntReleaseArray(vFlowRefs);
+    Vec_IntFree(vFlowRefs);
+    // create
+    p = ABC_CALLOC( Pf_Man_t, 1 );
+    p->clkStart = Abc_Clock();
+    p->pGia     = pGia;
+    p->pPars    = pPars;
+    p->pPfObjs  = ABC_CALLOC( Pf_Obj_t, Gia_ManObjNum(pGia) );
+    p->iCur     = 2;
+    // other
+    Vec_PtrGrow( &p->vPages, 256 );                                    // cut memory
+    Vec_IntFill( &p->vCutSets,  Gia_ManObjNum(pGia), 0 );              // cut offsets
+    Vec_FltFill( &p->vCutFlows, Gia_ManObjNum(pGia), 0 );              // cut area
+    Vec_IntFill( &p->vCutDelays,Gia_ManObjNum(pGia), 0 );              // cut delay
+    // matching
+    p->vTtMem    = Vec_MemAllocForTT( 6, 0 );          
+    p->vTt2Match = Vec_WecAlloc( 1000 ); 
+    Vec_WecPushLevel( p->vTt2Match );
+    Vec_WecPushLevel( p->vTt2Match );
+    assert( Vec_WecSize(p->vTt2Match) == Vec_MemEntryNum(p->vTtMem) );
+    Pf_StoDeriveMatches( p, 0 );//pPars->fVerbose );
+    p->InvDelay = p->pCells[3].Delays[0];
+    p->InvArea  = p->pCells[3].Area;
+    //Pf_ObjMatchD(p, 0, 0)->Gate = 0;
+    //Pf_ObjMatchD(p, 0, 1)->Gate = 1;
+    // prepare cuts
+    return p;
+}
+void Pf_StoDelete( Pf_Man_t * p )
+{
+    Vec_PtrFreeData( &p->vPages );
+    ABC_FREE( p->vPages.pArray );
+    ABC_FREE( p->vCutSets.pArray );
+    ABC_FREE( p->vCutFlows.pArray );
+    ABC_FREE( p->vCutDelays.pArray );
+    ABC_FREE( p->pPfObjs );
+    // matching
+    Vec_WecFree( p->vTt2Match );
+    Vec_MemHashFree( p->vTtMem );
+    Vec_MemFree( p->vTtMem );
+    ABC_FREE( p->pCells );
+    ABC_FREE( p );
+}
+
+
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Pf_CutComputeTruth6( Pf_Man_t * p, Pf_Cut_t * pCut0, Pf_Cut_t * pCut1, int fCompl0, int fCompl1, Pf_Cut_t * pCutR, int fIsXor )
+{
+//    extern int Pf_ManTruthCanonicize( word * t, int nVars );
+    int nOldSupp = pCutR->nLeaves, truthId, fCompl; word t;
+    word t0 = *Vec_MemReadEntry(p->vTtMem, Abc_Lit2Var(pCut0->iFunc));
+    word t1 = *Vec_MemReadEntry(p->vTtMem, Abc_Lit2Var(pCut1->iFunc));
+    if ( Abc_LitIsCompl(pCut0->iFunc) ^ fCompl0 ) t0 = ~t0;
+    if ( Abc_LitIsCompl(pCut1->iFunc) ^ fCompl1 ) t1 = ~t1;
+    t0 = Abc_Tt6Expand( t0, pCut0->pLeaves, pCut0->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
+    t1 = Abc_Tt6Expand( t1, pCut1->pLeaves, pCut1->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
+    t =  fIsXor ? t0 ^ t1 : t0 & t1;
+    if ( (fCompl = (int)(t & 1)) ) t = ~t;
+    pCutR->nLeaves = Abc_Tt6MinBase( &t, pCutR->pLeaves, pCutR->nLeaves );
+    assert( (int)(t & 1) == 0 );
+    truthId        = Vec_MemHashInsert(p->vTtMem, &t);
+    pCutR->iFunc   = Abc_Var2Lit( truthId, fCompl );
+    pCutR->Useless = Pf_ObjCutUseless( p, truthId );
+    assert( (int)pCutR->nLeaves <= nOldSupp );
+    return (int)pCutR->nLeaves < nOldSupp;
+}
+static inline int Pf_CutComputeTruthMux6( Pf_Man_t * p, Pf_Cut_t * pCut0, Pf_Cut_t * pCut1, Pf_Cut_t * pCutC, int fCompl0, int fCompl1, int fComplC, Pf_Cut_t * pCutR )
+{
+    int nOldSupp = pCutR->nLeaves, truthId, fCompl; word t;
+    word t0 = *Vec_MemReadEntry(p->vTtMem, Abc_Lit2Var(pCut0->iFunc));
+    word t1 = *Vec_MemReadEntry(p->vTtMem, Abc_Lit2Var(pCut1->iFunc));
+    word tC = *Vec_MemReadEntry(p->vTtMem, Abc_Lit2Var(pCutC->iFunc));
+    if ( Abc_LitIsCompl(pCut0->iFunc) ^ fCompl0 ) t0 = ~t0;
+    if ( Abc_LitIsCompl(pCut1->iFunc) ^ fCompl1 ) t1 = ~t1;
+    if ( Abc_LitIsCompl(pCutC->iFunc) ^ fComplC ) tC = ~tC;
+    t0 = Abc_Tt6Expand( t0, pCut0->pLeaves, pCut0->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
+    t1 = Abc_Tt6Expand( t1, pCut1->pLeaves, pCut1->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
+    tC = Abc_Tt6Expand( tC, pCutC->pLeaves, pCutC->nLeaves, pCutR->pLeaves, pCutR->nLeaves );
+    t = (tC & t1) | (~tC & t0);
+    if ( (fCompl = (int)(t & 1)) ) t = ~t;
+    pCutR->nLeaves = Abc_Tt6MinBase( &t, pCutR->pLeaves, pCutR->nLeaves );
+    assert( (int)(t & 1) == 0 );
+    truthId        = Vec_MemHashInsert(p->vTtMem, &t);
+    pCutR->iFunc   = Abc_Var2Lit( truthId, fCompl );
+    pCutR->Useless = Pf_ObjCutUseless( p, truthId );
+    assert( (int)pCutR->nLeaves <= nOldSupp );
+    return (int)pCutR->nLeaves < nOldSupp;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Pf_CutCountBits( word i )
+{
+    i = i - ((i >> 1) & 0x5555555555555555);
+    i = (i & 0x3333333333333333) + ((i >> 2) & 0x3333333333333333);
+    i = ((i + (i >> 4)) & 0x0F0F0F0F0F0F0F0F);
+    return (i*(0x0101010101010101))>>56;
+}
+static inline word Pf_CutGetSign( int * pLeaves, int nLeaves )
+{
+    word Sign = 0; int i; 
+    for ( i = 0; i < nLeaves; i++ )
+        Sign |= ((word)1) << (pLeaves[i] & 0x3F);
+    return Sign;
+}
+static inline int Pf_CutCreateUnit( Pf_Cut_t * p, int i )
+{
+    p->Delay      = 0;
+    p->Flow       = 0;
+    p->iFunc      = 2;
+    p->nLeaves    = 1;
+    p->pLeaves[0] = i;
+    p->Sign       = ((word)1) << (i & 0x3F);
+    return 1;
+}
+static inline void Pf_Cutprintf( Pf_Man_t * p, Pf_Cut_t * pCut )
+{
+    int i, nDigits = Abc_Base10Log(Gia_ManObjNum(p->pGia)); 
+    printf( "%d  {", pCut->nLeaves );
+    for ( i = 0; i < (int)pCut->nLeaves; i++ )
+        printf( " %*d", nDigits, pCut->pLeaves[i] );
+    for ( ; i < (int)p->pPars->nLutSize; i++ )
+        printf( " %*s", nDigits, " " );
+    printf( "  }   Useless = %d. D = %4d  A = %9.4f  F = %6d  ", 
+        pCut->Useless, pCut->Delay, pCut->Flow, pCut->iFunc );
+    if ( p->vTtMem )
+        Dau_DsdPrintFromTruth( Vec_MemReadEntry(p->vTtMem, Abc_Lit2Var(pCut->iFunc)), pCut->nLeaves );
+    else
+        printf( "\n" );
+}
+static inline int Pf_ManPrepareCuts( Pf_Cut_t * pCuts, Pf_Man_t * p, int iObj, int fAddUnit )
+{
+    if ( Pf_ObjHasCuts(p, iObj) )
+    {
+        Pf_Cut_t * pMfCut = pCuts;
+        int i, * pCut, * pList = Pf_ObjCutSet(p, iObj);
+        Pf_SetForEachCut( pList, pCut, i )
+        {
+            pMfCut->Delay   = 0;
+            pMfCut->Flow    = 0;
+            pMfCut->iFunc   = Pf_CutFunc( pCut );
+            pMfCut->nLeaves = Pf_CutSize( pCut );
+            pMfCut->Sign    = Pf_CutGetSign( pCut+1, Pf_CutSize(pCut) );
+            pMfCut->Useless = Pf_ObjCutUseless( p, Abc_Lit2Var(pMfCut->iFunc) );
+            memcpy( pMfCut->pLeaves, pCut+1, sizeof(int) * Pf_CutSize(pCut) );
+            pMfCut++;
+        }
+        if ( fAddUnit && pCuts->nLeaves > 1 )
+            return pList[0] + Pf_CutCreateUnit( pMfCut, iObj );
+        return pList[0];
+    }
+    return Pf_CutCreateUnit( pCuts, iObj );
+}
+static inline int Pf_ManSaveCuts( Pf_Man_t * p, Pf_Cut_t ** pCuts, int nCuts, int fUseful )
+{
+    int i, * pPlace, iCur, nInts = 1, nCutsNew = 0;
+    for ( i = 0; i < nCuts; i++ )
+        if ( !fUseful || !pCuts[i]->Useless )
+            nInts += pCuts[i]->nLeaves + 1, nCutsNew++;
+    if ( (p->iCur & 0xFFFF) + nInts > 0xFFFF )
+        p->iCur = ((p->iCur >> 16) + 1) << 16;
+    if ( Vec_PtrSize(&p->vPages) == (p->iCur >> 16) )
+        Vec_PtrPush( &p->vPages, ABC_ALLOC(int, (1<<16)) );
+    iCur = p->iCur; p->iCur += nInts;
+    pPlace = Pf_ManCutSet( p, iCur );
+    *pPlace++ = nCutsNew;
+    for ( i = 0; i < nCuts; i++ )
+        if ( !fUseful || !pCuts[i]->Useless )
+        {
+            *pPlace++ = Pf_CutSetBoth( pCuts[i]->nLeaves, pCuts[i]->iFunc );
+            memcpy( pPlace, pCuts[i]->pLeaves, sizeof(int) * pCuts[i]->nLeaves );
+            pPlace += pCuts[i]->nLeaves;
+        }
+    return iCur;
+}
+static inline int Pf_ManCountUseful( Pf_Cut_t ** pCuts, int nCuts )
+{
+    int i, Count = 0;
+    for ( i = 0; i < nCuts; i++ )
+        Count += !pCuts[i]->Useless;
+    return Count;
+}
+static inline int Pf_ManCountMatches( Pf_Man_t * p, Pf_Cut_t ** pCuts, int nCuts )
+{
+    int i, Count = 0;
+    for ( i = 0; i < nCuts; i++ )
+        if ( !pCuts[i]->Useless )
+            Count += Vec_IntSize(Vec_WecEntry(p->vTt2Match, Abc_Lit2Var(pCuts[i]->iFunc))) / 2;
+    return Count;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Check correctness of cuts.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Pf_CutCheck( Pf_Cut_t * pBase, Pf_Cut_t * pCut ) // check if pCut is contained in pBase
+{
+    int nSizeB = pBase->nLeaves;
+    int nSizeC = pCut->nLeaves;
+    int i, * pB = pBase->pLeaves;
+    int k, * pC = pCut->pLeaves;
+    for ( i = 0; i < nSizeC; i++ )
+    {
+        for ( k = 0; k < nSizeB; k++ )
+            if ( pC[i] == pB[k] )
+                break;
+        if ( k == nSizeB )
+            return 0;
+    }
+    return 1;
+}
+static inline int Pf_SetCheckArray( Pf_Cut_t ** ppCuts, int nCuts )
+{
+    Pf_Cut_t * pCut0, * pCut1; 
+    int i, k, m, n, Value;
+    assert( nCuts > 0 );
+    for ( i = 0; i < nCuts; i++ )
+    {
+        pCut0 = ppCuts[i];
+        assert( pCut0->nLeaves <= PF_LEAF_MAX );
+        assert( pCut0->Sign == Pf_CutGetSign(pCut0->pLeaves, pCut0->nLeaves) );
+        // check duplicates
+        for ( m = 0; m < (int)pCut0->nLeaves; m++ )
+        for ( n = m + 1; n < (int)pCut0->nLeaves; n++ )
+            assert( pCut0->pLeaves[m] < pCut0->pLeaves[n] );
+        // check pairs
+        for ( k = 0; k < nCuts; k++ )
+        {
+            pCut1 = ppCuts[k];
+            if ( pCut0 == pCut1 )
+                continue;
+            // check containments
+            Value = Pf_CutCheck( pCut0, pCut1 );
+            assert( Value == 0 );
+        }
+    }
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Pf_CutMergeOrder( Pf_Cut_t * pCut0, Pf_Cut_t * pCut1, Pf_Cut_t * pCut, int nLutSize )
+{ 
+    int nSize0   = pCut0->nLeaves;
+    int nSize1   = pCut1->nLeaves;
+    int i, * pC0 = pCut0->pLeaves;
+    int k, * pC1 = pCut1->pLeaves;
+    int c, * pC  = pCut->pLeaves;
+    // the case of the largest cut sizes
+    if ( nSize0 == nLutSize && nSize1 == nLutSize )
+    {
+        for ( i = 0; i < nSize0; i++ )
+        {
+            if ( pC0[i] != pC1[i] )  return 0;
+            pC[i] = pC0[i];
+        }
+        pCut->nLeaves = nLutSize;
+        pCut->iFunc = -1;
+        pCut->Sign = pCut0->Sign | pCut1->Sign;
+        return 1;
+    }
+    // compare two cuts with different numbers
+    i = k = c = 0;
+    if ( nSize0 == 0 ) goto FlushCut1;
+    if ( nSize1 == 0 ) goto FlushCut0;
+    while ( 1 )
+    {
+        if ( c == nLutSize ) return 0;
+        if ( pC0[i] < pC1[k] )
+        {
+            pC[c++] = pC0[i++];
+            if ( i >= nSize0 ) goto FlushCut1;
+        }
+        else if ( pC0[i] > pC1[k] )
+        {
+            pC[c++] = pC1[k++];
+            if ( k >= nSize1 ) goto FlushCut0;
+        }
+        else
+        {
+            pC[c++] = pC0[i++]; k++;
+            if ( i >= nSize0 ) goto FlushCut1;
+            if ( k >= nSize1 ) goto FlushCut0;
+        }
+    }
+
+FlushCut0:
+    if ( c + nSize0 > nLutSize + i ) return 0;
+    while ( i < nSize0 )
+        pC[c++] = pC0[i++];
+    pCut->nLeaves = c;
+    pCut->iFunc = -1;
+    pCut->Sign = pCut0->Sign | pCut1->Sign;
+    return 1;
+
+FlushCut1:
+    if ( c + nSize1 > nLutSize + k ) return 0;
+    while ( k < nSize1 )
+        pC[c++] = pC1[k++];
+    pCut->nLeaves = c;
+    pCut->iFunc = -1;
+    pCut->Sign = pCut0->Sign | pCut1->Sign;
+    return 1;
+}
+static inline int Pf_CutMergeOrderMux( Pf_Cut_t * pCut0, Pf_Cut_t * pCut1, Pf_Cut_t * pCut2, Pf_Cut_t * pCut, int nLutSize )
+{ 
+    int x0, i0 = 0, nSize0 = pCut0->nLeaves, * pC0 = pCut0->pLeaves;
+    int x1, i1 = 0, nSize1 = pCut1->nLeaves, * pC1 = pCut1->pLeaves;
+    int x2, i2 = 0, nSize2 = pCut2->nLeaves, * pC2 = pCut2->pLeaves;
+    int xMin, c = 0, * pC  = pCut->pLeaves;
+    while ( 1 )
+    {
+        x0 = (i0 == nSize0) ? ABC_INFINITY : pC0[i0];
+        x1 = (i1 == nSize1) ? ABC_INFINITY : pC1[i1];
+        x2 = (i2 == nSize2) ? ABC_INFINITY : pC2[i2];
+        xMin = Abc_MinInt( Abc_MinInt(x0, x1), x2 );
+        if ( xMin == ABC_INFINITY ) break;
+        if ( c == nLutSize ) return 0;
+        pC[c++] = xMin;
+        if (x0 == xMin) i0++;
+        if (x1 == xMin) i1++;
+        if (x2 == xMin) i2++;
+    }
+    pCut->nLeaves = c;
+    pCut->iFunc = -1;
+    pCut->Sign = pCut0->Sign | pCut1->Sign | pCut2->Sign;
+    return 1;
+}
+static inline int Pf_SetCutIsContainedOrder( Pf_Cut_t * pBase, Pf_Cut_t * pCut ) // check if pCut is contained in pBase
+{
+    int i, nSizeB = pBase->nLeaves;
+    int k, nSizeC = pCut->nLeaves;
+    if ( nSizeB == nSizeC )
+    {
+        for ( i = 0; i < nSizeB; i++ )
+            if ( pBase->pLeaves[i] != pCut->pLeaves[i] )
+                return 0;
+        return 1;
+    }
+    assert( nSizeB > nSizeC ); 
+    if ( nSizeC == 0 )
+        return 1;
+    for ( i = k = 0; i < nSizeB; i++ )
+    {
+        if ( pBase->pLeaves[i] > pCut->pLeaves[k] )
+            return 0;
+        if ( pBase->pLeaves[i] == pCut->pLeaves[k] )
+        {
+            if ( ++k == nSizeC )
+                return 1;
+        }
+    }
+    return 0;
+}
+static inline int Pf_SetLastCutIsContained( Pf_Cut_t ** pCuts, int nCuts )
+{
+    int i;
+    for ( i = 0; i < nCuts; i++ )
+        if ( pCuts[i]->nLeaves <= pCuts[nCuts]->nLeaves && (pCuts[i]->Sign & pCuts[nCuts]->Sign) == pCuts[i]->Sign && Pf_SetCutIsContainedOrder(pCuts[nCuts], pCuts[i]) )
+            return 1;
+    return 0;
+}
+static inline int Pf_SetLastCutContainsArea( Pf_Cut_t ** pCuts, int nCuts )
+{
+    int i, k, fChanges = 0;
+    for ( i = 0; i < nCuts; i++ )
+        if ( pCuts[nCuts]->nLeaves < pCuts[i]->nLeaves && (pCuts[nCuts]->Sign & pCuts[i]->Sign) == pCuts[nCuts]->Sign && Pf_SetCutIsContainedOrder(pCuts[i], pCuts[nCuts]) )
+            pCuts[i]->nLeaves = PF_NO_LEAF, fChanges = 1;
+    if ( !fChanges )
+        return nCuts;
+    for ( i = k = 0; i <= nCuts; i++ )
+    {
+        if ( pCuts[i]->nLeaves == PF_NO_LEAF )
+            continue;
+        if ( k < i )
+            ABC_SWAP( Pf_Cut_t *, pCuts[k], pCuts[i] );
+        k++;
+    }
+    return k - 1;
+}
+static inline int Pf_CutCompareArea( Pf_Cut_t * pCut0, Pf_Cut_t * pCut1 )
+{
+    if ( pCut0->Useless < pCut1->Useless )  return -1;
+    if ( pCut0->Useless > pCut1->Useless )  return  1;
+    if ( pCut0->Flow    < pCut1->Flow    )  return -1;
+    if ( pCut0->Flow    > pCut1->Flow    )  return  1;
+    if ( pCut0->Delay   < pCut1->Delay   )  return -1;
+    if ( pCut0->Delay   > pCut1->Delay   )  return  1;
+    if ( pCut0->nLeaves < pCut1->nLeaves )  return -1;
+    if ( pCut0->nLeaves > pCut1->nLeaves )  return  1;
+    return 0;
+}
+static inline void Pf_SetSortByArea( Pf_Cut_t ** pCuts, int nCuts )
+{
+    int i;
+    for ( i = nCuts; i > 0; i-- )
+    {
+        if ( Pf_CutCompareArea(pCuts[i - 1], pCuts[i]) < 0 )//!= 1 )
+            return;
+        ABC_SWAP( Pf_Cut_t *, pCuts[i - 1], pCuts[i] );
+    }
+}
+static inline int Pf_SetAddCut( Pf_Cut_t ** pCuts, int nCuts, int nCutNum )
+{
+    if ( nCuts == 0 )
+        return 1;
+    nCuts = Pf_SetLastCutContainsArea(pCuts, nCuts);
+    Pf_SetSortByArea( pCuts, nCuts );
+    return Abc_MinInt( nCuts + 1, nCutNum - 1 );
+}
+static inline int Pf_CutArea( Pf_Man_t * p, int nLeaves )
+{
+    if ( nLeaves < 2 )
+        return 0;
+    return nLeaves + p->pPars->nAreaTuner;
+}
+static inline void Pf_CutParams( Pf_Man_t * p, Pf_Cut_t * pCut, int nGiaRefs )
+{
+    int i, nLeaves = pCut->nLeaves; 
+    assert( nLeaves <= p->pPars->nLutSize );
+    pCut->Delay = 0;
+    pCut->Flow  = 0;
+    for ( i = 0; i < nLeaves; i++ )
+    {
+        pCut->Delay = Abc_MaxInt( pCut->Delay, Pf_ObjCutDelay(p, pCut->pLeaves[i]) );
+        pCut->Flow += Pf_ObjCutFlow(p, pCut->pLeaves[i]);
+    }
+    pCut->Delay += (int)(nLeaves > 1);
+    pCut->Flow = (pCut->Flow + Pf_CutArea(p, nLeaves)) / (nGiaRefs ? nGiaRefs : 1);
+}
+void Pf_ObjMergeOrder( Pf_Man_t * p, int iObj )
+{
+    Pf_Cut_t pCuts0[PF_CUT_MAX], pCuts1[PF_CUT_MAX], pCuts[PF_CUT_MAX], * pCutsR[PF_CUT_MAX];
+    Gia_Obj_t * pObj = Gia_ManObj(p->pGia, iObj);
+    int nGiaRefs = 2*Gia_ObjRefNumId(p->pGia, iObj);
+    int nLutSize = p->pPars->nLutSize;
+    int nCutNum  = p->pPars->nCutNum;
+    int nCuts0   = Pf_ManPrepareCuts(pCuts0, p, Gia_ObjFaninId0(pObj, iObj), 1);
+    int nCuts1   = Pf_ManPrepareCuts(pCuts1, p, Gia_ObjFaninId1(pObj, iObj), 1);
+    int fComp0   = Gia_ObjFaninC0(pObj);
+    int fComp1   = Gia_ObjFaninC1(pObj);
+    int iSibl    = Gia_ObjSibl(p->pGia, iObj);
+    Pf_Cut_t * pCut0, * pCut1, * pCut0Lim = pCuts0 + nCuts0, * pCut1Lim = pCuts1 + nCuts1;
+    int i, nCutsUse, nCutsR = 0;
+    assert( !Gia_ObjIsBuf(pObj) );
+    for ( i = 0; i < nCutNum; i++ )
+        pCutsR[i] = pCuts + i;
+    if ( iSibl )
+    {
+        Pf_Cut_t pCuts2[PF_CUT_MAX];
+        Gia_Obj_t * pObjE = Gia_ObjSiblObj(p->pGia, iObj);
+        int fCompE = Gia_ObjPhase(pObj) ^ Gia_ObjPhase(pObjE);
+        int nCuts2 = Pf_ManPrepareCuts(pCuts2, p, iSibl, 0);
+        Pf_Cut_t * pCut2, * pCut2Lim = pCuts2 + nCuts2;
+        for ( pCut2 = pCuts2; pCut2 < pCut2Lim; pCut2++ )
+        {
+            *pCutsR[nCutsR] = *pCut2;
+            pCutsR[nCutsR]->iFunc = Abc_LitNotCond( pCutsR[nCutsR]->iFunc, fCompE );
+            Pf_CutParams( p, pCutsR[nCutsR], nGiaRefs );
+            nCutsR = Pf_SetAddCut( pCutsR, nCutsR, nCutNum );
+        }
+    }
+    if ( Gia_ObjIsMuxId(p->pGia, iObj) )
+    {
+        Pf_Cut_t pCuts2[PF_CUT_MAX];
+        int nCuts2  = Pf_ManPrepareCuts(pCuts2, p, Gia_ObjFaninId2(p->pGia, iObj), 1);
+        int fComp2  = Gia_ObjFaninC2(p->pGia, pObj);
+        Pf_Cut_t * pCut2, * pCut2Lim = pCuts2 + nCuts2;
+        p->CutCount[0] += nCuts0 * nCuts1 * nCuts2;
+        for ( pCut0 = pCuts0; pCut0 < pCut0Lim; pCut0++ )
+        for ( pCut1 = pCuts1; pCut1 < pCut1Lim; pCut1++ )
+        for ( pCut2 = pCuts2; pCut2 < pCut2Lim; pCut2++ )
+        {
+            if ( Pf_CutCountBits(pCut0->Sign | pCut1->Sign | pCut2->Sign) > nLutSize )
+                continue;
+            p->CutCount[1]++; 
+            if ( !Pf_CutMergeOrderMux(pCut0, pCut1, pCut2, pCutsR[nCutsR], nLutSize) )
+                continue;
+            if ( Pf_SetLastCutIsContained(pCutsR, nCutsR) )
+                continue;
+            p->CutCount[2]++;
+            if ( Pf_CutComputeTruthMux6(p, pCut0, pCut1, pCut2, fComp0, fComp1, fComp2, pCutsR[nCutsR]) )
+                pCutsR[nCutsR]->Sign = Pf_CutGetSign(pCutsR[nCutsR]->pLeaves, pCutsR[nCutsR]->nLeaves);
+            Pf_CutParams( p, pCutsR[nCutsR], nGiaRefs );
+            nCutsR = Pf_SetAddCut( pCutsR, nCutsR, nCutNum );
+        }
+    }
+    else
+    {
+        int fIsXor = Gia_ObjIsXor(pObj);
+        p->CutCount[0] += nCuts0 * nCuts1;
+        for ( pCut0 = pCuts0; pCut0 < pCut0Lim; pCut0++ )
+        for ( pCut1 = pCuts1; pCut1 < pCut1Lim; pCut1++ )
+        {
+            if ( (int)(pCut0->nLeaves + pCut1->nLeaves) > nLutSize && Pf_CutCountBits(pCut0->Sign | pCut1->Sign) > nLutSize )
+                continue;
+            p->CutCount[1]++; 
+            if ( !Pf_CutMergeOrder(pCut0, pCut1, pCutsR[nCutsR], nLutSize) )
+                continue;
+            if ( Pf_SetLastCutIsContained(pCutsR, nCutsR) )
+                continue;
+            p->CutCount[2]++;
+            if ( Pf_CutComputeTruth6(p, pCut0, pCut1, fComp0, fComp1, pCutsR[nCutsR], fIsXor) )
+                pCutsR[nCutsR]->Sign = Pf_CutGetSign(pCutsR[nCutsR]->pLeaves, pCutsR[nCutsR]->nLeaves);
+            Pf_CutParams( p, pCutsR[nCutsR], nGiaRefs );
+            nCutsR = Pf_SetAddCut( pCutsR, nCutsR, nCutNum );
+        }
+    }
+    // debug printout
+    if ( 0 )
+//    if ( iObj % 10000 == 0 )
+//    if ( iObj == 1090 )
+    {
+        printf( "*** Obj = %d  Useful = %d\n", iObj, Pf_ManCountUseful(pCutsR, nCutsR) );
+        for ( i = 0; i < nCutsR; i++ )
+            Pf_Cutprintf( p, pCutsR[i] );
+        printf( "\n" );
+    } 
+    // verify
+    assert( nCutsR > 0 && nCutsR < nCutNum );
+//    assert( Pf_SetCheckArray(pCutsR, nCutsR) );
+    // store the cutset
+    Pf_ObjSetCutFlow( p, iObj, pCutsR[0]->Flow );
+    Pf_ObjSetCutDelay( p, iObj, pCutsR[0]->Delay );
+    *Vec_IntEntryP(&p->vCutSets, iObj) = Pf_ManSaveCuts(p, pCutsR, nCutsR, 0);
+    p->CutCount[3] += nCutsR;
+    nCutsUse = Pf_ManCountUseful(pCutsR, nCutsR);
+    p->CutCount[4] += nCutsUse;
+    p->nCutUseAll  += nCutsUse == nCutsR;
+    p->CutCount[5] += Pf_ManCountMatches(p, pCutsR, nCutsR);
+}
+void Pf_ManComputeCuts( Pf_Man_t * p )
+{
+    Gia_Obj_t * pObj; int i, iFanin;
+    Gia_ManForEachAnd( p->pGia, pObj, i )
+        if ( Gia_ObjIsBuf(pObj) )
+        {
+            iFanin = Gia_ObjFaninId0(pObj, i);
+            Pf_ObjSetCutFlow( p, i,  Pf_ObjCutFlow(p, iFanin) );
+            Pf_ObjSetCutDelay( p, i, Pf_ObjCutDelay(p, iFanin) );
+        }
+        else
+            Pf_ObjMergeOrder( p, i );
+}
+
+
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Pf_ManPrintStats( Pf_Man_t * p, char * pTitle )
+{
+    if ( !p->pPars->fVerbose )
+        return;
+    printf( "%s :  ", pTitle );
+    printf( "Delay =%8.2f  ",  p->pPars->MapDelay );
+    printf( "Area =%12.2f  ",  p->pPars->MapArea );
+    printf( "Gate =%6d  ",    (int)p->pPars->Area );
+    printf( "Inv =%6d  ",     (int)p->nInvs );
+    printf( "Edge =%7d  ",    (int)p->pPars->Edge );
+    Abc_PrintTime( 1, "Time", Abc_Clock() - p->clkStart );
+    fflush( stdout );
+}
+void Pf_ManPrintInit( Pf_Man_t * p )
+{
+    int nChoices;
+    if ( !p->pPars->fVerbose )
+        return;
+    printf( "LutSize = %d  ", p->pPars->nLutSize );
+    printf( "CutNum = %d  ",  p->pPars->nCutNum );
+    printf( "Iter = %d  ",    p->pPars->nRounds + p->pPars->nRoundsEla );
+    printf( "Coarse = %d   ", p->pPars->fCoarsen );
+    printf( "Cells = %d  ",   p->nCells );
+    printf( "Funcs = %d  ",   Vec_MemEntryNum(p->vTtMem) );
+    printf( "Matches = %d  ", Vec_WecSizeSize(p->vTt2Match)/2 );
+    nChoices = Gia_ManChoiceNum( p->pGia );
+    if ( nChoices )
+    printf( "Choices = %d  ", nChoices );
+    printf( "\n" );
+    printf( "Computing cuts...\r" );
+    fflush( stdout );
+}
+void Pf_ManPrintQuit( Pf_Man_t * p )
+{
+    float MemGia   = Gia_ManMemory(p->pGia) / (1<<20);
+    float MemMan   =(1.0 * sizeof(Pf_Obj_t) + 3.0 * sizeof(int)) * Gia_ManObjNum(p->pGia) / (1<<20);
+    float MemCuts  = 1.0 * sizeof(int) * (1 << 16) * Vec_PtrSize(&p->vPages) / (1<<20);
+    float MemTt    = p->vTtMem ? Vec_MemMemory(p->vTtMem) / (1<<20) : 0;
+    if ( p->CutCount[0] == 0 )
+        p->CutCount[0] = 1;
+    if ( !p->pPars->fVerbose )
+        return;
+    printf( "CutPair = %.0f  ",         p->CutCount[0] );
+    printf( "Merge = %.0f (%.1f)  ",    p->CutCount[1], 1.0*p->CutCount[1]/Gia_ManAndNum(p->pGia) );
+    printf( "Eval = %.0f (%.1f)  ",     p->CutCount[2], 1.0*p->CutCount[2]/Gia_ManAndNum(p->pGia) );
+    printf( "Cut = %.0f (%.1f)  ",      p->CutCount[3], 1.0*p->CutCount[3]/Gia_ManAndNum(p->pGia) );
+    printf( "Use = %.0f (%.1f)  ",      p->CutCount[4], 1.0*p->CutCount[4]/Gia_ManAndNum(p->pGia) );
+    printf( "Mat = %.0f (%.1f)  ",      p->CutCount[5], 1.0*p->CutCount[5]/Gia_ManAndNum(p->pGia) );
+//    printf( "Equ = %d (%.2f %%)  ",     p->nCutUseAll,  100.0*p->nCutUseAll /p->CutCount[0] );
+    printf( "\n" );
+    printf( "Gia = %.2f MB  ",          MemGia );
+    printf( "Man = %.2f MB  ",          MemMan ); 
+    printf( "Cut = %.2f MB   ",         MemCuts );
+    printf( "TT = %.2f MB  ",           MemTt ); 
+    printf( "Total = %.2f MB   ",       MemGia + MemMan + MemCuts + MemTt ); 
+//    printf( "\n" );
+    Abc_PrintTime( 1, "Time", Abc_Clock() - p->clkStart );
+    fflush( stdout );
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+/*
+void Pf_ManSetMapRefsGate( Pf_Man_t * p, int iObj, float Required, Pf_Mat_t * pM )
+{
+    int k, iVar, fCompl;
+    Mio_Cell_t * pCell = Pf_ManCell( p, pM->Gate );
+    int * pCut = Pf_CutFromHandle( Pf_ObjCutSet(p, iObj), pM->CutH );
+    Pf_CutForEachVar( pCut, pM->Conf, iVar, fCompl, k )
+    {
+        Pf_ObjMapRefInc( p, iVar, fCompl );
+        Pf_ObjUpdateRequired( p, iVar, fCompl, Required - pCell->Delays[k] );
+    }
+    assert( Pf_CutSize(pCut) == (int)pCell->nFanins );
+    // update global stats
+    p->pPars->MapArea += pCell->Area;
+    p->pPars->Edge += Pf_CutSize(pCut);
+    p->pPars->Area++;
+    // update status of the gate
+    assert( pM->fBest == 0 );
+    pM->fBest = 1;
+}
+int Pf_ManSetMapRefs( Pf_Man_t * p )
+{
+    float Coef = 1.0 / (1.0 + (p->Iter + 1) * (p->Iter + 1));
+    float * pFlowRefs = Vec_FltArray( &p->vFlowRefs );
+    int * pMapRefs = Vec_IntArray( &p->vMapRefs );
+    float Epsilon = p->pPars->Epsilon;
+    int nLits = 2*Gia_ManObjNum(p->pGia);
+    int i, c, Id, nRefs[2];
+    Pf_Mat_t * pD, * pA, * pM;
+    Pf_Mat_t * pDs[2], * pAs[2], * pMs[2];
+    Gia_Obj_t * pObj;
+    float Required = 0, Requireds[2];
+    // check references
+    assert( !p->fUseEla );
+    memset( pMapRefs, 0, sizeof(int) * nLits );
+    Vec_FltFill( &p->vRequired, nLits, PF_INFINITY );
+//    for ( i = 0; i < Gia_ManObjNum(p->pGia); i++ )
+//        assert( !Pf_ObjMapRefNum(p, i, 0) && !Pf_ObjMapRefNum(p, i, 1) );
+    // compute delay
+    p->pPars->MapDelay = 0;
+    Gia_ManForEachCo( p->pGia, pObj, i )
+    {
+        Required = Pf_ObjMatchD( p, Gia_ObjFaninId0p(p->pGia, pObj), Gia_ObjFaninC0(pObj) )->D;
+        if ( Required == PF_INFINITY )
+        {
+            Pf_ManCutMatchprintf( p, Gia_ObjFaninId0p(p->pGia, pObj), Gia_ObjFaninC0(pObj), Pf_ObjMatchD( p, Gia_ObjFaninId0p(p->pGia, pObj), Gia_ObjFaninC0(pObj) ) );
+        }
+        p->pPars->MapDelay = Abc_MaxFloat( p->pPars->MapDelay, Required );
+    }
+    // check delay target
+    if ( p->pPars->MapDelayTarget == -1 && p->pPars->nRelaxRatio )
+        p->pPars->MapDelayTarget = (int)((float)p->pPars->MapDelay * (100.0 + p->pPars->nRelaxRatio) / 100.0);
+    if ( p->pPars->MapDelayTarget != -1 )
+    {
+        if ( p->pPars->MapDelay < p->pPars->MapDelayTarget + Epsilon )
+            p->pPars->MapDelay = p->pPars->MapDelayTarget;
+        else if ( p->pPars->nRelaxRatio == 0 )
+            Abc_Print( 0, "Relaxing user-specified delay target from %.2f to %.2f.\n", p->pPars->MapDelayTarget, p->pPars->MapDelay );
+    }
+    // set required times
+    Gia_ManForEachCo( p->pGia, pObj, i )
+    {
+        Required = Pf_ObjMatchD( p, Gia_ObjFaninId0p(p->pGia, pObj), Gia_ObjFaninC0(pObj) )->D;
+        Required = p->pPars->fDoAverage ? Required * (100.0 + p->pPars->nRelaxRatio) / 100.0 : p->pPars->MapDelay;
+        Pf_ObjUpdateRequired( p, Gia_ObjFaninId0p(p->pGia, pObj), Gia_ObjFaninC0(pObj), Required );
+        Pf_ObjMapRefInc( p, Gia_ObjFaninId0p(p->pGia, pObj), Gia_ObjFaninC0(pObj));
+    }
+    // compute area and edges
+    p->nInvs = 0;
+    p->pPars->MapArea = 0; 
+    p->pPars->Area = p->pPars->Edge = 0;
+    Gia_ManForEachAndReverse( p->pGia, pObj, i )
+    {
+        if ( Gia_ObjIsBuf(pObj) )
+        {
+            if ( Pf_ObjMapRefNum(p, i, 1) )
+            {
+                Pf_ObjMapRefInc( p, i, 0 );
+                Pf_ObjUpdateRequired( p, i, 0, Pf_ObjRequired(p, i, 1) - p->InvDelay );
+                p->pPars->MapArea += p->InvArea;
+                p->pPars->Edge++;
+                p->pPars->Area++;
+                p->nInvs++;
+            }
+            Pf_ObjUpdateRequired( p, Gia_ObjFaninId0(pObj, i), Gia_ObjFaninC0(pObj), Pf_ObjRequired(p, i, 0) );
+            Pf_ObjMapRefInc( p, Gia_ObjFaninId0(pObj, i), Gia_ObjFaninC0(pObj));
+            continue;
+        }
+        // skip if this node is not used
+        for ( c = 0; c < 2; c++ )
+        {
+            nRefs[c] = Pf_ObjMapRefNum(p, i, c);
+
+            //if ( Pf_ObjMatchD( p, i, c )->fCompl )
+            //    printf( "Match D of node %d has inv in phase %d.\n", i, c );
+            //if ( Pf_ObjMatchA( p, i, c )->fCompl )
+            //    printf( "Match A of node %d has inv in phase %d.\n", i, c );
+        }
+        if ( !nRefs[0] && !nRefs[1] )
+            continue;
+
+        // consider two cases
+        if ( nRefs[0] && nRefs[1] )
+        {
+            // find best matches for both phases
+            for ( c = 0; c < 2; c++ )
+            {
+                Requireds[c] = Pf_ObjRequired( p, i, c );
+                //assert( Requireds[c] < PF_INFINITY );
+                pDs[c] = Pf_ObjMatchD( p, i, c );
+                pAs[c] = Pf_ObjMatchA( p, i, c );
+                pMs[c] = (pAs[c]->D < Requireds[c] + Epsilon) ? pAs[c] : pDs[c];
+            }
+            // swap complemented matches
+            if ( pMs[0]->fCompl && pMs[1]->fCompl )
+            {
+                pMs[0]->fCompl = pMs[1]->fCompl = 0;
+                ABC_SWAP( Pf_Mat_t *, pMs[0], pMs[1] );
+            }
+            // check if intervers are involved
+            if ( !pMs[0]->fCompl && !pMs[1]->fCompl )
+            {
+                // no inverters
+                for ( c = 0; c < 2; c++ )
+                    Pf_ManSetMapRefsGate( p, i, Requireds[c], pMs[c] );
+            }
+            else 
+            {
+                // one interver
+                assert( !pMs[0]->fCompl || !pMs[1]->fCompl );
+                c = pMs[1]->fCompl;
+                assert( pMs[c]->fCompl && !pMs[!c]->fCompl );
+                //printf( "Using inverter at node %d in phase %d\n", i, c );
+
+                // update this phase phase
+                pM = pMs[c];
+                pM->fBest = 1;
+                Required = Requireds[c];
+
+                // update opposite phase
+                Pf_ObjMapRefInc( p, i, !c );
+                Pf_ObjUpdateRequired( p, i, !c, Required - p->InvDelay );
+
+                // select oppositve phase
+                Required = Pf_ObjRequired( p, i, !c );
+                //assert( Required < PF_INFINITY );
+                pD = Pf_ObjMatchD( p, i, !c );
+                pA = Pf_ObjMatchA( p, i, !c );
+                pM = (pA->D < Required + Epsilon) ? pA : pD;
+                assert( !pM->fCompl );
+
+                // account for the inverter
+                p->pPars->MapArea += p->InvArea;
+                p->pPars->Edge++;
+                p->pPars->Area++;
+                p->nInvs++;
+
+                // create gate
+                Pf_ManSetMapRefsGate( p, i, Required, pM );
+            }
+        }
+        else
+        {
+            c = (int)(nRefs[1] > 0);
+            assert( nRefs[c] && !nRefs[!c] );
+            // consider this phase
+            Required = Pf_ObjRequired( p, i, c );
+            //assert( Required < PF_INFINITY );
+            pD = Pf_ObjMatchD( p, i, c );
+            pA = Pf_ObjMatchA( p, i, c );
+            pM = (pA->D < Required + Epsilon) ? pA : pD;
+
+            if ( pM->fCompl ) // use inverter
+            {
+                p->nInvs++;
+                //printf( "Using inverter at node %d in phase %d\n", i, c );
+                pM->fBest = 1;
+                // update opposite phase
+                Pf_ObjMapRefInc( p, i, !c );
+                Pf_ObjUpdateRequired( p, i, !c, Required - p->InvDelay );
+                // select oppositve phase
+                Required = Pf_ObjRequired( p, i, !c );
+                //assert( Required < PF_INFINITY );
+                pD = Pf_ObjMatchD( p, i, !c );
+                pA = Pf_ObjMatchA( p, i, !c );
+                pM = (pA->D < Required + Epsilon) ? pA : pD;
+                assert( !pM->fCompl );
+
+                // account for the inverter
+                p->pPars->MapArea += p->InvArea;
+                p->pPars->Edge++;
+                p->pPars->Area++;
+            }
+
+            // create gate
+            Pf_ManSetMapRefsGate( p, i, Required, pM );
+        }
+
+
+        // the result of this:
+        // - only one phase can be implemented as inverter of the other phase
+        // - required times are propagated correctly
+        // - references are set correctly
+    }
+    Gia_ManForEachCiId( p->pGia, Id, i )
+        if ( Pf_ObjMapRefNum(p, Id, 1) )
+        {
+            Pf_ObjMapRefInc( p, Id, 0 );
+            Pf_ObjUpdateRequired( p, Id, 0, Required - p->InvDelay );
+            p->pPars->MapArea += p->InvArea;
+            p->pPars->Edge++;
+            p->pPars->Area++;
+            p->nInvs++;
+        }
+    // blend references
+    for ( i = 0; i < nLits; i++ )
+//        pFlowRefs[i] = Abc_MaxFloat(1.0, pMapRefs[i]);
+        pFlowRefs[i] = Abc_MaxFloat(1.0, Coef * pFlowRefs[i] + (1.0 - Coef) * Abc_MaxFloat(1, pMapRefs[i]));
+//        pFlowRefs[i] = 0.2 * pFlowRefs[i] + 0.8 * Abc_MaxFloat(1, pMapRefs[i]);
+//    memset( pMapRefs, 0, sizeof(int) * nLits );
+    return p->pPars->Area;
+}
+Gia_Man_t * Pf_ManDeriveMapping( Pf_Man_t * p )
+{
+    Vec_Int_t * vMapping;
+    Pf_Mat_t * pM;
+    int i, k, c, Id, iLit, * pCut;
+    assert( p->pGia->vCellMapping == NULL );
+    vMapping = Vec_IntAlloc( 2*Gia_ManObjNum(p->pGia) + (int)p->pPars->Edge + (int)p->pPars->Area * 2 );
+    Vec_IntFill( vMapping, 2*Gia_ManObjNum(p->pGia), 0 );
+    // create CI inverters
+    Gia_ManForEachCiId( p->pGia, Id, i )
+    if ( Pf_ObjMapRefNum(p, Id, 1) )
+        Vec_IntWriteEntry( vMapping, Abc_Var2Lit(Id, 1), -1 );
+    // create internal nodes
+    Gia_ManForEachAndId( p->pGia, i )
+    {
+        Gia_Obj_t * pObj = Gia_ManObj(p->pGia, i);
+        if ( Gia_ObjIsBuf(pObj) )
+        {
+            if ( Pf_ObjMapRefNum(p, i, 1) )
+                Vec_IntWriteEntry( vMapping, Abc_Var2Lit(i, 1), -1 );
+            Vec_IntWriteEntry( vMapping, Abc_Var2Lit(i, 0), -2 );
+            continue;
+        }
+        for ( c = 0; c < 2; c++ )
+        if ( Pf_ObjMapRefNum(p, i, c) )
+        {
+    //        printf( "Using %d %d\n", i, c );
+            pM = Pf_ObjMatchBest( p, i, c );
+            // remember inverter
+            if ( pM->fCompl )
+            {
+                Vec_IntWriteEntry( vMapping, Abc_Var2Lit(i, c), -1 );
+                continue;
+            }
+    //        Pf_ManCutMatchprintf( p, i, c, pM );
+            pCut = Pf_CutFromHandle( Pf_ObjCutSet(p, i), pM->CutH );
+            // create mapping
+            Vec_IntWriteEntry( vMapping, Abc_Var2Lit(i, c), Vec_IntSize(vMapping) );
+            Vec_IntPush( vMapping, Pf_CutSize(pCut) );
+            Pf_CutForEachLit( pCut, pM->Conf, iLit, k )
+                Vec_IntPush( vMapping, iLit );
+            Vec_IntPush( vMapping, pM->Gate );
+        }
+    }
+//    assert( Vec_IntCap(vMapping) == 16 || Vec_IntSize(vMapping) == Vec_IntCap(vMapping) );
+    p->pGia->vCellMapping = vMapping;
+    return p->pGia;
+}
+*/
+
+
+/**Function*************************************************************
+
+  Synopsis    [Technology mappping.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Pf_ManComputeMapping( Pf_Man_t * p )
+{
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Technology mappping.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Pf_ManSetDefaultPars( Jf_Par_t * pPars )
+{
+    memset( pPars, 0, sizeof(Jf_Par_t) );
+    pPars->nLutSize     =  6;
+    pPars->nCutNum      = 16;
+    pPars->nProcNum     =  0;
+    pPars->nRounds      =  3;
+    pPars->nRoundsEla   =  0;
+    pPars->nRelaxRatio  =  0;
+    pPars->nCoarseLimit =  3;
+    pPars->nAreaTuner   =  1;
+    pPars->nVerbLimit   =  5;
+    pPars->DelayTarget  = -1;
+    pPars->fAreaOnly    =  0;
+    pPars->fOptEdge     =  1; 
+    pPars->fCoarsen     =  0;
+    pPars->fCutMin      =  1;
+    pPars->fGenCnf      =  0;
+    pPars->fPureAig     =  0;
+    pPars->fVerbose     =  0;
+    pPars->fVeryVerbose =  0;
+    pPars->nLutSizeMax  =  PF_LEAF_MAX;
+    pPars->nCutNumMax   =  PF_CUT_MAX;
+    pPars->MapDelayTarget = -1;
+    pPars->Epsilon      = (float)0.01;
+}
+Gia_Man_t * Pf_ManPerformMapping( Gia_Man_t * pGia, Jf_Par_t * pPars )
+{
+    Gia_Man_t * pNew = NULL, * pCls;
+    Pf_Man_t * p; 
+    if ( Gia_ManHasChoices(pGia) )
+        pPars->fCoarsen = 0; 
+    pCls = pPars->fCoarsen ? Gia_ManDupMuxes(pGia, pPars->nCoarseLimit) : pGia;
+    p = Pf_StoCreate( pCls, pPars );
+//    if ( pPars->fVeryVerbose )
+        Pf_StoPrint( p, 1 );
+    if ( pPars->fVerbose && pPars->fCoarsen )
+    {
+        printf( "Initial " );  Gia_ManPrintMuxStats( pGia );  printf( "\n" );
+        printf( "Derived " );  Gia_ManPrintMuxStats( pCls );  printf( "\n" );
+    }
+    Pf_ManPrintInit( p );
+    Pf_ManComputeCuts( p );
+    Pf_ManPrintQuit( p );
+/*
+    Gia_ManForEachCiId( p->pGia, Id, i )
+        Pf_ObjPrepareCi( p, Id );
+    for ( p->Iter = 0; p->Iter < p->pPars->nRounds; p->Iter++ )
+    {
+        Pf_ManComputeMapping( p );
+        //Pf_ManSetMapRefs( p );
+        Pf_ManPrintStats( p, p->Iter ? "Area " : "Delay" );
+    }
+    p->fUseEla = 1;
+    for ( ; p->Iter < p->pPars->nRounds + pPars->nRoundsEla; p->Iter++ )
+    {
+        Pf_ManComputeMapping( p );
+        //Pf_ManUpdateStats( p );
+        Pf_ManPrintStats( p, "Ela  " );
+    }
+*/
+    pNew = NULL; //Pf_ManDeriveMapping( p );
+//    Gia_ManMappingVerify( pNew );
+    Pf_StoDelete( p );
+    if ( pCls != pGia )
+        Gia_ManStop( pCls );
+    if ( pNew == NULL )
+        return Gia_ManDup( pGia );
+    return pNew;
+}
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/abc-build/src/aig/gia/giaPolyn.c b/abc-build/src/aig/gia/giaPolyn.c
new file mode 100644
--- /dev/null
+++ b/abc-build/src/aig/gia/giaPolyn.c
@@ -0,0 +1,227 @@
+/**CFile****************************************************************
+
+  FileName    [giaPolyn.c]
+
+  SystemName  [ABC: Logic synthesis and verification system.]
+
+  PackageName [Scalable AIG package.]
+
+  Synopsis    [Polynomial manipulation.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - June 20, 2005.]
+
+  Revision    [$Id: giaPolyn.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+#include "misc/vec/vecWec.h"
+#include "misc/vec/vecHsh.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+/*
+!a            ->   1 - a
+a & b         ->   ab
+a | b         ->   a + b - ab
+a ^ b         ->   a + b - 2ab
+MUX(a, b, c)  ->   ab | (1 - a)c = ab + (1-a)c - ab(1-a)c = ab + c - ac
+
+!a & b        ->   (1 - a)b = b - ab
+ a & !b       ->   a(1 - b) = a - ab
+!a & !b       ->   1 - a - b + ab
+!(a & b)      ->   1 - ab
+*/
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Gia_PolynAddNew( Hsh_VecMan_t * pHash, Vec_Int_t * vCoef, int Coef, Vec_Int_t * vProd, Vec_Wec_t * vMap )
+{
+    int i, Lit, Value;
+    //Vec_IntPrint( vProd );
+
+    Value = Hsh_VecManAdd( pHash, vProd );
+    if ( Value == Vec_IntSize(vCoef) )
+    {
+        Vec_IntPush( vCoef, 0 );
+        Vec_IntForEachEntry( vProd, Lit, i )
+            Vec_WecPush( vMap, Abc_Lit2Var(Lit), Value );
+    }
+    assert( Value < Vec_IntSize(vCoef) );
+    Vec_IntAddToEntry( vCoef, Value, Coef );
+}
+int Gia_PolynTransform1( Hsh_VecMan_t * pHash, Vec_Int_t * vCoef, int Coef, Vec_Int_t * vProd, Vec_Wec_t * vMap, int Id )
+{
+    int i, Lit;
+    Vec_IntForEachEntry( vProd, Lit, i )
+        if ( Abc_Lit2Var(Lit) == Id )
+            break;
+    assert( i < Vec_IntSize(vProd) );
+    if ( !Abc_LitIsCompl(Lit) )
+        return 0;
+    // update array
+    Vec_IntWriteEntry( vProd, i, Abc_LitNot(Lit) );
+    Gia_PolynAddNew( pHash, vCoef, Coef, vProd, vMap );
+    Vec_IntWriteEntry( vProd, i, Lit );
+    return 1;
+}
+void Gia_PolynTransform( Hsh_VecMan_t * pHash, Vec_Int_t * vCoef, int Coef, Vec_Int_t * vProd, Vec_Wec_t * vMap, int Id, int Lit0, int Lit1, Vec_Int_t * vTemp )
+{
+    int pArray[2] = { Lit0, Lit1 };
+    Vec_Int_t vTwo = { 2, 2, pArray };
+
+    int Var0 = Abc_Lit2Var( Lit0 );
+    int Var1 = Abc_Lit2Var( Lit1 );
+    int i, Lit = Vec_IntPop(vProd);
+
+    assert( Abc_Lit2Var(Lit) == Id );
+    if ( Abc_LitIsCompl(Lit) )
+    {
+        Gia_PolynAddNew( pHash, vCoef, Coef, vProd, vMap );
+        Coef = -Coef;
+    }
+
+    assert( Var0 < Var1 );
+    Vec_IntForEachEntry( vProd, Lit, i )
+        if ( Abc_LitNot(Lit) == Lit0 || Abc_LitNot(Lit) == Lit1 )
+            return;
+    assert( Vec_IntCap(vTemp) >= Vec_IntSize(vTemp) + 2 );
+
+    // merge inputs
+    Vec_IntTwoMerge2Int( vProd, &vTwo, vTemp );
+/*
+    printf( "\n" );
+    Vec_IntPrint( vProd );
+    Vec_IntPrint( &vTwo );
+    Vec_IntPrint( vTemp );
+    printf( "\n" );
+*/
+    // create new
+    Gia_PolynAddNew( pHash, vCoef, Coef, vTemp, vMap );
+}
+int Gia_PolynPrint( Hsh_VecMan_t * pHash, Vec_Int_t * vCoef )
+{
+    Vec_Int_t * vProd;
+    int Value, Coef, Lit, i, Count = 0;
+    Vec_IntForEachEntry( vCoef, Coef, Value )
+    {
+        if ( Coef == 0 )
+            continue;
+        vProd = Hsh_VecReadEntry( pHash, Value );
+        printf( "(%d)", Coef );
+        Vec_IntForEachEntry( vProd, Lit, i )
+            printf( "*%d", Lit );
+        printf( " " );
+        Count++;
+    }
+    printf( "\n" );
+    return Count;
+}
+void Gia_PolynTest( Gia_Man_t * pGia )
+{
+    Hsh_VecMan_t * pHash = Hsh_VecManStart( 1000000 );
+    Vec_Int_t * vCoef = Vec_IntAlloc( 1000000 );
+    Vec_Wec_t * vMap = Vec_WecStart( Gia_ManObjNum(pGia) );
+    Vec_Int_t * vTemp = Vec_IntAlloc( 100000 );
+    Vec_Int_t * vThisOne, * vProd;
+    Gia_Obj_t * pObj;
+    int i, k, Value, Coef, Count;
+    abctime clk = Abc_Clock();
+
+    assert( Gia_ManPoNum(pGia) < 32 );
+
+    // add constant
+    Value = Hsh_VecManAdd( pHash, vTemp );
+    assert( Value == 0 );
+    Vec_IntPush( vCoef, 0 );
+
+    // start the outputs
+    Gia_ManForEachPo( pGia, pObj, i )
+    {
+        assert( Gia_ObjFaninId0p(pGia, pObj) > 0 );
+        Vec_IntFill( vTemp, 1, Gia_ObjFaninLit0p(pGia, pObj) );
+        Value = Hsh_VecManAdd( pHash, vTemp );
+        //assert( Value == i + 1 );
+        Vec_IntPush( vCoef, 1 << i );
+        Vec_WecPush( vMap, Gia_ObjFaninId0p(pGia, pObj), Value );
+    }
+    assert( Vec_IntSize(vCoef) == Hsh_VecSize(pHash) );
+
+    Gia_PolynPrint( pHash, vCoef );
+
+    // substitute
+    Gia_ManForEachAndReverse( pGia, pObj, i )
+    {
+        vThisOne = Vec_WecEntry( vMap, i );
+        assert( Vec_IntSize(vThisOne) > 0 );
+        Vec_IntForEachEntry( vThisOne, Value, k )
+        {
+            vProd = Hsh_VecReadEntry( pHash, Value );
+            Coef = Vec_IntEntry( vCoef, Value );
+            if ( Coef == 0 )
+                continue;
+            Gia_PolynTransform( pHash, vCoef, Coef, vProd, vMap, i, Gia_ObjFaninLit0p(pGia, pObj), Gia_ObjFaninLit1p(pGia, pObj), vTemp );
+            Vec_IntWriteEntry( vCoef, Value, 0 );
+        }
+        Vec_IntErase( vThisOne );
+    }
+
+    // inputs
+    Gia_ManForEachCiReverse( pGia, pObj, i )
+    {
+        vThisOne = Vec_WecEntry( vMap, Gia_ObjId(pGia, pObj) );
+        if ( Vec_IntSize(vThisOne) == 0 )
+            continue;
+        assert( Vec_IntSize(vThisOne) > 0 );
+        Vec_IntForEachEntry( vThisOne, Value, k )
+        {
+            vProd = Hsh_VecReadEntry( pHash, Value );
+            Coef = Vec_IntEntry( vCoef, Value );
+            if ( Coef == 0 )
+                continue;
+            if ( Gia_PolynTransform1( pHash, vCoef, Coef, vProd, vMap, Gia_ObjId(pGia, pObj) ) )
+                Vec_IntWriteEntry( vCoef, Value, 0 );
+        }
+        Vec_IntErase( vThisOne );
+    }
+
+    Count = Gia_PolynPrint( pHash, vCoef );
+    printf( "Entries = %d. Useful = %d.  ", Vec_IntSize(vCoef), Count );
+    Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
+
+    Hsh_VecManStop( pHash );
+    Vec_IntFree( vCoef );
+    Vec_WecFree( vMap );
+    Vec_IntFree( vTemp );
+}
+
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/abc-build/src/aig/gia/giaQbf.c b/abc-build/src/aig/gia/giaQbf.c
new file mode 100644
--- /dev/null
+++ b/abc-build/src/aig/gia/giaQbf.c
@@ -0,0 +1,492 @@
+/**CFile****************************************************************
+
+  FileName    [giaQbf.c]
+
+  SystemName  [ABC: Logic synthesis and verification system.]
+
+  PackageName [Scalable AIG package.]
+
+  Synopsis    [QBF solver.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - October 18, 2014.]
+
+  Revision    [$Id: giaQbf.c,v 1.00 2014/10/18 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+#include "sat/cnf/cnf.h"
+#include "sat/bsat/satStore.h"
+#include "misc/extra/extra.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+typedef struct Qbf_Man_t_ Qbf_Man_t; 
+struct Qbf_Man_t_
+{
+    Gia_Man_t *     pGia;           // original miter
+    int             nPars;          // parameter variables
+    int             nVars;          // functional variables
+    int             fVerbose;       // verbose flag
+    // internal variables
+    int             iParVarBeg;     // SAT var ID of the first par variable in the ver solver
+    sat_solver *    pSatVer;        // verification instance
+    sat_solver *    pSatSyn;        // synthesis instance
+    Vec_Int_t *     vValues;        // variable values
+    Vec_Int_t *     vParMap;        // parameter mapping
+    Vec_Int_t *     vLits;          // literals for the SAT solver
+    abctime         clkStart;       // global timeout
+    abctime         clkSat;         // SAT solver time
+};
+
+extern Cnf_Dat_t * Mf_ManGenerateCnf( Gia_Man_t * pGia, int nLutSize, int fCnfObjIds, int fAddOrCla, int fVerbose );
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    [Naive way to enumerate SAT assignments.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Gia_ManSatEnum( Gia_Man_t * pGia, int nConfLimit, int nTimeOut, int fVerbose )
+{
+    Cnf_Dat_t * pCnf;
+    sat_solver * pSat;
+    Vec_Int_t * vLits;
+    int i, iLit, iParVarBeg, Iter;
+    int nSolutions = 0, RetValue = 0;
+    abctime clkStart = Abc_Clock();
+    pCnf = Mf_ManGenerateCnf( pGia, 8, 0, 1, 0 );
+    pSat = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
+    iParVarBeg = pCnf->nVars - Gia_ManPiNum(pGia) - 1;
+    Cnf_DataFree( pCnf );
+    // iterate through the SAT assignment
+    vLits = Vec_IntAlloc( Gia_ManPiNum(pGia) );
+    for ( Iter = 1 ; ; Iter++ )
+    {
+        int status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)nConfLimit, 0, 0, 0 );
+        if ( status == l_False ) { RetValue =  1; break; }
+        if ( status == l_Undef ) { RetValue =  0; break; }
+        nSolutions++;
+        // extract SAT assignment
+        Vec_IntClear( vLits );
+        for ( i = 0; i < Gia_ManPiNum(pGia); i++ )
+            Vec_IntPush( vLits, Abc_Var2Lit(iParVarBeg+i, sat_solver_var_value(pSat, iParVarBeg+i)) );
+        if ( fVerbose )
+        {
+            printf( "%5d : ", Iter );
+            Vec_IntForEachEntry( vLits, iLit, i )
+                printf( "%d", !Abc_LitIsCompl(iLit) );
+            printf( "\n" );
+        }
+        // add clause
+        if ( !sat_solver_addclause( pSat, Vec_IntArray(vLits), Vec_IntArray(vLits) + Vec_IntSize(vLits) ) )
+            { RetValue =  1; break; }
+        if ( nTimeOut && (Abc_Clock() - clkStart)/CLOCKS_PER_SEC >= nTimeOut ) { RetValue = 0; break; }
+    }
+    sat_solver_delete( pSat );
+    Vec_IntFree( vLits );
+    if ( nTimeOut && (Abc_Clock() - clkStart)/CLOCKS_PER_SEC >= nTimeOut )
+        printf( "Enumerated %d assignments when timeout (%d sec) was reached.  ", nSolutions, nTimeOut );
+    else if ( nConfLimit && !RetValue )
+        printf( "Enumerated %d assignments when conflict limit (%d) was reached.  ", nSolutions, nConfLimit );
+    else 
+        printf( "Enumerated the complete set of %d assignments.  ", nSolutions );
+    Abc_PrintTime( 1, "Time", Abc_Clock() - clkStart );
+    return RetValue;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Dumps the original problem in QDIMACS format.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Gia_QbfDumpFile( Gia_Man_t * pGia, int nPars )
+{
+    // original problem: \exists p \forall x \exists y.  M(p,x,y)
+    // negated problem:  \forall p \exists x \exists y. !M(p,x,y)
+    Cnf_Dat_t * pCnf = Mf_ManGenerateCnf( pGia, 8, 0, 1, 0 );
+    Vec_Int_t * vVarMap, * vForAlls, * vExists;
+    Gia_Obj_t * pObj;
+    char * pFileName;
+    int i, Entry;
+    // create var map
+    vVarMap = Vec_IntStart( pCnf->nVars );
+    Gia_ManForEachCi( pGia, pObj, i )
+        if ( i < nPars )
+            Vec_IntWriteEntry( vVarMap, pCnf->pVarNums[Gia_ManCiIdToId(pGia, i)], 1 );
+    // create various maps
+    vForAlls = Vec_IntAlloc( nPars );
+    vExists = Vec_IntAlloc( Gia_ManCiNum(pGia) - nPars );
+    Vec_IntForEachEntry( vVarMap, Entry, i )
+        if ( Entry )
+            Vec_IntPush( vForAlls, i );
+        else
+            Vec_IntPush( vExists, i );
+    // generate CNF
+    pFileName = Extra_FileNameGenericAppend( pGia->pSpec, ".qdimacs" );
+    Cnf_DataWriteIntoFile( pCnf, pFileName, 0, vForAlls, vExists );
+    Cnf_DataFree( pCnf );
+    Vec_IntFree( vForAlls );
+    Vec_IntFree( vExists );
+    Vec_IntFree( vVarMap );
+    printf( "The 2QBF formula was written into file \"%s\".\n", pFileName );
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Generate one SAT assignment of the problem.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Qbf_Man_t * Gia_QbfAlloc( Gia_Man_t * pGia, int nPars, int fVerbose )
+{
+    Qbf_Man_t * p;
+    Cnf_Dat_t * pCnf;
+    Gia_ObjFlipFaninC0( Gia_ManPo(pGia, 0) );
+    pCnf = Mf_ManGenerateCnf( pGia, 8, 0, 1, 0 );
+    Gia_ObjFlipFaninC0( Gia_ManPo(pGia, 0) );
+    p = ABC_CALLOC( Qbf_Man_t, 1 );
+    p->clkStart   = Abc_Clock();
+    p->pGia       = pGia;
+    p->nPars      = nPars;
+    p->nVars      = Gia_ManPiNum(pGia) - nPars;
+    p->fVerbose   = fVerbose;
+    p->iParVarBeg = pCnf->nVars - Gia_ManPiNum(pGia) - 1;
+    p->pSatVer    = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
+    p->pSatSyn    = sat_solver_new();
+    p->vValues    = Vec_IntAlloc( Gia_ManPiNum(pGia) );
+    p->vParMap    = Vec_IntStartFull( nPars );
+    p->vLits      = Vec_IntAlloc( nPars );
+    sat_solver_setnvars( p->pSatSyn, nPars );
+    Cnf_DataFree( pCnf );
+    return p;
+}
+void Gia_QbfFree( Qbf_Man_t * p )
+{
+    sat_solver_delete( p->pSatVer );
+    sat_solver_delete( p->pSatSyn );
+    Vec_IntFree( p->vLits );
+    Vec_IntFree( p->vValues );
+    Vec_IntFree( p->vParMap );
+    ABC_FREE( p );
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Create and add one cofactor.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Gia_Man_t * Gia_QbfQuantify( Gia_Man_t * p, int nPars )
+{
+    Gia_Man_t * pNew, * pTemp;
+    Gia_Obj_t * pObj; 
+    int i, m, nMints = (1 << (Gia_ManPiNum(p) - nPars));
+    assert( Gia_ManPoNum(p) == 1 );
+    pNew = Gia_ManStart( Gia_ManObjNum(p) );
+    pNew->pName = Abc_UtilStrsav( p->pName );
+    Gia_ManHashAlloc( pNew );
+    Gia_ManConst0(p)->Value = 0;
+    for ( i = 0; i < nPars; i++ )
+        Gia_ManAppendCi(pNew);
+    for ( m = 0; m < nMints; m++ )
+    {
+        Gia_ManForEachPi( p, pObj, i )
+            pObj->Value = (i < nPars) ? Gia_Obj2Lit(pNew, Gia_ManPi(pNew, i)) : ((m >> (i - nPars)) & 1);
+        Gia_ManForEachAnd( p, pObj, i )
+            pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+        Gia_ManForEachCo( p, pObj, i )
+            pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+    }
+    pNew = Gia_ManCleanup( pTemp = pNew );
+    Gia_ManStop( pTemp );
+    assert( Gia_ManPiNum(pNew) == nPars );
+    assert( Gia_ManPoNum(pNew) == nMints );
+    return pNew;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Create and add one cofactor.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Gia_Man_t * Gia_QbfCofactor( Gia_Man_t * p, int nPars, Vec_Int_t * vValues, Vec_Int_t * vParMap )
+{
+    Gia_Man_t * pNew, * pTemp;
+    Gia_Obj_t * pObj; int i;
+    assert( Gia_ManPiNum(p) == nPars + Vec_IntSize(vValues) );
+    pNew = Gia_ManStart( Gia_ManObjNum(p) );
+    pNew->pName = Abc_UtilStrsav( p->pName );
+    Gia_ManHashAlloc( pNew );
+    Gia_ManConst0(p)->Value = 0;
+    Gia_ManForEachPi( p, pObj, i )
+        if ( i < nPars )
+        {
+            pObj->Value = Gia_ManAppendCi(pNew);
+            if ( Vec_IntEntry(vParMap, i) != -1 )
+                pObj->Value = Vec_IntEntry(vParMap, i);
+        }
+        else
+            pObj->Value = Vec_IntEntry(vValues, i - nPars);
+    Gia_ManForEachAnd( p, pObj, i )
+        pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+    Gia_ManForEachCo( p, pObj, i )
+        pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+    pNew = Gia_ManCleanup( pTemp = pNew );
+    Gia_ManStop( pTemp );
+    assert( Gia_ManPiNum(pNew) == nPars );
+    return pNew;
+}
+int Gia_QbfAddCofactor( Qbf_Man_t * p, Gia_Man_t * pCof )
+{
+    Cnf_Dat_t * pCnf = Mf_ManGenerateCnf( pCof, 8, 0, 1, 0 );
+    int i, iFirstVar = sat_solver_nvars(p->pSatSyn) + pCnf->nVars - Gia_ManPiNum(pCof) - 1;
+    pCnf->pMan = NULL;
+    Cnf_DataLift( pCnf, sat_solver_nvars(p->pSatSyn) );
+    for ( i = 0; i < pCnf->nClauses; i++ )
+        if ( !sat_solver_addclause( p->pSatSyn, pCnf->pClauses[i], pCnf->pClauses[i+1] ) )
+        {
+            Cnf_DataFree( pCnf );
+            return 0;
+        }
+    Cnf_DataFree( pCnf );
+    // add connection clauses
+    for ( i = 0; i < Gia_ManPiNum(p->pGia); i++ )
+        if ( !sat_solver_add_buffer( p->pSatSyn, i, iFirstVar+i, 0 ) )
+            return 0;
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Extract SAT assignment.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Gia_QbfOnePattern( Qbf_Man_t * p, Vec_Int_t * vValues )
+{
+    int i;
+    Vec_IntClear( vValues );
+    for ( i = 0; i < p->nPars; i++ )
+        Vec_IntPush( vValues, sat_solver_var_value(p->pSatSyn, i) );
+}
+void Gia_QbfPrint( Qbf_Man_t * p, Vec_Int_t * vValues, int Iter )
+{
+    printf( "%5d : ", Iter );
+    assert( Vec_IntSize(vValues) == p->nVars );
+    Vec_IntPrintBinary( vValues ); printf( "  " );
+    printf( "Var = %6d  ", sat_solver_nvars(p->pSatSyn) );
+    printf( "Cla = %6d  ", sat_solver_nclauses(p->pSatSyn) );
+    printf( "Conf = %6d  ", sat_solver_nconflicts(p->pSatSyn) );
+    Abc_PrintTime( 1, "Time", Abc_Clock() - p->clkStart );
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Generate one SAT assignment in terms of functional vars.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Gia_QbfVerify( Qbf_Man_t * p, Vec_Int_t * vValues )
+{
+    int i, Entry, RetValue;
+    assert( Vec_IntSize(vValues) == p->nPars );
+    Vec_IntClear( p->vLits );
+    Vec_IntForEachEntry( vValues, Entry, i )
+        Vec_IntPush( p->vLits, Abc_Var2Lit(p->iParVarBeg+i, !Entry) );
+    RetValue = sat_solver_solve( p->pSatVer, Vec_IntArray(p->vLits), Vec_IntLimit(p->vLits), 0, 0, 0, 0 );
+    if ( RetValue == l_True )
+    {
+        Vec_IntClear( vValues );
+        for ( i = 0; i < p->nVars; i++ )
+            Vec_IntPush( vValues, sat_solver_var_value(p->pSatVer, p->iParVarBeg+p->nPars+i) );
+    }
+    return RetValue == l_True ? 1 : 0;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Constraint learning.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Gia_QbfAddSpecialConstr( Qbf_Man_t * p )
+{
+    int i, status, Lits[2];
+    for ( i = 0; i < 4*11; i++ )
+        if ( i % 4 == 0 )
+        {
+            assert( Vec_IntEntry(p->vParMap, i) == -1 );
+            Vec_IntWriteEntry( p->vParMap, i, (i % 4) == 3 );
+            Lits[0] = Abc_Var2Lit( i, (i % 4) != 3 );
+            status = sat_solver_addclause( p->pSatSyn, Lits, Lits+1 );
+            assert( status );
+        }
+}
+void Gia_QbfLearnConstraint( Qbf_Man_t * p, Vec_Int_t * vValues )
+{
+    int i, status, Entry, Lits[2];
+    assert( Vec_IntSize(vValues) == p->nPars );
+    printf( "  Pattern   " );
+    Vec_IntPrintBinary( vValues );
+    printf( "\n" );
+    Vec_IntForEachEntry( vValues, Entry, i )
+    {
+        Lits[0] = Abc_Var2Lit( i, Entry );
+        status = sat_solver_solve( p->pSatSyn, Lits, Lits+1, 0, 0, 0, 0 );
+        printf( "  Var =%4d ", i );
+        if ( status != l_True )
+        {
+            printf( "UNSAT\n" );
+            Lits[0] = Abc_LitNot(Lits[0]);
+            status = sat_solver_addclause( p->pSatSyn, Lits, Lits+1 );
+            assert( status );
+            continue;
+        }
+        Gia_QbfOnePattern( p, p->vLits );
+        Vec_IntPrintBinary( p->vLits );
+        printf( "\n" );
+    }
+    assert( Vec_IntSize(vValues) == p->nPars );
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Performs QBF solving using an improved algorithm.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Gia_QbfSolve( Gia_Man_t * pGia, int nPars, int nIterLimit, int nConfLimit, int nTimeOut, int fVerbose )
+{
+    Qbf_Man_t * p = Gia_QbfAlloc( pGia, nPars, fVerbose );
+    Gia_Man_t * pCof;
+    int i, status, RetValue = 0;
+    abctime clk;
+//    Gia_QbfAddSpecialConstr( p );
+    if ( fVerbose )
+        printf( "Solving QBF for \"%s\" with %d parameters, %d variables and %d AIG nodes.\n", 
+            Gia_ManName(pGia), p->nPars, p->nVars, Gia_ManAndNum(pGia) );
+    assert( Gia_ManRegNum(pGia) == 0 );
+    Vec_IntFill( p->vValues, nPars, 0 );
+    for ( i = 0; Gia_QbfVerify(p, p->vValues); i++ )
+    {
+        // generate next constraint
+        assert( Vec_IntSize(p->vValues) == p->nVars );
+        pCof = Gia_QbfCofactor( pGia, nPars, p->vValues, p->vParMap );
+        status = Gia_QbfAddCofactor( p, pCof );
+        Gia_ManStop( pCof );
+        if ( status == 0 )       { RetValue =  1; break; }
+        // synthesize next assignment
+        clk = Abc_Clock();
+        status = sat_solver_solve( p->pSatSyn, NULL, NULL, (ABC_INT64_T)nConfLimit, 0, 0, 0 );
+        p->clkSat += Abc_Clock() - clk;
+        if ( fVerbose )
+            Gia_QbfPrint( p, p->vValues, i );
+        if ( status == l_False ) { RetValue =  1; break; }
+        if ( status == l_Undef ) { RetValue = -1; break; }
+        // extract SAT assignment
+        Gia_QbfOnePattern( p, p->vValues );
+        assert( Vec_IntSize(p->vValues) == p->nPars );
+        // examine variables
+//        Gia_QbfLearnConstraint( p, p->vValues );
+//        Vec_IntPrintBinary( p->vValues ); printf( "\n" );
+        if ( nIterLimit && i+1 == nIterLimit ) { RetValue = -1; break; }
+        if ( nTimeOut && (Abc_Clock() - p->clkStart)/CLOCKS_PER_SEC >= nTimeOut ) { RetValue = -1; break; }
+    }
+    if ( RetValue == 0 )
+    {
+        printf( "Parameters: " );
+        assert( Vec_IntSize(p->vValues) == nPars );
+        Vec_IntPrintBinary( p->vValues );
+        printf( "\n" );
+    }
+    if ( RetValue == -1 && nTimeOut && (Abc_Clock() - p->clkStart)/CLOCKS_PER_SEC >= nTimeOut )
+        printf( "The problem timed out after %d sec.  ", nTimeOut );
+    else if ( RetValue == -1 && nConfLimit )
+        printf( "The problem aborted after %d conflicts.  ", nConfLimit );
+    else if ( RetValue == -1 && nIterLimit )
+        printf( "The problem aborted after %d iterations.  ", nIterLimit );
+    else if ( RetValue == 1 )
+        printf( "The problem is UNSAT after %d iterations.  ", i );
+    else 
+        printf( "The problem is SAT after %d iterations.  ", i );
+    if ( fVerbose )
+    {
+        printf( "\n" );
+        Abc_PrintTime( 1, "SAT  ", p->clkSat );
+        Abc_PrintTime( 1, "Other", Abc_Clock() - p->clkStart - p->clkSat );
+        Abc_PrintTime( 1, "TOTAL", Abc_Clock() - p->clkStart );
+    }
+    else
+        Abc_PrintTime( 1, "Time", Abc_Clock() - p->clkStart );
+    Gia_QbfFree( p );
+    return RetValue;
+}
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/abc-build/src/aig/gia/giaScl.c b/abc-build/src/aig/gia/giaScl.c
--- a/abc-build/src/aig/gia/giaScl.c
+++ b/abc-build/src/aig/gia/giaScl.c
@@ -33,7 +33,7 @@
 
 /**Function*************************************************************
 
-  Synopsis    [Marks unreachable internal nodes and returned their number.]
+  Synopsis    [Marks unreachable internal nodes and returns their number.]
 
   Description []
                
@@ -49,31 +49,22 @@
     if ( !pObj->fMark0 )
         return 0;
     pObj->fMark0 = 0;
-    assert( Gia_ObjIsAnd(pObj) );
+    assert( Gia_ObjIsAnd(pObj) );
+    assert( !Gia_ObjIsBuf(pObj) );
     return 1 + Gia_ManCombMarkUsed_rec( p, Gia_ObjFanin0(pObj) )
              + Gia_ManCombMarkUsed_rec( p, Gia_ObjFanin1(pObj) )
              + (p->pNexts ? Gia_ManCombMarkUsed_rec( p, Gia_ObjNextObj(p, Gia_ObjId(p, pObj)) ) : 0)
              + (p->pSibls ? Gia_ManCombMarkUsed_rec( p, Gia_ObjSiblObj(p, Gia_ObjId(p, pObj)) ) : 0)
              + (p->pMuxes ? Gia_ManCombMarkUsed_rec( p, Gia_ObjFanin2(p, pObj) ) : 0);
 }
-
-/**Function*************************************************************
-
-  Synopsis    [Marks unreachable internal nodes and returned their number.]
-
-  Description []
-               
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
 int Gia_ManCombMarkUsed( Gia_Man_t * p )
 {
     Gia_Obj_t * pObj;
     int i, nNodes = 0;
     Gia_ManForEachObj( p, pObj, i )
-        pObj->fMark0 = Gia_ObjIsAnd(pObj);
+        pObj->fMark0 = Gia_ObjIsAnd(pObj) && !Gia_ObjIsBuf(pObj);
+    Gia_ManForEachBuf( p, pObj, i )
+        nNodes += Gia_ManCombMarkUsed_rec( p, Gia_ObjFanin0(pObj) );
     Gia_ManForEachCo( p, pObj, i )
         nNodes += Gia_ManCombMarkUsed_rec( p, Gia_ObjFanin0(pObj) );
     return nNodes;
diff --git a/abc-build/src/aig/gia/giaScript.c b/abc-build/src/aig/gia/giaScript.c
--- a/abc-build/src/aig/gia/giaScript.c
+++ b/abc-build/src/aig/gia/giaScript.c
@@ -18,9 +18,11 @@
 
 ***********************************************************************/
 
-#include "gia.h"
+#include "giaAig.h"
 #include "base/main/main.h"
 #include "base/cmd/cmd.h"
+#include "proof/dch/dch.h"
+#include "opt/dau/dau.h"
 
 ABC_NAMESPACE_IMPL_START
 
@@ -224,6 +226,35 @@
 
 /**Function*************************************************************
 
+  Synopsis    [Duplicates the AIG manager.]
+
+  Description [This duplicator works for AIGs with choices.]
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Vec_Ptr_t * Gia_ManOrderPios( Aig_Man_t * p, Gia_Man_t * pOrder )
+{
+    Vec_Ptr_t * vPios;
+    Gia_Obj_t * pObj;
+    int i;
+    assert( Aig_ManCiNum(p) == Gia_ManCiNum(pOrder) );
+    assert( Aig_ManCoNum(p) == Gia_ManCoNum(pOrder) );
+    vPios = Vec_PtrAlloc( Aig_ManCiNum(p) + Aig_ManCoNum(p) );
+    Gia_ManForEachObj( pOrder, pObj, i )
+    {
+        if ( Gia_ObjIsCi(pObj) )
+            Vec_PtrPush( vPios, Aig_ManCi(p, Gia_ObjCioId(pObj)) );
+        else if ( Gia_ObjIsCo(pObj) )
+            Vec_PtrPush( vPios, Aig_ManCo(p, Gia_ObjCioId(pObj)) );
+    }
+    return vPios;
+}
+
+/**Function*************************************************************
+
   Synopsis    []
 
   Description []
@@ -233,10 +264,230 @@
   SeeAlso     []
 
 ***********************************************************************/
-void Gia_ManPerformMap( int nAnds, int nLutSize, int nCutNum, int fVerbose )
+Gia_Man_t * Gia_ManDupFromBarBufs( Gia_Man_t * p )
 {
+    Vec_Int_t * vBufObjs;
+    Gia_Man_t * pNew;
+    Gia_Obj_t * pObj;
+    int i, k = 0;
+    assert( Gia_ManBufNum(p) > 0 );
+    assert( Gia_ManRegNum(p) == 0 );
+    assert( !Gia_ManHasChoices(p) );
+    pNew = Gia_ManStart( Gia_ManObjNum(p) );
+    pNew->pName = Abc_UtilStrsav( p->pName );
+    pNew->pSpec = Abc_UtilStrsav( p->pSpec );
+    Gia_ManFillValue(p);
+    Gia_ManConst0(p)->Value = 0;
+    Gia_ManForEachCi( p, pObj, i )
+        pObj->Value = Gia_ManAppendCi( pNew );
+    vBufObjs = Vec_IntAlloc( Gia_ManBufNum(p) );
+    for ( i = 0; i < Gia_ManBufNum(p); i++ )
+        Vec_IntPush( vBufObjs, Gia_ManAppendCi(pNew) );
+    Gia_ManForEachAnd( p, pObj, i )
+    {
+        if ( Gia_ObjIsBuf(pObj) )
+        {
+            pObj->Value = Vec_IntEntry( vBufObjs, k );
+            Vec_IntWriteEntry( vBufObjs, k++, Gia_ObjFanin0Copy(pObj) );
+        }
+        else 
+            pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+    }
+    assert( k == Gia_ManBufNum(p) );
+    for ( i = 0; i < Gia_ManBufNum(p); i++ )
+        Gia_ManAppendCo( pNew, Vec_IntEntry(vBufObjs, i) );
+    Vec_IntFree( vBufObjs );
+    Gia_ManForEachCo( p, pObj, i )
+        Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+    Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+    return pNew;
+}
+Gia_Man_t * Gia_ManDupToBarBufs( Gia_Man_t * p, int nBarBufs )
+{
+    Gia_Man_t * pNew;
+    Gia_Obj_t * pObj;
+    int nPiReal = Gia_ManCiNum(p) - nBarBufs;
+    int nPoReal = Gia_ManCoNum(p) - nBarBufs;
+    int i, k = 0;
+    assert( Gia_ManBufNum(p) == 0 );
+    assert( Gia_ManRegNum(p) == 0 );
+    assert( Gia_ManHasChoices(p) );
+    pNew = Gia_ManStart( Gia_ManObjNum(p) );
+    pNew->pName = Abc_UtilStrsav( p->pName );
+    pNew->pSpec = Abc_UtilStrsav( p->pSpec );
+    if ( Gia_ManHasChoices(p) )
+        pNew->pSibls = ABC_CALLOC( int, Gia_ManObjNum(p) );
+    Gia_ManFillValue(p);
+    Gia_ManConst0(p)->Value = 0;
+    for ( i = 0; i < nPiReal; i++ )
+        Gia_ManCi(p, i)->Value = Gia_ManAppendCi( pNew );
+    Gia_ManForEachAnd( p, pObj, i )
+    {
+        for ( ; k < nBarBufs; k++ )
+            if ( ~Gia_ObjFanin0(Gia_ManCo(p, k))->Value )
+                Gia_ManCi(p, nPiReal + k)->Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(Gia_ManCo(p, k)) );
+            else
+                break;
+        pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+        if ( Gia_ObjSibl(p, Gia_ObjId(p, pObj)) )
+            pNew->pSibls[Abc_Lit2Var(pObj->Value)] = Abc_Lit2Var(Gia_ObjSiblObj(p, Gia_ObjId(p, pObj))->Value);  
+    }
+    for ( ; k < nBarBufs; k++ )
+        if ( ~Gia_ObjFanin0Copy(Gia_ManCo(p, k)) )
+            Gia_ManCi(p, nPiReal + k)->Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(Gia_ManCo(p, k)) );
+    assert( k == nBarBufs );
+    for ( i = 0; i < nPoReal; i++ )
+        Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(Gia_ManCo(p, nBarBufs+i)) );
+    Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+    assert( Gia_ManBufNum(pNew) == nBarBufs );
+    assert( Gia_ManCiNum(pNew) == nPiReal );
+    assert( Gia_ManCoNum(pNew) == nPoReal );
+    return pNew;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManAigSynch2Choices( Gia_Man_t * pGia1, Gia_Man_t * pGia2, Gia_Man_t * pGia3, Dch_Pars_t * pPars )
+{
+    Aig_Man_t * pMan, * pTemp;
+    Gia_Man_t * pGia, * pMiter;
+    // derive miter
+    Vec_Ptr_t * vPios, * vGias = Vec_PtrAlloc( 3 );
+    if ( pGia3 ) Vec_PtrPush( vGias, pGia3 );
+    if ( pGia2 ) Vec_PtrPush( vGias, pGia2 );
+    if ( pGia1 ) Vec_PtrPush( vGias, pGia1 );
+    pMiter = Gia_ManChoiceMiter( vGias );
+    Vec_PtrFree( vGias );
+    // transform into an AIG
+    pMan = Gia_ManToAigSkip( pMiter, 3 );
+    Gia_ManStop( pMiter );
+    // compute choices
+    pMan = Dch_ComputeChoices( pTemp = pMan, pPars );
+    Aig_ManStop( pTemp );
+    // reconstruct the network
+    vPios = Gia_ManOrderPios( pMan, pGia1 ); 
+    pMan = Aig_ManDupDfsGuided( pTemp = pMan, vPios );
+    Aig_ManStop( pTemp );
+    Vec_PtrFree( vPios );
+    // convert to GIA
+    pGia = Gia_ManFromAigChoices( pMan );
+    Aig_ManStop( pMan );
+    return pGia;
+}
+Gia_Man_t * Gia_ManAigSynch2( Gia_Man_t * pInit, void * pPars0, int nLutSize, int nRelaxRatio )
+{
+    extern Gia_Man_t * Gia_ManLutBalance( Gia_Man_t * p, int nLutSize, int fUseMuxes, int fRecursive, int fOptArea, int fVerbose );
+    Dch_Pars_t * pParsDch = (Dch_Pars_t *)pPars0;
+    Gia_Man_t * pGia1, * pGia2, * pGia3, * pNew, * pTemp;
+    int fVerbose = pParsDch->fVerbose;
+    Jf_Par_t Pars, * pPars = &Pars;
+    Lf_ManSetDefaultPars( pPars );
+    pPars->fCutMin     = 1;
+    pPars->fCoarsen    = 1;
+    pPars->nRelaxRatio = nRelaxRatio;
+    pPars->nAreaTuner  = 5;
+    pPars->nCutNum     = 12;
+    pPars->fVerbose    = fVerbose;
+    if ( fVerbose )  Gia_ManPrintStats( pInit, NULL );
+    pGia1 = Gia_ManDup( pInit );
+    if ( Gia_ManAndNum(pGia1) == 0 )
+    {
+        Gia_ManTransferTiming( pGia1, pInit );
+        return pGia1;
+    }
+    if ( pGia1->pManTime && pGia1->vLevels == NULL )
+        Gia_ManLevelWithBoxes( pGia1 );
+    // unmap if mapped
+    if ( Gia_ManHasMapping(pInit) )
+    {
+        Gia_ManTransferMapping( pGia1, pInit );
+        pGia1 = (Gia_Man_t *)Dsm_ManDeriveGia( pTemp = pGia1, 0 );
+        Gia_ManStop( pTemp );
+    }
+    // perform balancing
+    if ( Gia_ManBufNum(pGia1) || 1 )
+        pGia2 = Gia_ManAreaBalance( pGia1, 0, ABC_INFINITY, 0, 0 );
+    else
+    {
+        pGia2 = Gia_ManLutBalance( pGia1, nLutSize, 1, 1, 1, 0 );
+        pGia2 = Gia_ManAreaBalance( pTemp = pGia2, 0, ABC_INFINITY, 0, 0 );
+        Gia_ManStop( pTemp );
+    }
+    if ( fVerbose )     Gia_ManPrintStats( pGia2, NULL );
+    // perform mapping
+    pGia2 = Lf_ManPerformMapping( pTemp = pGia2, pPars );
+    if ( fVerbose )     Gia_ManPrintStats( pGia2, NULL );
+    if ( pTemp != pGia2 )
+        Gia_ManStop( pTemp );
+    // perform balancing
+    if ( pParsDch->fLightSynth || Gia_ManBufNum(pGia2) )
+        pGia3 = Gia_ManAreaBalance( pGia2, 0, ABC_INFINITY, 0, 0 );
+    else
+    {
+        assert( Gia_ManBufNum(pGia2) == 0 );
+        pGia2 = Gia_ManAreaBalance( pTemp = pGia2, 0, ABC_INFINITY, 0, 0 );
+        if ( fVerbose )     Gia_ManPrintStats( pGia2, NULL );
+        Gia_ManStop( pTemp );
+        // perform DSD balancing
+        pGia3 = Gia_ManPerformDsdBalance( pGia2, 6, 8, 0, 0 );
+    }
+    if ( fVerbose )     Gia_ManPrintStats( pGia3, NULL );
+    // perform choice computation
+    if ( Gia_ManBufNum(pInit) )
+    {
+        assert( Gia_ManBufNum(pInit) == Gia_ManBufNum(pGia1) );
+        pGia1 = Gia_ManDupFromBarBufs( pTemp = pGia1 );
+        Gia_ManStop( pTemp );
+        assert( Gia_ManBufNum(pInit) == Gia_ManBufNum(pGia2) );
+        pGia2 = Gia_ManDupFromBarBufs( pTemp = pGia2 );
+        Gia_ManStop( pTemp );
+        assert( Gia_ManBufNum(pInit) == Gia_ManBufNum(pGia3) );
+        pGia3 = Gia_ManDupFromBarBufs( pTemp = pGia3 );
+        Gia_ManStop( pTemp );
+    }
+    pNew = Gia_ManAigSynch2Choices( pGia1, pGia2, pGia3, pParsDch );
+    Gia_ManStop( pGia1 );
+    Gia_ManStop( pGia2 );
+    Gia_ManStop( pGia3 );
+    if ( Gia_ManBufNum(pInit) )
+    {
+        pNew = Gia_ManDupToBarBufs( pTemp = pNew, Gia_ManBufNum(pInit) );
+        Gia_ManStop( pTemp );
+    }
+    // copy names
+    ABC_FREE( pNew->pName );
+    ABC_FREE( pNew->pSpec );
+    pNew->pName = Abc_UtilStrsav(pInit->pName);
+    pNew->pSpec = Abc_UtilStrsav(pInit->pSpec);
+    Gia_ManTransferTiming( pNew, pInit );
+    return pNew;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Gia_ManPerformMap( int nAnds, int nLutSize, int nCutNum, int fMinAve, int fUseMfs, int fVerbose )
+{
     char Command[200];
-    sprintf( Command, "&unmap; &lf -K %d -C %d -k; &save", nLutSize, nCutNum );
+    sprintf( Command, "&unmap; &lf -K %d -C %d -k %s; &save", nLutSize, nCutNum, fMinAve?"-t":"" );
+//    sprintf( Command, "&unmap; &if -K %d -C %d %s; &save", nLutSize, nCutNum, fMinAve?"-t":"" );
     Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Command );
 	if ( fVerbose )
 	{
@@ -244,7 +495,7 @@
 		printf( "Mapping with &lf -k:\n" );
 		Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" );
 	}
-    sprintf( Command, "&unmap; &lf -K %d -C %d; &save", nLutSize, nCutNum );
+    sprintf( Command, "&unmap; &lf -K %d -C %d %s; &save", nLutSize, nCutNum, fMinAve?"-t":"" );
     Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Command );
 	if ( fVerbose )
 	{
@@ -253,24 +504,26 @@
 	}
 	if ( (nLutSize == 4 && nAnds < 100000) || (nLutSize == 6 && nAnds < 2000) )
 	{
-		sprintf( Command, "&unmap; &if -sz -S %d%d -K %d -C %d", nLutSize, nLutSize, 2*nLutSize-1, 2*nCutNum );
+		sprintf( Command, "&unmap; &if -sz -S %d%d -K %d -C %d %s", nLutSize, nLutSize, 2*nLutSize-1, 2*nCutNum, fMinAve?"-t":"" );
 		Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Command );
 		Vec_IntFreeP( &Abc_FrameReadGia(Abc_FrameGetGlobalFrame())->vPacking );
 		Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&save" );
 		if ( fVerbose )
 		{
-			printf( "Mapping with &if -sz -S %d%d -K %d -C %d:\n", nLutSize, nLutSize, 2*nLutSize-1, 2*nCutNum );
+			printf( "Mapping with &if -sz -S %d%d -K %d -C %d %s:\n", nLutSize, nLutSize, 2*nLutSize-1, 2*nCutNum, fMinAve?"-t":"" );
 			Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" );
 		}
 	}
 	Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&load" );
+    if ( fUseMfs )
+	    Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&put; mfs2 -W 4 -M 500 -C 7000; &get -m" );
 	if ( fVerbose )
 	{
 		printf( "Mapping final:\n" );
 		Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" );
 	}
 }
-void Gia_ManPerformRound( int fIsMapped, int nAnds, int nLevels, int nLutSize, int nCutNum, int nRelaxRatio, int fVerbose )
+void Gia_ManPerformRound( int fIsMapped, int nAnds, int nLevels, int nLutSize, int nCutNum, int fMinAve, int fUseMfs, int fVerbose )
 {
     char Command[200];
 
@@ -278,11 +531,11 @@
 	if ( nAnds < 50000 )
 	{
 		Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "" );
-		sprintf( Command, "&dsdb; &dch -f; &if -K %d -C %d; &save", nLutSize, nCutNum );
+		sprintf( Command, "&dsdb; &dch -C 500; &if -K %d -C %d %s; &save", nLutSize, nCutNum, fMinAve?"-t":"" );
 		Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Command );
 		if ( fVerbose )
 		{
-			printf( "Mapping with &dch -f; &if -K %d -C %d:\n", nLutSize, nCutNum );
+			printf( "Mapping with &dch -C 500; &if -K %d -C %d %s:\n", nLutSize, nCutNum, fMinAve?"-t":"" );
 			Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" );
 		}
 		Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&st" );
@@ -292,25 +545,25 @@
 	if ( nAnds < 20000 )
 	{
 		Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "" );
-		sprintf( Command, "&dsdb; &dch -f; &if -K %d -C %d; &save", nLutSize, nCutNum );
+		sprintf( Command, "&dsdb; &dch -C 500; &if -K %d -C %d %s; &save", nLutSize, nCutNum, fMinAve?"-t":"" );
 		Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Command );
 		if ( fVerbose )
 		{
-			printf( "Mapping with &dch -f; &if -K %d -C %d:\n", nLutSize, nCutNum );
+			printf( "Mapping with &dch -C 500; &if -K %d -C %d %s:\n", nLutSize, nCutNum, fMinAve?"-t":"" );
 			Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" );
 		}
 		Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&st" );
 	}
 
 	// perform first round of mapping
-	Gia_ManPerformMap( nAnds, nLutSize, nCutNum, fVerbose );
+	Gia_ManPerformMap( nAnds, nLutSize, nCutNum, fMinAve, fUseMfs, fVerbose );
 	Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&st" );
 
 	// perform synthesis
 	Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&dsdb" );
 
 	// perform second round of mapping
-	Gia_ManPerformMap( nAnds, nLutSize, nCutNum, fVerbose );
+	Gia_ManPerformMap( nAnds, nLutSize, nCutNum, fMinAve, fUseMfs, fVerbose );
 	Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&st" );
 
 	// perform synthesis
@@ -321,44 +574,151 @@
     Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Command );
 
 	// perform third round of mapping
-	Gia_ManPerformMap( nAnds, nLutSize, nCutNum, fVerbose );
+	Gia_ManPerformMap( nAnds, nLutSize, nCutNum, fMinAve, fUseMfs, fVerbose );
 }
-void Gia_ManPerformFlow( int fIsMapped, int nAnds, int nLevels, int nLutSize, int nCutNum, int nRelaxRatio, int fVerbose )
+void Gia_ManPerformFlow( int fIsMapped, int nAnds, int nLevels, int nLutSize, int nCutNum, int fMinAve, int fUseMfs, int fVerbose )
 {
 	// remove comb equivs
 	if ( fIsMapped )
 	    Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&st" );
-	if ( Abc_FrameReadGia(Abc_FrameGetGlobalFrame())->pManTime )
-		Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&sweep" );
-	else
-		Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&fraig -c" );
+//	if ( Abc_FrameReadGia(Abc_FrameGetGlobalFrame())->pManTime )
+//		Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&sweep" );
+//	else
+//		Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&fraig -c" );
 
 	// perform first round
-	Gia_ManPerformRound( fIsMapped, nAnds, nLevels, nLutSize, nCutNum, nRelaxRatio, fVerbose );
+	Gia_ManPerformRound( fIsMapped, nAnds, nLevels, nLutSize, nCutNum, fMinAve, fUseMfs, fVerbose );
 
 	// perform synthesis
 	Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&st; &sopb" );
 
 	// perform first round
-	Gia_ManPerformRound( fIsMapped, nAnds, nLevels, nLutSize, nCutNum, nRelaxRatio, fVerbose );
+	Gia_ManPerformRound( fIsMapped, nAnds, nLevels, nLutSize, nCutNum, fMinAve, fUseMfs, fVerbose );
 }
 
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-               
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-Gia_Man_t * Gia_ManAigSynch2( Gia_Man_t * p, int fVerbose )
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Gia_ManPerformFlow2( int fIsMapped, int nAnds, int nLevels, int nLutSize, int nCutNum, int fBalance, int fMinAve, int fUseMfs, int fVerbose )
 {
-    return NULL;
+    char Comm1[100], Comm2[100], Comm3[100], Comm4[100];
+    sprintf( Comm1, "&synch2 -K %d -C 500; &if -m%s       -K %d -C %d; %s &save", nLutSize, fMinAve?"t":"", nLutSize, nCutNum,   fUseMfs ? "&put; mfs2 -W 4 -M 500 -C 7000; &get -m;":"" );
+    sprintf( Comm2, "&dch -C 500;          &if -m%s       -K %d -C %d; %s &save",           fMinAve?"t":"", nLutSize, nCutNum+4, fUseMfs ? "&put; mfs2 -W 4 -M 500 -C 7000; &get -m;":"" );
+    sprintf( Comm3, "&synch2 -K %d -C 500; &lf -m%s  -E 5 -K %d -C %d; %s &save", nLutSize, fMinAve?"t":"", nLutSize, nCutNum,   fUseMfs ? "&put; mfs2 -W 4 -M 500 -C 7000; &get -m;":"" );
+    sprintf( Comm4, "&dch -C 500;          &lf -m%sk -E 5 -K %d -C %d; %s &save",           fMinAve?"t":"", nLutSize, nCutNum+4, fUseMfs ? "&put; mfs2 -W 4 -M 500 -C 7000; &get -m;":"" );
+
+	// perform synthesis
+    if ( fVerbose )
+        printf( "Trying synthesis...\n" );
+	if ( fIsMapped )
+	Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&st" );
+    Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Comm1 );
+    if ( fVerbose )
+	Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" );
+
+	// perform synthesis
+    Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&st" );
+    Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Comm2 );
+    if ( fVerbose )
+	Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" );
+
+    // return the result
+	Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&load" );
+    if ( fVerbose )
+	Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" );
+
+
+	// perform balancing
+    if ( fBalance )
+    {
+        if ( fVerbose )
+            printf( "Trying SOP balancing...\n" );
+	    Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&st; &sopb -R 10 -C 4" );
+    }
+
+
+	// perform synthesis
+    Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Comm3 );
+    if ( fVerbose )
+	Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" );
+
+	// perform synthesis
+    Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&st" );
+    Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Comm2 );
+    if ( fVerbose )
+	Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" );
+
+    // return the result
+	Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&load" );
+    if ( fVerbose )
+	Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" );
+    if ( nAnds > 100000 )
+        return;
+
+
+	// perform balancing
+    if ( fBalance )
+    {
+        if ( fVerbose )
+            printf( "Trying SOP balancing...\n" );
+	    Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&st; &sopb -R 10" );
+    }
+
+
+	// perform synthesis
+    Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Comm3 );
+    if ( fVerbose )
+	Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" );
+
+	// perform synthesis
+    Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&st" );
+    Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Comm2 );
+    if ( fVerbose )
+	Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" );
+
+	// return the result
+	Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&load" );
+    if ( fVerbose )
+	Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" );
+    if ( nAnds > 50000 )
+        return;
+
+
+	// perform balancing
+    if ( fBalance )
+    {
+        if ( fVerbose )
+            printf( "Trying SOP balancing...\n" );
+	    Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&st; &sopb -R 10" );
+    }
+
+
+	// perform synthesis
+    Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Comm3 );
+    if ( fVerbose )
+	Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" );
+
+	// perform synthesis
+    Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&st" );
+    Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Comm2 );
+    if ( fVerbose )
+	Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" );
+
+	// return the result
+	Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&load" );
+    if ( fVerbose )
+	Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" );
 }
+
+
 
 ////////////////////////////////////////////////////////////////////////
 ///                       END OF FILE                                ///
diff --git a/abc-build/src/aig/gia/giaShrink6.c b/abc-build/src/aig/gia/giaShrink6.c
--- a/abc-build/src/aig/gia/giaShrink6.c
+++ b/abc-build/src/aig/gia/giaShrink6.c
@@ -170,11 +170,14 @@
 ***********************************************************************/
 static inline void Shr_ManAddFanout( Shr_Man_t * p, int iFanin, int iFanout )
 {
-    Shr_Fan_t FanStr;
-    FanStr.iFan = iFanout;
-    FanStr.Next = Vec_IntEntry(p->vObj2Fan, iFanin);
+    union {
+        Shr_Fan_t sFan;
+        word      sWord;
+    } FanStr;
+    FanStr.sFan.iFan = iFanout;
+    FanStr.sFan.Next = Vec_IntEntry(p->vObj2Fan, iFanin);
     Vec_IntWriteEntry( p->vObj2Fan, iFanin, Vec_WrdSize(p->vFanMem) );
-    Vec_WrdPush(p->vFanMem, *((word *)&FanStr) );
+    Vec_WrdPush(p->vFanMem, FanStr.sWord );
 }
 static inline int Shr_ManFanIterStart( Shr_Man_t * p, int iNode )
 {
diff --git a/abc-build/src/aig/gia/giaSim.c b/abc-build/src/aig/gia/giaSim.c
--- a/abc-build/src/aig/gia/giaSim.c
+++ b/abc-build/src/aig/gia/giaSim.c
@@ -26,24 +26,14 @@
 ////////////////////////////////////////////////////////////////////////
 ///                        DECLARATIONS                              ///
 ////////////////////////////////////////////////////////////////////////
-
-typedef struct Gia_ManSim_t_ Gia_ManSim_t;
-struct Gia_ManSim_t_
-{
-    Gia_Man_t *    pAig;
-    Gia_ParSim_t * pPars; 
-    int            nWords;
-    Vec_Int_t *    vCis2Ids;
-    Vec_Int_t *    vConsts;
-    // simulation information
-    unsigned *     pDataSim;     // simulation data
-    unsigned *     pDataSimCis;  // simulation data for CIs
-    unsigned *     pDataSimCos;  // simulation data for COs
-};
-
-static inline unsigned * Gia_SimData( Gia_ManSim_t * p, int i )    { return p->pDataSim + i * p->nWords;    }
-static inline unsigned * Gia_SimDataCi( Gia_ManSim_t * p, int i )  { return p->pDataSimCis + i * p->nWords; }
-static inline unsigned * Gia_SimDataCo( Gia_ManSim_t * p, int i )  { return p->pDataSimCos + i * p->nWords; }
+
+static inline unsigned * Gia_SimData( Gia_ManSim_t * p, int i )    { return p->pDataSim + i * p->nWords;    }
+static inline unsigned * Gia_SimDataCi( Gia_ManSim_t * p, int i )  { return p->pDataSimCis + i * p->nWords; }
+static inline unsigned * Gia_SimDataCo( Gia_ManSim_t * p, int i )  { return p->pDataSimCos + i * p->nWords; }
+
+unsigned * Gia_SimDataExt( Gia_ManSim_t * p, int i )    { return Gia_SimData(p, i);    }
+unsigned * Gia_SimDataCiExt( Gia_ManSim_t * p, int i )  { return Gia_SimDataCi(p, i);  }
+unsigned * Gia_SimDataCoExt( Gia_ManSim_t * p, int i )  { return Gia_SimDataCo(p, i);  }
 
 ////////////////////////////////////////////////////////////////////////
 ///                     FUNCTION DEFINITIONS                         ///
@@ -436,7 +426,7 @@
   SeeAlso     []
 
 ***********************************************************************/
-static inline void Gia_ManSimInfoInit( Gia_ManSim_t * p )
+void Gia_ManSimInfoInit( Gia_ManSim_t * p )
 {
     int iPioNum, i;
     Vec_IntForEachEntry( p->vCis2Ids, iPioNum, i )
@@ -459,7 +449,7 @@
   SeeAlso     []
 
 ***********************************************************************/
-static inline void Gia_ManSimInfoTransfer( Gia_ManSim_t * p )
+void Gia_ManSimInfoTransfer( Gia_ManSim_t * p )
 {
     int iPioNum, i;
     Vec_IntForEachEntry( p->vCis2Ids, iPioNum, i )
@@ -482,7 +472,7 @@
   SeeAlso     []
 
 ***********************************************************************/
-static inline void Gia_ManSimulateRound( Gia_ManSim_t * p )
+void Gia_ManSimulateRound( Gia_ManSim_t * p )
 {
     Gia_Obj_t * pObj;
     int i, iCis = 0, iCos = 0;
diff --git a/abc-build/src/aig/gia/giaStr.c b/abc-build/src/aig/gia/giaStr.c
--- a/abc-build/src/aig/gia/giaStr.c
+++ b/abc-build/src/aig/gia/giaStr.c
@@ -6,53 +6,1859 @@
 
   PackageName [Scalable AIG package.]
 
-  Synopsis    [Cut computation.]
-
-  Author      [Alan Mishchenko]
-  
-  Affiliation [UC Berkeley]
-
-  Date        [Ver. 1.0. Started - June 20, 2005.]
-
-  Revision    [$Id: giaStr.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "gia.h"
-
-ABC_NAMESPACE_IMPL_START
-
-////////////////////////////////////////////////////////////////////////
-///                        DECLARATIONS                              ///
-////////////////////////////////////////////////////////////////////////
-
-
-////////////////////////////////////////////////////////////////////////
-///                     FUNCTION DEFINITIONS                         ///
-////////////////////////////////////////////////////////////////////////
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-               
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-Gia_Man_t * Gia_ManLutBalance( Gia_Man_t * p, int nLutSize, int fUseMuxes, int fRecursive, int fOptArea, int fVerbose )
-{
-    return Gia_ManDup(p);
-}
-
-
-////////////////////////////////////////////////////////////////////////
-///                       END OF FILE                                ///
-////////////////////////////////////////////////////////////////////////
-
-
-ABC_NAMESPACE_IMPL_END
-
+  Synopsis    [AIG structuring.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - June 20, 2005.]
+
+  Revision    [$Id: giaStr.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+#include "misc/util/utilNam.h"
+#include "misc/vec/vecWec.h"
+#include "misc/tim/tim.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+#define STR_SUPER  100
+
+enum { 
+    STR_NONE   =  0,
+    STR_CONST0 =  1,
+    STR_PI     =  2,
+    STR_AND    =  3,
+    STR_XOR    =  4,
+    STR_MUX    =  5,
+    STR_BUF    =  6,
+    STR_PO     =  7,
+    STR_UNUSED =  8      
+};
+
+typedef struct Str_Obj_t_ Str_Obj_t; 
+struct Str_Obj_t_
+{
+    unsigned       Type    :  4;     // object type
+    unsigned       nFanins : 28;     // fanin count
+    int            iOffset;          // place where fanins are stored
+    int            iTop;             // top level MUX
+    int            iCopy;            // copy of this node
+};
+typedef struct Str_Ntk_t_ Str_Ntk_t; 
+struct Str_Ntk_t_
+{
+    int            nObjs;            // object count
+    int            nObjsAlloc;       // alloc objects
+    Str_Obj_t *    pObjs;            // objects 
+    Vec_Int_t      vFanins;          // object fanins
+    int            nObjCount[STR_UNUSED];
+    int            nTrees;
+    int            nGroups;
+    int            DelayGain;
+};
+typedef struct Str_Man_t_ Str_Man_t; 
+struct Str_Man_t_
+{
+    // user data
+    Gia_Man_t *     pOld;            // manager
+    int             nLutSize;        // LUT size
+    int             fCutMin;         // cut minimization
+    // internal data
+    Str_Ntk_t *     pNtk;            // balanced network
+    // AIG under construction
+    Gia_Man_t *     pNew;            // newly constructed 
+    Vec_Int_t *     vDelays;         // delays of each object
+};
+
+static inline Str_Obj_t * Str_NtkObj( Str_Ntk_t * p, int i )                         { assert( i < p->nObjs );  return p->pObjs + i;                                        }
+static inline int         Str_ObjFaninId( Str_Ntk_t * p, Str_Obj_t * pObj, int i )   { return Abc_Lit2Var( Vec_IntEntry(&p->vFanins, pObj->iOffset + i) );                  }
+static inline Str_Obj_t * Str_ObjFanin( Str_Ntk_t * p, Str_Obj_t * pObj, int i )     { return Str_NtkObj( p, Str_ObjFaninId(p, pObj, i) );                                  }
+static inline int         Str_ObjFaninC( Str_Ntk_t * p, Str_Obj_t * pObj, int i )    { return Abc_LitIsCompl( Vec_IntEntry(&p->vFanins, pObj->iOffset + i) );               }
+static inline int         Str_ObjFaninCopy( Str_Ntk_t * p, Str_Obj_t * pObj, int i ) { return Abc_LitNotCond( Str_ObjFanin(p, pObj, i)->iCopy, Str_ObjFaninC(p, pObj, i) ); }
+static inline int         Str_ObjId( Str_Ntk_t * p, Str_Obj_t * pObj )               { return pObj - p->pObjs;                                                              }
+
+#define Str_NtkManForEachObj( p, pObj )  \
+    for ( pObj = p->pObjs; Str_ObjId(p, pObj) < p->nObjs; pObj++ )
+#define Str_NtkManForEachObjVec( vVec, p, pObj, i )  \
+    for ( i = 0; (i < Vec_IntSize(vVec)) && ((pObj) = Str_NtkObj(p, Vec_IntEntry(vVec,i))); i++ )
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    [Logic network manipulation.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Str_ObjCreate( Str_Ntk_t * p, int Type, int nFanins, int * pFanins )
+{
+    Str_Obj_t * pObj = p->pObjs + p->nObjs; int i;
+    assert( p->nObjs < p->nObjsAlloc );
+    pObj->Type    = Type;
+    pObj->nFanins = nFanins;
+    pObj->iOffset = Vec_IntSize(&p->vFanins);
+    pObj->iTop    = pObj->iCopy = -1;
+    for ( i = 0; i < nFanins; i++ )
+    {
+        Vec_IntPush( &p->vFanins, pFanins[i] );
+        assert( pFanins[i] >= 0 );
+    }
+    p->nObjCount[Type]++;
+    return Abc_Var2Lit( p->nObjs++, 0 );
+}
+static inline Str_Ntk_t * Str_NtkCreate( int nObjsAlloc, int nFaninsAlloc )
+{
+    Str_Ntk_t * p;
+    p = ABC_CALLOC( Str_Ntk_t, 1 );
+    p->pObjs = ABC_ALLOC( Str_Obj_t, nObjsAlloc );
+    p->nObjsAlloc = nObjsAlloc;
+    Str_ObjCreate( p, STR_CONST0, 0, NULL );
+    Vec_IntGrow( &p->vFanins, nFaninsAlloc );
+    return p;
+}
+static inline void Str_NtkDelete( Str_Ntk_t * p )
+{
+//    printf( "Total delay gain = %d.\n", p->DelayGain );
+    ABC_FREE( p->vFanins.pArray );
+    ABC_FREE( p->pObjs );
+    ABC_FREE( p );
+}
+static inline void Str_NtkPs( Str_Ntk_t * p, abctime clk )
+{
+    printf( "Network contains %d ands, %d xors, %d muxes (%d trees in %d groups).  ", 
+        p->nObjCount[STR_AND], p->nObjCount[STR_XOR], p->nObjCount[STR_MUX], p->nTrees, p->nGroups );
+    Abc_PrintTime( 1, "Time", clk );
+}
+static inline void Str_ObjReadGroup( Str_Ntk_t * p, Str_Obj_t * pObj, int * pnGroups, int * pnMuxes )
+{
+    Str_Obj_t * pObj1, * pObj2;
+    *pnGroups = *pnMuxes = 0;
+    if ( pObj->iTop == 0 )
+        return;
+    pObj1 = Str_NtkObj( p, pObj->iTop ); 
+    pObj2 = Str_NtkObj( p, pObj1->iTop );
+    *pnMuxes  = pObj1 - pObj + 1;
+    *pnGroups = (pObj2 - pObj + 1) / *pnMuxes;
+}
+static inline void Str_NtkPrintGroups( Str_Ntk_t * p )
+{
+    Str_Obj_t * pObj; 
+    int nGroups, nMuxes;
+    Str_NtkManForEachObj( p, pObj )
+        if ( pObj->Type == STR_MUX && pObj->iTop > 0 )
+        {
+            Str_ObjReadGroup( p, pObj, &nGroups, &nMuxes );
+            pObj += nGroups * nMuxes - 1;
+            printf( "%d x %d  ", nGroups, nMuxes );
+        }
+    printf( "\n" );
+}
+Gia_Man_t * Str_NtkToGia( Gia_Man_t * pGia, Str_Ntk_t * p )
+{
+    Gia_Man_t * pNew, * pTemp;
+    Str_Obj_t * pObj; int k;
+    assert( pGia->pMuxes == NULL );
+    pNew = Gia_ManStart( 3 * Gia_ManObjNum(pGia) / 2 );
+    pNew->pName = Abc_UtilStrsav( pGia->pName );
+    pNew->pSpec = Abc_UtilStrsav( pGia->pSpec );
+    Gia_ManHashStart( pNew );
+    Str_NtkManForEachObj( p, pObj )
+    {
+        if ( pObj->Type == STR_PI )
+            pObj->iCopy = Gia_ManAppendCi( pNew );
+        else if ( pObj->Type == STR_AND )
+        {
+            pObj->iCopy = 1;
+            for ( k = 0; k < (int)pObj->nFanins; k++ )
+                pObj->iCopy = Gia_ManHashAnd( pNew, pObj->iCopy, Str_ObjFaninCopy(p, pObj, k) );
+        }
+        else if ( pObj->Type == STR_XOR )
+        {
+            pObj->iCopy = 0;
+            for ( k = 0; k < (int)pObj->nFanins; k++ )
+                pObj->iCopy = Gia_ManHashXor( pNew, pObj->iCopy, Str_ObjFaninCopy(p, pObj, k) );
+        }
+        else if ( pObj->Type == STR_MUX )
+            pObj->iCopy = Gia_ManHashMux( pNew, Str_ObjFaninCopy(p, pObj, 2), Str_ObjFaninCopy(p, pObj, 1), Str_ObjFaninCopy(p, pObj, 0) );
+        else if ( pObj->Type == STR_PO )
+            pObj->iCopy = Gia_ManAppendCo( pNew, Str_ObjFaninCopy(p, pObj, 0) );
+        else if ( pObj->Type == STR_CONST0 )
+            pObj->iCopy = 0;
+        else assert( 0 );
+    }
+    Gia_ManHashStop( pNew );
+//    assert( Gia_ManObjNum(pNew) <= Gia_ManObjNum(pGia) );
+    Gia_ManSetRegNum( pNew, Gia_ManRegNum(pGia) );
+    pNew = Gia_ManCleanup( pTemp = pNew );
+    Gia_ManStop( pTemp );
+    return pNew;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    [Constructs a normalized AIG without structural hashing.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManDupMuxesNoHash( Gia_Man_t * p )
+{
+    Gia_Man_t * pNew;
+    Gia_Obj_t * pObj, * pFan0, * pFan1, * pFanC;
+    int i, iLit0, iLit1, fCompl;
+    assert( p->pMuxes == NULL );
+    ABC_FREE( p->pRefs );
+    Gia_ManCreateRefs( p ); 
+    // discount nodes with one fanout pointed to by MUX type
+    Gia_ManForEachAnd( p, pObj, i )
+    {
+        if ( !Gia_ObjIsMuxType(pObj) )
+            continue;
+        Gia_ObjRefDec(p, Gia_ObjFanin0(pObj));
+        Gia_ObjRefDec(p, Gia_ObjFanin1(pObj));
+    }
+    // start the new manager
+    pNew = Gia_ManStart( Gia_ManObjNum(p) );
+    pNew->pName  = Abc_UtilStrsav( p->pName );
+    pNew->pSpec  = Abc_UtilStrsav( p->pSpec );
+    pNew->pMuxes = ABC_CALLOC( unsigned, pNew->nObjsAlloc );
+    Gia_ManFillValue(p);
+    Gia_ManConst0(p)->Value = 0;
+    Gia_ManForEachCi( p, pObj, i )
+        pObj->Value = Gia_ManAppendCi( pNew );
+    Gia_ManForEachAnd( p, pObj, i )
+    {
+        if ( !Gia_ObjRefNumId(p, i) )
+            continue;
+        if ( !Gia_ObjIsMuxType(pObj) )
+            pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+        else if ( Gia_ObjRecognizeExor(pObj, &pFan0, &pFan1) )
+        {
+            iLit0 = Gia_ObjLitCopy(p, Gia_ObjToLit(p, pFan0));
+            iLit1 = Gia_ObjLitCopy(p, Gia_ObjToLit(p, pFan1));
+            fCompl = Abc_LitIsCompl(iLit0) ^ Abc_LitIsCompl(iLit1);
+            pObj->Value = fCompl ^ Gia_ManAppendXorReal( pNew, Abc_LitRegular(iLit0), Abc_LitRegular(iLit1) );
+        }
+        else
+        {
+            pFanC = Gia_ObjRecognizeMux( pObj, &pFan1, &pFan0 );
+            iLit0 = Gia_ObjLitCopy(p, Gia_ObjToLit(p, pFan0));
+            iLit1 = Gia_ObjLitCopy(p, Gia_ObjToLit(p, pFan1));
+            if ( iLit0 == iLit1 )
+                pObj->Value = iLit0;
+            else if ( Abc_Lit2Var(iLit0) == Abc_Lit2Var(iLit1) )
+            {
+                iLit1 = Gia_ObjLitCopy(p, Gia_ObjToLit(p, pFanC));
+                fCompl = Abc_LitIsCompl(iLit0) ^ Abc_LitIsCompl(iLit1);
+                pObj->Value = fCompl ^ Gia_ManAppendXorReal( pNew, Abc_LitRegular(iLit0), Abc_LitRegular(iLit1) );
+            }
+            else
+                pObj->Value = Gia_ManAppendMuxReal( pNew, Gia_ObjLitCopy(p, Gia_ObjToLit(p, pFanC)), Gia_ObjLitCopy(p, Gia_ObjToLit(p, pFan1)), Gia_ObjLitCopy(p, Gia_ObjToLit(p, pFan0)) );
+        }
+    }
+    Gia_ManForEachCo( p, pObj, i )
+        pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+    Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+    assert( !Gia_ManHasDangling(pNew) );
+    return pNew;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Constructs AIG ordered for balancing.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Str_MuxInputsCollect_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vNodes )
+{
+    if ( !pObj->fMark0 )
+    {
+        Vec_IntPush( vNodes, Gia_ObjId(p, pObj) );
+        return;
+    }
+    Vec_IntPush( vNodes, Gia_ObjFaninId2p(p, pObj) );
+    Str_MuxInputsCollect_rec( p, Gia_ObjFanin0(pObj), vNodes );
+    Str_MuxInputsCollect_rec( p, Gia_ObjFanin1(pObj), vNodes );
+}
+void Str_MuxInputsCollect( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vNodes )
+{
+    assert( !pObj->fMark0 );
+    pObj->fMark0 = 1;
+    Vec_IntClear( vNodes );
+    Str_MuxInputsCollect_rec( p, pObj, vNodes );
+    pObj->fMark0 = 0;
+}
+void Str_MuxStructCollect_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vNodes )
+{
+    if ( !pObj->fMark0 )
+        return;
+    Str_MuxStructCollect_rec( p, Gia_ObjFanin0(pObj), vNodes );
+    Str_MuxStructCollect_rec( p, Gia_ObjFanin1(pObj), vNodes );
+    Vec_IntPush( vNodes, Gia_ObjId(p, pObj) );
+}
+void Str_MuxStructCollect( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vNodes )
+{
+    assert( !pObj->fMark0 );
+    pObj->fMark0 = 1;
+    Vec_IntClear( vNodes );
+    Str_MuxStructCollect_rec( p, pObj, vNodes );
+    pObj->fMark0 = 0;
+}
+void Str_MuxStructDump_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Str_t * vStr )
+{
+    if ( !pObj->fMark0 )
+        return;
+    Vec_StrPush( vStr, '[' );
+    Vec_StrPush( vStr, '(' );
+    Vec_StrPrintNum( vStr, Gia_ObjFaninId2p(p, pObj) );
+    Vec_StrPush( vStr, ')' );
+    Str_MuxStructDump_rec( p, Gia_ObjFaninC2(p, pObj) ? Gia_ObjFanin0(pObj) : Gia_ObjFanin1(pObj), vStr );
+    Vec_StrPush( vStr, '|' );
+    Str_MuxStructDump_rec( p, Gia_ObjFaninC2(p, pObj) ? Gia_ObjFanin1(pObj) : Gia_ObjFanin0(pObj), vStr );
+    Vec_StrPush( vStr, ']' );
+}
+void Str_MuxStructDump( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Str_t * vStr )
+{
+    assert( !pObj->fMark0 );
+    pObj->fMark0 = 1;
+    Vec_StrClear( vStr );
+    Str_MuxStructDump_rec( p, pObj, vStr );
+    Vec_StrPush( vStr, '\0' );
+    pObj->fMark0 = 0;
+}
+int Str_ManMuxCountOne( char * p )
+{
+    int Count = 0;
+    for ( ; *p; p++ )
+        Count += (*p == '[');
+    return Count;
+}
+Vec_Wec_t * Str_ManDeriveTrees( Gia_Man_t * p )
+{
+    int fPrintStructs = 0;
+    Abc_Nam_t * pNames; 
+    Vec_Wec_t * vGroups;  
+    Vec_Str_t * vStr;
+    Gia_Obj_t * pObj, * pFanin;
+    int i, iStructId, fFound;
+    assert( p->pMuxes != NULL );
+    // mark MUXes whose only fanout is a MUX
+    ABC_FREE( p->pRefs );
+    Gia_ManCreateRefs( p ); 
+    Gia_ManForEachMuxId( p, i )
+    {
+        pObj = Gia_ManObj(p, i);
+        pFanin = Gia_ObjFanin0(pObj);
+        if ( Gia_ObjIsMux(p, pFanin) && Gia_ObjRefNum(p, pFanin) == 1 )
+            pFanin->fMark0 = 1;
+        pFanin = Gia_ObjFanin1(pObj);
+        if ( Gia_ObjIsMux(p, pFanin) && Gia_ObjRefNum(p, pFanin) == 1 )
+            pFanin->fMark0 = 1;
+    }
+    // traverse for top level MUXes
+    vStr   = Vec_StrAlloc( 1000 );
+    pNames = Abc_NamStart( 10000, 50 );
+    vGroups = Vec_WecAlloc( 1000 );
+    Vec_WecPushLevel( vGroups );
+    Gia_ManForEachMuxId( p, i )
+    {
+        // skip internal
+        pObj = Gia_ManObj(p, i);
+        if ( pObj->fMark0 )
+            continue;
+        // skip trees of size one
+        if ( !Gia_ObjFanin0(pObj)->fMark0 && !Gia_ObjFanin1(pObj)->fMark0 )
+            continue;
+        // hash the tree
+        Str_MuxStructDump( p, pObj, vStr );
+        iStructId = Abc_NamStrFindOrAdd( pNames, Vec_StrArray(vStr), &fFound );
+        if ( !fFound ) Vec_WecPushLevel( vGroups );
+        assert( Abc_NamObjNumMax(pNames) == Vec_WecSize(vGroups) );
+        Vec_IntPush( Vec_WecEntry(vGroups, iStructId), i );
+    }
+    if ( fPrintStructs )
+    {
+        char * pTemp; 
+        Abc_NamManForEachObj( pNames, pTemp, i )
+        {
+            printf( "%5d : ", i );
+            printf( "Occur = %4d   ", Vec_IntSize(Vec_WecEntry(vGroups,i)) );
+            printf( "Size = %4d   ",  Str_ManMuxCountOne(pTemp) );
+            printf( "%s\n", pTemp );
+        }
+    }
+    Abc_NamStop( pNames );
+    Vec_StrFree( vStr );
+    return vGroups;
+}
+Vec_Int_t * Str_ManCreateRoots( Vec_Wec_t * vGroups, int nObjs )
+{   // map tree MUXes into their classes
+    Vec_Int_t * vRoots;
+    Vec_Int_t * vGroup;
+    int i, k, Entry;
+    vRoots = Vec_IntStartFull( nObjs );
+    Vec_WecForEachLevel( vGroups, vGroup, i )
+        Vec_IntForEachEntry( vGroup, Entry, k )
+            Vec_IntWriteEntry( vRoots, Entry, i );
+    return vRoots;
+}
+
+void Str_MuxTraverse_rec( Gia_Man_t * p, int i )
+{
+    Gia_Obj_t * pObj;
+    if ( Gia_ObjIsTravIdCurrentId(p, i) )
+        return;
+    Gia_ObjSetTravIdCurrentId(p, i);
+    pObj = Gia_ManObj(p, i);
+    if ( !Gia_ObjIsAnd(pObj) )
+        return;
+    Str_MuxTraverse_rec(p, Gia_ObjFaninId0(pObj, i) );
+    Str_MuxTraverse_rec(p, Gia_ObjFaninId1(pObj, i) );
+    if ( Gia_ObjIsMux(p, pObj) )
+        Str_MuxTraverse_rec(p, Gia_ObjFaninId2(p, i) );
+}
+void Str_ManCheckOverlap( Gia_Man_t * p, Vec_Wec_t * vGroups )
+{   // check that members of each group are not in the TFI of each other
+    Vec_Int_t * vGroup, * vGroup2;
+    int i, k, n, iObj, iObj2;
+
+//    vGroup = Vec_WecEntry(vGroups, 7);
+//    Vec_IntForEachEntry( vGroup, iObj, n )
+//        Gia_ManPrintCone2( p, Gia_ManObj(p, iObj) ), printf( "\n" );
+
+    Vec_WecForEachLevel( vGroups, vGroup, i )
+    Vec_IntForEachEntry( vGroup, iObj, k )
+    {
+        if ( Vec_IntSize(vGroup) == 1 )
+            continue;
+        // high light the cone
+        Gia_ManIncrementTravId( p );
+        Str_MuxTraverse_rec( p, iObj );
+        // check that none of the others are highlighted
+        Vec_IntForEachEntry( vGroup, iObj2, n )
+            if ( iObj != iObj2 && Gia_ObjIsTravIdCurrentId(p, iObj2) )
+                break;
+        if ( n == Vec_IntSize(vGroup) )
+            continue;
+        // split the group into individual trees
+        Vec_IntForEachEntryStart( vGroup, iObj2, n, 1 )
+        {
+            vGroup2 = Vec_WecPushLevel( vGroups );
+            vGroup  = Vec_WecEntry( vGroups, i );
+            Vec_IntPush( vGroup2, iObj2 );
+        }
+        Vec_IntShrink( vGroup, 1 );
+
+/*
+        // this does not work because there can be a pair of independent trees
+        // with another tree squeezed in between them, so that there is a combo loop
+
+        // divide this group
+        nNew = 0;
+        vGroup2 = Vec_WecPushLevel( vGroups );
+        vGroup  = Vec_WecEntry( vGroups, i );
+        Vec_IntForEachEntry( vGroup, iObj2, n )
+        {
+            if ( iObj != iObj2 && Gia_ObjIsTravIdCurrentId(p, iObj2) )
+                Vec_IntPush( vGroup2, iObj2 );
+            else
+                Vec_IntWriteEntry( vGroup, nNew++, iObj2 );
+        }
+        Vec_IntShrink( vGroup, nNew );
+        i--;
+        break;
+*/
+
+/*
+        // check that none of the others are highlighted
+        Vec_IntForEachEntry( vGroup, iObj, n )
+            if ( n != k && Gia_ObjIsTravIdCurrentId(p, iObj) )
+            {
+                printf( "Overlap of TFI cones of trees %d and %d in group %d of size %d!\n", k, n, i, Vec_IntSize(vGroup) );
+                Vec_IntShrink( vGroup, 1 );
+                break;
+            }
+*/
+    }
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Simplify multi-input AND/XOR.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline void Gia_ManSimplifyXor( Vec_Int_t * vSuper )
+{
+    int i, k = 0, Prev = -1, This, fCompl = 0;
+    Vec_IntForEachEntry( vSuper, This, i )
+    {
+        if ( This == 0 )
+            continue;
+        if ( This == 1 )
+            fCompl ^= 1; 
+        else if ( Prev != This )
+            Vec_IntWriteEntry( vSuper, k++, This ), Prev = This;
+        else
+            Prev = -1, k--;
+    }
+    Vec_IntShrink( vSuper, k );
+    if ( Vec_IntSize( vSuper ) == 0 )
+        Vec_IntPush( vSuper, fCompl );
+    else if ( fCompl )
+        Vec_IntWriteEntry( vSuper, 0, Abc_LitNot(Vec_IntEntry(vSuper, 0)) );
+}
+static inline void Gia_ManSimplifyAnd( Vec_Int_t * vSuper )
+{
+    int i, k = 0, Prev = -1, This;
+    Vec_IntForEachEntry( vSuper, This, i )
+    {
+        if ( This == 0 )
+            { Vec_IntFill(vSuper, 1, 0); return; }
+        if ( This == 1 )
+            continue;
+        if ( Prev == -1 || Abc_Lit2Var(Prev) != Abc_Lit2Var(This) )
+            Vec_IntWriteEntry( vSuper, k++, This ), Prev = This;
+        else if ( Prev != This )
+            { Vec_IntFill(vSuper, 1, 0); return; }
+    }
+    Vec_IntShrink( vSuper, k );
+    if ( Vec_IntSize( vSuper ) == 0 )
+        Vec_IntPush( vSuper, 1 );
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Collect multi-input AND/XOR.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline void Gia_ManSuperCollectXor_rec( Gia_Man_t * p, Gia_Obj_t * pObj )
+{
+    assert( !Gia_IsComplement(pObj) );
+    if ( !Gia_ObjIsXor(pObj) || 
+        Gia_ObjRefNum(p, pObj) > 1 || 
+//        Gia_ObjRefNum(p, pObj) > 3 || 
+//        (Gia_ObjRefNum(p, pObj) == 2 && (Gia_ObjRefNum(p, Gia_ObjFanin0(pObj)) == 1 || Gia_ObjRefNum(p, Gia_ObjFanin1(pObj)) == 1)) || 
+        Vec_IntSize(p->vSuper) > STR_SUPER )
+    {
+        Vec_IntPush( p->vSuper, Gia_ObjToLit(p, pObj) );
+        return;
+    }
+    assert( !Gia_ObjFaninC0(pObj) && !Gia_ObjFaninC1(pObj) );
+    Gia_ManSuperCollectXor_rec( p, Gia_ObjFanin0(pObj) );
+    Gia_ManSuperCollectXor_rec( p, Gia_ObjFanin1(pObj) );
+}
+static inline void Gia_ManSuperCollectAnd_rec( Gia_Man_t * p, Gia_Obj_t * pObj )
+{
+    if ( Gia_IsComplement(pObj) || 
+        !Gia_ObjIsAndReal(p, pObj) || 
+        Gia_ObjRefNum(p, pObj) > 1 || 
+//        Gia_ObjRefNum(p, pObj) > 3 || 
+//        (Gia_ObjRefNum(p, pObj) == 2 && (Gia_ObjRefNum(p, Gia_ObjFanin0(pObj)) == 1 || Gia_ObjRefNum(p, Gia_ObjFanin1(pObj)) == 1)) || 
+        Vec_IntSize(p->vSuper) > STR_SUPER )
+    {
+        Vec_IntPush( p->vSuper, Gia_ObjToLit(p, pObj) );
+        return;
+    }
+    Gia_ManSuperCollectAnd_rec( p, Gia_ObjChild0(pObj) );
+    Gia_ManSuperCollectAnd_rec( p, Gia_ObjChild1(pObj) );
+}
+static inline void Gia_ManSuperCollect( Gia_Man_t * p, Gia_Obj_t * pObj )
+{
+    if ( p->vSuper == NULL )
+        p->vSuper = Vec_IntAlloc( STR_SUPER );
+    else
+        Vec_IntClear( p->vSuper );
+    if ( Gia_ObjIsXor(pObj) )
+    {
+        assert( !Gia_ObjFaninC0(pObj) && !Gia_ObjFaninC1(pObj) );
+        Gia_ManSuperCollectXor_rec( p, Gia_ObjFanin0(pObj) );
+        Gia_ManSuperCollectXor_rec( p, Gia_ObjFanin1(pObj) );
+        Vec_IntSort( p->vSuper, 0 );
+        Gia_ManSimplifyXor( p->vSuper );
+    }
+    else if ( Gia_ObjIsAndReal(p, pObj) )
+    {
+        Gia_ManSuperCollectAnd_rec( p, Gia_ObjChild0(pObj) );
+        Gia_ManSuperCollectAnd_rec( p, Gia_ObjChild1(pObj) );
+        Vec_IntSort( p->vSuper, 0 );
+        Gia_ManSimplifyAnd( p->vSuper );
+    }
+    else assert( 0 );
+    assert( Vec_IntSize(p->vSuper) > 0 );
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Constructs AIG ordered for balancing.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Str_ManNormalize_rec( Str_Ntk_t * pNtk, Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Wec_t * vGroups, Vec_Int_t * vRoots )
+{
+    int i, k, iVar, iLit, iBeg, iEnd;
+    if ( ~pObj->Value )
+        return;
+    pObj->Value = 0;
+    assert( Gia_ObjIsAnd(pObj) );
+    if ( Gia_ObjIsMux(p, pObj) )
+    {
+        Vec_Int_t * vGroup;
+        Gia_Obj_t * pRoot, * pMux;
+        int pFanins[3];
+        if ( Vec_IntEntry(vRoots, Gia_ObjId(p, pObj)) == -1 )
+        {
+            Str_ManNormalize_rec( pNtk, p, Gia_ObjFanin0(pObj), vGroups, vRoots );
+            Str_ManNormalize_rec( pNtk, p, Gia_ObjFanin1(pObj), vGroups, vRoots );
+            Str_ManNormalize_rec( pNtk, p, Gia_ObjFanin2(p, pObj), vGroups, vRoots );
+            pFanins[0] = Gia_ObjFanin0Copy(pObj);
+            pFanins[1] = Gia_ObjFanin1Copy(pObj);
+            pFanins[2] = Gia_ObjFanin2Copy(p, pObj);
+            if ( Abc_LitIsCompl(pFanins[2]) )
+            {
+                pFanins[2] = Abc_LitNot(pFanins[2]);
+                ABC_SWAP( int, pFanins[0], pFanins[1] );
+            }
+            pObj->Value = Str_ObjCreate( pNtk, STR_MUX, 3, pFanins );
+            return;
+        }
+        vGroup = Vec_WecEntry( vGroups, Vec_IntEntry(vRoots, Gia_ObjId(p, pObj)) );
+        // build data-inputs for each tree
+        Gia_ManForEachObjVec( vGroup, p, pRoot, i )
+        {
+            Str_MuxInputsCollect( p, pRoot, p->vSuper );
+            iBeg = Vec_IntSize( p->vStore );
+            Vec_IntAppend( p->vStore, p->vSuper );
+            iEnd = Vec_IntSize( p->vStore );
+            Vec_IntForEachEntryStartStop( p->vStore, iVar, k, iBeg, iEnd )
+                Str_ManNormalize_rec( pNtk, p, Gia_ManObj(p, iVar), vGroups, vRoots );
+            Vec_IntShrink( p->vStore, iBeg );
+        }
+        // build internal structures
+        Gia_ManForEachObjVec( vGroup, p, pRoot, i )
+        {
+            Str_MuxStructCollect( p, pRoot, p->vSuper );
+            Gia_ManForEachObjVec( p->vSuper, p, pMux, k )
+            {
+                pFanins[0] = Gia_ObjFanin0Copy(pMux);
+                pFanins[1] = Gia_ObjFanin1Copy(pMux);
+                pFanins[2] = Gia_ObjFanin2Copy(p, pMux);
+                if ( Abc_LitIsCompl(pFanins[2]) )
+                {
+                    pFanins[2] = Abc_LitNot(pFanins[2]);
+                    ABC_SWAP( int, pFanins[0], pFanins[1] );
+                }
+                pMux->Value = Str_ObjCreate( pNtk, STR_MUX, 3, pFanins );
+            }
+            assert( ~pRoot->Value );
+            // set mapping
+            Gia_ManForEachObjVec( p->vSuper, p, pMux, k )
+                Str_NtkObj(pNtk, Abc_Lit2Var(pMux->Value))->iTop = Abc_Lit2Var(pRoot->Value);
+            pNtk->nTrees++;
+        }
+        assert( ~pObj->Value );
+        // set mapping
+        pObj = Gia_ManObj( p, Vec_IntEntryLast(vGroup) );
+        Gia_ManForEachObjVec( vGroup, p, pRoot, i )
+            Str_NtkObj(pNtk, Abc_Lit2Var(pRoot->Value))->iTop = Abc_Lit2Var(pObj->Value);
+        pNtk->nGroups++;
+        //printf( "%d x %d  ", Vec_IntSize(vGroup), Vec_IntSize(p->vSuper) );
+        return;
+    }
+    // find supergate
+    Gia_ManSuperCollect( p, pObj );
+    // save entries
+    iBeg = Vec_IntSize( p->vStore );
+    Vec_IntAppend( p->vStore, p->vSuper );
+    iEnd = Vec_IntSize( p->vStore );
+    // call recursively
+    Vec_IntForEachEntryStartStop( p->vStore, iLit, i, iBeg, iEnd )
+    {
+        Gia_Obj_t * pTemp = Gia_ManObj( p, Abc_Lit2Var(iLit) );
+        Str_ManNormalize_rec( pNtk, p, pTemp, vGroups, vRoots );
+        Vec_IntWriteEntry( p->vStore, i, Abc_LitNotCond(pTemp->Value, Abc_LitIsCompl(iLit)) );
+    }
+    assert( Vec_IntSize(p->vStore) == iEnd );
+    // consider general case
+    pObj->Value = Str_ObjCreate( pNtk, Gia_ObjIsXor(pObj) ? STR_XOR : STR_AND, iEnd-iBeg, Vec_IntEntryP(p->vStore, iBeg) );
+    Vec_IntShrink( p->vStore, iBeg );
+}
+Str_Ntk_t * Str_ManNormalizeInt( Gia_Man_t * p, Vec_Wec_t * vGroups, Vec_Int_t * vRoots )
+{
+    Str_Ntk_t * pNtk;
+    Gia_Obj_t * pObj;
+    int i, iFanin;
+    assert( p->pMuxes != NULL );
+    if ( p->vSuper == NULL )
+        p->vSuper = Vec_IntAlloc( STR_SUPER );
+    if ( p->vStore == NULL )
+        p->vStore = Vec_IntAlloc( STR_SUPER );
+    Gia_ManFillValue( p );
+    pNtk = Str_NtkCreate( Gia_ManObjNum(p), 1 + Gia_ManCoNum(p) + 2 * Gia_ManAndNum(p) + Gia_ManMuxNum(p) );
+    Gia_ManConst0(p)->Value = 0;
+    Gia_ManForEachObj1( p, pObj, i )
+    {
+        if ( Gia_ObjIsCi(pObj) )
+            pObj->Value = Str_ObjCreate( pNtk, STR_PI, 0, NULL );
+        else if ( Gia_ObjIsCo(pObj) )
+        {
+            Str_ManNormalize_rec( pNtk, p, Gia_ObjFanin0(pObj), vGroups, vRoots );
+            iFanin = Gia_ObjFanin0Copy(pObj);
+            pObj->Value = Str_ObjCreate( pNtk, STR_PO, 1, &iFanin );
+        }
+    }
+    assert( pNtk->nObjs <= Gia_ManObjNum(p) );
+    return pNtk;
+}
+Str_Ntk_t * Str_ManNormalize( Gia_Man_t * p )
+{
+    Str_Ntk_t * pNtk;
+    Gia_Man_t * pMuxes = Gia_ManDupMuxes( p, 5 );
+    Vec_Wec_t * vGroups = Str_ManDeriveTrees( pMuxes );
+    Vec_Int_t * vRoots;
+    Str_ManCheckOverlap( pMuxes, vGroups );
+    vRoots = Str_ManCreateRoots( vGroups, Gia_ManObjNum(pMuxes) );
+    pNtk = Str_ManNormalizeInt( pMuxes, vGroups, vRoots );
+    Gia_ManCleanMark0( pMuxes );
+    Gia_ManStop( pMuxes );
+    Vec_IntFree( vRoots );
+    Vec_WecFree( vGroups );
+    return pNtk;
+}
+ 
+/**Function*************************************************************
+
+  Synopsis    [Delay computation]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Str_Delay2( int d0, int d1, int nLutSize )
+{
+    int n, d = Abc_MaxInt( d0 >> 4, d1 >> 4 );
+    n  = (d == (d0 >> 4)) ? (d0 & 15) : 1;
+    n += (d == (d1 >> 4)) ? (d1 & 15) : 1;
+    return (d << 4) + (n > nLutSize ? 18 : n);
+}
+static inline int Str_Delay3( int d0, int d1, int d2, int nLutSize )
+{
+    int n, d = Abc_MaxInt( Abc_MaxInt(d0 >> 4, d1 >> 4), d2 >> 4 );
+    n  = (d == (d0 >> 4)) ? (d0 & 15) : 1;
+    n += (d == (d1 >> 4)) ? (d1 & 15) : 1;
+    n += (d == (d2 >> 4)) ? (d2 & 15) : 1;
+    return (d << 4) + (n > nLutSize ? 19 : n);
+}
+static inline int Str_ObjDelay( Gia_Man_t * pNew, int iObj, int nLutSize, Vec_Int_t * vDelay )
+{
+    int Delay = Vec_IntEntry( vDelay, iObj );
+    if ( Delay == 0 )
+    {
+        if ( Gia_ObjIsMuxId(pNew, iObj) )
+        {
+            int d0 = Vec_IntEntry( vDelay, Gia_ObjFaninId0(Gia_ManObj(pNew, iObj), iObj) );
+            int d1 = Vec_IntEntry( vDelay, Gia_ObjFaninId1(Gia_ManObj(pNew, iObj), iObj) );
+            int d2 = Vec_IntEntry( vDelay, Gia_ObjFaninId2(pNew, iObj) );
+            Delay = Str_Delay3( d0, d1, d2, nLutSize );
+        }
+        else
+        {
+            int d0 = Vec_IntEntry( vDelay, Gia_ObjFaninId0(Gia_ManObj(pNew, iObj), iObj) );
+            int d1 = Vec_IntEntry( vDelay, Gia_ObjFaninId1(Gia_ManObj(pNew, iObj), iObj) );
+            Delay = Str_Delay2( d0, d1, nLutSize );
+        }
+        Vec_IntWriteEntry( vDelay, iObj, Delay );
+    }
+    return Delay;
+}
+
+
+
+/**Function*************************************************************
+
+  Synopsis    [Transposing 64-bit matrix.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline void transpose64( word A[64] )
+{
+    int j, k;
+    word t, m = 0x00000000FFFFFFFF;
+    for ( j = 32; j != 0; j = j >> 1, m = m ^ (m << j) )
+    {
+        for ( k = 0; k < 64; k = (k + j + 1) & ~j )
+        {
+            t = (A[k] ^ (A[k+j] >> j)) & m;
+            A[k] = A[k] ^ t;
+            A[k+j] = A[k+j] ^ (t << j);
+        }
+    }
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Perform affinity computation.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int  Str_ManNum( Gia_Man_t * p, int iObj )             { return Vec_IntEntry(&p->vCopies, iObj);     }
+static inline void Str_ManSetNum( Gia_Man_t * p, int iObj, int Num ) { Vec_IntWriteEntry(&p->vCopies, iObj, Num);  }
+
+int Str_ManVectorAffinity( Gia_Man_t * p, Vec_Int_t * vSuper, Vec_Int_t * vDelay, word Matrix[256], int nLimit )
+{
+    int fVerbose = 0;
+    int Levels[256];
+    int nSize = Vec_IntSize(vSuper);
+    int Prev = nSize, nLevels = 1;
+    int i, k, iLit, iFanin, nSizeNew;
+    word Mask; 
+    assert( nSize > 2 );
+    if ( nSize > 64 )
+    {
+        for ( i = 0; i < 64; i++ )
+            Matrix[i] = 0;
+        return 0;
+    }
+    // mark current nodes
+    Gia_ManIncrementTravId( p );
+    Vec_IntForEachEntry( vSuper, iLit, i )
+    {
+        Gia_ObjSetTravIdCurrentId( p, Abc_Lit2Var(iLit) );
+        Str_ManSetNum( p, Abc_Lit2Var(iLit), i );
+        Matrix[i] = ((word)1) << (63-i);
+        Levels[i] = 0;
+    }
+    // collect 64 nodes
+    Vec_IntForEachEntry( vSuper, iLit, i )
+    {
+        Gia_Obj_t * pObj = Gia_ManObj( p, Abc_Lit2Var(iLit) );
+        if ( Gia_ObjIsAnd(pObj) )
+        {
+            for ( k = 0; k < 2; k++ )
+            {
+                iFanin = k ? Gia_ObjFaninId1p(p, pObj) : Gia_ObjFaninId0p(p, pObj);
+                if ( !Gia_ObjIsTravIdCurrentId(p, iFanin) )
+                {
+                    if ( Vec_IntSize(vSuper) == nLimit )
+                        break;
+                    Gia_ObjSetTravIdCurrentId( p, iFanin );
+                    Matrix[Vec_IntSize(vSuper)] = 0;
+                    Levels[Vec_IntSize(vSuper)] = nLevels;
+                    Str_ManSetNum( p, iFanin, Vec_IntSize(vSuper) );
+                    Vec_IntPush( vSuper, Abc_Var2Lit(iFanin, 0) );
+                }
+                Matrix[Str_ManNum(p, iFanin)] |= Matrix[i];
+            }
+        }
+        if ( Gia_ObjIsMux(p, pObj) )
+        {
+            iFanin = Gia_ObjFaninId2p(p, pObj);
+            if ( !Gia_ObjIsTravIdCurrentId(p, iFanin) )
+            {
+                if ( Vec_IntSize(vSuper) == nLimit )
+                    break;
+                Gia_ObjSetTravIdCurrentId( p, iFanin );
+                Matrix[Vec_IntSize(vSuper)] = 0;
+                Levels[Vec_IntSize(vSuper)] = nLevels;
+                Str_ManSetNum( p, iFanin, Vec_IntSize(vSuper) );
+                Vec_IntPush( vSuper, Abc_Var2Lit(iFanin, 0) );
+            }
+            Matrix[Str_ManNum(p, iFanin)] |= Matrix[i];
+        }
+        if ( Prev == i )
+            Prev = Vec_IntSize(vSuper), nLevels++;
+        if ( nLevels == 8 )
+            break;
+    }
+
+    // remove those that have all 1s or only one 1
+    Mask = (~(word)0) << (64 - nSize);
+    for ( k = i = 0; i < Vec_IntSize(vSuper); i++ )
+    {
+        assert( Matrix[i] );
+        if ( (Matrix[i] & (Matrix[i] - 1)) == 0 )
+            continue;
+        if ( Matrix[i] == Mask )
+            continue;
+        Matrix[k] = Matrix[i];
+        Levels[k] = Levels[i];
+        k++;
+        if ( k == 64 )
+            break;
+    }
+    // clean the remaining ones
+    for ( i = k; i < 64; i++ )
+        Matrix[i] = 0;
+    nSizeNew = k;
+    if ( nSizeNew == 0 )
+    {
+        Vec_IntShrink( vSuper, nSize );
+        return 0;
+    }
+/*
+    // report
+    if ( fVerbose && nSize > 20 )
+    {
+        for ( i = 0; i < nSizeNew; i++ )
+            Extra_PrintBinary( stdout, Matrix+i, 64 ), printf( "\n" );
+        printf( "\n" );
+    }
+*/
+    transpose64( Matrix );
+
+    // report
+    if ( fVerbose && nSize > 10 )
+    {
+        printf( "Gate inputs = %d.  Collected fanins = %d.  All = %d.  Good = %d.  Levels = %d\n", 
+            nSize, Vec_IntSize(vSuper) - nSize, Vec_IntSize(vSuper), nSizeNew, nLevels );
+        printf( "                     " );
+        for ( i = 0; i < nSizeNew; i++ )
+            printf( "%d", Levels[i] );
+        printf( "\n" );
+        for ( i = 0; i < nSize; i++ )
+        {
+            printf( "%6d : ", Abc_Lit2Var(Vec_IntEntry(vSuper, i)) );
+            printf( "%3d   ", Vec_IntEntry(vDelay, i) >> 4 );
+            printf( "%3d   ", Vec_IntEntry(vDelay, i) & 15 );
+//            Extra_PrintBinary( stdout, Matrix+i, 64 ), printf( "\n" );
+        }
+        i = 0;
+    }
+    Vec_IntShrink( vSuper, nSize );
+    return nSizeNew;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Count 1s.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Str_CountBits( word i )
+{
+    if ( i == 0 )
+        return 0;
+    i = (i & (i - 1));
+    if ( i == 0 )
+        return 1;
+    i = (i & (i - 1));
+    if ( i == 0 )
+        return 2;
+    i = i - ((i >> 1) & 0x5555555555555555);
+    i = (i & 0x3333333333333333) + ((i >> 2) & 0x3333333333333333);
+    i = ((i + (i >> 4)) & 0x0F0F0F0F0F0F0F0F);
+    return (i*(0x0101010101010101))>>56;
+}
+
+static inline void Str_PrintState( int * pCost, int * pSuper, word * pMatrix, int nSize )
+{
+    int i;
+    for ( i = 0; i < nSize; i++ )
+    {
+        printf( "%6d : ", i );
+        printf( "%6d : ", Abc_Lit2Var(pSuper[i]) );
+        printf( "%3d   ", pCost[i] >> 4 );
+        printf( "%3d   ", pCost[i] & 15 );
+//        Extra_PrintBinary( stdout, pMatrix+i, 64 ), printf( "\n" );
+    }
+    printf( "\n" );
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    [Perform balancing.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Str_NtkBalanceMulti2( Gia_Man_t * pNew, Str_Ntk_t * p, Str_Obj_t * pObj, Vec_Int_t * vDelay, int nLutSize )
+{
+    int k;
+    pObj->iCopy = (pObj->Type == STR_AND);
+    for ( k = 0; k < (int)pObj->nFanins; k++ )
+    {
+        if ( pObj->Type == STR_AND )
+            pObj->iCopy = Gia_ManHashAnd( pNew, pObj->iCopy, Str_ObjFaninCopy(p, pObj, k) );
+        else
+            pObj->iCopy = Gia_ManHashXorReal( pNew, pObj->iCopy, Str_ObjFaninCopy(p, pObj, k) );
+        Str_ObjDelay( pNew, Abc_Lit2Var(pObj->iCopy), nLutSize, vDelay );
+    }
+}
+
+int Str_NtkBalanceTwo( Gia_Man_t * pNew, Str_Ntk_t * p, Str_Obj_t * pObj, int i, int j, Vec_Int_t * vDelay, int * pCost, int * pSuper, word * pMatrix, int nSize, int nLutSize, int CostBest )
+{
+    int k, iLitRes, Delay;
+    assert( i < j );
+//    printf( "Merging node %d and %d\n", i, j );
+    if ( pObj->Type == STR_AND )
+        iLitRes = Gia_ManHashAnd( pNew, pSuper[i], pSuper[j] );
+    else
+        iLitRes = Gia_ManHashXorReal( pNew, pSuper[i], pSuper[j] );
+    Delay = Str_ObjDelay( pNew, Abc_Lit2Var(iLitRes), nLutSize, vDelay );
+    // update
+    pCost[i] = Delay;
+    pSuper[i] = iLitRes;
+    pMatrix[i] |= pMatrix[j];
+//    assert( (pCost[i] & 15) == CostBest || CostBest == -1 );
+    // remove entry j
+    nSize--;
+    for ( k = j; k < nSize; k++ )
+    {
+        pCost[k] = pCost[k+1];
+        pSuper[k] = pSuper[k+1];
+        pMatrix[k] = pMatrix[k+1];
+    }
+    // move up the first one
+    nSize--;
+    for ( k = 0; k < nSize; k++ )
+    {
+        if ( pCost[k] <= pCost[k+1] )
+            break;
+        ABC_SWAP( int, pCost[k], pCost[k+1] );
+        ABC_SWAP( int, pSuper[k], pSuper[k+1] );
+        ABC_SWAP( word, pMatrix[k], pMatrix[k+1] );
+    }
+    return iLitRes;
+}
+
+void Str_NtkBalanceMulti( Gia_Man_t * pNew, Str_Ntk_t * p, Str_Obj_t * pObj, Vec_Int_t * vDelay, int nLutSize )
+{
+    word pMatrix[256];
+    int Limit = 256;
+    Vec_Int_t * vSuper = pNew->vSuper;
+    Vec_Int_t * vCosts = pNew->vStore;
+    int * pSuper = Vec_IntArray(vSuper);
+    int * pCost  = Vec_IntArray(vCosts);
+    int k, iLit, MatrixSize = 0;
+    assert( Limit <= Vec_IntCap(vSuper) );
+    assert( Limit <= Vec_IntCap(vCosts) );
+
+    // collect nodes
+    Vec_IntClear( vSuper );
+    for ( k = 0; k < (int)pObj->nFanins; k++ )
+        Vec_IntPush( vSuper, Str_ObjFaninCopy(p, pObj, k) );
+    Vec_IntSort( vSuper, 0 );
+    if ( pObj->Type == STR_AND )
+        Gia_ManSimplifyAnd( vSuper );
+    else
+        Gia_ManSimplifyXor( vSuper );
+    assert( Vec_IntSize(vSuper) > 0 );
+    if ( Vec_IntSize(vSuper) == 1 )
+    {
+        pObj->iCopy = Vec_IntEntry(vSuper, 0);
+        return;
+    }
+    if ( Vec_IntSize(vSuper) == 2 )
+    {
+        pObj->iCopy = Str_NtkBalanceTwo( pNew, p, pObj, 0, 1, vDelay, pCost, pSuper, pMatrix, 2, nLutSize, -1 );
+        return;
+    }
+
+    // sort by cost
+    Vec_IntClear( vCosts );
+    Vec_IntForEachEntry( vSuper, iLit, k )
+        Vec_IntPush( vCosts, Vec_IntEntry(vDelay, Abc_Lit2Var(iLit)) );
+    Vec_IntSelectSortCost2( pSuper, Vec_IntSize(vSuper), pCost );
+
+    // compute affinity
+    if ( Vec_IntSize(vSuper) < 64 )
+        MatrixSize = Str_ManVectorAffinity( pNew, vSuper, vCosts, pMatrix, Limit );
+
+    // start the new product
+    while ( Vec_IntSize(vSuper) > 2 )
+    {
+        // pair the first entry with another one on the same level
+        int i, iStop, iBest,iBest2;
+        int CostNew, CostBest, CostBest2;
+        int OccurNew, OccurBest, OccurBest2;
+
+        if ( Vec_IntSize(vSuper) > 64 )
+        {
+            Str_NtkBalanceTwo( pNew, p, pObj, 0, 1, vDelay, pCost, pSuper, pMatrix, Vec_IntSize(vSuper), nLutSize, -1 );
+            vSuper->nSize--;
+            vCosts->nSize--;
+            continue;
+        }
+
+        // compute affinity
+        if ( Vec_IntSize(vSuper) == 64 )
+            MatrixSize = Str_ManVectorAffinity( pNew, vSuper, vCosts, pMatrix, Limit );
+        assert( Vec_IntSize(vSuper) <= 64 );
+//        Str_PrintState( pCost, pSuper, pMatrix, Vec_IntSize(vSuper) );
+
+        // if the first two are PIs group them
+        if ( pCost[0] == 17 && pCost[1] == 17 )
+        {
+            Str_NtkBalanceTwo( pNew, p, pObj, 0, 1, vDelay, pCost, pSuper, pMatrix, Vec_IntSize(vSuper), nLutSize, 2 );
+            vSuper->nSize--;
+            vCosts->nSize--;
+            continue;
+        }
+
+        // find the end of the level
+        for ( iStop = 0; iStop < Vec_IntSize(vSuper); iStop++ )
+            if ( (pCost[iStop] >> 4) != (pCost[0] >> 4) )
+                break;
+        // if there is only one this level, pair it with the best match in the next level
+        if ( iStop == 1 )
+        {
+            iBest = iStop, OccurBest = Str_CountBits(pMatrix[0] & pMatrix[iStop]);
+            for ( i = iStop + 1; i < Vec_IntSize(vSuper); i++ )
+            {
+                if ( (pCost[i] >> 4) != (pCost[iStop] >> 4) )
+                    break;
+                OccurNew = Str_CountBits(pMatrix[0] & pMatrix[i]);
+                if ( OccurBest < OccurNew )
+                    iBest = i, OccurBest = OccurNew;
+            }
+            assert( iBest > 0 && iBest < Vec_IntSize(vSuper) );
+            Str_NtkBalanceTwo( pNew, p, pObj, 0, iBest, vDelay, pCost, pSuper, pMatrix, Vec_IntSize(vSuper), nLutSize, -1 );
+            vSuper->nSize--;
+            vCosts->nSize--;
+            continue;
+        }
+        // pair the first entry with another one on the same level
+        iBest = -1; CostBest = -1; OccurBest2 = -1; OccurBest = -1;
+        for ( i = 1; i < iStop; i++ )
+        {
+            CostNew = (pCost[0] & 15) + (pCost[i] & 15);
+            if ( CostNew > nLutSize )
+                continue;
+            OccurNew = Str_CountBits(pMatrix[0] & pMatrix[i]);
+            if ( CostBest < CostNew || (CostBest == CostNew && OccurBest < OccurNew) )
+                CostBest = CostNew, iBest = i, OccurBest = OccurNew;
+        }
+        // if the best found is perfect, take it
+        if ( CostBest == nLutSize )
+        {
+            assert( iBest > 0 && iBest < Vec_IntSize(vSuper) );
+            Str_NtkBalanceTwo( pNew, p, pObj, 0, iBest, vDelay, pCost, pSuper, pMatrix, Vec_IntSize(vSuper), nLutSize, CostBest );
+            vSuper->nSize--;
+            vCosts->nSize--;
+            continue;
+        }
+        // find the best pair on this level
+        iBest = iBest2 = -1; CostBest = CostBest2 = -1, OccurBest = OccurBest2 = -1;
+        for ( i = 0; i < iStop; i++ )
+        for ( k = i+1; k < iStop; k++ )
+        {
+            CostNew  = (pCost[i] & 15) + (pCost[k] & 15);
+            OccurNew = Str_CountBits(pMatrix[i] & pMatrix[k]);
+            if ( CostNew <= nLutSize ) // the same level
+            {
+                if ( OccurBest < OccurNew || (OccurBest == OccurNew && CostBest < CostNew ))
+                    CostBest = CostNew, iBest = (i << 16) | k, OccurBest = OccurNew;
+            }
+            else // overflow to the next level
+            {
+                if ( OccurBest2 < OccurNew || (OccurBest2 == OccurNew && CostBest2 < CostNew) )
+                    CostBest2 = CostNew, iBest2 = (i << 16) | k, OccurBest2 = OccurNew;
+            }
+        }
+        if ( iBest >= 0 )
+        {
+            assert( iBest > 0 );
+            Str_NtkBalanceTwo( pNew, p, pObj, iBest>>16, iBest&0xFFFF, vDelay, pCost, pSuper, pMatrix, Vec_IntSize(vSuper), nLutSize, CostBest );
+            vSuper->nSize--;
+            vCosts->nSize--;
+            continue;
+        }
+        // take any remaining pair
+        assert( iBest2 > 0 );
+        Str_NtkBalanceTwo( pNew, p, pObj, iBest2>>16, iBest2&0xFFFF, vDelay, pCost, pSuper, pMatrix, Vec_IntSize(vSuper), nLutSize, -1 );
+        vSuper->nSize--;
+        vCosts->nSize--;
+        continue;
+    }
+    pObj->iCopy = Str_NtkBalanceTwo( pNew, p, pObj, 0, 1, vDelay, pCost, pSuper, pMatrix, 2, nLutSize, -1 );
+
+/*
+    // simple
+    pObj->iCopy = (pObj->Type == STR_AND);
+    for ( k = 0; k < Vec_IntSize(vSuper); k++ )
+    {
+        if ( pObj->Type == STR_AND )
+            pObj->iCopy = Gia_ManHashAnd( pNew, pObj->iCopy, Vec_IntEntry(vSuper, k) );
+        else
+            pObj->iCopy = Gia_ManHashXorReal( pNew, pObj->iCopy, Vec_IntEntry(vSuper, k) );
+        Str_ObjDelay( pNew, Abc_Lit2Var(pObj->iCopy), nLutSize, vDelay );
+    }
+*/
+}
+void Str_NtkBalanceMux( Gia_Man_t * pNew, Str_Ntk_t * p, Str_Obj_t * pObj, Vec_Int_t * vDelay, int nLutSize, int nGroups, int nMuxes, int fRecursive, int fOptArea, int fVerbose )
+{
+    extern int Str_MuxRestructure( Gia_Man_t * pNew, Str_Ntk_t * pNtk, int iMux, int nMuxes, Vec_Int_t * vDelay, int nLutSize, int fRecursive, int fOptArea, int fVerbose );
+    int n, m, iRes, fUseRestruct = 1;
+    if ( fUseRestruct )
+    {
+        for ( n = 0; n < nGroups; n++ )
+        {            
+            iRes = Str_MuxRestructure( pNew, p, Str_ObjId(p, pObj), nMuxes, vDelay, nLutSize, fRecursive, fOptArea, fVerbose );
+            if ( iRes == -1 )
+            {
+                for ( m = 0; m < nMuxes; m++, pObj++ )
+                {
+                    pObj->iCopy = Gia_ManHashMuxReal( pNew, Str_ObjFaninCopy(p, pObj, 2), Str_ObjFaninCopy(p, pObj, 1), Str_ObjFaninCopy(p, pObj, 0) );
+                    Str_ObjDelay( pNew, Abc_Lit2Var(pObj->iCopy), nLutSize, vDelay );
+                }
+            }
+            else
+            {
+                pObj += nMuxes - 1;
+                pObj->iCopy = iRes;
+                pObj++;
+            }
+        }
+    }
+    else
+    {
+        for ( n = 0; n < nGroups * nMuxes; n++, pObj++ )
+        {
+            pObj->iCopy = Gia_ManHashMuxReal( pNew, Str_ObjFaninCopy(p, pObj, 2), Str_ObjFaninCopy(p, pObj, 1), Str_ObjFaninCopy(p, pObj, 0) );
+            Str_ObjDelay( pNew, Abc_Lit2Var(pObj->iCopy), nLutSize, vDelay );
+        }
+    }
+}
+Gia_Man_t * Str_NtkBalance( Gia_Man_t * pGia, Str_Ntk_t * p, int nLutSize, int fUseMuxes, int fRecursive, int fOptArea, int fVerbose )
+{
+    Gia_Man_t * pNew, * pTemp;
+    Vec_Int_t * vDelay;
+    Str_Obj_t * pObj; 
+    int nGroups, nMuxes, CioId;
+    int arrTime, Delay = 0;
+    assert( nLutSize < 16 );
+    assert( pGia->pMuxes == NULL );
+    pNew = Gia_ManStart( Gia_ManObjNum(pGia) );
+    pNew->pName = Abc_UtilStrsav( pGia->pName );
+    pNew->pSpec = Abc_UtilStrsav( pGia->pSpec );
+    pNew->pMuxes = ABC_CALLOC( unsigned, pNew->nObjsAlloc );
+    Vec_IntFill( &pNew->vCopies, pNew->nObjsAlloc, -1 );
+    if ( pNew->vSuper == NULL )
+        pNew->vSuper = Vec_IntAlloc( 1000 );
+    if ( pNew->vStore == NULL )
+        pNew->vStore = Vec_IntAlloc( 1000 );
+    vDelay = Vec_IntStart( pNew->nObjsAlloc );
+    Gia_ManHashStart( pNew );
+    if ( pGia->pManTime != NULL ) // Tim_Man with unit delay 16
+    {
+        Tim_ManInitPiArrivalAll( (Tim_Man_t *)pGia->pManTime, 17 );
+        Tim_ManIncrementTravId( (Tim_Man_t *)pGia->pManTime );
+    }
+    Str_NtkManForEachObj( p, pObj )
+    {
+        if ( pObj->Type == STR_PI )
+        {
+            pObj->iCopy = Gia_ManAppendCi( pNew );
+            arrTime = 17;
+            if ( pGia->pManTime != NULL )
+            {
+                CioId = Gia_ObjCioId( Gia_ManObj(pNew, Abc_Lit2Var(pObj->iCopy)) );
+                arrTime = (int)Tim_ManGetCiArrival( (Tim_Man_t *)pGia->pManTime, CioId );
+            }
+            Vec_IntWriteEntry( vDelay, Abc_Lit2Var(pObj->iCopy), arrTime );
+        }
+        else if ( pObj->Type == STR_AND || pObj->Type == STR_XOR )
+            Str_NtkBalanceMulti( pNew, p, pObj, vDelay, nLutSize );
+        else if ( pObj->Type == STR_MUX && pObj->iTop >= 0 && fUseMuxes )
+        {
+            Str_ObjReadGroup( p, pObj, &nGroups, &nMuxes );
+            assert( nGroups * nMuxes >= 2 );
+            Str_NtkBalanceMux( pNew, p, pObj, vDelay, nLutSize, nGroups, nMuxes, fRecursive, fOptArea, fVerbose );
+            pObj += nGroups * nMuxes - 1;
+        }
+        else if ( pObj->Type == STR_MUX )
+        {
+            pObj->iCopy = Gia_ManHashMuxReal( pNew, Str_ObjFaninCopy(p, pObj, 2), Str_ObjFaninCopy(p, pObj, 1), Str_ObjFaninCopy(p, pObj, 0) );
+            Str_ObjDelay( pNew, Abc_Lit2Var(pObj->iCopy), nLutSize, vDelay );
+        }
+        else if ( pObj->Type == STR_PO )
+        {
+            pObj->iCopy = Gia_ManAppendCo( pNew, Str_ObjFaninCopy(p, pObj, 0) );
+            arrTime = Vec_IntEntry(vDelay, Abc_Lit2Var(Str_ObjFaninCopy(p, pObj, 0)) );
+            Delay = Abc_MaxInt( Delay, arrTime );
+            if ( pGia->pManTime != NULL )
+            {
+                CioId = Gia_ObjCioId( Gia_ManObj(pNew, Abc_Lit2Var(pObj->iCopy)) );
+                Tim_ManSetCoArrival( (Tim_Man_t *)pGia->pManTime, CioId, (float)arrTime );
+            }
+        }
+        else if ( pObj->Type == STR_CONST0 )
+            pObj->iCopy = 0, Vec_IntWriteEntry(vDelay, 0, 17);
+        else assert( 0 );
+    }
+    if ( fVerbose )
+        printf( "Max delay = %d.  Old objs = %d.  New objs = %d.\n", Delay >> 4, Gia_ManObjNum(pGia), Gia_ManObjNum(pNew) );
+    Vec_IntFree( vDelay );
+    ABC_FREE( pNew->vCopies.pArray );
+    Gia_ManHashStop( pNew );
+    Gia_ManSetRegNum( pNew, Gia_ManRegNum(pGia) );
+    pNew = Gia_ManDupNoMuxes( pTemp = pNew );
+    Gia_ManStop( pTemp );
+//    if ( pGia->pManTime != NULL )
+//        pNew->pManTime = Tim_ManDup( (Tim_Man_t *)pGia->pManTime, 0 );
+    return pNew;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Test normalization procedure.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManLutBalance( Gia_Man_t * p, int nLutSize, int fUseMuxes, int fRecursive, int fOptArea, int fVerbose )
+{
+    Str_Ntk_t * pNtk;
+    Gia_Man_t * pNew;
+    abctime clk = Abc_Clock();
+    if ( p->pManTime && Tim_ManBoxNum(p->pManTime) && Gia_ManIsNormalized(p) )
+    {
+        Tim_Man_t * pTimOld = (Tim_Man_t *)p->pManTime;
+        p->pManTime = Tim_ManDup( pTimOld, 16 );
+        pNew = Gia_ManDupUnnormalize( p );
+        if ( pNew == NULL )
+            return NULL;
+        Gia_ManTransferTiming( pNew, p );
+        p = pNew;
+        // optimize
+        pNtk = Str_ManNormalize( p );
+        pNew = Str_NtkBalance( p, pNtk, nLutSize, fUseMuxes, fRecursive, fOptArea, fVerbose );
+        Gia_ManTransferTiming( pNew, p );
+        Gia_ManStop( p );
+        // normalize
+        pNew = Gia_ManDupNormalize( p = pNew );
+        Gia_ManTransferTiming( pNew, p );
+        Gia_ManStop( p );
+        // cleanup
+        Tim_ManStop( (Tim_Man_t *)pNew->pManTime );
+        pNew->pManTime = pTimOld;
+        assert( Gia_ManIsNormalized(pNew) );
+    }
+    else 
+    {
+        pNtk = Str_ManNormalize( p );
+    //    Str_NtkPrintGroups( pNtk );
+        pNew = Str_NtkBalance( p, pNtk, nLutSize, fUseMuxes, fRecursive, fOptArea, fVerbose );
+        Gia_ManTransferTiming( pNew, p );
+    }
+    if ( fVerbose )
+        Str_NtkPs( pNtk, Abc_Clock() - clk );
+    Str_NtkDelete( pNtk );   
+    return pNew;
+}
+
+
+
+
+
+/**Function*************************************************************
+
+  Synopsis    [Perform MUX restructuring.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+typedef struct Str_Edg_t_ Str_Edg_t; 
+struct Str_Edg_t_
+{
+    int            Fan;      // fanin ID
+    int            fCompl;   // fanin complement
+    int            FanDel;   // fanin delay
+    int            Copy;     // fanin copy
+};
+
+typedef struct Str_Mux_t_ Str_Mux_t; // 64 bytes
+struct Str_Mux_t_
+{
+    int            Id;       // node ID
+    int            Delay;    // node delay
+    int            Copy;     // node copy
+    int            nLutSize; // LUT size
+    Str_Edg_t      Edge[3];  // fanins
+};
+
+static inline Str_Mux_t * Str_MuxFanin( Str_Mux_t * pMux, int i )     { return pMux - pMux->Id + pMux->Edge[i].Fan;                         }
+static inline int         Str_MuxHasFanin( Str_Mux_t * pMux, int i )  { return pMux->Edge[i].Fan > 0 && Str_MuxFanin(pMux, i)->Copy != -2;  }
+
+void Str_MuxDelayPrint_rec( Str_Mux_t * pMux, int i )
+{
+    int fShowDelay = 1;
+    Str_Mux_t * pFanin;
+    if ( pMux->Edge[i].Fan <= 0 )
+    {
+        printf( "%d", -pMux->Edge[i].Fan );
+        if ( fShowDelay )
+            printf( "{%d}", pMux->Edge[i].FanDel );
+        return;
+    }
+    pFanin = Str_MuxFanin( pMux, i );
+    printf( "[ " );
+    if ( pFanin->Edge[0].fCompl )
+        printf( "!" );
+    Str_MuxDelayPrint_rec( pFanin, 0 );
+    printf( "|" );
+    if ( pFanin->Edge[1].fCompl )
+        printf( "!" );
+    Str_MuxDelayPrint_rec( pFanin, 1 );
+    printf( "(" );
+    if ( pFanin->Edge[2].fCompl )
+        printf( "!" );
+    Str_MuxDelayPrint_rec( pFanin, 2 );
+    printf( ")" );
+    printf( " ]" );
+}
+int Str_MuxDelayEdge_rec( Str_Mux_t * pMux, int i )
+{
+    if ( pMux->Edge[i].Fan > 0 )
+    {
+        Str_Mux_t * pFanin = Str_MuxFanin( pMux, i );
+        Str_MuxDelayEdge_rec( pFanin, 0 );
+        Str_MuxDelayEdge_rec( pFanin, 1 );
+        pMux->Edge[i].FanDel = Str_Delay3( pFanin->Edge[0].FanDel, pFanin->Edge[1].FanDel, pFanin->Edge[2].FanDel, pFanin->nLutSize );
+    }
+    return pMux->Edge[i].FanDel;
+}
+void Str_MuxCreate( Str_Mux_t * pTree, Str_Ntk_t * pNtk, int iMux, int nMuxes, Vec_Int_t * vDelay, int nLutSize )
+{
+    Str_Obj_t * pObj;
+    Str_Mux_t * pMux;
+    int i, k, nPis = 0;
+    assert( nMuxes >= 2 );
+    memset( pTree, 0, sizeof(Str_Mux_t) * (nMuxes + 1) );
+    pTree->nLutSize = nLutSize;
+    pTree->Edge[0].Fan = 1;
+    for ( i = 1; i <= nMuxes; i++ )
+    {
+        pMux = pTree + i;
+        pMux->Id = i;
+        pMux->nLutSize = nLutSize;
+        pMux->Delay = pMux->Copy = -1;
+        // assign fanins
+        pObj = Str_NtkObj( pNtk, iMux + nMuxes - i );
+        assert( pObj->Type == STR_MUX );
+        for ( k = 0; k < 3; k++ )
+        {
+            pMux->Edge[k].fCompl = Str_ObjFaninC(pNtk, pObj, k);
+            if ( Str_ObjFaninId(pNtk, pObj, k) >= iMux )
+                pMux->Edge[k].Fan = iMux + nMuxes - Str_ObjFaninId(pNtk, pObj, k);
+            else
+            {
+                pMux->Edge[k].Fan = -nPis++; // count external inputs, including controls
+                pMux->Edge[k].Copy = Str_ObjFanin(pNtk, pObj, k)->iCopy;
+                pMux->Edge[k].FanDel = Vec_IntEntry( vDelay, Abc_Lit2Var(pMux->Edge[k].Copy) );
+            }
+        }
+    }
+}
+int Str_MuxToGia_rec( Gia_Man_t * pNew, Str_Mux_t * pMux, int i, Vec_Int_t * vDelay )
+{
+    if ( pMux->Edge[i].Fan > 0 )
+    {
+        Str_Mux_t * pFanin = Str_MuxFanin( pMux, i );
+        int iLit0 = Str_MuxToGia_rec( pNew, pFanin, 0, vDelay );
+        int iLit1 = Str_MuxToGia_rec( pNew, pFanin, 1, vDelay );
+        assert( pFanin->Edge[2].Fan <= 0 );
+        assert( pFanin->Edge[2].fCompl == 0 );
+        pMux->Edge[i].Copy = Gia_ManHashMuxReal( pNew, pFanin->Edge[2].Copy, iLit1, iLit0 );
+        Str_ObjDelay( pNew, Abc_Lit2Var(pMux->Edge[i].Copy), pFanin->nLutSize, vDelay );
+    }
+    return Abc_LitNotCond( pMux->Edge[i].Copy, pMux->Edge[i].fCompl );
+}
+void Str_MuxChangeOnce( Str_Mux_t * pTree, int * pPath, int i, int k, Str_Mux_t * pBackup, Gia_Man_t * pNew, Vec_Int_t * vDelay )
+{
+    Str_Mux_t * pSpots[3];
+    int pInds[3], MidFan, MidCom, MidDel, MidCop, c;
+    int iRes, iCond, fCompl;
+    // save backup
+    assert( i + 1 < k );
+    if ( pBackup )
+    {
+        pBackup[0] = pTree[ Abc_Lit2Var(pPath[k])  ];
+        pBackup[1] = pTree[ Abc_Lit2Var(pPath[i+1])];
+        pBackup[2] = pTree[ Abc_Lit2Var(pPath[i])  ];
+    }
+    // perform changes
+    pSpots[0] = pTree + Abc_Lit2Var(pPath[k]); 
+    pSpots[1] = pTree + Abc_Lit2Var(pPath[i+1]); 
+    pSpots[2] = pTree + Abc_Lit2Var(pPath[i]); 
+    pInds[0] = Abc_LitIsCompl(pPath[k]);
+    pInds[1] = Abc_LitIsCompl(pPath[i+1]);
+    pInds[2] = Abc_LitIsCompl(pPath[i]);
+    // check
+    assert( pSpots[0]->Edge[pInds[0]].Fan > 0 );
+    assert( pSpots[1]->Edge[pInds[1]].Fan > 0 );
+    // collect complement
+    fCompl = 0;
+    for ( c = i+1; c < k; c++ )
+        fCompl ^= pTree[Abc_Lit2Var(pPath[c])].Edge[Abc_LitIsCompl(pPath[c])].fCompl;
+    // remember bottom side
+    MidFan = pSpots[2]->Edge[!pInds[2]].Fan;
+    MidCom = pSpots[2]->Edge[!pInds[2]].fCompl;
+    MidDel = pSpots[2]->Edge[!pInds[2]].FanDel;
+    MidCop = pSpots[2]->Edge[!pInds[2]].Copy;
+    // update bottom
+    pSpots[2]->Edge[!pInds[2]].Fan    = pSpots[0]->Edge[pInds[0]].Fan;
+    pSpots[2]->Edge[!pInds[2]].fCompl = 0;
+    // update top 
+    pSpots[0]->Edge[pInds[0]].Fan     = pSpots[2]->Id;
+    // update middle
+    pSpots[1]->Edge[pInds[1]].Fan     = MidFan;
+    pSpots[1]->Edge[pInds[1]].fCompl ^= MidCom;
+    pSpots[1]->Edge[pInds[1]].FanDel  = MidDel;
+    pSpots[1]->Edge[pInds[1]].Copy    = MidCop;
+    // update delay of the control
+    for ( c = i + 1; c < k; c++ )
+        pSpots[2]->Edge[2].FanDel = Str_Delay2( pSpots[2]->Edge[2].FanDel, pTree[Abc_Lit2Var(pPath[c])].Edge[2].FanDel, pTree->nLutSize );
+    if ( pNew == NULL )
+        return;
+    // create AND gates
+    iRes = 1;
+    for ( c = i; c < k; c++ )
+    {
+        assert( pTree[Abc_Lit2Var(pPath[c])].Edge[2].fCompl == 0 );
+        iCond = pTree[Abc_Lit2Var(pPath[c])].Edge[2].Copy;
+        iCond = Abc_LitNotCond( iCond, !Abc_LitIsCompl(pPath[c]) );
+        iRes  = Gia_ManHashAnd( pNew, iRes, iCond );
+        Str_ObjDelay( pNew, Abc_Lit2Var(iRes), pTree->nLutSize, vDelay );
+    }
+    // complement the condition
+    pSpots[2]->Edge[2].Copy = Abc_LitNotCond( iRes, !Abc_LitIsCompl(pPath[i]) );
+    // complement the path
+    pSpots[2]->Edge[pInds[2]].fCompl ^= fCompl;
+}
+void Str_MuxChangeUndo( Str_Mux_t * pTree, int * pPath, int i, int k, Str_Mux_t * pBackup )
+{
+    pTree[ Abc_Lit2Var(pPath[k])  ] = pBackup[0]; 
+    pTree[ Abc_Lit2Var(pPath[i+1])] = pBackup[1]; 
+    pTree[ Abc_Lit2Var(pPath[i])  ] = pBackup[2]; 
+}
+int Str_MuxFindPathEdge_rec( Str_Mux_t * pMux, int i, int * pPath, int * pnLength )
+{
+    extern int Str_MuxFindPath_rec( Str_Mux_t * pMux, int * pPath, int * pnLength );
+    if ( pMux->Edge[i].Fan > 0 && !Str_MuxFindPath_rec(Str_MuxFanin(pMux, i), pPath, pnLength) )
+        return 0;
+    pPath[ (*pnLength)++ ] = Abc_Var2Lit(pMux->Id, i);
+    return 1;
+}
+int Str_MuxFindPath_rec( Str_Mux_t * pMux, int * pPath, int * pnLength )
+{
+    int i, DelayMax = Abc_MaxInt( pMux->Edge[0].FanDel, Abc_MaxInt(pMux->Edge[1].FanDel, pMux->Edge[2].FanDel) );
+    for ( i = 0; i < 2; i++ )
+        if ( pMux->Edge[i].FanDel == DelayMax )
+            return Str_MuxFindPathEdge_rec( pMux, i, pPath, pnLength );
+    if ( pMux->Edge[2].FanDel == DelayMax )
+        return 0;
+    assert( 0 );
+    return -1;
+}
+// return node whose both branches are non-trivial
+Str_Mux_t * Str_MuxFindBranching( Str_Mux_t * pRoot, int i )
+{
+    Str_Mux_t * pMux;
+    if ( pRoot->Edge[i].Fan <= 0 )
+        return NULL;
+    pMux = Str_MuxFanin( pRoot, i );
+    while ( 1 )
+    {
+        if ( pMux->Edge[0].Fan <= 0 && pMux->Edge[1].Fan <= 0 )
+            return NULL;
+        if ( pMux->Edge[0].Fan > 0 && pMux->Edge[1].Fan > 0 )
+            return pMux;
+        if ( pMux->Edge[0].Fan > 0 )
+            pMux = Str_MuxFanin( pMux, 0 );
+        if ( pMux->Edge[1].Fan > 0 )
+            pMux = Str_MuxFanin( pMux, 1 );
+    }
+    assert( 0 );
+    return NULL;
+}
+int Str_MuxTryOnce( Gia_Man_t * pNew, Str_Ntk_t * pNtk, Str_Mux_t * pTree, Str_Mux_t * pRoot, int Edge, Vec_Int_t * vDelay, int fVerbose )
+{
+    int pPath[500];
+    Str_Mux_t pBackup[3];
+    int Delay, DelayBest = Str_MuxDelayEdge_rec( pRoot, Edge ), DelayInit = DelayBest;
+    int i, k, nLength = 0, ForkBest = -1, nChecks = 0;
+    int RetValue = Str_MuxFindPathEdge_rec( pRoot, Edge, pPath, &nLength );
+    if ( RetValue == 0 )
+        return 0;
+    if ( fVerbose )
+        printf( "Trying node %d with path of length %d.\n", pRoot->Id, nLength );
+    for ( i = 0; i < nLength; i++ )
+    for ( k = i+2; k < nLength; k++ )
+    {
+        Str_MuxChangeOnce( pTree, pPath, i, k, pBackup, NULL, NULL );
+        Delay = Str_MuxDelayEdge_rec( pRoot, Edge );
+        Str_MuxChangeUndo( pTree, pPath, i, k, pBackup );
+        if ( DelayBest > Delay || (ForkBest > 0 && DelayBest == Delay) )
+            DelayBest = Delay, ForkBest = (i << 16) | k;
+        if ( fVerbose )
+            printf( "%2d %2d -> %3d (%3d)\n", i, k, Delay, DelayBest );
+        nChecks++;
+    }
+    if ( ForkBest == -1 )
+    {
+        if ( fVerbose )
+            printf( "Did not find!\n" );
+        return 0;
+    }
+//    Str_MuxDelayPrint_rec( pRoot, Edge ); printf( "\n" );
+    Str_MuxChangeOnce( pTree, pPath, ForkBest >> 16, ForkBest & 0xFFFF, NULL, pNew, vDelay );
+//    Str_MuxDelayPrint_rec( pRoot, Edge ); printf( "\n" );
+    if ( fVerbose )
+        printf( "Node %6d (%3d %3d) : Checks = %d. Delay: %d -> %d.\n", 
+            pRoot->Id, ForkBest >> 16, ForkBest & 0xFFFF, nChecks, DelayInit, DelayBest );
+    if ( fVerbose )
+        printf( "\n" );
+    return 1;
+}
+int Str_MuxRestruct_rec( Gia_Man_t * pNew, Str_Ntk_t * pNtk, Str_Mux_t * pTree, Str_Mux_t * pRoot, int Edge, Vec_Int_t * vDelay, int fVerbose )
+{
+    int fChanges = 0;
+    Str_Mux_t * pMux = Str_MuxFindBranching( pRoot, Edge );
+    if ( pMux != NULL )
+        fChanges |= Str_MuxRestruct_rec( pNew, pNtk, pTree, pMux, 0, vDelay, fVerbose );
+    if ( pMux != NULL )
+        fChanges |= Str_MuxRestruct_rec( pNew, pNtk, pTree, pMux, 1, vDelay, fVerbose );
+    fChanges |= Str_MuxTryOnce( pNew, pNtk, pTree, pRoot, Edge, vDelay, fVerbose );
+    return fChanges;
+}
+int Str_MuxRestructure2( Gia_Man_t * pNew, Str_Ntk_t * pNtk, int iMux, int nMuxes, Vec_Int_t * vDelay, int nLutSize, int fVerbose )
+{
+    int Limit = 500;
+    Str_Mux_t pTree[500];
+    int Delay, Delay2, fChanges = 0;
+    if ( nMuxes >= Limit )
+        return -1;
+    assert( nMuxes < Limit );
+    Str_MuxCreate( pTree, pNtk, iMux, nMuxes, vDelay, nLutSize );
+    Delay = Str_MuxDelayEdge_rec( pTree, 0 );
+    while ( 1 )
+    {     
+        if ( !Str_MuxRestruct_rec(pNew, pNtk, pTree, pTree, 0, vDelay, fVerbose) )
+            break;
+        fChanges = 1;
+    }
+    if ( !fChanges )
+        return -1;
+    Delay2 = Str_MuxDelayEdge_rec( pTree, 0 );
+//    printf( "Improved delay for tree %d with %d MUXes (%d -> %d).\n", iMux, nMuxes, Delay, Delay2 );
+    pNtk->DelayGain += Delay - Delay2;
+    return Str_MuxToGia_rec( pNew, pTree, 0, vDelay );
+}
+int Str_MuxRestructure1( Gia_Man_t * pNew, Str_Ntk_t * pNtk, int iMux, int nMuxes, Vec_Int_t * vDelay, int nLutSize, int fVerbose )
+{
+    int Limit = 500;
+    Str_Mux_t pTree[500];
+    int Delay, Delay2, fChanges = 0;
+    if ( nMuxes >= Limit )
+        return -1;
+    assert( nMuxes < Limit );
+    Str_MuxCreate( pTree, pNtk, iMux, nMuxes, vDelay, nLutSize );
+    Delay = Str_MuxDelayEdge_rec( pTree, 0 );
+    while ( 1 )
+    {     
+        if ( !Str_MuxTryOnce(pNew, pNtk, pTree, pTree, 0, vDelay, fVerbose) )
+            break;
+        fChanges = 1;
+    }
+    if ( !fChanges )
+        return -1;
+    Delay2 = Str_MuxDelayEdge_rec( pTree, 0 );
+//    printf( "Improved delay for tree %d with %d MUXes (%d -> %d).\n", iMux, nMuxes, Delay, Delay2 );
+    pNtk->DelayGain += Delay - Delay2;
+    return Str_MuxToGia_rec( pNew, pTree, 0, vDelay );
+}
+int Str_MuxRestructure( Gia_Man_t * pNew, Str_Ntk_t * pNtk, int iMux, int nMuxes, Vec_Int_t * vDelay, int nLutSize, int fRecursive, int fOptArea, int fVerbose )
+{
+    extern int Str_MuxRestructureArea( Gia_Man_t * pNew, Str_Ntk_t * pNtk, int iMux, int nMuxes, Vec_Int_t * vDelay, int nLutSize, int fVerbose );
+    if ( fOptArea )
+    {
+        if ( nMuxes < 2 )
+            return Str_MuxRestructure1( pNew, pNtk, iMux, nMuxes, vDelay, nLutSize, fVerbose );
+        return Str_MuxRestructureArea( pNew, pNtk, iMux, nMuxes, vDelay, nLutSize, fVerbose );
+    }
+    if ( fRecursive )
+        return Str_MuxRestructure2( pNew, pNtk, iMux, nMuxes, vDelay, nLutSize, fVerbose );
+    return Str_MuxRestructure1( pNew, pNtk, iMux, nMuxes, vDelay, nLutSize, fVerbose );
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Perform MUX restructuring for area.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Str_MuxRestructAreaThree( Gia_Man_t * pNew, Str_Mux_t * pMux, Vec_Int_t * vDelay, int fVerbose )
+{
+    int iRes;
+    Str_Mux_t * pFanin0 = Str_MuxFanin( pMux, 0 );
+    Str_Mux_t * pFanin1 = Str_MuxFanin( pMux, 1 );
+    assert( pMux->Copy == -1 );
+    pMux->Copy = -2;
+    if ( pFanin0->Edge[2].Copy == pFanin1->Edge[2].Copy )
+        return 0;
+    iRes = Gia_ManHashMuxReal( pNew, pMux->Edge[2].Copy, pFanin1->Edge[2].Copy, pFanin0->Edge[2].Copy );
+    Str_ObjDelay( pNew, Abc_Lit2Var(iRes), pMux->nLutSize, vDelay );
+    pFanin0->Edge[2].Copy = pFanin1->Edge[2].Copy = iRes;
+//    printf( "Created triple\n" );
+    return 0;
+}
+int Str_MuxRestructArea_rec( Gia_Man_t * pNew, Str_Mux_t * pTree, Str_Mux_t * pRoot, int i, Vec_Int_t * vDelay, int fVerbose )
+{
+    int Path[4];
+    int fSkipMoving = 1;
+    Str_Mux_t * pMux, * pFanin0, * pFanin1;
+    int nMuxes0, nMuxes1;
+    if ( pRoot->Edge[i].Fan <= 0 )
+        return 0;
+    pMux    = Str_MuxFanin( pRoot, i );
+    nMuxes0 = Str_MuxRestructArea_rec( pNew, pTree, pMux, 0, vDelay, fVerbose );
+    nMuxes1 = Str_MuxRestructArea_rec( pNew, pTree, pMux, 1, vDelay, fVerbose );
+    if ( nMuxes0 + nMuxes1 < 2 )
+        return 1 + nMuxes0 + nMuxes1;
+    if ( nMuxes0 + nMuxes1 == 2 )
+    {
+        if ( nMuxes0 == 2 || nMuxes1 == 2 )
+        {
+            pFanin0 = Str_MuxFanin( pMux, (int)(nMuxes1 == 2) );
+            assert( Str_MuxHasFanin(pFanin0, 0) != Str_MuxHasFanin(pFanin0, 1) );
+            Path[2] = Abc_Var2Lit(pRoot->Id, i);
+            Path[1] = Abc_Var2Lit(pMux->Id, (int)(nMuxes1 == 2) );
+            Path[0] = Abc_Var2Lit(pFanin0->Id, Str_MuxHasFanin(pFanin0, 1));
+            Str_MuxChangeOnce( pTree, Path, 0, 2, NULL, pNew, vDelay );
+        }
+        Str_MuxRestructAreaThree( pNew, Str_MuxFanin(pRoot, i), vDelay, fVerbose );
+        return 0;
+    }
+    assert( nMuxes0 + nMuxes1 == 3 || nMuxes0 + nMuxes1 == 4 );
+    assert( nMuxes0 == 2 || nMuxes1 == 2 );
+    if ( fSkipMoving )
+    {
+        Str_MuxRestructAreaThree( pNew, pMux, vDelay, fVerbose );
+        return 0;
+    }
+    if ( nMuxes0 == 2 )
+    {
+        pFanin0 = Str_MuxFanin( pMux, 0 );
+        assert( Str_MuxHasFanin(pFanin0, 0) != Str_MuxHasFanin(pFanin0, 1) );
+        Path[3] = Abc_Var2Lit(pRoot->Id, i);
+        Path[2] = Abc_Var2Lit(pMux->Id, 0 );
+        Path[1] = Abc_Var2Lit(pFanin0->Id, Str_MuxHasFanin(pFanin0, 1));
+        pFanin1 = Str_MuxFanin( pFanin0, Str_MuxHasFanin(pFanin0, 1) );
+        assert( !Str_MuxHasFanin(pFanin1, 0) && !Str_MuxHasFanin(pFanin1, 1) );
+        Path[0] = Abc_Var2Lit(pFanin1->Id, 0);
+        Str_MuxChangeOnce( pTree, Path, 0, 3, NULL, pNew, vDelay );
+    }
+    if ( nMuxes1 == 2 )
+    {
+        pFanin0 = Str_MuxFanin( pMux, 1 );
+        assert( Str_MuxHasFanin(pFanin0, 0) != Str_MuxHasFanin(pFanin0, 1) );
+        Path[3] = Abc_Var2Lit(pRoot->Id, i);
+        Path[2] = Abc_Var2Lit(pMux->Id, 1 );
+        Path[1] = Abc_Var2Lit(pFanin0->Id, Str_MuxHasFanin(pFanin0, 1));
+        pFanin1 = Str_MuxFanin( pFanin0, Str_MuxHasFanin(pFanin0, 1) );
+        assert( !Str_MuxHasFanin(pFanin1, 0) && !Str_MuxHasFanin(pFanin1, 1) );
+        Path[0] = Abc_Var2Lit(pFanin1->Id, 0);
+        Str_MuxChangeOnce( pTree, Path, 0, 3, NULL, pNew, vDelay );
+    }
+    Str_MuxRestructAreaThree( pNew, pMux, vDelay, fVerbose );
+    return nMuxes0 + nMuxes1 - 2;
+}
+int Str_MuxRestructureArea( Gia_Man_t * pNew, Str_Ntk_t * pNtk, int iMux, int nMuxes, Vec_Int_t * vDelay, int nLutSize, int fVerbose )
+{
+    int Limit = 500;
+    Str_Mux_t pTree[500];
+    int Result;
+    if ( nMuxes >= Limit )
+        return -1;
+    assert( nMuxes < Limit );
+    Str_MuxCreate( pTree, pNtk, iMux, nMuxes, vDelay, nLutSize );
+    Result = Str_MuxRestructArea_rec( pNew, pTree, pTree, 0, vDelay, fVerbose );
+    assert( Result >= 0 && Result <= 2 );
+    return Str_MuxToGia_rec( pNew, pTree, 0, vDelay );
+}
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/abc-build/src/aig/gia/giaSweep.c b/abc-build/src/aig/gia/giaSweep.c
--- a/abc-build/src/aig/gia/giaSweep.c
+++ b/abc-build/src/aig/gia/giaSweep.c
@@ -21,6 +21,8 @@
 #include "gia.h"
 #include "giaAig.h"
 #include "proof/dch/dch.h"
+#include "misc/tim/tim.h"
+#include "proof/cec/cec.h"
 
 ABC_NAMESPACE_IMPL_START
 
@@ -36,6 +38,167 @@
 
   Synopsis    [Mark GIA nodes that feed into POs.]
 
+  Description [Returns the array of classes of remaining registers.]
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Gia_ManMarkSeqGiaWithBoxes_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vRoots )
+{
+    Tim_Man_t * pManTime = (Tim_Man_t *)p->pManTime;
+    int i, iBox, nBoxIns, nBoxOuts, iShift, nRealCis;
+    if ( Gia_ObjIsTravIdCurrent(p, pObj) )
+        return;
+    Gia_ObjSetTravIdCurrent(p, pObj);
+    if ( Gia_ObjIsAnd(pObj) )
+    {
+        Gia_ManMarkSeqGiaWithBoxes_rec( p, Gia_ObjFanin0(pObj), vRoots );
+        Gia_ManMarkSeqGiaWithBoxes_rec( p, Gia_ObjFanin1(pObj), vRoots );
+        return;
+    }
+    assert( Gia_ObjIsCi(pObj) );
+    nRealCis = Tim_ManPiNum(pManTime);
+    if ( Gia_ObjCioId(pObj) < nRealCis )
+    {
+        int nRegs = Gia_ManRegBoxNum(p);
+        int iFlop = Gia_ObjCioId(pObj) - (nRealCis - nRegs);
+        assert( iFlop >= 0 && iFlop < nRegs );
+        pObj = Gia_ManCo( p, Gia_ManPoNum(p) - nRegs + iFlop );
+        Vec_IntPush( vRoots, Gia_ObjId(p, pObj) );
+        return;
+    }
+    // get the box
+    iBox = Tim_ManBoxForCi( pManTime, Gia_ObjCioId(pObj) );
+    nBoxIns = Tim_ManBoxInputNum(pManTime, iBox);
+    nBoxOuts = Tim_ManBoxOutputNum(pManTime, iBox);
+    // mark all outputs
+    iShift = Tim_ManBoxOutputFirst(pManTime, iBox);
+    for ( i = 0; i < nBoxOuts; i++ )
+        Gia_ObjSetTravIdCurrent(p, Gia_ManCi(p, iShift + i));
+    // traverse from inputs
+    iShift = Tim_ManBoxInputFirst(pManTime, iBox);
+    for ( i = 0; i < nBoxIns; i++ )
+        Gia_ObjSetTravIdCurrent(p, Gia_ManCo(p, iShift + i));
+    for ( i = 0; i < nBoxIns; i++ )
+        Gia_ManMarkSeqGiaWithBoxes_rec( p, Gia_ObjFanin0(Gia_ManCo(p, iShift + i)), vRoots );
+}
+void Gia_ManMarkSeqGiaWithBoxes( Gia_Man_t * p, int fSeq )
+{
+    // CI order: real PIs + flop outputs + box outputs
+    // CO order: box inputs + real POs + flop inputs
+    Tim_Man_t * pManTime = (Tim_Man_t *)p->pManTime;
+    Vec_Int_t * vRoots;
+    Gia_Obj_t * pObj;
+    int nRealCis = Tim_ManPiNum(pManTime);
+    int nRealCos = Tim_ManPoNum(pManTime);
+    int i, nRegs = fSeq ? Gia_ManRegBoxNum(p) : 0;
+    assert( Gia_ManRegNum(p) == 0 );
+    assert( Gia_ManBoxNum(p) > 0 );
+    // mark the terminals
+    Gia_ManIncrementTravId( p );
+    Gia_ObjSetTravIdCurrent( p, Gia_ManConst0(p) );
+    for ( i = 0; i < nRealCis - nRegs; i++ )
+        Gia_ObjSetTravIdCurrent( p, Gia_ManPi(p, i) );
+    // collect flops reachable from the POs
+    vRoots = Vec_IntAlloc( Gia_ManRegBoxNum(p) );
+    for ( i = Gia_ManPoNum(p) - nRealCos; i < Gia_ManPoNum(p) - nRegs; i++ )
+    {
+        Gia_ObjSetTravIdCurrent( p, Gia_ManPo(p, i) );
+        Gia_ManMarkSeqGiaWithBoxes_rec( p, Gia_ObjFanin0(Gia_ManPo(p, i)), vRoots );
+    }
+    // collect flops reachable from roots
+    if ( fSeq )
+    {
+        Gia_ManForEachObjVec( vRoots, p, pObj, i )
+        {
+            assert( Gia_ObjIsCo(pObj) );
+            Gia_ObjSetTravIdCurrent( p, pObj );
+            Gia_ManMarkSeqGiaWithBoxes_rec( p, Gia_ObjFanin0(pObj), vRoots );
+        }
+        //printf( "Explored %d flops\n", Vec_IntSize(vRoots) );
+    }
+    Vec_IntFree( vRoots );
+}
+Gia_Man_t * Gia_ManDupWithBoxes( Gia_Man_t * p, int fSeq )
+{
+    Tim_Man_t * pManTime = (Tim_Man_t *)p->pManTime;
+    Gia_Man_t * pNew;
+    Gia_Obj_t * pObj;
+    Vec_Int_t * vBoxesLeft;
+    int curCi, curCo, nBoxIns, nBoxOuts;
+    int i, k, iShift, nMarked;
+    assert( Gia_ManBoxNum(p) > 0 );
+    // mark useful boxes
+    Gia_ManMarkSeqGiaWithBoxes( p, fSeq );
+    // duplicate marked entries
+    pNew = Gia_ManStart( Gia_ManObjNum(p) );
+    pNew->pName = Abc_UtilStrsav( p->pName );
+    pNew->pSpec = Abc_UtilStrsav( p->pSpec );
+    Gia_ManConst0(p)->Value = 0;
+    Gia_ManForEachObj1( p, pObj, i )
+    {
+        if ( !Gia_ObjIsTravIdCurrent(p, pObj) )
+            continue;
+        if ( Gia_ObjIsCi(pObj) )
+            pObj->Value = Gia_ManAppendCi(pNew);
+        else if ( Gia_ObjIsAnd(pObj) )
+            pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+        else if ( Gia_ObjIsCo(pObj) )
+            pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+        else assert( 0 );
+    }
+    assert( !Gia_ManHasDangling(pNew) );
+    // collect remaining flops
+    if ( fSeq )
+    {
+        pNew->vRegClasses = Vec_IntAlloc( Gia_ManRegBoxNum(p) );
+        iShift = Gia_ManPoNum(p) - Gia_ManRegBoxNum(p);
+        for ( i = 0; i < Gia_ManRegBoxNum(p); i++ )
+            if ( Gia_ObjIsTravIdCurrent(p, Gia_ManCo(p, iShift + i)) )
+                Vec_IntPush( pNew->vRegClasses, Vec_IntEntry(p->vRegClasses, i) );
+    }
+    else if ( p->vRegClasses )
+        pNew->vRegClasses = Vec_IntDup( p->vRegClasses );
+    // collect remaining boxes
+    vBoxesLeft = Vec_IntAlloc( Gia_ManBoxNum(p) );
+    curCi = Tim_ManPiNum(pManTime);
+    curCo = 0;
+    for ( i = 0; i < Gia_ManBoxNum(p); i++ )
+    {
+        nBoxIns = Tim_ManBoxInputNum(pManTime, i);
+        nBoxOuts = Tim_ManBoxOutputNum(pManTime, i);
+        nMarked = 0;
+        for ( k = 0; k < nBoxIns; k++ )
+            nMarked += Gia_ObjIsTravIdCurrent( p, Gia_ManCo(p, curCo + k) );
+        for ( k = 0; k < nBoxOuts; k++ )
+            nMarked += Gia_ObjIsTravIdCurrent( p, Gia_ManCi(p, curCi + k) );
+        curCo += nBoxIns;
+        curCi += nBoxOuts;
+        // check presence
+        assert( nMarked == 0 || nMarked == nBoxIns + nBoxOuts );
+        if ( nMarked )
+            Vec_IntPush( vBoxesLeft, i );
+    }
+    curCo += Tim_ManPoNum(pManTime);
+    assert( curCi == Gia_ManCiNum(p) );
+    assert( curCo == Gia_ManCoNum(p) );
+    // update timing manager
+    pNew->pManTime = Gia_ManUpdateTimMan2( p, vBoxesLeft, Gia_ManRegBoxNum(p) - Gia_ManRegBoxNum(pNew) );
+    // update extra STG
+    assert( p->pAigExtra != NULL );
+    assert( pNew->pAigExtra == NULL );
+    pNew->pAigExtra = Gia_ManUpdateExtraAig2( p->pManTime, p->pAigExtra, vBoxesLeft );
+    assert( Gia_ManCiNum(pNew) == Tim_ManPiNum(pNew->pManTime) + Gia_ManCoNum(pNew->pAigExtra) );
+    Vec_IntFree( vBoxesLeft );
+    return pNew;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Mark GIA nodes that feed into POs.]
+
   Description []
                
   SideEffects []
@@ -198,6 +361,75 @@
 
 /**Function*************************************************************
 
+  Synopsis    [Compute the set of CIs representing carry-outs of boxes.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Vec_Int_t * Gia_ManComputeCarryOuts( Gia_Man_t * p )
+{
+    Gia_Obj_t * pObj;
+    Tim_Man_t * pManTime = (Tim_Man_t *)p->pManTime;
+    int i, iLast, iBox, nBoxes =  Tim_ManBoxNum( pManTime );
+    Vec_Int_t * vCarryOuts = Vec_IntAlloc( nBoxes );
+    for ( i = 0; i < nBoxes; i++ )
+    {
+        iLast = Tim_ManBoxInputLast( pManTime, i );
+        pObj = Gia_ObjFanin0( Gia_ManCo(p, iLast) );
+        if ( !Gia_ObjIsCi(pObj) )
+            continue;
+        iBox = Tim_ManBoxForCi( pManTime, Gia_ObjCioId(pObj) );
+        if ( iBox == -1 ) 
+            continue;
+        assert( Gia_ObjIsCi(pObj) );
+        if ( Gia_ObjCioId(pObj) == Tim_ManBoxOutputLast(pManTime, iBox) )
+            Vec_IntPush( vCarryOuts, Gia_ObjId(p, pObj) );
+    }
+    return vCarryOuts;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Checks integriting of complex flops and carry-chains.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Gia_ManCheckIntegrityWithBoxes( Gia_Man_t * p )
+{
+    Gia_Obj_t * pObj;
+    Vec_Int_t * vCarryOuts;
+    int i, nCountReg = 0, nCountCarry = 0;
+    if ( p->pManTime == NULL )
+        return;
+    Gia_ManCreateRefs( p );
+    for ( i = Gia_ManPoNum(p) - Gia_ManRegBoxNum(p); i < Gia_ManPoNum(p); i++ )
+    {
+        pObj = Gia_ObjFanin0( Gia_ManPo(p, i) );
+        assert( Gia_ObjIsCi(pObj) );
+        if ( Gia_ObjRefNum(p, pObj) > 1 )
+            nCountReg++;
+    }
+    vCarryOuts = Gia_ManComputeCarryOuts( p );
+    Gia_ManForEachObjVec( vCarryOuts, p, pObj, i )
+        if ( Gia_ObjRefNum(p, pObj) > 1 )
+            nCountCarry++;
+    Vec_IntFree( vCarryOuts );
+    if ( nCountReg || nCountCarry )
+        printf( "Warning: AIG with boxes has internal fanout in %d complex flops and %d carries.\n", nCountReg, nCountCarry );
+    ABC_FREE( p->pRefs );
+}
+
+/**Function*************************************************************
+
   Synopsis    [Computes representatives in terms of the original objects.]
 
   Description []
@@ -207,44 +439,85 @@
   SeeAlso     []
 
 ***********************************************************************/
-int * Gia_ManFraigSelectReprs( Gia_Man_t * p, Gia_Man_t * pGia, int fVerbose )
+int * Gia_ManFraigSelectReprs( Gia_Man_t * p, Gia_Man_t * pClp, int fVerbose )
 {
     Gia_Obj_t * pObj;
+    Vec_Int_t * vCarryOuts;
+    Tim_Man_t * pManTime = (Tim_Man_t *)p->pManTime;
     int * pReprs   = ABC_FALLOC( int, Gia_ManObjNum(p) );
-    int * pGia2Abc = ABC_FALLOC( int, Gia_ManObjNum(pGia) );
-    int i, iLitGia, iLitGia2, iReprGia, fCompl;
+    int * pClp2Gia = ABC_FALLOC( int, Gia_ManObjNum(pClp) );
+    int i, iLitClp, iLitClp2, iReprClp, fCompl;
     int nConsts = 0, nReprs = 0;
-    pGia2Abc[0] = 0;
-    Gia_ManSetPhase( pGia );
+    assert( pManTime != NULL );
+    // count the number of equivalent objects
+    Gia_ManForEachObj1( pClp, pObj, i )
+    {
+        if ( Gia_ObjIsCo(pObj) )
+            continue;
+        if ( i == Gia_ObjReprSelf(pClp, i) )
+            continue;
+        if ( Gia_ObjReprSelf(pClp, i) == 0 )
+            nConsts++;
+        else
+            nReprs++;
+    }
+    if ( fVerbose )
+        printf( "Computed %d const objects and %d other objects.\n", nConsts, nReprs );
+    nConsts = nReprs = 0;
+
+    // mark flop input boxes
+    Gia_ManCleanMark0( p );
+    for ( i = Gia_ManPoNum(p) - Gia_ManRegBoxNum(p); i < Gia_ManPoNum(p); i++ )
+    {
+        pObj = Gia_ObjFanin0( Gia_ManPo(p, i) );
+        assert( Gia_ObjIsCi(pObj) );
+        pObj->fMark0 = 1;
+    }
+    // mark connects between last box inputs and first box outputs
+    vCarryOuts = Gia_ManComputeCarryOuts( p );
+    Gia_ManForEachObjVec( vCarryOuts, p, pObj, i )
+        pObj->fMark0 = 1;
+    if ( fVerbose )
+        printf( "Fixed %d flop inputs and %d box/box connections (out of %d non-flop boxes).\n", 
+            Gia_ManRegBoxNum(p), Vec_IntSize(vCarryOuts), Gia_ManNonRegBoxNum(p) );
+    Vec_IntFree( vCarryOuts );
+
+    // compute representatives
+    pClp2Gia[0] = 0;
+    Gia_ManSetPhase( pClp );
     Gia_ManForEachObj1( p, pObj, i )
     {
         if ( Gia_ObjIsCo(pObj) )
             continue;
+        if ( Gia_ObjIsCi(pObj) && pObj->fMark0 ) // skip CI pointed by CO
+            continue;
         assert( Gia_ObjIsCi(pObj) || Gia_ObjIsAnd(pObj) );
-        iLitGia = Gia_ObjValue(pObj);
-        if ( iLitGia == -1 )
+        iLitClp = Gia_ObjValue(pObj);
+        if ( iLitClp == -1 )
             continue;
-        iReprGia = Gia_ObjReprSelf( pGia, Abc_Lit2Var(iLitGia) );
-        if ( pGia2Abc[iReprGia] == -1 )
-            pGia2Abc[iReprGia] = i;
+        iReprClp = Gia_ObjReprSelf( pClp, Abc_Lit2Var(iLitClp) );
+        if ( pClp2Gia[iReprClp] == -1 )
+            pClp2Gia[iReprClp] = i;
         else
         { 
-            iLitGia2 = Gia_ObjValue( Gia_ManObj(p, pGia2Abc[iReprGia]) );
-            assert( Gia_ObjReprSelf(pGia, Abc_Lit2Var(iLitGia)) == Gia_ObjReprSelf(pGia, Abc_Lit2Var(iLitGia2)) );
-            fCompl  = Abc_LitIsCompl(iLitGia) ^ Abc_LitIsCompl(iLitGia2);
-            fCompl ^= Gia_ManObj(pGia, Abc_Lit2Var(iLitGia))->fPhase;
-            fCompl ^= Gia_ManObj(pGia, Abc_Lit2Var(iLitGia2))->fPhase;
-            pReprs[i] = Abc_Var2Lit( pGia2Abc[iReprGia], fCompl );
+            iLitClp2 = Gia_ObjValue( Gia_ManObj(p, pClp2Gia[iReprClp]) );
+            assert( Gia_ObjReprSelf(pClp, Abc_Lit2Var(iLitClp)) == Gia_ObjReprSelf(pClp, Abc_Lit2Var(iLitClp2)) );
+            fCompl  = Abc_LitIsCompl(iLitClp) ^ Abc_LitIsCompl(iLitClp2);
+            fCompl ^= Gia_ManObj(pClp, Abc_Lit2Var(iLitClp))->fPhase;
+            fCompl ^= Gia_ManObj(pClp, Abc_Lit2Var(iLitClp2))->fPhase;
+            pReprs[i] = Abc_Var2Lit( pClp2Gia[iReprClp], fCompl );
             assert( Abc_Lit2Var(pReprs[i]) < i );
-            if ( pGia2Abc[iReprGia] == 0 )
+            if ( pClp2Gia[iReprClp] == 0 )
                 nConsts++;
             else
                 nReprs++;
         }
     }
-    ABC_FREE( pGia2Abc );
+    ABC_FREE( pClp2Gia );
+    Gia_ManForEachCi( p, pObj, i )
+        pObj->fMark0 = 0;
     if ( fVerbose )
-        printf( "Found %d const reprs and %d other reprs.\n", nConsts, nReprs );
+        printf( "Found %d const objects and %d other objects.\n", nConsts, nReprs );
     return pReprs;
 }
 
@@ -271,7 +544,7 @@
 
 /**Function*************************************************************
 
-  Synopsis    [Reduces root model with scorr.]
+  Synopsis    []
 
   Description []
                
@@ -280,59 +553,174 @@
   SeeAlso     []
 
 ***********************************************************************/
-Gia_Man_t * Gia_ManFraigSweep( Gia_Man_t * p, void * pPars )
-{ 
-    Gia_Man_t * pGia, * pNew, * pTemp;
-    int * pReprs;
-    assert( Gia_ManRegNum(p) == 0 );
-    if ( p->pManTime == NULL )
+Gia_Man_t * Gia_ManFraigSweepSimple( Gia_Man_t * p, void * pPars )
+{
+    Gia_Man_t * pNew;
+    assert( p->pManTime == NULL || Gia_ManBoxNum(p) == 0 );
+    Gia_ManFraigSweepPerform( p, pPars );
+    pNew = Gia_ManEquivReduce( p, 1, 0, 0, 0 );
+    if ( pNew == NULL )
+        pNew = Gia_ManDup(p);
+    Gia_ManTransferTiming( pNew, p );
+    return pNew;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Computes equivalences for one clock domain.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Gia_ManSweepComputeOneDomainEquivs( Gia_Man_t * p, Vec_Int_t * vRegClasses, int iDom, void * pParsS, int fConst, int fEquiv, int fVerbose )
+{
+    Gia_Man_t * pNew;
+    Gia_Obj_t * pObj;
+    Vec_Int_t * vPerm;
+    int i, Class, nFlops;
+    int nDoms = Vec_IntFindMax(vRegClasses);
+    assert( iDom >= 1 && iDom <= nDoms );
+    assert( p->pManTime == NULL );
+    assert( Gia_ManRegNum(p) > 0 );
+    // create required flop permutation
+    vPerm = Vec_IntAlloc( Gia_ManRegNum(p) );
+    Vec_IntForEachEntry( vRegClasses, Class, i )
+        if ( Class != iDom )
+            Vec_IntPush( vPerm, i );
+    nFlops = Vec_IntSize( vPerm );
+    Vec_IntForEachEntry( vRegClasses, Class, i )
+        if ( Class == iDom )
+            Vec_IntPush( vPerm, i );
+    nFlops = Vec_IntSize(vPerm) - nFlops;
+    assert( Vec_IntSize(vPerm) == Gia_ManRegNum(p) );
+    // derive new AIG
+    pNew = Gia_ManDupPermFlop( p, vPerm );
+    assert( Gia_ManObjNum(pNew) == Gia_ManObjNum(p) );
+    Vec_IntFree( vPerm );
+    // perform computation of equivalences 
+    pNew->nRegs = nFlops;
+    if ( pParsS )
+        Cec_ManLSCorrespondenceClasses( pNew, (Cec_ParCor_t *)pParsS );
+    else 
+        Gia_ManSeqCleanupClasses( pNew, fConst, fEquiv, fVerbose );
+    pNew->nRegs = Gia_ManRegNum(p);
+    // make new point to old
+    Gia_ManForEachObj( p, pObj, i )
     {
-        Gia_ManFraigSweepPerform( p, pPars );
-        pNew = Gia_ManEquivReduce( p, 1, 0, 0, 0 );
-        if ( pNew == NULL )
-            return Gia_ManDup(p);
-        return pNew;
+        assert( !Abc_LitIsCompl(pObj->Value) );
+        Gia_ManObj(pNew, Abc_Lit2Var(pObj->Value))->Value = Abc_Var2Lit(i, 0);
     }
-    if ( p->pAigExtra == NULL )
-    {
-        printf( "Timing manager is given but there is no GIA of boxes.\n" );
+    // transfer
+    Gia_ManDupRemapEquiv( p, pNew );
+    Gia_ManStop( pNew );
+}
+Gia_Man_t * Gia_ManSweepWithBoxesAndDomains( Gia_Man_t * p, void * pParsS, int fConst, int fEquiv, int fVerbose )
+{ 
+    Gia_Man_t * pClp, * pNew, * pTemp;
+    int nDoms = Vec_IntFindMax(p->vRegClasses);
+    int * pReprs, iDom;
+    assert( Gia_ManRegNum(p) == 0 );
+    assert( p->pAigExtra != NULL );
+    assert( nDoms > 1 );
+    // order AIG objects
+    pNew = Gia_ManDupUnnormalize( p );
+    if ( pNew == NULL )
         return NULL;
+    Gia_ManTransferTiming( pNew, p );
+    // iterate over domains
+    for ( iDom = 1; iDom <= nDoms; iDom++ )
+    {
+        int nFlops = Vec_IntCountEntry(pNew->vRegClasses, iDom);
+        if ( nFlops < 2 )
+            continue;
+        // find global equivalences
+        pClp = Gia_ManDupCollapse( pNew, pNew->pAigExtra, NULL, 1 );
+        // compute equivalences
+        Gia_ManSweepComputeOneDomainEquivs( pClp, pNew->vRegClasses, iDom, pParsS, fConst, fEquiv, fVerbose );
+        // transfer equivalences
+        pReprs = Gia_ManFraigSelectReprs( pNew, pClp, fVerbose );
+        Gia_ManStop( pClp );
+        // reduce AIG
+        Gia_ManTransferTiming( p, pNew );
+        pNew = Gia_ManFraigReduceGia( pTemp = pNew, pReprs );
+        Gia_ManTransferTiming( pNew, p );
+        Gia_ManStop( pTemp );
+        ABC_FREE( pReprs );
+        // derive new AIG
+        pNew = Gia_ManDupWithBoxes( pTemp = pNew, 1 );
+        Gia_ManStop( pTemp );
+        // report
+        if ( fVerbose )
+        {
+        printf( "Domain %2d : %5d -> %5d :  ", iDom, nFlops, Vec_IntCountEntry(pNew->vRegClasses, iDom) );
+        Gia_ManPrintStats( pNew, NULL );
+        }
     }
+    // normalize the result
+    pNew = Gia_ManDupNormalize( pTemp = pNew );
+    Gia_ManTransferTiming( pNew, pTemp );
+    Gia_ManStop( pTemp );
+    // check integrity
+    //Gia_ManCheckIntegrityWithBoxes( pNew );
+    return pNew;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Reduces root model with scorr.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManSweepWithBoxes( Gia_Man_t * p, void * pParsC, void * pParsS, int fConst, int fEquiv, int fVerbose )
+{ 
+    Gia_Man_t * pClp, * pNew, * pTemp;
+    int * pReprs;
+    assert( Gia_ManRegNum(p) == 0 );
+    assert( p->pAigExtra != NULL );
+    // consider seq synthesis with multiple clock domains
+    if ( pParsC == NULL && Gia_ManClockDomainNum(p) > 1 )
+        return Gia_ManSweepWithBoxesAndDomains( p, pParsS, fConst, fEquiv, fVerbose );
     // order AIG objects
     pNew = Gia_ManDupUnnormalize( p );
     if ( pNew == NULL )
         return NULL;
+    Gia_ManTransferTiming( pNew, p );
     // find global equivalences
-    pNew->pManTime = p->pManTime;
-    pGia = Gia_ManDupCollapse( pNew, p->pAigExtra, NULL );
-    pNew->pManTime = NULL;
-    Gia_ManFraigSweepPerform( pGia, pPars );
+    pClp = Gia_ManDupCollapse( pNew, pNew->pAigExtra, NULL, pParsC ? 0 : 1 );
+    // compute equivalences
+    if ( pParsC )
+        Gia_ManFraigSweepPerform( pClp, pParsC );
+    else if ( pParsS )
+        Cec_ManLSCorrespondenceClasses( pClp, (Cec_ParCor_t *)pParsS );
+    else 
+        Gia_ManSeqCleanupClasses( pClp, fConst, fEquiv, fVerbose );
     // transfer equivalences
-    pReprs = Gia_ManFraigSelectReprs( pNew, pGia, ((Dch_Pars_t *)pPars)->fVerbose );
-    Gia_ManStop( pGia );
+    pReprs = Gia_ManFraigSelectReprs( pNew, pClp, fVerbose );
+    Gia_ManStop( pClp );
     // reduce AIG
+    Gia_ManTransferTiming( p, pNew );
     pNew = Gia_ManFraigReduceGia( pTemp = pNew, pReprs );
+    Gia_ManTransferTiming( pNew, p );
     Gia_ManStop( pTemp );
     ABC_FREE( pReprs );
     // derive new AIG
-    assert( pNew->pManTime  == NULL );
-    assert( pNew->pAigExtra == NULL );
-    pNew->pManTime   = p->pManTime;
-    pNew->pAigExtra  = p->pAigExtra;
-    pNew->nAnd2Delay = p->nAnd2Delay;
-    pNew = Gia_ManFraigCreateGia( pTemp = pNew );
-    assert( pTemp->pManTime  == p->pManTime );
-    assert( pTemp->pAigExtra == p->pAigExtra );
-    pTemp->pManTime  = NULL;
-    pTemp->pAigExtra = NULL;
+    pNew = Gia_ManDupWithBoxes( pTemp = pNew, pParsC ? 0 : 1 );
     Gia_ManStop( pTemp );
     // normalize the result
     pNew = Gia_ManDupNormalize( pTemp = pNew );
     Gia_ManTransferTiming( pNew, pTemp );
     Gia_ManStop( pTemp );
-    // return the result
-    assert( pNew->pManTime  != NULL );
-    assert( pNew->pAigExtra != NULL );
+    // check integrity
+    //Gia_ManCheckIntegrityWithBoxes( pNew );
     return pNew;
 }
 
diff --git a/abc-build/src/aig/gia/giaTim.c b/abc-build/src/aig/gia/giaTim.c
--- a/abc-build/src/aig/gia/giaTim.c
+++ b/abc-build/src/aig/gia/giaTim.c
@@ -19,8 +19,10 @@
 ***********************************************************************/
 
 #include "gia.h"
+#include "giaAig.h"
 #include "misc/tim/tim.h"
 #include "proof/cec/cec.h"
+#include "proof/fra/fra.h"
 
 ABC_NAMESPACE_IMPL_START
 
@@ -35,6 +37,91 @@
 
 /**Function*************************************************************
 
+  Synopsis    [Returns the number of boxes in the AIG with boxes.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Gia_ManBoxNum( Gia_Man_t * p )
+{
+    return p->pManTime ? Tim_ManBoxNum((Tim_Man_t *)p->pManTime) : 0;
+}
+int Gia_ManRegBoxNum( Gia_Man_t * p )
+{
+    return p->vRegClasses ? Vec_IntSize(p->vRegClasses) : 0;
+}
+int Gia_ManNonRegBoxNum( Gia_Man_t * p )
+{
+    return Gia_ManBoxNum(p) - Gia_ManRegBoxNum(p);
+}
+int Gia_ManBoxCiNum( Gia_Man_t * p )
+{
+    return p->pManTime ? Gia_ManCiNum(p) - Tim_ManPiNum((Tim_Man_t *)p->pManTime) : 0;
+}
+int Gia_ManBoxCoNum( Gia_Man_t * p )
+{
+    return p->pManTime ? Gia_ManCoNum(p) - Tim_ManPoNum((Tim_Man_t *)p->pManTime) : 0;
+}
+int Gia_ManClockDomainNum( Gia_Man_t * p )
+{
+    int i, nDoms, Count = 0;
+    if ( p->vRegClasses == NULL )
+        return 0;
+    nDoms = Vec_IntFindMax(p->vRegClasses);
+    assert( Vec_IntCountEntry(p->vRegClasses, 0) == 0 );
+    for ( i = 1; i <= nDoms; i++ )
+        if ( Vec_IntCountEntry(p->vRegClasses, i) > 0 )
+            Count++;
+    return Count;    
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Returns one if this is a seq AIG with non-trivial boxes.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Gia_ManIsSeqWithBoxes( Gia_Man_t * p )
+{
+    return (Gia_ManRegNum(p) > 0 && Gia_ManBoxNum(p) > 0);
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Makes sure the manager is normalized.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Gia_ManIsNormalized( Gia_Man_t * p )  
+{
+    int i, nOffset;
+    nOffset = 1;
+    for ( i = 0; i < Gia_ManCiNum(p); i++ )
+        if ( !Gia_ObjIsCi( Gia_ManObj(p, nOffset+i) ) )
+            return 0;
+    nOffset = 1 + Gia_ManCiNum(p) + Gia_ManAndNum(p);
+    for ( i = 0; i < Gia_ManCoNum(p); i++ )
+        if ( !Gia_ObjIsCo( Gia_ManObj(p, nOffset+i) ) )
+            return 0;
+    return 1;
+}
+
+/**Function*************************************************************
+
   Synopsis    [Duplicates AIG in the DFS order while putting CIs first.]
 
   Description []
@@ -54,9 +141,89 @@
     pNew->pName = Abc_UtilStrsav( p->pName );
     pNew->pSpec = Abc_UtilStrsav( p->pSpec );
     Gia_ManConst0(p)->Value = 0;
-    Gia_ManForEachCi( p, pObj, i )
-        pObj->Value = Gia_ManAppendCi(pNew);
+    if ( !Gia_ManIsSeqWithBoxes(p) )
+    {
+        Gia_ManForEachCi( p, pObj, i )
+            pObj->Value = Gia_ManAppendCi(pNew);
+    }
+    else
+    {
+        // current CI order:  PIs + FOs + NewCIs
+        // desired reorder:   PIs + NewCIs + FOs
+        int nCIs = Tim_ManPiNum( (Tim_Man_t *)p->pManTime );
+        int nAll = Tim_ManCiNum( (Tim_Man_t *)p->pManTime );
+        int nPis = nCIs - Gia_ManRegNum(p);
+        assert( nAll == Gia_ManCiNum(p) );
+        assert( nPis > 0 );
+        // copy PIs first
+        for ( i = 0; i < nPis; i++ )
+            Gia_ManCi(p, i)->Value = Gia_ManAppendCi(pNew);
+       // copy new CIs second
+        for ( i = nCIs; i < nAll; i++ )
+            Gia_ManCi(p, i)->Value = Gia_ManAppendCi(pNew);
+        // copy flops last
+        for ( i = nCIs - Gia_ManRegNum(p); i < nCIs; i++ )
+            Gia_ManCi(p, i)->Value = Gia_ManAppendCi(pNew);
+        printf( "Warning: Shuffled CI order to be correct sequential AIG.\n" );
+    }
     Gia_ManForEachAnd( p, pObj, i )
+        if ( Gia_ObjIsBuf(pObj) )
+            pObj->Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(pObj) );
+        else 
+            pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+    Gia_ManForEachCo( p, pObj, i )
+        pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+    Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+    pNew->nConstrs = p->nConstrs;
+    assert( Gia_ManIsNormalized(pNew) );
+    Gia_ManDupRemapEquiv( pNew, p );
+    return pNew;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Reorders flops for sequential AIGs with boxes.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManDupUnshuffleInputs( Gia_Man_t * p )
+{
+    Gia_Man_t * pNew;
+    Gia_Obj_t * pObj;
+    int i, nCIs, nAll, nPis;
+    // sanity checks
+    assert( Gia_ManIsNormalized(p) );
+    assert( Gia_ManIsSeqWithBoxes(p) );
+    Gia_ManFillValue( p );
+    pNew = Gia_ManStart( Gia_ManObjNum(p) );
+    pNew->pName = Abc_UtilStrsav( p->pName );
+    pNew->pSpec = Abc_UtilStrsav( p->pSpec );
+    Gia_ManConst0(p)->Value = 0;
+    // change input order
+    // desired reorder:   PIs + NewCIs + FOs
+    // current CI order:  PIs + FOs + NewCIs
+    nCIs = Tim_ManPiNum( (Tim_Man_t *)p->pManTime );
+    nAll = Tim_ManCiNum( (Tim_Man_t *)p->pManTime );
+    nPis = nCIs - Gia_ManRegNum(p);
+    assert( nAll == Gia_ManCiNum(p) );
+    assert( nPis > 0 );
+    // copy PIs first
+    for ( i = 0; i < nPis; i++ )
+        Gia_ManCi(p, i)->Value = Gia_ManAppendCi(pNew);
+    // copy flops second
+    for ( i = nAll - Gia_ManRegNum(p); i < nAll; i++ )
+        Gia_ManCi(p, i)->Value = Gia_ManAppendCi(pNew);
+    // copy new CIs last
+    for ( i = nPis; i < nAll - Gia_ManRegNum(p); i++ )
+        Gia_ManCi(p, i)->Value = Gia_ManAppendCi(pNew);
+    printf( "Warning: Unshuffled CI order to be correct AIG with boxes.\n" );
+    // other things
+    Gia_ManForEachAnd( p, pObj, i )
         pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
     Gia_ManForEachCo( p, pObj, i )
         pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
@@ -67,6 +234,7 @@
     return pNew;
 }
 
+
 /**Function*************************************************************
 
   Synopsis    [Find the ordering of AIG objects.]
@@ -89,6 +257,13 @@
         return 1;
     }
     assert( Gia_ObjIsAnd(pObj) );
+    if ( Gia_ObjIsBuf(pObj) )
+    {
+        if ( Gia_ManOrderWithBoxes_rec( p, Gia_ObjFanin0(pObj), vNodes ) )
+            return 1;
+        Vec_IntPush( vNodes, Gia_ObjId(p, pObj) );
+        return 0;
+    }
     if ( Gia_ObjSibl(p, Gia_ObjId(p, pObj)) )
         if ( Gia_ManOrderWithBoxes_rec( p, Gia_ObjSiblObj(p, Gia_ObjId(p, pObj)), vNodes ) )
             return 1;
@@ -117,7 +292,7 @@
     // include primary inputs
     for ( i = 0; i < Tim_ManPiNum(pManTime); i++ )
     {
-        pObj = Gia_ManPi( p, i );
+        pObj = Gia_ManCi( p, i );
         Vec_IntPush( vNodes, Gia_ObjId(p, pObj) );
         Gia_ObjSetTravIdCurrent( p, pObj );
         assert( Gia_ObjId(p, pObj) == i+1 );
@@ -130,7 +305,7 @@
         // add internal nodes
         for ( k = 0; k < Tim_ManBoxInputNum(pManTime, i); k++ )
         {
-            pObj = Gia_ManPo( p, curCo + k );
+            pObj = Gia_ManCo( p, curCo + k );
             if ( Gia_ManOrderWithBoxes_rec( p, Gia_ObjFanin0(pObj), vNodes ) )
             {
                 int iCiNum  = p->iData2;
@@ -151,14 +326,14 @@
         // add POs corresponding to box inputs
         for ( k = 0; k < Tim_ManBoxInputNum(pManTime, i); k++ )
         {
-            pObj = Gia_ManPo( p, curCo + k );
+            pObj = Gia_ManCo( p, curCo + k );
             Vec_IntPush( vNodes, Gia_ObjId(p, pObj) );
         }
         curCo += Tim_ManBoxInputNum(pManTime, i);
         // add PIs corresponding to box outputs
         for ( k = 0; k < Tim_ManBoxOutputNum(pManTime, i); k++ )
         {
-            pObj = Gia_ManPi( p, curCi + k );
+            pObj = Gia_ManCi( p, curCi + k );
             Vec_IntPush( vNodes, Gia_ObjId(p, pObj) );
             Gia_ObjSetTravIdCurrent( p, pObj );
         }
@@ -167,19 +342,19 @@
     // add remaining nodes
     for ( i = Tim_ManCoNum(pManTime) - Tim_ManPoNum(pManTime); i < Tim_ManCoNum(pManTime); i++ )
     {
-        pObj = Gia_ManPo( p, i );
+        pObj = Gia_ManCo( p, i );
         Gia_ManOrderWithBoxes_rec( p, Gia_ObjFanin0(pObj), vNodes );
     }
     // add POs
     for ( i = Tim_ManCoNum(pManTime) - Tim_ManPoNum(pManTime); i < Tim_ManCoNum(pManTime); i++ )
     {
-        pObj = Gia_ManPo( p, i );
+        pObj = Gia_ManCo( p, i );
         Vec_IntPush( vNodes, Gia_ObjId(p, pObj) );
     }
     curCo += Tim_ManPoNum(pManTime);
     // verify counts
-    assert( curCi == Gia_ManPiNum(p) );
-    assert( curCo == Gia_ManPoNum(p) );
+    assert( curCi == Gia_ManCiNum(p) );
+    assert( curCo == Gia_ManCoNum(p) );
     assert( Vec_IntSize(vNodes) == Gia_ManObjNum(p) );
     return vNodes;
 }
@@ -201,6 +376,7 @@
     Gia_Man_t * pNew;
     Gia_Obj_t * pObj;
     int i;
+    assert( !Gia_ManBufNum(p) );
     vNodes = Gia_ManOrderWithBoxes( p );
     if ( vNodes == NULL )
         return NULL;
@@ -212,7 +388,9 @@
         pNew->pSibls = ABC_CALLOC( int, Gia_ManObjNum(p) );
     Gia_ManForEachObjVec( vNodes, p, pObj, i )
     {
-        if ( Gia_ObjIsAnd(pObj) )
+        if ( Gia_ObjIsBuf(pObj) )
+            pObj->Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(pObj) );
+        else if ( Gia_ObjIsAnd(pObj) )
         {
             pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
             if ( Gia_ObjSibl(p, Gia_ObjId(p, pObj)) )
@@ -260,130 +438,6 @@
     }
 }
 
-/**Function*************************************************************
-
-  Synopsis    [Computes AIG with boxes.]
-
-  Description []
-               
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-void Gia_ManDupCollapse_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Gia_Man_t * pNew )
-{
-    if ( Gia_ObjIsTravIdCurrent(p, pObj) )
-        return;
-    Gia_ObjSetTravIdCurrent(p, pObj);
-    assert( Gia_ObjIsAnd(pObj) );
-    if ( Gia_ObjSibl(p, Gia_ObjId(p, pObj)) )
-        Gia_ManDupCollapse_rec( p, Gia_ObjSiblObj(p, Gia_ObjId(p, pObj)), pNew );
-    Gia_ManDupCollapse_rec( p, Gia_ObjFanin0(pObj), pNew );
-    Gia_ManDupCollapse_rec( p, Gia_ObjFanin1(pObj), pNew );
-//    assert( !~pObj->Value );
-    pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
-    if ( Gia_ObjSibl(p, Gia_ObjId(p, pObj)) )
-        pNew->pSibls[Abc_Lit2Var(pObj->Value)] = Abc_Lit2Var(Gia_ObjSiblObj(p, Gia_ObjId(p, pObj))->Value);        
-}
-Gia_Man_t * Gia_ManDupCollapse( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t * vBoxPres )
-{
-    Tim_Man_t * pManTime = (Tim_Man_t *)p->pManTime;
-    Gia_Man_t * pNew, * pTemp;
-    Gia_Obj_t * pObj, * pObjBox;
-    int i, k, curCi, curCo;
-    assert( Gia_ManRegNum(p) == 0 );
-    assert( Gia_ManPiNum(p) == Tim_ManPiNum(pManTime) + Gia_ManPoNum(pBoxes) );
-    pNew = Gia_ManStart( Gia_ManObjNum(p) );
-    pNew->pName = Abc_UtilStrsav( p->pName );
-    pNew->pSpec = Abc_UtilStrsav( p->pSpec );
-    if ( Gia_ManHasChoices(p) )
-        pNew->pSibls = ABC_CALLOC( int, Gia_ManObjNum(p) );
-    Gia_ManHashAlloc( pNew );
-    // copy const and real PIs
-    Gia_ManFillValue( p );
-    Gia_ManConst0(p)->Value = 0;
-    Gia_ManIncrementTravId( p );
-    Gia_ObjSetTravIdCurrent( p, Gia_ManConst0(p) );
-    for ( i = 0; i < Tim_ManPiNum(pManTime); i++ )
-    {
-        pObj = Gia_ManPi( p, i );
-        pObj->Value = Gia_ManAppendCi(pNew);
-        Gia_ObjSetTravIdCurrent( p, pObj );
-    }
-    // create logic for each box
-    curCi = Tim_ManPiNum(pManTime);
-    curCo = 0;
-    for ( i = 0; i < Tim_ManBoxNum(pManTime); i++ )
-    {
-        // clean boxes
-        Gia_ManIncrementTravId( pBoxes );
-        Gia_ObjSetTravIdCurrent( pBoxes, Gia_ManConst0(pBoxes) );
-        Gia_ManConst0(pBoxes)->Value = 0;
-        // add internal nodes
-        if ( Tim_ManBoxIsBlack(pManTime, i) )
-        {
-            int fSkip = (vBoxPres != NULL && !Vec_IntEntry(vBoxPres, i));
-            for ( k = 0; k < Tim_ManBoxInputNum(pManTime, i); k++ )
-            {
-                pObj = Gia_ManPo( p, curCo + k );
-                Gia_ManDupCollapse_rec( p, Gia_ObjFanin0(pObj), pNew );
-                pObj->Value = fSkip ? -1 : Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
-            }
-            for ( k = 0; k < Tim_ManBoxOutputNum(pManTime, i); k++ )
-            {
-                pObj = Gia_ManPi( p, curCi + k );
-                pObj->Value = fSkip ? 0 : Gia_ManAppendCi(pNew);
-                Gia_ObjSetTravIdCurrent( p, pObj );
-            }
-        }
-        else
-        {
-            for ( k = 0; k < Tim_ManBoxInputNum(pManTime, i); k++ )
-            {
-                // build logic
-                pObj = Gia_ManPo( p, curCo + k );
-                Gia_ManDupCollapse_rec( p, Gia_ObjFanin0(pObj), pNew );
-                // transfer to the PI
-                pObjBox = Gia_ManPi( pBoxes, k );
-                pObjBox->Value = Gia_ObjFanin0Copy(pObj);
-                Gia_ObjSetTravIdCurrent( pBoxes, pObjBox );
-            }
-            for ( k = 0; k < Tim_ManBoxOutputNum(pManTime, i); k++ )
-            {
-                // build logic
-                pObjBox = Gia_ManPo( pBoxes, curCi - Tim_ManPiNum(pManTime) + k );
-                Gia_ManDupCollapse_rec( pBoxes, Gia_ObjFanin0(pObjBox), pNew );
-                // transfer to the PI
-                pObj = Gia_ManPi( p, curCi + k );
-                pObj->Value = Gia_ObjFanin0Copy(pObjBox);
-                Gia_ObjSetTravIdCurrent( p, pObj );
-            }
-        }
-        curCo += Tim_ManBoxInputNum(pManTime, i);
-        curCi += Tim_ManBoxOutputNum(pManTime, i);
-    }
-    // add remaining nodes
-    for ( i = Tim_ManCoNum(pManTime) - Tim_ManPoNum(pManTime); i < Tim_ManCoNum(pManTime); i++ )
-    {
-        pObj = Gia_ManPo( p, i );
-        Gia_ManDupCollapse_rec( p, Gia_ObjFanin0(pObj), pNew );
-        pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
-    }
-    curCo += Tim_ManPoNum(pManTime);
-    // verify counts
-    assert( curCi == Gia_ManPiNum(p) );
-    assert( curCo == Gia_ManPoNum(p) );
-    Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
-    Gia_ManHashStop( pNew );
-    pNew = Gia_ManCleanup( pTemp = pNew );
-    Gia_ManCleanupRemap( p, pTemp );
-    Gia_ManStop( pTemp );
-    assert( Tim_ManPoNum(pManTime) == Gia_ManPoNum(pNew) );
-    assert( Tim_ManPiNum(pManTime) == Gia_ManPiNum(pNew) );
-    return pNew;
-}
-
 /**Function*************************************************************
 
   Synopsis    [Computes level with boxes.]
@@ -419,6 +473,7 @@
     Gia_Obj_t * pObj, * pObjIn;
     int i, k, j, curCi, curCo, LevelMax;
     assert( Gia_ManRegNum(p) == 0 );
+    assert( Gia_ManBufNum(p) == 0 );
     // copy const and real PIs
     Gia_ManCleanLevels( p, Gia_ManObjNum(p) );
     Gia_ObjSetLevel( p, Gia_ManConst0(p), 0 );
@@ -426,7 +481,7 @@
     Gia_ObjSetTravIdCurrent( p, Gia_ManConst0(p) );
     for ( i = 0; i < Tim_ManPiNum(pManTime); i++ )
     {
-        pObj = Gia_ManPi( p, i );
+        pObj = Gia_ManCi( p, i );
         Gia_ObjSetLevel( p, pObj, Tim_ManGetCiArrival(pManTime, i) / nAnd2Delay );
         Gia_ObjSetTravIdCurrent( p, pObj );
     }
@@ -441,7 +496,7 @@
         // compute level for TFI of box inputs
         for ( k = 0; k < nBoxInputs; k++ )
         {
-            pObj = Gia_ManPo( p, curCo + k );
+            pObj = Gia_ManCo( p, curCo + k );
             if ( Gia_ManLevelWithBoxes_rec( p, Gia_ObjFanin0(pObj) ) )
             {
                 printf( "Boxes are not in a topological order. Switching to level computation without boxes.\n" );
@@ -453,12 +508,12 @@
         // compute level for box outputs
         for ( k = 0; k < nBoxOutputs; k++ )
         {
-            pObj = Gia_ManPi( p, curCi + k );
+            pObj = Gia_ManCi( p, curCi + k );
             Gia_ObjSetTravIdCurrent( p, pObj );
             // evaluate delay of this output
             LevelMax = 0;
             assert( nBoxInputs == (int)pDelayTable[1] );
-            for ( j = 0; j < nBoxInputs && (pObjIn = Gia_ManPo(p, curCo + j)); j++ )
+            for ( j = 0; j < nBoxInputs && (pObjIn = Gia_ManCo(p, curCo + j)); j++ )
                 if ( (int)pDelayTable[3+k*nBoxInputs+j] != -ABC_INFINITY )
                     LevelMax = Abc_MaxInt( LevelMax, Gia_ObjLevel(p, pObjIn) + ((int)pDelayTable[3+k*nBoxInputs+j] / nAnd2Delay) );
             // set box output level
@@ -471,15 +526,15 @@
     p->nLevels = 0;
     for ( i = Tim_ManCoNum(pManTime) - Tim_ManPoNum(pManTime); i < Tim_ManCoNum(pManTime); i++ )
     {
-        pObj = Gia_ManPo( p, i );
+        pObj = Gia_ManCo( p, i );
         Gia_ManLevelWithBoxes_rec( p, Gia_ObjFanin0(pObj) );
         Gia_ObjSetCoLevel( p, pObj );
         p->nLevels = Abc_MaxInt( p->nLevels, Gia_ObjLevel(p, pObj) );
     }
     curCo += Tim_ManPoNum(pManTime);
     // verify counts
-    assert( curCi == Gia_ManPiNum(p) );
-    assert( curCo == Gia_ManPoNum(p) );
+    assert( curCi == Gia_ManCiNum(p) );
+    assert( curCo == Gia_ManCoNum(p) );
 //    printf( "Max level is %d.\n", p->nLevels );
     return p->nLevels;
 }
@@ -528,7 +583,7 @@
     Gia_ObjSetTravIdCurrent( p, Gia_ManConst0(p) );
     for ( i = 0; i < Tim_ManPiNum(pManTime); i++ )
     {
-        pObj = Gia_ManPi( p, i );
+        pObj = Gia_ManCi( p, i );
 //        Gia_ObjSetLevel( p, pObj, Tim_ManGetCiArrival(pManTime, i) / nAnd2Delay );
         Gia_ObjSetLevel( p, pObj, 0 );
         Gia_ObjSetTravIdCurrent( p, pObj );
@@ -544,7 +599,7 @@
         // compute level for TFI of box inputs
         for ( k = 0; k < nBoxInputs; k++ )
         {
-            pObj = Gia_ManPo( p, curCo + k );
+            pObj = Gia_ManCo( p, curCo + k );
             if ( Gia_ManLutLevelWithBoxes_rec( p, Gia_ObjFanin0(pObj) ) )
             {
                 printf( "Boxes are not in a topological order. Switching to level computation without boxes.\n" );
@@ -556,12 +611,12 @@
         // compute level for box outputs
         for ( k = 0; k < nBoxOutputs; k++ )
         {
-            pObj = Gia_ManPi( p, curCi + k );
+            pObj = Gia_ManCi( p, curCi + k );
             Gia_ObjSetTravIdCurrent( p, pObj );
             // evaluate delay of this output
             LevelMax = 0;
             assert( nBoxInputs == (int)pDelayTable[1] );
-            for ( j = 0; j < nBoxInputs && (pObjIn = Gia_ManPo(p, curCo + j)); j++ )
+            for ( j = 0; j < nBoxInputs && (pObjIn = Gia_ManCo(p, curCo + j)); j++ )
                 if ( (int)pDelayTable[3+k*nBoxInputs+j] != -ABC_INFINITY )
 //                    LevelMax = Abc_MaxInt( LevelMax, Gia_ObjLevel(p, pObjIn) + ((int)pDelayTable[3+k*nBoxInputs+j] / nAnd2Delay) );
                     LevelMax = Abc_MaxInt( LevelMax, Gia_ObjLevel(p, pObjIn) + 1 );
@@ -575,22 +630,22 @@
     p->nLevels = 0;
     for ( i = Tim_ManCoNum(pManTime) - Tim_ManPoNum(pManTime); i < Tim_ManCoNum(pManTime); i++ )
     {
-        pObj = Gia_ManPo( p, i );
+        pObj = Gia_ManCo( p, i );
         Gia_ManLutLevelWithBoxes_rec( p, Gia_ObjFanin0(pObj) );
         Gia_ObjSetCoLevel( p, pObj );
         p->nLevels = Abc_MaxInt( p->nLevels, Gia_ObjLevel(p, pObj) );
     }
     curCo += Tim_ManPoNum(pManTime);
     // verify counts
-    assert( curCi == Gia_ManPiNum(p) );
-    assert( curCo == Gia_ManPoNum(p) );
+    assert( curCi == Gia_ManCiNum(p) );
+    assert( curCo == Gia_ManCoNum(p) );
 //    printf( "Max level is %d.\n", p->nLevels );
     return p->nLevels;
 }
 
 /**Function*************************************************************
 
-  Synopsis    [Verify XAIG against its spec.]
+  Synopsis    [Update hierarchy/timing manager.]
 
   Description []
                
@@ -599,87 +654,74 @@
   SeeAlso     []
 
 ***********************************************************************/
-int Gia_ManVerifyWithBoxes( Gia_Man_t * pGia, void * pParsInit )
+void * Gia_ManUpdateTimMan( Gia_Man_t * p, Vec_Int_t * vBoxPres )
 {
-    int fVerbose =  1;
-    int Status   = -1;
-    Gia_Man_t * pSpec, * pGia0, * pGia1, * pMiter;
-    Vec_Int_t * vBoxPres = NULL;
-    if ( pGia->pSpec == NULL )
-    {
-        printf( "Spec file is not given. Use standard flow.\n" );
-        return Status;
-    }
-    if ( pGia->pManTime == NULL )
-    {
-        printf( "Design has no tim manager. Use standard flow.\n" );
-        return Status;
-    }
-    if ( pGia->pAigExtra == NULL )
-    {
-        printf( "Design has no box logic. Use standard flow.\n" );
-        return Status;
-    }
-    // read original AIG
-    pSpec = Gia_AigerRead( pGia->pSpec, 0, 0 );
-    if ( pSpec->pManTime == NULL )
-    {
-        printf( "Spec has no tim manager. Use standard flow.\n" );
-        return Status;
-    }
-    if ( pSpec->pAigExtra == NULL )
-    {
-        printf( "Spec has no box logic. Use standard flow.\n" );
-        return Status;
-    }
-    // if timing managers have different number of black boxes,
-    // it is possible that some of the boxes are swept away
-    if ( Tim_ManBlackBoxNum( (Tim_Man_t *)pSpec->pManTime ) > 0 )
+    Tim_Man_t * pManTime = (Tim_Man_t *)p->pManTime;
+    assert( pManTime != NULL );
+    assert( Vec_IntSize(vBoxPres) == Tim_ManBoxNum(pManTime) );
+    return Tim_ManTrim( pManTime, vBoxPres );
+}
+void * Gia_ManUpdateTimMan2( Gia_Man_t * p, Vec_Int_t * vBoxesLeft, int nTermsDiff )
+{
+    Tim_Man_t * pManTime = (Tim_Man_t *)p->pManTime;
+    assert( pManTime != NULL );
+    assert( Vec_IntSize(vBoxesLeft) <= Tim_ManBoxNum(pManTime) );
+    return Tim_ManReduce( pManTime, vBoxesLeft, nTermsDiff );
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Update AIG of the holes.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManUpdateExtraAig( void * pTime, Gia_Man_t * p, Vec_Int_t * vBoxPres )
+{
+    Gia_Man_t * pNew;
+    Tim_Man_t * pManTime = (Tim_Man_t *)pTime;
+    Vec_Int_t * vOutPres = Vec_IntAlloc( 100 );
+    int i, k, curPo = 0;
+    assert( Vec_IntSize(vBoxPres) == Tim_ManBoxNum(pManTime) );
+    assert( Gia_ManCoNum(p) == Tim_ManCiNum(pManTime) - Tim_ManPiNum(pManTime) );
+    for ( i = 0; i < Tim_ManBoxNum(pManTime); i++ )
     {
-        // specification cannot have fewer boxes than implementation
-        if ( Tim_ManBoxNum( (Tim_Man_t *)pSpec->pManTime ) < Tim_ManBoxNum( (Tim_Man_t *)pGia->pManTime ) )
-        {
-            printf( "Spec has more boxes than the design. Cannot proceed.\n" );
-            return Status;
-        }
-        // to align the boxes, find what boxes of pSpec are dropped in pGia
-        if ( Tim_ManBoxNum( (Tim_Man_t *)pSpec->pManTime ) != Tim_ManBoxNum( (Tim_Man_t *)pGia->pManTime ) )
-        {
-            vBoxPres = Tim_ManAlignTwo( (Tim_Man_t *)pSpec->pManTime, (Tim_Man_t *)pGia->pManTime );
-            if ( vBoxPres == NULL )
-            {
-                printf( "Boxes of spec and design cannot be aligned. Cannot proceed.\n" );
-                return Status;
-            }
-        }
+        for ( k = 0; k < Tim_ManBoxOutputNum(pManTime, i); k++ )
+            Vec_IntPush( vOutPres, Vec_IntEntry(vBoxPres, i) );
+        curPo += Tim_ManBoxOutputNum(pManTime, i);
     }
-    // collapse two designs
-    pGia0 = Gia_ManDupCollapse( pSpec, pSpec->pAigExtra, vBoxPres );
-    pGia1 = Gia_ManDupCollapse( pGia,  pGia->pAigExtra,  NULL  );
-    Vec_IntFreeP( &vBoxPres );
-    // compute the miter
-    pMiter = Gia_ManMiter( pGia0, pGia1, 0, 1, 0, 0, fVerbose );
-    if ( pMiter )
+    assert( curPo == Gia_ManCoNum(p) );
+    pNew = Gia_ManDupOutputVec( p, vOutPres );
+    Vec_IntFree( vOutPres );
+    return pNew;
+}
+Gia_Man_t * Gia_ManUpdateExtraAig2( void * pTime, Gia_Man_t * p, Vec_Int_t * vBoxesLeft )
+{
+    Gia_Man_t * pNew;
+    Tim_Man_t * pManTime = (Tim_Man_t *)pTime;
+    int nRealPis = Tim_ManPiNum(pManTime);
+    Vec_Int_t * vOutsLeft = Vec_IntAlloc( 100 );
+    int i, k, iBox, iOutFirst;
+    assert( Vec_IntSize(vBoxesLeft) <= Tim_ManBoxNum(pManTime) );
+    assert( Gia_ManCoNum(p) == Tim_ManCiNum(pManTime) - nRealPis );
+    Vec_IntForEachEntry( vBoxesLeft, iBox, i )
     {
-        Cec_ParCec_t ParsCec, * pPars = &ParsCec;
-        Cec_ManCecSetDefaultParams( pPars );
-        pPars->fVerbose = fVerbose;
-        if ( pParsInit )
-            memcpy( pPars, pParsInit, sizeof(Cec_ParCec_t) );
-        Status = Cec_ManVerify( pMiter, pPars );
-        Gia_ManStop( pMiter );
-        if ( pPars->iOutFail >= 0 )
-            Abc_Print( 1, "Verification failed for at least one output (%d).\n", pPars->iOutFail );
+        iOutFirst = Tim_ManBoxOutputFirst(pManTime, iBox) - nRealPis;
+        for ( k = 0; k < Tim_ManBoxOutputNum(pManTime, iBox); k++ )
+            Vec_IntPush( vOutsLeft, iOutFirst + k );
     }
-    Gia_ManStop( pGia0 );
-    Gia_ManStop( pGia1 );
-    Gia_ManStop( pSpec );
-    return Status;
+    pNew = Gia_ManDupSelectedOutputs( p, vOutsLeft );
+    Vec_IntFree( vOutsLeft );
+    return pNew;
 }
 
 /**Function*************************************************************
 
-  Synopsis    [Update hierarchy/timing manager.]
+  Synopsis    [Computes AIG with boxes.]
 
   Description []
                
@@ -688,17 +730,124 @@
   SeeAlso     []
 
 ***********************************************************************/
-void * Gia_ManUpdateTimMan( Gia_Man_t * p, Vec_Int_t * vBoxPres )
+void Gia_ManDupCollapse_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Gia_Man_t * pNew )
 {
+    if ( Gia_ObjIsTravIdCurrent(p, pObj) )
+        return;
+    Gia_ObjSetTravIdCurrent(p, pObj);
+    assert( Gia_ObjIsAnd(pObj) );
+    if ( Gia_ObjSibl(p, Gia_ObjId(p, pObj)) )
+        Gia_ManDupCollapse_rec( p, Gia_ObjSiblObj(p, Gia_ObjId(p, pObj)), pNew );
+    Gia_ManDupCollapse_rec( p, Gia_ObjFanin0(pObj), pNew );
+    Gia_ManDupCollapse_rec( p, Gia_ObjFanin1(pObj), pNew );
+//    assert( !~pObj->Value );
+    pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+    if ( Gia_ObjSibl(p, Gia_ObjId(p, pObj)) )
+        pNew->pSibls[Abc_Lit2Var(pObj->Value)] = Abc_Lit2Var(Gia_ObjSiblObj(p, Gia_ObjId(p, pObj))->Value);        
+}
+Gia_Man_t * Gia_ManDupCollapse( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t * vBoxPres, int fSeq )
+{
+    // this procedure assumes that sequential AIG with boxes is unshuffled to have valid boxes
     Tim_Man_t * pManTime = (Tim_Man_t *)p->pManTime;
-    assert( pManTime != NULL );
-    assert( Tim_ManBoxNum(pManTime) == Vec_IntSize(vBoxPres) );
-    return Tim_ManTrim( pManTime, vBoxPres );
+    Gia_Man_t * pNew, * pTemp;
+    Gia_Obj_t * pObj, * pObjBox;
+    int i, k, curCi, curCo;
+    assert( !fSeq || p->vRegClasses );
+    //assert( Gia_ManRegNum(p) == 0 );
+    assert( Gia_ManCiNum(p) == Tim_ManPiNum(pManTime) + Gia_ManCoNum(pBoxes) );
+    pNew = Gia_ManStart( Gia_ManObjNum(p) );
+    pNew->pName = Abc_UtilStrsav( p->pName );
+    pNew->pSpec = Abc_UtilStrsav( p->pSpec );
+    if ( Gia_ManHasChoices(p) )
+        pNew->pSibls = ABC_CALLOC( int, Gia_ManObjNum(p) );
+    Gia_ManHashAlloc( pNew );
+    // copy const and real PIs
+    Gia_ManFillValue( p );
+    Gia_ManConst0(p)->Value = 0;
+    Gia_ManIncrementTravId( p );
+    Gia_ObjSetTravIdCurrent( p, Gia_ManConst0(p) );
+    for ( i = 0; i < Tim_ManPiNum(pManTime); i++ )
+    {
+        pObj = Gia_ManCi( p, i );
+        pObj->Value = Gia_ManAppendCi(pNew);
+        Gia_ObjSetTravIdCurrent( p, pObj );
+    }
+    // create logic for each box
+    curCi = Tim_ManPiNum(pManTime);
+    curCo = 0;
+    for ( i = 0; i < Tim_ManBoxNum(pManTime); i++ )
+    {
+        // clean boxes
+        Gia_ManIncrementTravId( pBoxes );
+        Gia_ObjSetTravIdCurrent( pBoxes, Gia_ManConst0(pBoxes) );
+        Gia_ManConst0(pBoxes)->Value = 0;
+        // add internal nodes
+        if ( Tim_ManBoxIsBlack(pManTime, i) )
+        {
+            int fSkip = (vBoxPres != NULL && !Vec_IntEntry(vBoxPres, i));
+            for ( k = 0; k < Tim_ManBoxInputNum(pManTime, i); k++ )
+            {
+                pObj = Gia_ManCo( p, curCo + k );
+                Gia_ManDupCollapse_rec( p, Gia_ObjFanin0(pObj), pNew );
+                pObj->Value = fSkip ? -1 : Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+            }
+            for ( k = 0; k < Tim_ManBoxOutputNum(pManTime, i); k++ )
+            {
+                pObj = Gia_ManCi( p, curCi + k );
+                pObj->Value = fSkip ? 0 : Gia_ManAppendCi(pNew);
+                Gia_ObjSetTravIdCurrent( p, pObj );
+            }
+        }
+        else
+        {
+            for ( k = 0; k < Tim_ManBoxInputNum(pManTime, i); k++ )
+            {
+                // build logic
+                pObj = Gia_ManCo( p, curCo + k );
+                Gia_ManDupCollapse_rec( p, Gia_ObjFanin0(pObj), pNew );
+                // transfer to the PI
+                pObjBox = Gia_ManCi( pBoxes, k );
+                pObjBox->Value = Gia_ObjFanin0Copy(pObj);
+                Gia_ObjSetTravIdCurrent( pBoxes, pObjBox );
+            }
+            for ( k = 0; k < Tim_ManBoxOutputNum(pManTime, i); k++ )
+            {
+                // build logic
+                pObjBox = Gia_ManCo( pBoxes, curCi - Tim_ManPiNum(pManTime) + k );
+                Gia_ManDupCollapse_rec( pBoxes, Gia_ObjFanin0(pObjBox), pNew );
+                // transfer to the PI
+                pObj = Gia_ManCi( p, curCi + k );
+                pObj->Value = Gia_ObjFanin0Copy(pObjBox);
+                Gia_ObjSetTravIdCurrent( p, pObj );
+            }
+        }
+        curCo += Tim_ManBoxInputNum(pManTime, i);
+        curCi += Tim_ManBoxOutputNum(pManTime, i);
+    }
+    // add remaining nodes
+    for ( i = Tim_ManCoNum(pManTime) - Tim_ManPoNum(pManTime); i < Tim_ManCoNum(pManTime); i++ )
+    {
+        pObj = Gia_ManCo( p, i );
+        Gia_ManDupCollapse_rec( p, Gia_ObjFanin0(pObj), pNew );
+        pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+    }
+    curCo += Tim_ManPoNum(pManTime);
+    // verify counts
+    assert( curCi == Gia_ManCiNum(p) );
+    assert( curCo == Gia_ManCoNum(p) );
+    Gia_ManSetRegNum( pNew, (fSeq && p->vRegClasses) ? Vec_IntSize(p->vRegClasses) : Gia_ManRegNum(p) );
+    Gia_ManHashStop( pNew );
+    pNew = Gia_ManCleanup( pTemp = pNew );
+    Gia_ManCleanupRemap( p, pTemp );
+    Gia_ManStop( pTemp );
+    assert( Tim_ManPoNum(pManTime) == Gia_ManCoNum(pNew) );
+    assert( Tim_ManPiNum(pManTime) == Gia_ManCiNum(pNew) );
+    return pNew;
 }
 
 /**Function*************************************************************
 
-  Synopsis    [Update AIG of the holes.]
+  Synopsis    [Verify XAIG against its spec.]
 
   Description []
                
@@ -707,25 +856,108 @@
   SeeAlso     []
 
 ***********************************************************************/
-Gia_Man_t * Gia_ManUpdateExtraAig( void * pTime, Gia_Man_t * p, Vec_Int_t * vBoxPres )
+int Gia_ManVerifyWithBoxes( Gia_Man_t * pGia, int nBTLimit, int nTimeLim, int fSeq, int fVerbose, char * pFileSpec )
 {
-    Gia_Man_t * pNew = NULL;
-    Tim_Man_t * pManTime = (Tim_Man_t *)pTime;
-    Vec_Int_t * vOutPres = Vec_IntAlloc( 100 );
-    int i, k, curPo = 0;
-    assert( Vec_IntSize(vBoxPres) == Tim_ManBoxNum(pManTime) );
-    assert( Gia_ManPoNum(p) == Tim_ManCiNum(pManTime) - Tim_ManPiNum(pManTime) );
-    for ( i = 0; i < Tim_ManBoxNum(pManTime); i++ )
+    int Status   = -1;
+    Gia_Man_t * pSpec, * pGia0, * pGia1, * pMiter;
+    Vec_Int_t * vBoxPres = NULL;
+    if ( pFileSpec == NULL && pGia->pSpec == NULL )
     {
-        for ( k = 0; k < Tim_ManBoxOutputNum(pManTime, i); k++ )
-            Vec_IntPush( vOutPres, Vec_IntEntry(vBoxPres, i) );
-        curPo += Tim_ManBoxOutputNum(pManTime, i);
+        printf( "Spec file is not given. Use standard flow.\n" );
+        return Status;
     }
-    assert( curPo == Gia_ManPoNum(p) );
-//    if ( Vec_IntSize(vOutPres) > 0 )
-        pNew = Gia_ManDupOutputVec( p, vOutPres );
-    Vec_IntFree( vOutPres );
-    return pNew;
+    if ( Gia_ManBoxNum(pGia) && pGia->pAigExtra == NULL )
+    {
+        printf( "Design has no box logic. Use standard flow.\n" );
+        return Status;
+    }
+    // read original AIG
+    pSpec = Gia_AigerRead( pFileSpec ? pFileSpec : pGia->pSpec, 0, 0 );
+    if ( Gia_ManBoxNum(pSpec) && pSpec->pAigExtra == NULL )
+    {
+        Gia_ManStop( pSpec );
+        printf( "Spec has no box logic. Use standard flow.\n" );
+        return Status;
+    }
+    // prepare miter
+    if ( pGia->pManTime == NULL && pSpec->pManTime == NULL )
+    {
+        pGia0 = Gia_ManDup( pSpec );
+        pGia1 = Gia_ManDup( pGia );
+    }
+    else
+    {
+        // if timing managers have different number of black boxes,
+        // it is possible that some of the boxes are swept away
+        if ( pSpec->pManTime && Tim_ManBlackBoxNum((Tim_Man_t *)pSpec->pManTime) > 0 && Gia_ManBoxNum(pGia) > 0 )
+        {
+            // specification cannot have fewer boxes than implementation
+            if ( Gia_ManBoxNum(pSpec) < Gia_ManBoxNum(pGia) )
+            {
+                printf( "Spec has less boxes than the design. Cannot proceed.\n" );
+                return Status;
+            }
+            // to align the boxes, find what boxes of pSpec are dropped in pGia
+            if ( Gia_ManBoxNum(pSpec) > Gia_ManBoxNum(pGia) )
+            {
+                vBoxPres = Tim_ManAlignTwo( (Tim_Man_t *)pSpec->pManTime, (Tim_Man_t *)pGia->pManTime );
+                if ( vBoxPres == NULL )
+                {
+                    printf( "Boxes of spec and design cannot be aligned. Cannot proceed.\n" );
+                    return Status;
+                }
+            }
+        }
+        // collapse two designs
+        if ( Gia_ManBoxNum(pSpec) > 0 )
+            pGia0 = Gia_ManDupCollapse( pSpec, pSpec->pAigExtra, vBoxPres, fSeq );
+        else
+            pGia0 = Gia_ManDup( pSpec );
+        if ( Gia_ManBoxNum(pGia) > 0 )
+            pGia1 = Gia_ManDupCollapse( pGia,  pGia->pAigExtra,  NULL, fSeq  );
+        else
+            pGia1 = Gia_ManDup( pGia );
+        Vec_IntFreeP( &vBoxPres );
+    }
+    // compute the miter
+    if ( fSeq )
+    {
+        pMiter = Gia_ManMiter( pGia0, pGia1, 0, 0, 1, 0, fVerbose );
+        if ( pMiter )
+        {
+            Aig_Man_t * pMan;
+            Fra_Sec_t SecPar, * pSecPar = &SecPar;
+            Fra_SecSetDefaultParams( pSecPar );
+            pSecPar->fRetimeFirst = 0;
+            pSecPar->nBTLimit  = nBTLimit;
+            pSecPar->TimeLimit = nTimeLim;
+            pSecPar->fVerbose  = fVerbose;
+            pMan = Gia_ManToAig( pMiter, 0 );
+            Gia_ManStop( pMiter );
+            Status = Fra_FraigSec( pMan, pSecPar, NULL );
+            Aig_ManStop( pMan );
+        }
+    }
+    else
+    {
+        pMiter = Gia_ManMiter( pGia0, pGia1, 0, 1, 0, 0, fVerbose );
+        if ( pMiter )
+        {
+            Cec_ParCec_t ParsCec, * pPars = &ParsCec;
+            Cec_ManCecSetDefaultParams( pPars );
+            pPars->nBTLimit  = nBTLimit;
+            pPars->TimeLimit = nTimeLim;
+            pPars->fVerbose  = fVerbose;
+            Status = Cec_ManVerify( pMiter, pPars );
+            if ( pPars->iOutFail >= 0 )
+                Abc_Print( 1, "Verification failed for at least one output (%d).\n", pPars->iOutFail );
+            Gia_ManStop( pMiter );
+        }
+    }
+    Gia_ManStop( pGia0 );
+    Gia_ManStop( pGia1 );
+    Gia_ManStop( pSpec );
+    return Status;
 }
 
 ////////////////////////////////////////////////////////////////////////
diff --git a/abc-build/src/aig/gia/giaUtil.c b/abc-build/src/aig/gia/giaUtil.c
--- a/abc-build/src/aig/gia/giaUtil.c
+++ b/abc-build/src/aig/gia/giaUtil.c
@@ -510,7 +510,9 @@
     p->nLevels = 0;
     Gia_ManForEachObj( p, pObj, i )
     {
-        if ( Gia_ObjIsAnd(pObj) )
+        if ( Gia_ObjIsBuf(pObj) )
+            Gia_ObjSetBufLevel( p, pObj );
+        else if ( Gia_ObjIsAnd(pObj) )
             Gia_ObjSetGateLevel( p, pObj );
         else if ( Gia_ObjIsCo(pObj) )
             Gia_ObjSetCoLevel( p, pObj );
@@ -610,6 +612,10 @@
             Vec_IntUpdateEntry( vLevelRev, Gia_ObjFaninId0(pObj, i), LevelR + 2 );
             Vec_IntUpdateEntry( vLevelRev, Gia_ObjFaninId1(pObj, i), LevelR + 2 );
         }
+        else if ( Gia_ObjIsBuf(pObj) )
+        {
+            Vec_IntUpdateEntry( vLevelRev, Gia_ObjFaninId0(pObj, i), LevelR );
+        }
         else
         {
             Vec_IntUpdateEntry( vLevelRev, Gia_ObjFaninId0(pObj, i), LevelR + 1 );
@@ -840,31 +846,6 @@
     Gia_ManForEachObj( p, pObj, i )
         assert( pObj->Value == 0 );
     return nCutMax;
-}
-
-/**Function*************************************************************
-
-  Synopsis    [Makes sure the manager is normalized.]
-
-  Description []
-               
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Gia_ManIsNormalized( Gia_Man_t * p )  
-{
-    int i, nOffset;
-    nOffset = 1;
-    for ( i = 0; i < Gia_ManCiNum(p); i++ )
-        if ( !Gia_ObjIsCi( Gia_ManObj(p, nOffset+i) ) )
-            return 0;
-    nOffset = 1 + Gia_ManCiNum(p) + Gia_ManAndNum(p);
-    for ( i = 0; i < Gia_ManCoNum(p); i++ )
-        if ( !Gia_ObjIsCo( Gia_ManObj(p, nOffset+i) ) )
-            return 0;
-    return 1;
 }
 
 
diff --git a/abc-build/src/aig/gia/module.make b/abc-build/src/aig/gia/module.make
--- a/abc-build/src/aig/gia/module.make
+++ b/abc-build/src/aig/gia/module.make
@@ -21,6 +21,7 @@
 	src/aig/gia/giaEquiv.c \
 	src/aig/gia/giaEra.c \
 	src/aig/gia/giaEra2.c \
+	src/aig/gia/giaFadds.c \
 	src/aig/gia/giaFalse.c \
 	src/aig/gia/giaFanout.c \
 	src/aig/gia/giaForce.c \
@@ -46,6 +47,8 @@
 	src/aig/gia/giaMuxes.c \
 	src/aig/gia/giaNf.c \
 	src/aig/gia/giaPat.c \
+	src/aig/gia/giaPf.c \
+	src/aig/gia/giaQbf.c \
 	src/aig/gia/giaResub.c \
 	src/aig/gia/giaRetime.c \
 	src/aig/gia/giaScl.c \
diff --git a/abc-build/src/aig/ivy/ivyRwr.c b/abc-build/src/aig/ivy/ivyRwr.c
--- a/abc-build/src/aig/ivy/ivyRwr.c
+++ b/abc-build/src/aig/ivy/ivyRwr.c
@@ -163,7 +163,7 @@
     char * pPerm;
     int Required, nNodesSaved;
     int nNodesSaveCur = -1; // Suppress "might be used uninitialized"
-    int i, c, GainCur, GainBest = -1;
+    int i, c, GainCur = -1, GainBest = -1;
     abctime clk, clk2;
 
     p->nNodesConsidered++;
diff --git a/abc-build/src/aig/ivy/ivySeq.c b/abc-build/src/aig/ivy/ivySeq.c
--- a/abc-build/src/aig/ivy/ivySeq.c
+++ b/abc-build/src/aig/ivy/ivySeq.c
@@ -156,7 +156,7 @@
     char * pPerm;
     int nNodesSaved;
     int nNodesSaveCur = -1; // Suppress "might be used uninitialized"
-    int i, c, GainCur, GainBest = -1;
+    int i, c, GainCur = -1, GainBest = -1;
     abctime clk, clk2;//, clk3;
 
     p->nNodesConsidered++;
diff --git a/abc-build/src/aig/saig/saigDup.c b/abc-build/src/aig/saig/saigDup.c
--- a/abc-build/src/aig/saig/saigDup.c
+++ b/abc-build/src/aig/saig/saigDup.c
@@ -303,6 +303,70 @@
     Aig_ManCleanMarkB(pAig);
     return RetValue;
 }
+
+/**Function*************************************************************
+
+  Synopsis    [Resimulates the counter-example.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Saig_ManVerifyCexNoClear( Aig_Man_t * pAig, Abc_Cex_t * p )
+{
+    Aig_Obj_t * pObj, * pObjRi, * pObjRo;
+    int RetValue, i, k, iBit = 0;
+    Aig_ManCleanMarkB(pAig);
+    Aig_ManConst1(pAig)->fMarkB = 1;
+    Saig_ManForEachLo( pAig, pObj, i )
+        pObj->fMarkB = Abc_InfoHasBit(p->pData, iBit++);
+    for ( i = 0; i <= p->iFrame; i++ )
+    {
+        Saig_ManForEachPi( pAig, pObj, k )
+            pObj->fMarkB = Abc_InfoHasBit(p->pData, iBit++);
+        Aig_ManForEachNode( pAig, pObj, k )
+            pObj->fMarkB = (Aig_ObjFanin0(pObj)->fMarkB ^ Aig_ObjFaninC0(pObj)) & 
+                           (Aig_ObjFanin1(pObj)->fMarkB ^ Aig_ObjFaninC1(pObj));
+        Aig_ManForEachCo( pAig, pObj, k )
+            pObj->fMarkB = Aig_ObjFanin0(pObj)->fMarkB ^ Aig_ObjFaninC0(pObj);
+        if ( i == p->iFrame )
+            break;
+        Saig_ManForEachLiLo( pAig, pObjRi, pObjRo, k )
+            pObjRo->fMarkB = pObjRi->fMarkB;
+    }
+    assert( iBit == p->nBits );
+    RetValue = Aig_ManCo(pAig, p->iPo)->fMarkB;
+    //Aig_ManCleanMarkB(pAig);
+    return RetValue;
+}
+Vec_Int_t * Saig_ManReturnFailingState( Aig_Man_t * pAig, Abc_Cex_t * p, int fNextOne )
+{
+    Aig_Obj_t * pObj;
+    Vec_Int_t * vState;
+    int i, RetValue = Saig_ManVerifyCexNoClear( pAig, p );
+    if ( RetValue == 0 )
+    {
+        Aig_ManCleanMarkB(pAig);
+        printf( "CEX does fail the given sequential miter.\n" );
+        return NULL;
+    }
+    vState = Vec_IntAlloc( Aig_ManRegNum(pAig) );
+    if ( fNextOne )
+    {
+        Saig_ManForEachLi( pAig, pObj, i )
+            Vec_IntPush( vState, pObj->fMarkB );
+    }
+    else
+    {
+        Saig_ManForEachLo( pAig, pObj, i )
+            Vec_IntPush( vState, pObj->fMarkB );
+    }
+    Aig_ManCleanMarkB(pAig);
+    return vState;
+}
 
 /**Function*************************************************************
 
diff --git a/abc-build/src/base/abc/abc.h b/abc-build/src/base/abc/abc.h
--- a/abc-build/src/base/abc/abc.h
+++ b/abc-build/src/base/abc/abc.h
@@ -172,6 +172,7 @@
     int               nObjs;         // the number of live objs
     int               nConstrs;      // the number of constraints
     int               nBarBufs;      // the number of barrier buffers
+    int               nBarBufs2;     // the number of barrier buffers
     // the backup network and the step number
     Abc_Ntk_t *       pNetBackup;    // the pointer to the previous backup network
     int               iStep;         // the generation number for the given network
@@ -257,6 +258,7 @@
 static inline int         Abc_NtkHasBlackbox( Abc_Ntk_t * pNtk )     { return pNtk->ntkFunc == ABC_FUNC_BLACKBOX;   }
 
 static inline int         Abc_NtkIsSopNetlist( Abc_Ntk_t * pNtk )    { return pNtk->ntkFunc == ABC_FUNC_SOP && pNtk->ntkType == ABC_NTK_NETLIST;  }
+static inline int         Abc_NtkIsBddNetlist( Abc_Ntk_t * pNtk )    { return pNtk->ntkFunc == ABC_FUNC_BDD && pNtk->ntkType == ABC_NTK_NETLIST;  }
 static inline int         Abc_NtkIsAigNetlist( Abc_Ntk_t * pNtk )    { return pNtk->ntkFunc == ABC_FUNC_AIG && pNtk->ntkType == ABC_NTK_NETLIST;  }
 static inline int         Abc_NtkIsMappedNetlist( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_MAP && pNtk->ntkType == ABC_NTK_NETLIST;  }
 static inline int         Abc_NtkIsBlifMvNetlist( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_BLIFMV && pNtk->ntkType == ABC_NTK_NETLIST;  }
@@ -356,7 +358,7 @@
 static inline int         Abc_ObjIsBox( Abc_Obj_t * pObj )           { return pObj->Type == ABC_OBJ_LATCH || pObj->Type == ABC_OBJ_WHITEBOX || pObj->Type == ABC_OBJ_BLACKBOX; }
 static inline int         Abc_ObjIsWhitebox( Abc_Obj_t * pObj )      { return pObj->Type == ABC_OBJ_WHITEBOX;}
 static inline int         Abc_ObjIsBlackbox( Abc_Obj_t * pObj )      { return pObj->Type == ABC_OBJ_BLACKBOX;}
-static inline int         Abc_ObjIsBarBuf( Abc_Obj_t * pObj )        { assert( Abc_NtkIsMappedLogic(pObj->pNtk) ); return Vec_IntSize(&pObj->vFanins) == 1 && pObj->pData == NULL;  }
+static inline int         Abc_ObjIsBarBuf( Abc_Obj_t * pObj )        { return Abc_NtkHasMapping(pObj->pNtk) && Abc_ObjIsNode(pObj) && Vec_IntSize(&pObj->vFanins) == 1 && pObj->pData == NULL;  }
 static inline void        Abc_ObjBlackboxToWhitebox( Abc_Obj_t * pObj ) { assert( Abc_ObjIsBlackbox(pObj) ); pObj->Type = ABC_OBJ_WHITEBOX; pObj->pNtk->nObjCounts[ABC_OBJ_BLACKBOX]--; pObj->pNtk->nObjCounts[ABC_OBJ_WHITEBOX]++; }
 
 // working with fanin/fanout edges
@@ -460,15 +462,24 @@
 #define Abc_NtkForEachNode( pNtk, pNode, i )                                                       \
     for ( i = 0; (i < Vec_PtrSize((pNtk)->vObjs)) && (((pNode) = Abc_NtkObj(pNtk, i)), 1); i++ )   \
         if ( (pNode) == NULL || !Abc_ObjIsNode(pNode) ) {} else
+#define Abc_NtkForEachNodeNotBarBuf( pNtk, pNode, i )                                              \
+    for ( i = 0; (i < Vec_PtrSize((pNtk)->vObjs)) && (((pNode) = Abc_NtkObj(pNtk, i)), 1); i++ )   \
+        if ( (pNode) == NULL || !Abc_ObjIsNode(pNode) || Abc_ObjIsBarBuf(pNode) ) {} else
 #define Abc_NtkForEachNode1( pNtk, pNode, i )                                                      \
     for ( i = 0; (i < Vec_PtrSize((pNtk)->vObjs)) && (((pNode) = Abc_NtkObj(pNtk, i)), 1); i++ )   \
         if ( (pNode) == NULL || !Abc_ObjIsNode(pNode) || !Abc_ObjFaninNum(pNode) ) {} else
+#define Abc_NtkForEachNodeNotBarBuf1( pNtk, pNode, i )                                             \
+    for ( i = 0; (i < Vec_PtrSize((pNtk)->vObjs)) && (((pNode) = Abc_NtkObj(pNtk, i)), 1); i++ )   \
+        if ( (pNode) == NULL || !Abc_ObjIsNode(pNode) || !Abc_ObjFaninNum(pNode) || Abc_ObjIsBarBuf(pNode) ) {} else
 #define Abc_NtkForEachNodeReverse( pNtk, pNode, i )                                                \
     for ( i = Vec_PtrSize((pNtk)->vObjs) - 1; (i >= 0) && (((pNode) = Abc_NtkObj(pNtk, i)), 1); i-- ) \
         if ( (pNode) == NULL || !Abc_ObjIsNode(pNode) ) {} else
 #define Abc_NtkForEachNodeReverse1( pNtk, pNode, i )                                               \
     for ( i = Vec_PtrSize((pNtk)->vObjs) - 1; (i >= 0) && (((pNode) = Abc_NtkObj(pNtk, i)), 1); i-- ) \
         if ( (pNode) == NULL || !Abc_ObjIsNode(pNode) || !Abc_ObjFaninNum(pNode) ) {} else
+#define Abc_NtkForEachBarBuf( pNtk, pNode, i )                                                     \
+    for ( i = 0; (i < Vec_PtrSize((pNtk)->vObjs)) && (((pNode) = Abc_NtkObj(pNtk, i)), 1); i++ )   \
+        if ( (pNode) == NULL || !Abc_ObjIsBarBuf(pNode) ) {} else
 #define Abc_NtkForEachGate( pNtk, pNode, i )                                                       \
     for ( i = 0; (i < Vec_PtrSize((pNtk)->vObjs)) && (((pNode) = Abc_NtkObj(pNtk, i)), 1); i++ )   \
         if ( (pNode) == NULL || !Abc_ObjIsGate(pNode) ) {} else
@@ -600,6 +611,7 @@
 extern ABC_DLL float              Abc_NtkDelayTraceLut( Abc_Ntk_t * pNtk, int fUseLutLib );
 /*=== abcDfs.c ==========================================================*/
 extern ABC_DLL Vec_Ptr_t *        Abc_NtkDfs( Abc_Ntk_t * pNtk, int fCollectAll );
+extern ABC_DLL Vec_Ptr_t *        Abc_NtkDfs2( Abc_Ntk_t * pNtk );
 extern ABC_DLL Vec_Ptr_t *        Abc_NtkDfsNodes( Abc_Ntk_t * pNtk, Abc_Obj_t ** ppNodes, int nNodes );
 extern ABC_DLL Vec_Ptr_t *        Abc_NtkDfsReverse( Abc_Ntk_t * pNtk );
 extern ABC_DLL Vec_Ptr_t *        Abc_NtkDfsReverseNodes( Abc_Ntk_t * pNtk, Abc_Obj_t ** ppNodes, int nNodes );
@@ -609,7 +621,8 @@
 extern ABC_DLL Vec_Ptr_t *        Abc_NtkDfsIter( Abc_Ntk_t * pNtk, int fCollectAll );
 extern ABC_DLL Vec_Ptr_t *        Abc_NtkDfsIterNodes( Abc_Ntk_t * pNtk, Vec_Ptr_t * vRoots );
 extern ABC_DLL Vec_Ptr_t *        Abc_NtkDfsHie( Abc_Ntk_t * pNtk, int fCollectAll );
-extern ABC_DLL int                Abc_NtkIsDfsOrdered( Abc_Ntk_t * pNtk );
+extern ABC_DLL int                Abc_NtkIsDfsOrdered( Abc_Ntk_t * pNtk );
+extern ABC_DLL Vec_Ptr_t *        Abc_NtkDfsWithBoxes( Abc_Ntk_t * pNtk );
 extern ABC_DLL Vec_Ptr_t *        Abc_NtkSupport( Abc_Ntk_t * pNtk );
 extern ABC_DLL Vec_Ptr_t *        Abc_NtkNodeSupport( Abc_Ntk_t * pNtk, Abc_Obj_t ** ppNodes, int nNodes );
 extern ABC_DLL Vec_Ptr_t *        Abc_AigDfs( Abc_Ntk_t * pNtk, int fCollectAll, int fCollectCos );
@@ -618,7 +631,8 @@
 extern ABC_DLL Vec_Vec_t *        Abc_NtkLevelize( Abc_Ntk_t * pNtk );
 extern ABC_DLL int                Abc_NtkLevel( Abc_Ntk_t * pNtk );
 extern ABC_DLL int                Abc_NtkLevelReverse( Abc_Ntk_t * pNtk );
-extern ABC_DLL int                Abc_NtkIsAcyclic( Abc_Ntk_t * pNtk );
+extern ABC_DLL int                Abc_NtkIsAcyclic( Abc_Ntk_t * pNtk );
+extern ABC_DLL int                Abc_NtkIsAcyclicWithBoxes( Abc_Ntk_t * pNtk );
 extern ABC_DLL Vec_Ptr_t *        Abc_AigGetLevelizedOrder( Abc_Ntk_t * pNtk, int fCollectCis );
 /*=== abcFanio.c ==========================================================*/
 extern ABC_DLL void               Abc_ObjAddFanin( Abc_Obj_t * pObj, Abc_Obj_t * pFanin );
@@ -659,6 +673,9 @@
 extern ABC_DLL Abc_Ntk_t *        Abc_NtkConvertBlackboxes( Abc_Ntk_t * pNtk );
 extern ABC_DLL Abc_Ntk_t *        Abc_NtkInsertNewLogic( Abc_Ntk_t * pNtkH, Abc_Ntk_t * pNtkL );
 extern ABC_DLL void               Abc_NtkPrintBoxInfo( Abc_Ntk_t * pNtk );
+/*=== abcHieGia.c ==========================================================*/
+extern ABC_DLL Gia_Man_t *        Abc_NtkFlattenHierarchyGia( Abc_Ntk_t * pNtk, Vec_Ptr_t ** pvBuffers, int fVerbose );
+extern ABC_DLL void               Abc_NtkInsertHierarchyGia( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNew, int fVerbose );
 /*=== abcLatch.c ==========================================================*/
 extern ABC_DLL int                Abc_NtkLatchIsSelfFeed( Abc_Obj_t * pLatch );
 extern ABC_DLL int                Abc_NtkCountSelfFeedLatches( Abc_Ntk_t * pNtk );
@@ -740,6 +757,7 @@
 extern ABC_DLL void               Abc_NtkFinalizeRead( Abc_Ntk_t * pNtk );
 extern ABC_DLL Abc_Ntk_t *        Abc_NtkDup( Abc_Ntk_t * pNtk );
 extern ABC_DLL Abc_Ntk_t *        Abc_NtkDupDfs( Abc_Ntk_t * pNtk );
+extern ABC_DLL Abc_Ntk_t *        Abc_NtkDupDfsNoBarBufs( Abc_Ntk_t * pNtk );
 extern ABC_DLL Abc_Ntk_t *        Abc_NtkDupTransformMiter( Abc_Ntk_t * pNtk );
 extern ABC_DLL Abc_Ntk_t *        Abc_NtkCreateCone( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode, char * pNodeName, int fUseAllCis );
 extern ABC_DLL Abc_Ntk_t *        Abc_NtkCreateConeArray( Abc_Ntk_t * pNtk, Vec_Ptr_t * vRoots, int fUseAllCis );
diff --git a/abc-build/src/base/abc/abcCheck.c b/abc-build/src/base/abc/abcCheck.c
--- a/abc-build/src/base/abc/abcCheck.c
+++ b/abc-build/src/base/abc/abcCheck.c
@@ -526,7 +526,9 @@
     }
     // the node should have a function assigned unless it is an AIG
     if ( pNode->pData == NULL )
-    {
+    {
+        if ( Abc_ObjIsBarBuf(pNode) )
+            return 1;
         fprintf( stdout, "NodeCheck: An internal node \"%s\" does not have a logic function.\n", Abc_ObjNameNet(pNode) );
         return 0;
     }
diff --git a/abc-build/src/base/abc/abcDfs.c b/abc-build/src/base/abc/abcDfs.c
--- a/abc-build/src/base/abc/abcDfs.c
+++ b/abc-build/src/base/abc/abcDfs.c
@@ -86,12 +86,19 @@
     // set the traversal ID
     Abc_NtkIncrementTravId( pNtk );
     // start the array of nodes
-    vNodes = Vec_PtrAlloc( 100 );
-    Abc_NtkForEachCo( pNtk, pObj, i )
-    {
-        Abc_NodeSetTravIdCurrent( pObj );
-        Abc_NtkDfs_rec( Abc_ObjFanin0Ntk(Abc_ObjFanin0(pObj)), vNodes );
-    }
+    vNodes = Vec_PtrAlloc( 100 );
+    if ( pNtk->nBarBufs2 > 0 )
+    Abc_NtkForEachBarBuf( pNtk, pObj, i )
+    {
+        Abc_NodeSetTravIdCurrent( pObj );
+        Abc_NtkDfs_rec( Abc_ObjFanin0Ntk(Abc_ObjFanin0(pObj)), vNodes );
+        Vec_PtrPush( vNodes, pObj );
+    }
+    Abc_NtkForEachCo( pNtk, pObj, i )
+    {
+        Abc_NodeSetTravIdCurrent( pObj );
+        Abc_NtkDfs_rec( Abc_ObjFanin0Ntk(Abc_ObjFanin0(pObj)), vNodes );
+    }
     // collect dangling nodes if asked to
     if ( fCollectAll )
     {
@@ -101,6 +108,31 @@
     }
     return vNodes;
 }
+
+/**Function*************************************************************
+
+  Synopsis    [Returns the DFS ordered array of logic nodes.]
+
+  Description [Collects only the internal nodes, leaving out CIs and CO.
+  However it marks with the current TravId both CIs and COs.]
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Vec_Ptr_t * Abc_NtkDfs2( Abc_Ntk_t * pNtk )
+{
+    Vec_Ptr_t * vNodes = Vec_PtrAlloc( 100 );
+    Abc_Obj_t * pObj;  int i;
+    Abc_NtkIncrementTravId( pNtk );
+    Abc_NtkForEachCo( pNtk, pObj, i )
+    {
+        Abc_NodeSetTravIdCurrent( pObj );
+        Abc_NtkDfs_rec( Abc_ObjFanin0Ntk(Abc_ObjFanin0(pObj)), vNodes );
+    }
+    return vNodes;
+}
 
 /**Function*************************************************************
 
@@ -686,6 +718,95 @@
     }
     return 1;
 }
+
+/**Function*************************************************************
+
+  Synopsis    [Create DFS ordering of nets.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Abc_NtkDfsNets_rec( Abc_Obj_t * pNet, Vec_Ptr_t * vNets )
+{
+    Abc_Obj_t * pNext;
+    Abc_Obj_t * pNode; int i;
+    assert( Abc_ObjIsNet(pNet) );
+    if ( Abc_NodeIsTravIdCurrent( pNet ) )
+        return;
+    Abc_NodeSetTravIdCurrent( pNet );
+    pNode = Abc_ObjFanin0( pNet );
+    Abc_ObjForEachFanin( pNode, pNext, i )
+        Abc_NtkDfsNets_rec( pNext, vNets );
+    Abc_ObjForEachFanout( pNode, pNext, i )
+        Vec_PtrPush( vNets, pNext );
+}
+Vec_Ptr_t * Abc_NtkDfsNets( Abc_Ntk_t * pNtk )
+{
+    Vec_Ptr_t * vNets;
+    Abc_Obj_t * pObj; int i;
+    vNets = Vec_PtrAlloc( 100 );
+    Abc_NtkIncrementTravId( pNtk );
+    Abc_NtkForEachCi( pNtk, pObj, i )
+        Abc_NodeSetTravIdCurrent( Abc_ObjFanout0(pObj) );
+    Abc_NtkForEachCi( pNtk, pObj, i )
+        Vec_PtrPush( vNets, Abc_ObjFanout0(pObj) );
+    Abc_NtkForEachCo( pNtk, pObj, i )
+        Abc_NtkDfsNets_rec( Abc_ObjFanin0(pObj), vNets );
+    return vNets;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Returns the DFS ordered array of logic nodes.]
+
+  Description [Collects only the internal nodes, leaving out CIs and CO.
+  However it marks with the current TravId both CIs and COs.]
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Abc_NtkDfsWithBoxes_rec( Abc_Obj_t * pNode, Vec_Ptr_t * vNodes )
+{
+    Abc_Obj_t * pFanin;
+    int i;
+    assert( !Abc_ObjIsNet(pNode) );
+    if ( Abc_ObjIsBo(pNode) )
+        pNode = Abc_ObjFanin0(pNode);
+    if ( Abc_ObjIsPi(pNode) )
+        return;
+    assert( Abc_ObjIsNode( pNode ) || Abc_ObjIsBox( pNode ) );
+    if ( Abc_NodeIsTravIdCurrent( pNode ) )
+        return;
+    Abc_NodeSetTravIdCurrent( pNode );
+    Abc_ObjForEachFanin( pNode, pFanin, i )
+    {
+        if ( Abc_ObjIsBox(pNode) )
+            pFanin = Abc_ObjFanin0(pFanin);
+        assert( Abc_ObjIsNet(pFanin) );
+        Abc_NtkDfsWithBoxes_rec( Abc_ObjFanin0Ntk(pFanin), vNodes );
+    }
+    Vec_PtrPush( vNodes, pNode );
+}
+Vec_Ptr_t * Abc_NtkDfsWithBoxes( Abc_Ntk_t * pNtk )
+{
+    Vec_Ptr_t * vNodes;
+    Abc_Obj_t * pObj;
+    int i;
+    Abc_NtkIncrementTravId( pNtk );
+    vNodes = Vec_PtrAlloc( 100 );
+    Abc_NtkForEachPo( pNtk, pObj, i )
+    {
+        assert( Abc_ObjIsNet(Abc_ObjFanin0(pObj)) );
+        Abc_NtkDfsWithBoxes_rec( Abc_ObjFanin0Ntk(Abc_ObjFanin0(pObj)), vNodes );
+    }
+    return vNodes;
+}
 
 
 /**Function*************************************************************
@@ -1089,7 +1210,7 @@
         if ( pNode->Level < (unsigned)Level )
             pNode->Level = Level;
     }
-    if ( Abc_ObjFaninNum(pNode) > 0 )
+    if ( Abc_ObjFaninNum(pNode) > 0 && !Abc_ObjIsBarBuf(pNode) )
         pNode->Level++;
     return pNode->Level;
 }
@@ -1127,7 +1248,7 @@
         if ( pNode->Level < (unsigned)Level )
             pNode->Level = Level;
     }
-    if ( Abc_ObjFaninNum(pNode) > 0 )
+    if ( Abc_ObjFaninNum(pNode) > 0 && !Abc_ObjIsBarBuf(pNode) )
         pNode->Level++;
     return pNode->Level;
 }
@@ -1353,6 +1474,114 @@
     }
     return fAcyclic;
 }
+ 
+/**Function*************************************************************
+
+  Synopsis    [Checks for the loops with boxes.]
+
+  Description []
+                
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_NtkIsAcyclicWithBoxes_rec( Abc_Obj_t * pNode )
+{
+    Abc_Ntk_t * pNtk = pNode->pNtk;
+    Abc_Obj_t * pFanin;
+    int fAcyclic, i;
+    assert( !Abc_ObjIsNet(pNode) );
+    if ( Abc_ObjIsPi(pNode) || Abc_ObjIsLatch(pNode) || Abc_ObjIsBlackbox(pNode) )
+        return 1;
+    assert( Abc_ObjIsNode(pNode) || Abc_ObjIsBox(pNode) );
+    // make sure the node is not visited
+    assert( !Abc_NodeIsTravIdPrevious(pNode) );
+    // check if the node is part of the combinational loop
+    if ( Abc_NodeIsTravIdCurrent(pNode) )
+    {
+        fprintf( stdout, "Network \"%s\" contains combinational loop!\n", Abc_NtkName(pNtk) );
+        if ( Abc_ObjIsBox(pNode) )
+            fprintf( stdout, "Box \"%s\" is encountered twice on the following path to the COs:\n", Abc_ObjName(pNode) );
+        else
+            fprintf( stdout, "Node \"%s\" is encountered twice on the following path to the COs:\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
+        return 0;
+    }
+    // mark this node as a node on the current path
+    Abc_NodeSetTravIdCurrent( pNode );
+    // visit the transitive fanin
+    Abc_ObjForEachFanin( pNode, pFanin, i )
+    { 
+        if ( Abc_ObjIsBox(pNode) )
+            pFanin = Abc_ObjFanin0(pFanin);
+        pFanin = Abc_ObjFanin0Ntk(pFanin);
+        if ( Abc_ObjIsBo(pFanin) )
+            pFanin = Abc_ObjFanin0(pFanin);
+        // check if the fanin is visited
+        if ( Abc_ObjIsPi(pFanin) || Abc_ObjIsLatch(pFanin) || Abc_ObjIsBlackbox(pFanin) )
+            continue;
+        assert( Abc_ObjIsNode(pFanin) || Abc_ObjIsBox(pFanin) );
+        if ( Abc_NodeIsTravIdPrevious(pFanin) ) 
+            continue;
+        // traverse the fanin's cone searching for the loop
+        if ( (fAcyclic = Abc_NtkIsAcyclicWithBoxes_rec(pFanin)) )
+            continue;
+        // return as soon as the loop is detected
+        fprintf( stdout, " %s ->", Abc_ObjName( Abc_ObjIsBox(pFanin) ? pFanin : Abc_ObjFanout0(pFanin) ) );
+        return 0;
+    }
+    // mark this node as a visited node
+    assert( Abc_ObjIsNode(pNode) || Abc_ObjIsBox(pNode) );
+    Abc_NodeSetTravIdPrevious( pNode );
+    return 1;
+}
+int Abc_NtkIsAcyclicWithBoxes( Abc_Ntk_t * pNtk )
+{
+    Abc_Obj_t * pNode;
+    int fAcyclic;
+    int i;
+    // set the traversal ID for this DFS ordering
+    Abc_NtkIncrementTravId( pNtk );   
+    Abc_NtkIncrementTravId( pNtk );   
+    // pNode->TravId == pNet->nTravIds      means "pNode is on the path"
+    // pNode->TravId == pNet->nTravIds - 1  means "pNode is visited but is not on the path"
+    // pNode->TravId <  pNet->nTravIds - 1  means "pNode is not visited"
+    // traverse the network to detect cycles
+    fAcyclic = 1;
+    Abc_NtkForEachPo( pNtk, pNode, i )
+    {
+        pNode = Abc_ObjFanin0Ntk(Abc_ObjFanin0(pNode));
+        if ( Abc_ObjIsBo(pNode) )
+            pNode = Abc_ObjFanin0(pNode);
+        if ( Abc_NodeIsTravIdPrevious(pNode) )
+            continue;
+        // traverse the output logic cone
+        if ( (fAcyclic = Abc_NtkIsAcyclicWithBoxes_rec(pNode)) )
+            continue;
+        // stop as soon as the first loop is detected
+        fprintf( stdout, " PO \"%s\"\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
+        break;
+    }
+    if ( fAcyclic )
+    {
+        Abc_NtkForEachLatchInput( pNtk, pNode, i )
+        {
+            pNode = Abc_ObjFanin0Ntk(Abc_ObjFanin0(pNode));
+            if ( Abc_ObjIsBo(pNode) )
+                pNode = Abc_ObjFanin0(pNode);
+            if ( Abc_NodeIsTravIdPrevious(pNode) )
+                continue;
+            // traverse the output logic cone
+            if ( (fAcyclic = Abc_NtkIsAcyclicWithBoxes_rec(pNode)) )
+                continue;
+            // stop as soon as the first loop is detected
+            fprintf( stdout, " PO \"%s\"\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
+            break;
+        }
+    }
+    return fAcyclic;
+}
+
 
 
 /**Function*************************************************************
diff --git a/abc-build/src/base/abc/abcFunc.c b/abc-build/src/base/abc/abcFunc.c
--- a/abc-build/src/base/abc/abcFunc.c
+++ b/abc-build/src/base/abc/abcFunc.c
@@ -30,7 +30,7 @@
 ///                        DECLARATIONS                              ///
 ////////////////////////////////////////////////////////////////////////
 
-#define ABC_MUX_CUBES   100000
+#define ABC_MAX_CUBES   100000
 
 int Abc_ConvertZddToSop( DdManager * dd, DdNode * zCover, char * pSop, int nFanins, Vec_Str_t * vCube, int fPhase );
 static DdNode * Abc_ConvertAigToBdd( DdManager * dd, Hop_Obj_t * pRoot);
@@ -136,6 +136,8 @@
     // convert each node from SOP to BDD
     Abc_NtkForEachNode( pNtk, pNode, i )
     {
+        if ( Abc_ObjIsBarBuf(pNode) )
+            continue;
         assert( pNode->pData );
         if ( Abc_ObjFaninNum(pNode) > 10 )
         {
@@ -305,10 +307,10 @@
         assert( 0 );
     }
 
-    if ( nCubes > ABC_MUX_CUBES )
+    if ( nCubes > ABC_MAX_CUBES )
     {
         Cudd_RecursiveDerefZdd( dd, zCover );
-        printf( "The number of cubes exceeded the predefined limit (%d).\n", ABC_MUX_CUBES );
+        printf( "The number of cubes exceeded the predefined limit (%d).\n", ABC_MAX_CUBES );
         return NULL;
     }
 
@@ -379,6 +381,8 @@
     vCube = Vec_StrAlloc( 100 );
     Abc_NtkForEachNode( pNtk, pNode, i )
     {
+        if ( Abc_ObjIsBarBuf(pNode) )
+            continue;
         assert( pNode->pData );
         bFunc = (DdNode *)pNode->pData;
         pNode->pNext = (Abc_Obj_t *)Abc_ConvertBddToSop( pManNew, dd, bFunc, bFunc, Abc_ObjFaninNum(pNode), 0, vCube, fMode );
@@ -400,6 +404,8 @@
     // transfer from next to data
     Abc_NtkForEachNode( pNtk, pNode, i )
     {
+        if ( Abc_ObjIsBarBuf(pNode) )
+            continue;
         Cudd_RecursiveDeref( dd, (DdNode *)pNode->pData );
         pNode->pData = pNode->pNext;
         pNode->pNext = NULL;
@@ -513,7 +519,7 @@
     // check if there are nodes with complemented SOPs
     fFound = 0;
     Abc_NtkForEachNode( pNtk, pNode, i )
-        if ( Abc_SopIsComplement((char *)pNode->pData) )
+        if ( !Abc_ObjIsBarBuf(pNode) && Abc_SopIsComplement((char *)pNode->pData) )
         {
             fFound = 1;
             break;
@@ -530,7 +536,7 @@
     // change the cover of negated nodes
     vCube = Vec_StrAlloc( 100 );
     Abc_NtkForEachNode( pNtk, pNode, i )
-        if ( Abc_SopIsComplement((char *)pNode->pData) )
+        if ( !Abc_ObjIsBarBuf(pNode) && Abc_SopIsComplement((char *)pNode->pData) )
         {
             bFunc = Abc_ConvertSopToBdd( dd, (char *)pNode->pData, NULL );  Cudd_Ref( bFunc );
             pNode->pData = Abc_ConvertBddToSop( (Mem_Flex_t *)pNtk->pManFunc, dd, bFunc, bFunc, Abc_ObjFaninNum(pNode), 0, vCube, 1 );
@@ -565,7 +571,7 @@
         (*pnCubes)++;
         return;
     }
-    if ( (*pnCubes) > ABC_MUX_CUBES )
+    if ( (*pnCubes) > ABC_MAX_CUBES )
         return;
     extraDecomposeCover( dd, zCover, &zC0, &zC1, &zC2 );
     Abc_CountZddCubes_rec( dd, zC0, pnCubes );
@@ -620,6 +626,8 @@
     // convert each node from SOP to BDD
     Abc_NtkForEachNode( pNtk, pNode, i )
     {
+        if ( Abc_ObjIsBarBuf(pNode) )
+            continue;
         assert( pNode->pData );
         pNode->pData = Abc_ConvertSopToAig( pMan, (char *)pNode->pData );
         if ( pNode->pData == NULL )
@@ -725,7 +733,8 @@
 int Abc_NtkAigToBdd( Abc_Ntk_t * pNtk )
 {
     Abc_Obj_t * pNode;
-    Hop_Man_t * pMan;
+    Hop_Man_t * pMan;
+    DdNode * pFunc;
     DdManager * dd, * ddTemp = NULL;
     Vec_Int_t * vFanins = NULL;
     int nFaninsMax, i, k, iVar;
@@ -753,7 +762,9 @@
     // convert each node from SOP to BDD
     Abc_NtkForEachNode( pNtk, pNode, i )
     {
-        DdNode * pFunc = Abc_ConvertAigToBdd( ddTemp, (Hop_Obj_t *)pNode->pData );
+        if ( Abc_ObjIsBarBuf(pNode) )
+            continue;
+        pFunc = Abc_ConvertAigToBdd( ddTemp, (Hop_Obj_t *)pNode->pData );
         if ( pFunc == NULL )
         {
             printf( "Abc_NtkAigToBdd: Error while converting AIG into BDD.\n" );
@@ -935,6 +946,7 @@
     // create new manager
     pNew = Gia_ManStart( 10000 );
     pNew->pName = Abc_UtilStrsav( Abc_NtkName(p) );
+    pNew->pSpec = Abc_UtilStrsav( Abc_NtkSpec(p) );
     Abc_NtkCleanCopy( p );
     Hop_ManConst1(pHopMan)->iData = 1;
     // create primary inputs
@@ -943,12 +955,18 @@
     // find the number of objects
     nObjs = 1 + Abc_NtkCiNum(p) + Abc_NtkCoNum(p);
     Abc_NtkForEachNode( p, pNode, i )
-        nObjs += Hop_DagSize( (Hop_Obj_t *)pNode->pData );
+        nObjs += Abc_ObjIsBarBuf(pNode) ? 1 : Hop_DagSize( (Hop_Obj_t *)pNode->pData );
     vMapping = Vec_IntStart( nObjs );
     // iterate through nodes used in the mapping
     vNodes = Abc_NtkDfs( p, 0 );
     Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
     {
+        if ( Abc_ObjIsBarBuf(pNode) )
+        {
+            assert( !Abc_ObjFaninC0(pNode) );
+            pNode->iTemp = Gia_ManAppendBuf( pNew, Abc_ObjFanin0(pNode)->iTemp );
+            continue;
+        }
         Abc_ObjForEachFanin( pNode, pFanin, k )
             Hop_ManPi(pHopMan, k)->iData = pFanin->iTemp;
         pHopObj = Hop_Regular( (Hop_Obj_t *)pNode->pData );
@@ -1063,15 +1081,17 @@
     // update the functionality manager
     assert( pNtk->pManFunc == Abc_FrameReadLibGen() );
     pNtk->pManFunc = Mem_FlexStart();
-    pNtk->ntkFunc  = ABC_FUNC_SOP;
     // update the nodes
     Abc_NtkForEachNode( pNtk, pNode, i )
-    {
+    {
+        if ( Abc_ObjIsBarBuf(pNode) )
+            continue;
         pSop = Mio_GateReadSop((Mio_Gate_t *)pNode->pData);
         assert( Abc_SopGetVarNum(pSop) == Abc_ObjFaninNum(pNode) );
         pNode->pData = Abc_SopRegister( (Mem_Flex_t *)pNtk->pManFunc, pSop );
     }
-    return 1;
+    pNtk->ntkFunc  = ABC_FUNC_SOP;
+    return 1;
 }
 
 /**Function*************************************************************
diff --git a/abc-build/src/base/abc/abcHie.c b/abc-build/src/base/abc/abcHie.c
--- a/abc-build/src/base/abc/abcHie.c
+++ b/abc-build/src/base/abc/abcHie.c
@@ -270,7 +270,8 @@
 
     // process the blackbox
     if ( Abc_NtkHasBlackbox(pNtk) )
-    {
+    {
+        printf( "Flatting black box \"%s\".\n", pNtk->pName );
         // duplicate the blackbox
         assert( Abc_NtkBoxNum(pNtk) == 1 );
         pObj = Abc_NtkBox( pNtk, 0 );
diff --git a/abc-build/src/base/abc/abcHieGia.c b/abc-build/src/base/abc/abcHieGia.c
new file mode 100644
--- /dev/null
+++ b/abc-build/src/base/abc/abcHieGia.c
@@ -0,0 +1,582 @@
+/**CFile****************************************************************
+
+  FileName    [abcHieGia.c]
+
+  SystemName  [ABC: Logic synthesis and verification system.]
+
+  PackageName [Network and node package.]
+
+  Synopsis    [Procedures to handle hierarchy.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - June 20, 2005.]
+
+  Revision    [$Id: abcHieGia.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "abc.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    [Transfers the AIG from one manager into another.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Abc_NodeStrashToGia_rec( Gia_Man_t * pNew, Hop_Obj_t * pObj )
+{
+    assert( !Hop_IsComplement(pObj) );
+    if ( !Hop_ObjIsNode(pObj) || Hop_ObjIsMarkA(pObj) )
+        return;
+    Abc_NodeStrashToGia_rec( pNew, Hop_ObjFanin0(pObj) ); 
+    Abc_NodeStrashToGia_rec( pNew, Hop_ObjFanin1(pObj) );
+    pObj->iData = Gia_ManHashAnd( pNew, Hop_ObjChild0CopyI(pObj), Hop_ObjChild1CopyI(pObj) );
+    assert( !Hop_ObjIsMarkA(pObj) ); // loop detection
+    Hop_ObjSetMarkA( pObj );
+}
+int Abc_NodeStrashToGia( Gia_Man_t * pNew, Abc_Obj_t * pNode )
+{
+    Hop_Man_t * pMan = (Hop_Man_t *)pNode->pNtk->pManFunc;
+    Hop_Obj_t * pRoot = (Hop_Obj_t *)pNode->pData;
+    Abc_Obj_t * pFanin;  int i;
+    assert( Abc_ObjIsNode(pNode) );
+    assert( Abc_NtkHasAig(pNode->pNtk) && !Abc_NtkIsStrash(pNode->pNtk) );
+    // check the constant case
+    if ( Abc_NodeIsConst(pNode) || Hop_Regular(pRoot) == Hop_ManConst1(pMan) )
+        return Abc_LitNotCond( 1, Hop_IsComplement(pRoot) );
+    // set elementary variables
+    Abc_ObjForEachFanin( pNode, pFanin, i )
+        assert( pFanin->iTemp != -1 );
+    Abc_ObjForEachFanin( pNode, pFanin, i )
+        Hop_IthVar(pMan, i)->iData = pFanin->iTemp;
+    // strash the AIG of this node
+    Abc_NodeStrashToGia_rec( pNew, Hop_Regular(pRoot) );
+    Hop_ConeUnmark_rec( Hop_Regular(pRoot) );
+    return Abc_LitNotCond( Hop_Regular(pRoot)->iData, Hop_IsComplement(pRoot) );
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    [Flattens the logic hierarchy of the netlist.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Abc_NtkFlattenHierarchyGia2_rec( Gia_Man_t * pNew, Abc_Ntk_t * pNtk, int * pCounter, Vec_Int_t * vBufs )
+{
+    Vec_Ptr_t * vDfs = (Vec_Ptr_t *)pNtk->pData;
+    Abc_Obj_t * pObj, * pTerm; 
+    int i, k; (*pCounter)++;
+    //printf( "[%d:%d] ", Abc_NtkPiNum(pNtk), Abc_NtkPoNum(pNtk) );
+    Vec_PtrForEachEntry( Abc_Obj_t *, vDfs, pObj, i )
+    {
+        if ( Abc_ObjIsNode(pObj) )
+            Abc_ObjFanout0(pObj)->iTemp = Abc_NodeStrashToGia( pNew, pObj );
+        else
+        {
+            int iBufStart = Gia_ManBufNum(pNew);
+            Abc_Ntk_t * pModel = (Abc_Ntk_t *)pObj->pData;
+            assert( !Abc_ObjIsLatch(pObj) );
+            assert( Abc_NtkPiNum(pModel) == Abc_ObjFaninNum(pObj) );
+            assert( Abc_NtkPoNum(pModel) == Abc_ObjFanoutNum(pObj) );
+            Abc_NtkFillTemp( pModel );
+            Abc_ObjForEachFanin( pObj, pTerm, k )
+            {
+                assert( Abc_ObjIsNet(Abc_ObjFanin0(pTerm)) );
+                Abc_ObjFanout0(Abc_NtkPi(pModel, k))->iTemp = Abc_ObjFanin0(pTerm)->iTemp;
+            }
+            if ( vBufs )
+                Abc_ObjForEachFanin( pObj, pTerm, k )
+                    Abc_ObjFanout0(Abc_NtkPi(pModel, k))->iTemp = Gia_ManAppendBuf( pNew, Abc_ObjFanout0(Abc_NtkPi(pModel, k))->iTemp );
+            Abc_NtkFlattenHierarchyGia2_rec( pNew, pModel, pCounter, vBufs );
+            if ( vBufs )
+                Abc_ObjForEachFanout( pObj, pTerm, k )
+                    Abc_ObjFanin0(Abc_NtkPo(pModel, k))->iTemp = Gia_ManAppendBuf( pNew, Abc_ObjFanin0(Abc_NtkPo(pModel, k))->iTemp );
+            Abc_ObjForEachFanout( pObj, pTerm, k )
+            {
+                assert( Abc_ObjIsNet(Abc_ObjFanout0(pTerm)) );
+                Abc_ObjFanout0(pTerm)->iTemp = Abc_ObjFanin0(Abc_NtkPo(pModel, k))->iTemp;
+            }
+            // save buffers
+            if ( vBufs == NULL )
+                continue;
+            Vec_IntPush( vBufs, iBufStart );
+            Vec_IntPush( vBufs, Abc_NtkPiNum(pModel) );
+            Vec_IntPush( vBufs, Gia_ManBufNum(pNew) - Abc_NtkPoNum(pModel) );
+            Vec_IntPush( vBufs, Abc_NtkPoNum(pModel) );
+        }
+    }
+}
+Gia_Man_t * Abc_NtkFlattenHierarchyGia2( Abc_Ntk_t * pNtk )
+{
+    int fUseBufs = 1;
+    int fUseInter = 0;
+    Gia_Man_t * pNew, * pTemp; 
+    Abc_Ntk_t * pModel;
+    Abc_Obj_t * pTerm;
+    int i, Counter = -1;
+    assert( Abc_NtkIsNetlist(pNtk) );
+//    Abc_NtkPrintBoxInfo( pNtk );
+    Abc_NtkFillTemp( pNtk );
+
+    // start the manager
+    pNew = Gia_ManStart( Abc_NtkObjNumMax(pNtk) );
+    pNew->pName = Abc_UtilStrsav(pNtk->pName);
+    pNew->pSpec = Abc_UtilStrsav(pNtk->pSpec);
+    if ( fUseBufs )
+        pNew->vBarBufs = Vec_IntAlloc( 1000 );
+
+    // create PIs and buffers
+    Abc_NtkForEachPi( pNtk, pTerm, i )
+        pTerm->iTemp = Gia_ManAppendCi( pNew );
+    Abc_NtkForEachPi( pNtk, pTerm, i )
+        Abc_ObjFanout0(pTerm)->iTemp = fUseInter ? Gia_ManAppendBuf(pNew, pTerm->iTemp) : pTerm->iTemp;
+
+    // create DFS order of nets
+    if ( !pNtk->pDesign )
+        pNtk->pData = Abc_NtkDfsWithBoxes( pNtk );
+    else
+        Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pModel, i )
+            pModel->pData = Abc_NtkDfsWithBoxes( pModel );
+
+    // call recursively
+    Gia_ManHashAlloc( pNew );
+    Abc_NtkFlattenHierarchyGia2_rec( pNew, pNtk, &Counter, pNew->vBarBufs );
+    Gia_ManHashStop( pNew );
+    printf( "Hierarchy reader flattened %d instances of logic boxes.\n", Counter );
+
+    // delete DFS order of nets
+    if ( !pNtk->pDesign )
+        Vec_PtrFreeP( (Vec_Ptr_t **)&pNtk->pData );
+    else
+        Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pModel, i )
+            Vec_PtrFreeP( (Vec_Ptr_t **)&pModel->pData );
+
+    // create buffers and POs
+    Abc_NtkForEachPo( pNtk, pTerm, i )
+        pTerm->iTemp = fUseInter ? Gia_ManAppendBuf(pNew, Abc_ObjFanin0(pTerm)->iTemp) : Abc_ObjFanin0(pTerm)->iTemp;
+    Abc_NtkForEachPo( pNtk, pTerm, i )
+        Gia_ManAppendCo( pNew, pTerm->iTemp );
+
+    // save buffers
+    if ( fUseInter )
+    {
+        Vec_IntPush( pNew->vBarBufs, 0 );
+        Vec_IntPush( pNew->vBarBufs, Abc_NtkPiNum(pNtk) );
+        Vec_IntPush( pNew->vBarBufs, Gia_ManBufNum(pNew) - Abc_NtkPoNum(pNtk) );
+        Vec_IntPush( pNew->vBarBufs, Abc_NtkPoNum(pNtk) );
+    }
+    if ( fUseBufs )
+        Vec_IntPrint( pNew->vBarBufs );
+
+    // cleanup
+    pNew = Gia_ManCleanup( pTemp = pNew );
+    Gia_ManStop( pTemp );
+    return pNew;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Gia_ManPrintBarBufDrivers( Gia_Man_t * p )
+{
+    Vec_Int_t * vMap, * vFan, * vCrits;
+    Gia_Obj_t * pObj;
+    int i, iFanin, CountCrit[2] = {0}, CountFans[2] = {0};
+    // map barbuf drivers into barbuf literals of the first barbuf driven by them
+    vMap = Vec_IntStart( Gia_ManObjNum(p) );
+    vFan = Vec_IntStart( Gia_ManObjNum(p) );
+    vCrits = Vec_IntAlloc( 100 );
+    Gia_ManForEachObj( p, pObj, i )
+    {
+        // count fanouts
+        if ( Gia_ObjIsBuf(pObj) || Gia_ObjIsCo(pObj) )
+            Vec_IntAddToEntry( vFan, Gia_ObjFaninId0(pObj, i), 1 );
+        else if ( Gia_ObjIsAnd(pObj) )
+        {
+            Vec_IntAddToEntry( vFan, Gia_ObjFaninId0(pObj, i), 1 );
+            Vec_IntAddToEntry( vFan, Gia_ObjFaninId1(pObj, i), 1 );
+        }
+        // count critical barbufs
+        if ( Gia_ObjIsBuf(pObj) )
+        {
+            iFanin = Gia_ObjFaninId0( pObj, i );
+            if ( iFanin == 0 || Vec_IntEntry(vMap, iFanin) != 0 )
+            {
+                CountCrit[(int)(iFanin != 0)]++;
+                Vec_IntPush( vCrits, i );
+                continue;
+            }
+            Vec_IntWriteEntry( vMap, iFanin, Abc_Var2Lit(i, Gia_ObjFaninC0(pObj)) );
+        }
+    }
+    // check fanouts of the critical barbufs
+    Gia_ManForEachObjVec( vCrits, p, pObj, i )
+    {
+        assert( Gia_ObjIsBuf(pObj) );
+        if ( Vec_IntEntry(vFan, i) == 0 )
+            continue;
+        iFanin = Gia_ObjFaninId0p( p, pObj );
+        CountFans[(int)(iFanin != 0)]++;
+    }
+    printf( "Detected %d const (out of %d) and %d shared (out of %d) barbufs with fanout.\n", 
+        CountFans[0], CountCrit[0], CountFans[1], CountCrit[1] );
+    Vec_IntFree( vMap );
+    Vec_IntFree( vFan );
+    Vec_IntFree( vCrits );
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline void Gia_ManPatchBufDriver( Gia_Man_t * p, int iBuf, int iLit0 )  
+{
+    Gia_Obj_t * pObjBuf  = Gia_ManObj( p, iBuf );
+    assert( Gia_ObjIsBuf(pObjBuf) );
+    assert( Gia_ObjId(p, pObjBuf) > Abc_Lit2Var(iLit0) );
+    pObjBuf->iDiff1  = pObjBuf->iDiff0  = Gia_ObjId(p, pObjBuf) - Abc_Lit2Var(iLit0);
+    pObjBuf->fCompl1 = pObjBuf->fCompl0 = Abc_LitIsCompl(iLit0);
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManSweepHierarchy( Gia_Man_t * p )
+{
+    Vec_Int_t * vMap = Vec_IntStart( Gia_ManObjNum(p) );
+    Gia_Man_t * pNew, * pTemp;
+    Gia_Obj_t * pObj, * pObjNew, * pObjNewR;
+    int i, iFanin, CountReals[2] = {0};
+
+    // duplicate AIG while propagating constants and equivalences 
+    pNew = Gia_ManStart( Gia_ManObjNum(p) );
+    pNew->pName = Abc_UtilStrsav( p->pName );
+    pNew->pSpec = Abc_UtilStrsav( p->pSpec );
+    Gia_ManConst0(p)->Value = 0;
+    Gia_ManHashAlloc( pNew );
+    Gia_ManForEachObj1( p, pObj, i )
+    {
+        if ( Gia_ObjIsBuf(pObj) )
+        {
+            pObj->Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(pObj) );
+            pObjNew = Gia_ManObj( pNew, Abc_Lit2Var(pObj->Value) );
+            iFanin = Gia_ObjFaninId0p( pNew, pObjNew );
+            if ( iFanin == 0 )
+            {
+                pObj->Value = Gia_ObjFaninC0(pObjNew);
+                CountReals[0]++;
+                Gia_ManPatchBufDriver( pNew, Gia_ObjId(pNew, pObjNew), 0 );
+            }
+            else if ( Vec_IntEntry(vMap, iFanin) )
+            {
+                pObjNewR = Gia_ManObj( pNew, Vec_IntEntry(vMap, iFanin) );
+                pObj->Value = Abc_Var2Lit( Vec_IntEntry(vMap, iFanin), Gia_ObjFaninC0(pObjNewR) ^ Gia_ObjFaninC0(pObjNew) );
+                CountReals[1]++;
+                Gia_ManPatchBufDriver( pNew, Gia_ObjId(pNew, pObjNew), 0 );
+            }
+            else
+                Vec_IntWriteEntry( vMap, iFanin, Gia_ObjId(pNew, pObjNew) );
+        }
+        else if ( Gia_ObjIsAnd(pObj) )
+            pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+        else if ( Gia_ObjIsCi(pObj) )
+            pObj->Value = Gia_ManAppendCi( pNew );
+        else if ( Gia_ObjIsCo(pObj) )
+            pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+    }
+    Gia_ManHashStop( pNew );
+    Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+    pNew = Gia_ManCleanup( pTemp = pNew );
+    Gia_ManStop( pTemp );
+//    printf( "Updated %d const and %d shared.\n", CountReals[0], CountReals[1] );
+    Vec_IntFree( vMap );
+    return pNew;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Flattens the logic hierarchy of the netlist.]
+
+  Description [This procedure requires that models are uniqified.]
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Gia_ManFlattenLogicPrepare( Abc_Ntk_t * pNtk )
+{
+    Abc_Obj_t * pTerm, * pBox; 
+    int i, k;
+    Abc_NtkFillTemp( pNtk );
+    Abc_NtkForEachPi( pNtk, pTerm, i )
+        pTerm->iData = i;
+    Abc_NtkForEachPo( pNtk, pTerm, i )
+        pTerm->iData = i;
+    Abc_NtkForEachBox( pNtk, pBox, i )
+    {
+        assert( !Abc_ObjIsLatch(pBox) );
+        Abc_ObjForEachFanin( pBox, pTerm, k )
+            pTerm->iData = k;
+        Abc_ObjForEachFanout( pBox, pTerm, k )
+            pTerm->iData = k;
+    }
+    return Abc_NtkPiNum(pNtk) + Abc_NtkPoNum(pNtk);
+}
+int Abc_NtkFlattenHierarchyGia_rec( Gia_Man_t * pNew, Vec_Ptr_t * vSupers, Abc_Obj_t * pObj, Vec_Ptr_t * vBuffers )
+{
+    Abc_Ntk_t * pModel;
+    Abc_Obj_t * pBox, * pFanin;  
+    int iLit, i;
+    if ( pObj->iTemp != -1 )
+        return pObj->iTemp;
+    if ( Abc_ObjIsNet(pObj) || Abc_ObjIsPo(pObj) || Abc_ObjIsBi(pObj) )
+        return (pObj->iTemp = Abc_NtkFlattenHierarchyGia_rec(pNew, vSupers, Abc_ObjFanin0(pObj), vBuffers));
+    if ( Abc_ObjIsPi(pObj) )
+    {
+        pBox   = (Abc_Obj_t *)Vec_PtrPop( vSupers );
+        pModel = Abc_ObjModel(pBox);
+        //printf( "   Exiting %s\n", Abc_NtkName(pModel) );
+        assert( Abc_ObjFaninNum(pBox) == Abc_NtkPiNum(pModel) );
+        assert( pObj->iData >= 0 && pObj->iData < Abc_NtkPiNum(pModel) );
+        pFanin = Abc_ObjFanin( pBox, pObj->iData );
+        iLit   = Abc_NtkFlattenHierarchyGia_rec( pNew, vSupers, pFanin, vBuffers );
+        Vec_PtrPush( vSupers, pBox );
+        //if ( vBuffers ) Vec_PtrPush( vBuffers, pFanin ); // save BI
+        if ( vBuffers ) Vec_PtrPush( vBuffers, pObj );   // save PI
+        return (pObj->iTemp = (vBuffers ? Gia_ManAppendBuf(pNew, iLit) : iLit));
+    }
+    if ( Abc_ObjIsBo(pObj) )
+    {
+        pBox   = Abc_ObjFanin0(pObj);
+        assert( Abc_ObjIsBox(pBox) );
+        Vec_PtrPush( vSupers, pBox );
+        pModel = Abc_ObjModel(pBox);
+        //printf( "Entering %s\n", Abc_NtkName(pModel) );
+        assert( Abc_ObjFanoutNum(pBox) == Abc_NtkPoNum(pModel) );
+        assert( pObj->iData >= 0 && pObj->iData < Abc_NtkPoNum(pModel) );
+        pFanin = Abc_NtkPo( pModel, pObj->iData );
+        iLit   = Abc_NtkFlattenHierarchyGia_rec( pNew, vSupers, pFanin, vBuffers );
+        Vec_PtrPop( vSupers );
+        //if ( vBuffers ) Vec_PtrPush( vBuffers, pObj );   // save BO
+        if ( vBuffers ) Vec_PtrPush( vBuffers, pFanin ); // save PO
+        return (pObj->iTemp = (vBuffers ? Gia_ManAppendBuf(pNew, iLit) : iLit));
+    }
+    assert( Abc_ObjIsNode(pObj) );
+    Abc_ObjForEachFanin( pObj, pFanin, i )
+        Abc_NtkFlattenHierarchyGia_rec( pNew, vSupers, pFanin, vBuffers );
+    return (pObj->iTemp = Abc_NodeStrashToGia( pNew, pObj ));
+}
+Gia_Man_t * Abc_NtkFlattenHierarchyGia( Abc_Ntk_t * pNtk, Vec_Ptr_t ** pvBuffers, int fVerbose )
+{
+    int fUseBufs = 1;
+    Gia_Man_t * pNew, * pTemp; 
+    Abc_Ntk_t * pModel;
+    Abc_Obj_t * pTerm;
+    Vec_Ptr_t * vSupers;
+    Vec_Ptr_t * vBuffers = fUseBufs ? Vec_PtrAlloc(1000) : NULL;
+    int i, Counter = 0; 
+    assert( Abc_NtkIsNetlist(pNtk) );
+//    Abc_NtkPrintBoxInfo( pNtk );
+
+    // set the PI/PO numbers
+    Counter -= Abc_NtkPiNum(pNtk) + Abc_NtkPoNum(pNtk);
+    if ( !pNtk->pDesign )
+        Counter += Gia_ManFlattenLogicPrepare( pNtk );
+    else
+        Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pModel, i )
+            Counter += Gia_ManFlattenLogicPrepare( pModel );
+
+    // start the manager
+    pNew = Gia_ManStart( Abc_NtkObjNumMax(pNtk) );
+    pNew->pName = Abc_UtilStrsav(pNtk->pName);
+    pNew->pSpec = Abc_UtilStrsav(pNtk->pSpec);
+
+    // create PIs and buffers
+    Abc_NtkForEachPi( pNtk, pTerm, i )
+        pTerm->iTemp = Gia_ManAppendCi( pNew );
+
+    // call recursively
+    vSupers = Vec_PtrAlloc( 100 );
+    Gia_ManHashAlloc( pNew );
+    Abc_NtkForEachPo( pNtk, pTerm, i )
+        Abc_NtkFlattenHierarchyGia_rec( pNew, vSupers, pTerm, vBuffers );
+    Gia_ManHashStop( pNew );
+    Vec_PtrFree( vSupers );
+    printf( "Hierarchy reader flattened %d instances of boxes and added %d barbufs (out of %d).\n", 
+        pNtk->pDesign ? Vec_PtrSize(pNtk->pDesign->vModules)-1 : 0, Vec_PtrSize(vBuffers), Counter );
+
+    // create buffers and POs
+    Abc_NtkForEachPo( pNtk, pTerm, i )
+        Gia_ManAppendCo( pNew, pTerm->iTemp );
+
+    if ( pvBuffers )
+        *pvBuffers = vBuffers;
+    else
+        Vec_PtrFreeP( &vBuffers );
+
+    // cleanup
+    pNew = Gia_ManCleanup( pTemp = pNew );
+    Gia_ManStop( pTemp );
+//    Gia_ManPrintStats( pNew, NULL );
+    pNew = Gia_ManSweepHierarchy( pTemp = pNew );
+    Gia_ManStop( pTemp );
+//    Gia_ManPrintStats( pNew, NULL );
+    return pNew;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Inserts the result of mapping into logic hierarchy.]
+
+  Description [When this procedure is called PIs/POs of pNtk
+  point to the corresponding nodes in network with barbufs.]
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Abc_Obj_t * Gia_ManInsertOne_rec( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNew, Abc_Obj_t * pObj )
+{
+    Abc_Obj_t * pFanin;  int i;
+    if ( pObj == NULL )
+        return Abc_NtkCreateNodeConst0( pNtk );
+    assert( Abc_ObjNtk(pObj) == pNew );
+    if ( pObj->pCopy )
+        return pObj->pCopy;
+    Abc_ObjForEachFanin( pObj, pFanin, i )
+        Gia_ManInsertOne_rec( pNtk, pNew, pFanin );
+    pObj->pCopy = Abc_NtkDupObj( pNtk, pObj, 0 );
+    Abc_ObjForEachFanin( pObj, pFanin, i )
+        Abc_ObjAddFanin( pObj, pFanin );
+    return pObj->pCopy;
+}
+void Gia_ManInsertOne( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNew )
+{
+    Abc_Obj_t * pObj, * pBox;  int i, k;
+    assert( !Abc_NtkHasMapping(pNtk) );
+    assert( Abc_NtkHasMapping(pNew) );
+    // check that PIs point to barbufs
+    Abc_NtkForEachPi( pNtk, pObj, i )
+        assert( !pObj->pCopy || Abc_ObjNtk(pObj->pCopy) == pNew );
+    // make barbufs point to box outputs
+    Abc_NtkForEachBox( pNtk, pBox, i )
+        Abc_ObjForEachFanout( pBox, pObj, k )
+        {
+            pObj->pCopy = Abc_NtkPo(Abc_ObjModel(pBox), k)->pCopy;
+            assert( !pObj->pCopy || Abc_ObjNtk(pObj->pCopy) == pNew );
+        }
+    // remove internal nodes
+    Abc_NtkForEachNode( pNtk, pObj, i )
+        Abc_NtkDeleteObj( pObj );
+    // start traversal from box inputs
+    Abc_NtkForEachBox( pNtk, pBox, i )
+        Abc_ObjForEachFanin( pBox, pObj, k )
+            if ( Abc_ObjFaninNum(pObj) == 0 )
+                Abc_ObjAddFanin( pObj, Gia_ManInsertOne_rec(pNtk, pNew, Abc_NtkPi(Abc_ObjModel(pBox), k)->pCopy) );
+    // start traversal from primary outputs
+    Abc_NtkForEachPo( pNtk, pObj, i )
+        if ( Abc_ObjFaninNum(pObj) == 0 )
+            Abc_ObjAddFanin( pObj, Gia_ManInsertOne_rec(pNtk, pNew, pObj->pCopy) );
+    // update the functionality manager
+    pNtk->pManFunc = pNew->pManFunc;
+    pNtk->ntkFunc  = pNew->ntkFunc;
+    assert( Abc_NtkHasMapping(pNtk) );
+}
+void Abc_NtkInsertHierarchyGia( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNew, int fVerbose )
+{
+    Vec_Ptr_t * vBuffers;
+    Gia_Man_t * pGia = Abc_NtkFlattenHierarchyGia( pNtk, &vBuffers, 0 );
+    Abc_Ntk_t * pModel;  
+    Abc_Obj_t * pObj; 
+    int i, k = 0;
+
+    assert( Gia_ManPiNum(pGia) == Abc_NtkPiNum(pNtk) );
+    assert( Gia_ManPiNum(pGia) == Abc_NtkPiNum(pNew) );
+    assert( Gia_ManPoNum(pGia) == Abc_NtkPoNum(pNtk) );
+    assert( Gia_ManPoNum(pGia) == Abc_NtkPoNum(pNew) );
+    assert( Gia_ManBufNum(pGia) == Vec_PtrSize(vBuffers) );
+    assert( Gia_ManBufNum(pGia) == pNew->nBarBufs2 );
+    Gia_ManStop( pGia );
+
+    // clean the networks
+    if ( !pNtk->pDesign )
+        Abc_NtkCleanCopy( pNtk );
+    else
+        Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pModel, i )
+            Abc_NtkCleanCopy( pModel );
+
+    // annotate PIs and POs of each network with barbufs
+    Abc_NtkForEachPi( pNew, pObj, i )
+        Abc_NtkPi(pNtk, i)->pCopy = pObj;
+    Abc_NtkForEachPo( pNew, pObj, i )
+        Abc_NtkPo(pNtk, i)->pCopy = pObj;
+    Abc_NtkForEachBarBuf( pNew, pObj, i )
+        ((Abc_Obj_t *)Vec_PtrEntry(vBuffers, k++))->pCopy = pObj;
+    Vec_PtrFree( vBuffers );
+
+    // connect each model
+    Abc_NtkCleanCopy( pNew );
+    Gia_ManInsertOne( pNtk, pNew );
+    if ( pNtk->pDesign )
+        Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pModel, i )
+            if ( pModel != pNtk )
+                Gia_ManInsertOne( pModel, pNew );
+}
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/abc-build/src/base/abc/abcLatch.c b/abc-build/src/base/abc/abcLatch.c
--- a/abc-build/src/base/abc/abcLatch.c
+++ b/abc-build/src/base/abc/abcLatch.c
@@ -729,13 +729,14 @@
     int RetValue, i, k, iBit = 0;
     assert( Abc_NtkIsStrash(pNtk) );
     assert( p->nPis  == Abc_NtkPiNum(pNtk) );
-    assert( p->nRegs == Abc_NtkLatchNum(pNtk) );
+//    assert( p->nRegs == Abc_NtkLatchNum(pNtk) );
     Abc_NtkCleanMarkC( pNtk );
     Abc_AigConst1(pNtk)->fMarkC = 1;
     // initialize flops
-    Abc_NtkForEachLatch( pNtk, pObj, i )
-        Abc_ObjFanout0(pObj)->fMarkC = Abc_InfoHasBit(p->pData, iBit++);
+//    Abc_NtkForEachLatch( pNtk, pObj, i )
+//        Abc_ObjFanout0(pObj)->fMarkC = Abc_InfoHasBit(p->pData, iBit++);
     // simulate timeframes
+    iBit = p->nRegs;
     for ( i = 0; i <= p->iFrame; i++ )
     {
         Abc_NtkForEachPi( pNtk, pObj, k )
diff --git a/abc-build/src/base/abc/abcMinBase.c b/abc-build/src/base/abc/abcMinBase.c
--- a/abc-build/src/base/abc/abcMinBase.c
+++ b/abc-build/src/base/abc/abcMinBase.c
@@ -674,6 +674,147 @@
     }
     return 1;
 }
+
+/**Function*************************************************************
+
+  Synopsis    [Sort nodes in the reverse topo order.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_ObjCompareByNumber( Abc_Obj_t ** pp1, Abc_Obj_t ** pp2 )
+{
+    return Abc_ObjRegular(*pp1)->iTemp - Abc_ObjRegular(*pp2)->iTemp;
+}
+void Abc_ObjSortInReverseOrder( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes )
+{
+    Vec_Ptr_t * vOrder;
+    Abc_Obj_t * pNode; 
+    int i;
+    vOrder = Abc_NtkDfsReverse( pNtk );
+    Vec_PtrForEachEntry( Abc_Obj_t *, vOrder, pNode, i )
+        pNode->iTemp = i;
+    Vec_PtrSort( vNodes, (int (*)())Abc_ObjCompareByNumber );
+    Vec_PtrForEachEntry( Abc_Obj_t *, vOrder, pNode, i )
+        pNode->iTemp = 0;
+    Vec_PtrFree( vOrder );
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    [Performs traditional eliminate -1.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_NtkEliminateSpecial( Abc_Ntk_t * pNtk, int nMaxSize, int fVerbose )
+{
+    extern void Abc_NtkBddReorder( Abc_Ntk_t * pNtk, int fVerbose );
+    Vec_Ptr_t * vFanouts, * vFanins, * vNodes;
+    Abc_Obj_t * pNode, * pFanout;
+    int * pPermFanin, * pPermFanout;
+    int RetValue, i, k;
+    assert( nMaxSize > 0 );
+    assert( Abc_NtkIsLogic(pNtk) ); 
+
+
+    // convert network to BDD representation
+    if ( !Abc_NtkToBdd(pNtk) )
+    {
+        fprintf( stdout, "Converting to BDD has failed.\n" );
+        return 0;
+    }
+
+    // prepare nodes for sweeping
+    Abc_NtkRemoveDupFanins( pNtk );
+    Abc_NtkMinimumBase( pNtk );
+    Abc_NtkCleanup( pNtk, 0 );
+
+    // convert network to SOPs
+    if ( !Abc_NtkToSop(pNtk, 0) )
+    {
+        fprintf( stdout, "Converting to SOP has failed.\n" );
+        return 0;
+    }
+
+    // collect info about the nodes to be eliminated
+    vNodes = Vec_PtrAlloc( 1000 );
+    Abc_NtkForEachNode( pNtk, pNode, i )
+    {
+        if ( Abc_ObjFanoutNum(pNode) != 1 )
+            continue;
+        pFanout = Abc_ObjFanout0(pNode);
+        if ( !Abc_ObjIsNode(pFanout) )
+            continue;
+        if ( Abc_SopGetCubeNum((char *)pNode->pData) != 1 )
+            continue;
+        if ( Abc_SopGetCubeNum((char *)pFanout->pData) != 1 )
+            continue;
+        // find the fanout's fanin
+        RetValue = Abc_NodeFindFanin( pFanout, pNode );
+        assert( RetValue >= 0 && RetValue < Abc_ObjFaninNum(pFanout) );
+        // both pNode and pFanout are AND/OR type nodes
+        if ( Abc_SopIsComplement((char *)pNode->pData) == Abc_SopGetIthCareLit((char *)pFanout->pData, RetValue) )
+            continue;
+        Vec_PtrPush( vNodes, pNode );
+    }
+    if ( Vec_PtrSize(vNodes) == 0 )
+    {
+        Vec_PtrFree( vNodes );
+        return 1;
+    }
+    Abc_ObjSortInReverseOrder( pNtk, vNodes );
+
+    // convert network to BDD representation
+    if ( !Abc_NtkToBdd(pNtk) )
+    {
+        fprintf( stdout, "Converting to BDD has failed.\n" );
+        return 0;
+    }
+
+    // go through the nodes and decide is they can be eliminated
+    pPermFanin = ABC_ALLOC( int, nMaxSize + 1000 );
+    pPermFanout = ABC_ALLOC( int, nMaxSize + 1000 );
+    vFanins = Vec_PtrAlloc( 1000 );
+    vFanouts = Vec_PtrAlloc( 1000 );
+    Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
+    {
+        assert( Abc_ObjIsNode(pNode) );
+        assert( Abc_NodeFindCoFanout(pNode) == NULL );
+        // perform elimination
+        Abc_NodeCollectFanouts( pNode, vFanouts );
+        Vec_PtrForEachEntry( Abc_Obj_t *, vFanouts, pFanout, k )
+        {
+            if ( fVerbose )
+                printf( "Collapsing fanin %5d (supp =%2d) into fanout %5d (supp =%2d) ",
+                    Abc_ObjId(pNode), Abc_ObjFaninNum(pNode), Abc_ObjId(pFanout), Abc_ObjFaninNum(pFanout) ); 
+            RetValue = Abc_NodeCollapse( pNode, pFanout, vFanins, pPermFanin, pPermFanout );
+            assert( RetValue );
+            if ( fVerbose )
+            {
+                Abc_Obj_t * pNodeNew = Abc_NtkObj( pNtk, Abc_NtkObjNumMax(pNtk) - 1 );
+                if ( pNodeNew )
+                    printf( "resulting in node %5d (supp =%2d).\n", Abc_ObjId(pNodeNew), Abc_ObjFaninNum(pNodeNew) );
+            }
+        }
+    }
+    Abc_NtkBddReorder( pNtk, 0 );
+    Vec_PtrFree( vFanins );
+    Vec_PtrFree( vFanouts );
+    Vec_PtrFree( vNodes );
+    ABC_FREE( pPermFanin );
+    ABC_FREE( pPermFanout );
+    return 1;
+}
 
 ////////////////////////////////////////////////////////////////////////
 ///                       END OF FILE                                ///
diff --git a/abc-build/src/base/abc/abcNtk.c b/abc-build/src/base/abc/abcNtk.c
--- a/abc-build/src/base/abc/abcNtk.c
+++ b/abc-build/src/base/abc/abcNtk.c
@@ -513,6 +513,50 @@
     pNtk->pCopy = pNtkNew;
     return pNtkNew;
 }
+Abc_Ntk_t * Abc_NtkDupDfsNoBarBufs( Abc_Ntk_t * pNtk )
+{
+    Vec_Ptr_t * vNodes;
+    Abc_Ntk_t * pNtkNew; 
+    Abc_Obj_t * pObj, * pFanin;
+    int i, k;
+    if ( pNtk == NULL )
+        return NULL;
+    assert( Abc_NtkIsLogic(pNtk) );
+    assert( pNtk->nBarBufs2 > 0 );
+    // start the network
+    pNtkNew = Abc_NtkStartFrom( pNtk, pNtk->ntkType, pNtk->ntkFunc );
+    // copy the internal nodes
+    vNodes = Abc_NtkDfs2( pNtk );
+    Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
+        if ( Abc_ObjIsBarBuf(pObj) )
+            pObj->pCopy = Abc_ObjFanin0(pObj)->pCopy;
+        else
+            Abc_NtkDupObj( pNtkNew, pObj, 0 );
+    Vec_PtrFree( vNodes );
+    // reconnect all objects (no need to transfer attributes on edges)
+    Abc_NtkForEachObj( pNtk, pObj, i )
+        if ( !Abc_ObjIsBox(pObj) && !Abc_ObjIsBo(pObj) && !Abc_ObjIsBarBuf(pObj) )
+            Abc_ObjForEachFanin( pObj, pFanin, k )
+                if ( pObj->pCopy && pFanin->pCopy )
+                    Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
+    // duplicate the EXDC Ntk
+    if ( pNtk->pExdc )
+        pNtkNew->pExdc = Abc_NtkDup( pNtk->pExdc );
+    if ( pNtk->pExcare )
+        pNtkNew->pExcare = Abc_NtkDup( (Abc_Ntk_t *)pNtk->pExcare );
+    // duplicate timing manager
+    if ( pNtk->pManTime )
+        Abc_NtkTimeInitialize( pNtkNew, pNtk );
+    if ( pNtk->vPhases )
+        Abc_NtkTransferPhases( pNtkNew, pNtk );
+    if ( pNtk->pWLoadUsed )
+        pNtkNew->pWLoadUsed = Abc_UtilStrsav( pNtk->pWLoadUsed );
+    // check correctness
+    if ( !Abc_NtkCheck( pNtkNew ) )
+        fprintf( stdout, "Abc_NtkDup(): Network check has failed.\n" );
+    pNtk->pCopy = pNtkNew;
+    return pNtkNew;
+}
 
 /**Function*************************************************************
 
diff --git a/abc-build/src/base/abc/abcObj.c b/abc-build/src/base/abc/abcObj.c
--- a/abc-build/src/base/abc/abcObj.c
+++ b/abc-build/src/base/abc/abcObj.c
@@ -377,7 +377,7 @@
             else if ( Abc_NtkHasAig(pNtkNew) )
                 pObjNew->pData = Hop_Transfer((Hop_Man_t *)pObj->pNtk->pManFunc, (Hop_Man_t *)pNtkNew->pManFunc, (Hop_Obj_t *)pObj->pData, Abc_ObjFaninNum(pObj));
             else if ( Abc_NtkHasMapping(pNtkNew) )
-                pObjNew->pData = pObj->pData;
+                pObjNew->pData = pObj->pData, pNtkNew->nBarBufs2 += !pObj->pData;
             else assert( 0 );
         }
     }
diff --git a/abc-build/src/base/abc/abcUtil.c b/abc-build/src/base/abc/abcUtil.c
--- a/abc-build/src/base/abc/abcUtil.c
+++ b/abc-build/src/base/abc/abcUtil.c
@@ -138,17 +138,19 @@
 int Abc_NtkGetCubePairNum( Abc_Ntk_t * pNtk )
 {
     Abc_Obj_t * pNode;
-    int i, nCubes, nCubePairs = 0;
+    int i;
+    word nCubes, nCubePairs = 0;
     assert( Abc_NtkHasSop(pNtk) );
     Abc_NtkForEachNode( pNtk, pNode, i )
     {
         if ( Abc_NodeIsConst(pNode) )
             continue;
         assert( pNode->pData );
-        nCubes = Abc_SopGetCubeNum( (char *)pNode->pData );
-        nCubePairs += nCubes * (nCubes - 1) / 2;
+        nCubes = (word)Abc_SopGetCubeNum( (char *)pNode->pData );
+        if ( nCubes > 1 )
+            nCubePairs += nCubes * (nCubes - 1) / 2;
     }
-    return nCubePairs;
+    return (int)(nCubePairs > (1<<30) ? (1<<30) : nCubePairs);
 }
 
 /**Function*************************************************************
@@ -339,7 +341,9 @@
     assert( Abc_NtkHasMapping(pNtk) );
     TotalArea = 0.0;
     Abc_NtkForEachNode( pNtk, pObj, i )
-    {
+    {
+        if ( Abc_ObjIsBarBuf(pObj) )
+            continue;
 //        assert( pObj->pData );
         if ( pObj->pData == NULL )
         {
@@ -991,6 +995,45 @@
     return nDupGates;
 }
 
+
+/**Function*************************************************************
+
+  Synopsis    [Transforms the network to have simple COs.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Abc_NtkLogicMakeSimpleCosTest( Abc_Ntk_t * pNtk, int fDuplicate )
+{
+    int nObjs = Abc_NtkObjNumMax(pNtk);
+    unsigned * pType = ABC_CALLOC( unsigned, nObjs );
+    Abc_Obj_t * pNode;
+    int i, Counts[4] = {0}, Consts[2] = {0}, Inputs[2] = {0};
+    // collect info
+    Abc_NtkForEachCo( pNtk, pNode, i ) 
+    {
+        if ( Abc_ObjFaninId0(pNode) == 0 )
+            Consts[Abc_ObjFaninC0(pNode)]++;
+        if ( Abc_ObjIsCi(Abc_ObjFanin0(pNode)) )
+            Inputs[Abc_ObjFaninC0(pNode)]++;
+        pType[Abc_ObjFaninId0(pNode)] |= (1 << Abc_ObjFaninC0(pNode));
+    }
+    // count the numbers
+    for ( i = 0; i < nObjs; i++ )
+        Counts[pType[i]]++;
+    for ( i = 0; i < 4; i++ )
+        printf( "%d = %d     ", i, Counts[i] );
+    for ( i = 0; i < 2; i++ )
+        printf( "c%d = %d     ", i, Consts[i] );
+    for ( i = 0; i < 2; i++ )
+        printf( "i%d = %d    ", i, Inputs[i] );
+    printf( "\n" );
+    ABC_FREE( pType );
+}
 
 /**Function*************************************************************
 
@@ -1010,6 +1053,7 @@
     int i, k, LevelMax, nTotal = 0;
     assert( Abc_NtkIsLogic(pNtk) );
     LevelMax = Abc_NtkLevel(pNtk);
+//    Abc_NtkLogicMakeSimpleCosTest( pNtk, fDuplicate );
 
     // fix constant drivers
     Abc_NtkForEachCo( pNtk, pNode, i ) 
diff --git a/abc-build/src/base/abc/module.make b/abc-build/src/base/abc/module.make
--- a/abc-build/src/base/abc/module.make
+++ b/abc-build/src/base/abc/module.make
@@ -8,6 +8,7 @@
 	src/base/abc/abcFunc.c \
 	src/base/abc/abcHie.c \
 	src/base/abc/abcHieCec.c \
+	src/base/abc/abcHieGia.c \
 	src/base/abc/abcHieNew.c \
 	src/base/abc/abcLatch.c \
 	src/base/abc/abcLib.c \
diff --git a/abc-build/src/base/abci/abc.c b/abc-build/src/base/abci/abc.c
--- a/abc-build/src/base/abci/abc.c
+++ b/abc-build/src/base/abci/abc.c
@@ -65,35703 +65,37153 @@
 ////////////////////////////////////////////////////////////////////////
 ///                        DECLARATIONS                              ///
 ////////////////////////////////////////////////////////////////////////
-
-static int Abc_CommandPrintStats             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandPrintExdc              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandPrintIo                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandPrintLatch             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandPrintFanio             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandPrintMffc              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandPrintFactor            ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandPrintLevel             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandPrintSupport           ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandPrintSymms             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandPrintUnate             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandPrintAuto              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandPrintKMap              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandPrintGates             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandPrintSharing           ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandPrintXCut              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandPrintDsd               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandPrintCone              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandPrintMiter             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandPrintStatus            ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandPrintDelay             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-
-static int Abc_CommandShow                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandShowBdd                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandShowCut                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-
-static int Abc_CommandCollapse               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandStrash                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandBalance                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandMuxStruct              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandMulti                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandRenode                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandCleanup                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandSweep                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandFastExtract            ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandEliminate              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandDisjoint               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandSparsify               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandLutpack                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandLutmin                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-//static int Abc_CommandImfs                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandMfs                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandMfs2                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandTrace                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandSpeedup                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandPowerdown              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAddBuffs               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-//static int Abc_CommandMerge                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandTestDec                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandTestNpn                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandTestRPO                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-
-static int Abc_CommandRewrite                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandRefactor               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandRestructure            ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandResubstitute           ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandRr                     ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandCascade                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandExtract                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandVarMin                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-
-static int Abc_CommandLogic                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandComb                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandMiter                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandDemiter                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandOrPos                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAndPos                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandZeroPo                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandSwapPos                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandRemovePo               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandDropSat                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAddPi                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAppend                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandPutOnTop               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandFrames                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandDFrames                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandSop                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandBdd                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAig                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandReorder                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandBidec                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandOrder                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandMuxes                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandCubes                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandSplitSop               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandExtSeqDcs              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandReach                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandCone                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandNode                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandTopmost                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandTopAnd                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandTrim                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandShortNames             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandMoveNames              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandExdcFree               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandExdcGet                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandExdcSet                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandCareSet                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandCut                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandEspresso               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandGen                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandGenFsm                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandCover                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandDouble                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandInter                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandBb2Wb                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandOutdec                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandNodeDup                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandTestColor              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandTest                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
-
-static int Abc_CommandQuaVar                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandQuaRel                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandQuaReach               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandSenseInput             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandNpnLoad                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandNpnSave                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-
-static int Abc_CommandSendAig                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandSendStatus             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-
-static int Abc_CommandIStrash                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandICut                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandIRewrite               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandDRewrite               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandDRefactor              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandDc2                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandDChoice                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandDch                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandDrwsat                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandIRewriteSeq            ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandIResyn                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandISat                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandIFraig                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandDFraig                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandCSweep                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandDProve                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbSec                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandSimSec                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandMatch                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
-//static int Abc_CommandHaig                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandQbf                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
-
-static int Abc_CommandFraig                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandFraigTrust             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandFraigStore             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandFraigRestore           ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandFraigClean             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandFraigSweep             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandFraigDress             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-
-static int Abc_CommandRecStart3              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandRecStop3               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandRecPs3                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandRecAdd3                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandRecDump3               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandRecMerge3              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-
-static int Abc_CommandMap                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAmap                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandUnmap                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAttach                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandSuperChoice            ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandSuperChoiceLut         ( Abc_Frame_t * pAbc, int argc, char ** argv );
-
-//static int Abc_CommandFpga                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
-//static int Abc_CommandFpgaFast               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandIf                     ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandIfif                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
-
-static int Abc_CommandDsdSave                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandDsdLoad                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandDsdFree                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandDsdPs                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandDsdTune                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandDsdMerge               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandDsdClean               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-
-static int Abc_CommandScut                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandInit                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandZero                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandUndc                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandOneHot                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandPipe                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandSeq                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandUnseq                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandRetime                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandDRetime                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandFlowRetime             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandCRetime                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandSeqFpga                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandSeqMap                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandSeqSweep               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandSeqSweep2              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandTestSeqSweep           ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandTestScorr              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandLcorr                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandSeqCleanup             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandCycle                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandXsim                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandSim                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandSim3                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandDarPhase               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandSynch                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandClockGate              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandExtWin                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandInsWin                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandPermute                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandUnpermute              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandCubeEnum               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-
-static int Abc_CommandCec                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandDCec                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandDSec                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandSat                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandDSat                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandPSat                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandProve                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandIProve                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandDebug                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandBmc                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandBmc2                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandBmc3                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandBmcInter               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandIndcut                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandEnlarge                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandTempor                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandInduction              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandConstr                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandUnfold                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandFold                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandUnfold2                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandFold2                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandBm                     ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandBm2                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandSaucy                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandTestCex                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandPdr                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandReconcile              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandCexSave                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandCexLoad                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandCexCut                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandCexMerge               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-//static int Abc_CommandCexMin                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandDualRail               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandBlockPo                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandIso                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
-
-static int Abc_CommandTraceStart             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandTraceCheck             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-
-static int Abc_CommandAbc9Get                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Put                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Save               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Load               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Read               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9ReadBlif           ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9ReadCBlif          ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9ReadStg            ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Write              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Ps                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9PFan               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9PSig               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Status             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9MuxProfile         ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Show               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Strash             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Topand             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Add1Hot            ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Cof                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Trim               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Dfs                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Sim                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Sim3               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Resim              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9SpecI              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Equiv              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Equiv2             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Equiv3             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Semi               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Times              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Frames             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Retime             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Enable             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Dc2                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Dsd                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Bidec              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Shrink             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Fx                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Balance            ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9BalanceLut         ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Syn2               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Syn3               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Syn4               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Synch2             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9False              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Miter              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Miter2             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Append             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Scl                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Lcorr              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Scorr              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Choice             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Sat                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Fraig              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9CFraig             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Srm                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Srm2               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Filter             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Reduce             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9EquivMark          ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9EquivFilter        ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Cec                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Verify             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Sweep              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Force              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Embed              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Sopb               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Dsdb               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Flow               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9If                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Iff                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9If2                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Jf                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Kf                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Lf                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Mf                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Nf                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Unmap              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Struct             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Trace              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Speedup            ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Era                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Dch                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Rpm                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9BackReach          ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Posplit            ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9ReachM             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9ReachP             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9ReachN             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9ReachY             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Undo               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Iso                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9CexInfo            ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Cycle              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Cone               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Slice              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9PoPart             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9GroupProve         ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9MultiProve         ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9SplitProve         ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Bmc                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9BCore              ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9ICheck             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9SatTest            ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9FFTest             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Inse               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Maxi               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Bmci               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9PoXsim             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Demiter            ( Abc_Frame_t * pAbc, int argc, char ** argv );
-//static int Abc_CommandAbc9PoPart2            ( Abc_Frame_t * pAbc, int argc, char ** argv );
-//static int Abc_CommandAbc9CexCut             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-//static int Abc_CommandAbc9CexMerge           ( Abc_Frame_t * pAbc, int argc, char ** argv );
-//static int Abc_CommandAbc9CexMin             ( Abc_Frame_t * pAbc, int argc, char ** argv );
-
-static int Abc_CommandAbc9AbsDerive          ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9AbsRefine          ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9GlaDerive          ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9GlaRefine          ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9GlaShrink          ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Gla                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Vta                ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Vta2Gla            ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Gla2Vta            ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Fla2Gla            ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc9Gla2Fla            ( Abc_Frame_t * pAbc, int argc, char ** argv );
-
-static int Abc_CommandAbc9Test               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-
-extern int Abc_CommandAbcLivenessToSafety    ( Abc_Frame_t * pAbc, int argc, char ** argv );
-extern int Abc_CommandAbcLivenessToSafetySim ( Abc_Frame_t * pAbc, int argc, char ** argv );
-extern int Abc_CommandAbcLivenessToSafetyWithLTL( Abc_Frame_t * pAbc, int argc, char ** argv );
-extern int Abc_CommandCS_kLiveness           ( Abc_Frame_t * pAbc, int argc, char ** argv );
-extern int Abc_CommandNChooseK               ( Abc_Frame_t * pAbc, int argc, char ** argv );
-
-extern Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fExors, int fRegisters );
-extern Abc_Ntk_t * Abc_NtkFromAigPhase( Aig_Man_t * pMan );
-
-////////////////////////////////////////////////////////////////////////
-///                     FUNCTION DEFINITIONS                         ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-               
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-void Abc_FrameReplaceCex( Abc_Frame_t * pAbc, Abc_Cex_t ** ppCex )
-{
-    // update CEX
-    ABC_FREE( pAbc->pCex );
-    pAbc->pCex = *ppCex;
-    *ppCex = NULL;
-    // remove CEX vector
-    if ( pAbc->vCexVec )
-    {
-        Vec_PtrFreeFree( pAbc->vCexVec );
-        pAbc->vCexVec = NULL;
-    }
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-               
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-void Abc_FrameReplaceCexVec( Abc_Frame_t * pAbc, Vec_Ptr_t ** pvCexVec )
-{
-    // update CEX vector
-    if ( pAbc->vCexVec )
-        Vec_PtrFreeFree( pAbc->vCexVec );
-    pAbc->vCexVec = *pvCexVec;
-    *pvCexVec = NULL;
-    // remove CEX
-    ABC_FREE( pAbc->pCex );
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-void Abc_FrameReplacePoEquivs( Abc_Frame_t * pAbc, Vec_Ptr_t ** pvPoEquivs )
-{
-    if ( pAbc->vPoEquivs )
-        Vec_VecFree( (Vec_Vec_t *)pAbc->vPoEquivs );
-    pAbc->vPoEquivs = *pvPoEquivs;
-    *pvPoEquivs = NULL;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-void Abc_FrameReplacePoStatuses( Abc_Frame_t * pAbc, Vec_Int_t ** pvStatuses )
-{
-    if ( pAbc->vStatuses )
-        Vec_IntFree( pAbc->vStatuses );
-    pAbc->vStatuses = *pvStatuses;
-    *pvStatuses = NULL;
-}
-
-/**Function*************************************************************
-
-  Synopsis    [Derives array of statuses from the array of CEXes.]
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-Vec_Int_t * Abc_FrameDeriveStatusArray( Vec_Ptr_t * vCexes )
-{
-    Vec_Int_t * vStatuses;
-    Abc_Cex_t * pCex;
-    int i;
-    if ( vCexes == NULL )
-        return NULL;
-    vStatuses = Vec_IntAlloc( Vec_PtrSize(vCexes) );
-    Vec_IntFill( vStatuses, Vec_PtrSize(vCexes), -1 ); // assume UNDEC
-    Vec_PtrForEachEntry( Abc_Cex_t *, vCexes, pCex, i )
-        if ( pCex != NULL )
-            Vec_IntWriteEntry( vStatuses, i, 0 ); // set this output as SAT
-    return vStatuses;    
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-void Abc_FrameClearDesign()
-{
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-void Abc_FrameUpdateGia( Abc_Frame_t * pAbc, Gia_Man_t * pNew )
-{
-    if ( pNew == NULL )
-    {
-        Abc_Print( -1, "Abc_FrameUpdateGia(): Tranformation has failed.\n" );
-        return;
-    }
-    if ( Gia_ManPoNum(pNew) == 0 )
-        Abc_Print( 0, "The current GIA has no primary outputs. Some commands may not work correctly.\n" );
-    if ( pNew == pAbc->pGia )
-        return;
-    // transfer names
-    if (!pNew->vNamesIn && pAbc->pGia && pAbc->pGia->vNamesIn && Gia_ManCiNum(pNew) == Vec_PtrSize(pAbc->pGia->vNamesIn))
-    {
-        pNew->vNamesIn = pAbc->pGia->vNamesIn;
-        pAbc->pGia->vNamesIn = NULL;
-    }
-    if (!pNew->vNamesOut && pAbc->pGia && pAbc->pGia->vNamesOut && Gia_ManCoNum(pNew) == Vec_PtrSize(pAbc->pGia->vNamesOut))
-    {
-        pNew->vNamesOut = pAbc->pGia->vNamesOut;
-        pAbc->pGia->vNamesOut = NULL;
-    }
-    // update
-    if ( pAbc->pGia2 )
-        Gia_ManStop( pAbc->pGia2 );
-    pAbc->pGia2 = pAbc->pGia;
-    pAbc->pGia  = pNew;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-Gia_Man_t * Abc_FrameGetGia( Abc_Frame_t * pAbc )
-{
-    Gia_Man_t * pGia;
-    if ( pAbc->pGia2 )
-        Gia_ManStop( pAbc->pGia2 );
-    pAbc->pGia2 = NULL;
-    pGia = pAbc->pGia;
-    pAbc->pGia = NULL;
-    return pGia;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-void Abc_Init( Abc_Frame_t * pAbc )
-{
-    Cmd_CommandAdd( pAbc, "Printing",     "print_stats",   Abc_CommandPrintStats,       0 );
-    Cmd_CommandAdd( pAbc, "Printing",     "print_exdc",    Abc_CommandPrintExdc,        0 );
-    Cmd_CommandAdd( pAbc, "Printing",     "print_io",      Abc_CommandPrintIo,          0 );
-    Cmd_CommandAdd( pAbc, "Printing",     "print_latch",   Abc_CommandPrintLatch,       0 );
-    Cmd_CommandAdd( pAbc, "Printing",     "print_fanio",   Abc_CommandPrintFanio,       0 );
-    Cmd_CommandAdd( pAbc, "Printing",     "print_mffc",    Abc_CommandPrintMffc,        0 );
-    Cmd_CommandAdd( pAbc, "Printing",     "print_factor",  Abc_CommandPrintFactor,      0 );
-    Cmd_CommandAdd( pAbc, "Printing",     "print_level",   Abc_CommandPrintLevel,       0 );
-    Cmd_CommandAdd( pAbc, "Printing",     "print_supp",    Abc_CommandPrintSupport,     0 );
-    Cmd_CommandAdd( pAbc, "Printing",     "print_symm",    Abc_CommandPrintSymms,       0 );
-    Cmd_CommandAdd( pAbc, "Printing",     "print_unate",   Abc_CommandPrintUnate,       0 );
-    Cmd_CommandAdd( pAbc, "Printing",     "print_auto",    Abc_CommandPrintAuto,        0 );
-    Cmd_CommandAdd( pAbc, "Printing",     "print_kmap",    Abc_CommandPrintKMap,        0 );
-    Cmd_CommandAdd( pAbc, "Printing",     "print_gates",   Abc_CommandPrintGates,       0 );
-    Cmd_CommandAdd( pAbc, "Printing",     "print_sharing", Abc_CommandPrintSharing,     0 );
-    Cmd_CommandAdd( pAbc, "Printing",     "print_xcut",    Abc_CommandPrintXCut,        0 );
-    Cmd_CommandAdd( pAbc, "Printing",     "print_dsd",     Abc_CommandPrintDsd,         0 );
-    Cmd_CommandAdd( pAbc, "Printing",     "print_cone",    Abc_CommandPrintCone,        0 );
-    Cmd_CommandAdd( pAbc, "Printing",     "print_miter",   Abc_CommandPrintMiter,       0 );
-    Cmd_CommandAdd( pAbc, "Printing",     "print_status",  Abc_CommandPrintStatus,      0 );
-    Cmd_CommandAdd( pAbc, "Printing",     "print_delay",   Abc_CommandPrintDelay,       0 );
-
-    Cmd_CommandAdd( pAbc, "Printing",     "show",          Abc_CommandShow,             0 );
-    Cmd_CommandAdd( pAbc, "Printing",     "show_bdd",      Abc_CommandShowBdd,          0 );
-    Cmd_CommandAdd( pAbc, "Printing",     "show_cut",      Abc_CommandShowCut,          0 );
-
-    Cmd_CommandAdd( pAbc, "Synthesis",    "collapse",      Abc_CommandCollapse,         1 );
-    Cmd_CommandAdd( pAbc, "Synthesis",    "strash",        Abc_CommandStrash,           1 );
-    Cmd_CommandAdd( pAbc, "Synthesis",    "balance",       Abc_CommandBalance,          1 );
-    Cmd_CommandAdd( pAbc, "Synthesis",    "mux_struct",    Abc_CommandMuxStruct,        1 );
-    Cmd_CommandAdd( pAbc, "Synthesis",    "multi",         Abc_CommandMulti,            1 );
-    Cmd_CommandAdd( pAbc, "Synthesis",    "renode",        Abc_CommandRenode,           1 );
-    Cmd_CommandAdd( pAbc, "Synthesis",    "cleanup",       Abc_CommandCleanup,          1 );
-    Cmd_CommandAdd( pAbc, "Synthesis",    "sweep",         Abc_CommandSweep,            1 );
-    Cmd_CommandAdd( pAbc, "Synthesis",    "fx",            Abc_CommandFastExtract,      1 );
-    Cmd_CommandAdd( pAbc, "Synthesis",    "eliminate",     Abc_CommandEliminate,        1 );
-    Cmd_CommandAdd( pAbc, "Synthesis",    "dsd",           Abc_CommandDisjoint,         1 );
-    Cmd_CommandAdd( pAbc, "Synthesis",    "sparsify",      Abc_CommandSparsify,         1 );
-    Cmd_CommandAdd( pAbc, "Synthesis",    "lutpack",       Abc_CommandLutpack,          1 );
-    Cmd_CommandAdd( pAbc, "Synthesis",    "lutmin",        Abc_CommandLutmin,           1 );
-//    Cmd_CommandAdd( pAbc, "Synthesis",    "imfs",          Abc_CommandImfs,             1 );
-    Cmd_CommandAdd( pAbc, "Synthesis",    "mfs",           Abc_CommandMfs,              1 );
-    Cmd_CommandAdd( pAbc, "Synthesis",    "mfs2",          Abc_CommandMfs2,             1 );
-    Cmd_CommandAdd( pAbc, "Synthesis",    "trace",         Abc_CommandTrace,            0 );
-    Cmd_CommandAdd( pAbc, "Synthesis",    "speedup",       Abc_CommandSpeedup,          1 );
-    Cmd_CommandAdd( pAbc, "Synthesis",    "powerdown",     Abc_CommandPowerdown,        1 );
-    Cmd_CommandAdd( pAbc, "Synthesis",    "addbuffs",      Abc_CommandAddBuffs,         1 );
-//    Cmd_CommandAdd( pAbc, "Synthesis",    "merge",         Abc_CommandMerge,            1 );
-    Cmd_CommandAdd( pAbc, "Synthesis",    "testdec",       Abc_CommandTestDec,          0 );
-    Cmd_CommandAdd( pAbc, "Synthesis",    "testnpn",       Abc_CommandTestNpn,          0 );
-    Cmd_CommandAdd( pAbc, "LogiCS",       "testrpo",       Abc_CommandTestRPO,          0 );
-
-    Cmd_CommandAdd( pAbc, "Synthesis",    "rewrite",       Abc_CommandRewrite,          1 );
-    Cmd_CommandAdd( pAbc, "Synthesis",    "refactor",      Abc_CommandRefactor,         1 );
-//    Cmd_CommandAdd( pAbc, "Synthesis",    "restructure",   Abc_CommandRestructure,      1 );
-    Cmd_CommandAdd( pAbc, "Synthesis",    "resub",         Abc_CommandResubstitute,     1 );
-//    Cmd_CommandAdd( pAbc, "Synthesis",    "rr",            Abc_CommandRr,               1 );
-    Cmd_CommandAdd( pAbc, "Synthesis",    "cascade",       Abc_CommandCascade,          1 );
-    Cmd_CommandAdd( pAbc, "Synthesis",    "extract",       Abc_CommandExtract,          1 );
-    Cmd_CommandAdd( pAbc, "Synthesis",    "varmin",        Abc_CommandVarMin,           0 );
-
-    Cmd_CommandAdd( pAbc, "Various",      "logic",         Abc_CommandLogic,            1 );
-    Cmd_CommandAdd( pAbc, "Various",      "comb",          Abc_CommandComb,             1 );
-    Cmd_CommandAdd( pAbc, "Various",      "miter",         Abc_CommandMiter,            1 );
-    Cmd_CommandAdd( pAbc, "Various",      "demiter",       Abc_CommandDemiter,          1 );
-    Cmd_CommandAdd( pAbc, "Various",      "orpos",         Abc_CommandOrPos,            1 );
-    Cmd_CommandAdd( pAbc, "Various",      "andpos",        Abc_CommandAndPos,           1 );
-    Cmd_CommandAdd( pAbc, "Various",      "zeropo",        Abc_CommandZeroPo,           1 );
-    Cmd_CommandAdd( pAbc, "Various",      "swappos",       Abc_CommandSwapPos,          1 );
-    Cmd_CommandAdd( pAbc, "Various",      "removepo",      Abc_CommandRemovePo,         1 );
-    Cmd_CommandAdd( pAbc, "Various",      "dropsat",       Abc_CommandDropSat,          1 );
-    Cmd_CommandAdd( pAbc, "Various",      "addpi",         Abc_CommandAddPi,            1 );
-    Cmd_CommandAdd( pAbc, "Various",      "append",        Abc_CommandAppend,           1 );
-    Cmd_CommandAdd( pAbc, "Various",      "putontop",      Abc_CommandPutOnTop,         1 );
-    Cmd_CommandAdd( pAbc, "Various",      "frames",        Abc_CommandFrames,           1 );
-    Cmd_CommandAdd( pAbc, "Various",      "dframes",       Abc_CommandDFrames,          1 );
-    Cmd_CommandAdd( pAbc, "Various",      "sop",           Abc_CommandSop,              0 );
-    Cmd_CommandAdd( pAbc, "Various",      "bdd",           Abc_CommandBdd,              0 );
-    Cmd_CommandAdd( pAbc, "Various",      "aig",           Abc_CommandAig,              0 );
-    Cmd_CommandAdd( pAbc, "Various",      "reorder",       Abc_CommandReorder,          0 );
-    Cmd_CommandAdd( pAbc, "Various",      "bidec",         Abc_CommandBidec,            1 );
-    Cmd_CommandAdd( pAbc, "Various",      "order",         Abc_CommandOrder,            0 );
-    Cmd_CommandAdd( pAbc, "Various",      "muxes",         Abc_CommandMuxes,            1 );
-    Cmd_CommandAdd( pAbc, "Various",      "cubes",         Abc_CommandCubes,            1 );
-    Cmd_CommandAdd( pAbc, "Various",      "splitsop",      Abc_CommandSplitSop,         1 );
-    Cmd_CommandAdd( pAbc, "Various",      "ext_seq_dcs",   Abc_CommandExtSeqDcs,        0 );
-    Cmd_CommandAdd( pAbc, "Various",      "reach",         Abc_CommandReach,            0 );
-    Cmd_CommandAdd( pAbc, "Various",      "cone",          Abc_CommandCone,             1 );
-    Cmd_CommandAdd( pAbc, "Various",      "node",          Abc_CommandNode,             1 );
-    Cmd_CommandAdd( pAbc, "Various",      "topmost",       Abc_CommandTopmost,          1 );
-    Cmd_CommandAdd( pAbc, "Various",      "topand",        Abc_CommandTopAnd,          1 );
-    Cmd_CommandAdd( pAbc, "Various",      "trim",          Abc_CommandTrim,             1 );
-    Cmd_CommandAdd( pAbc, "Various",      "short_names",   Abc_CommandShortNames,       0 );
-    Cmd_CommandAdd( pAbc, "Various",      "move_names",    Abc_CommandMoveNames,        0 );
-    Cmd_CommandAdd( pAbc, "Various",      "exdc_free",     Abc_CommandExdcFree,         1 );
-    Cmd_CommandAdd( pAbc, "Various",      "exdc_get",      Abc_CommandExdcGet,          1 );
-    Cmd_CommandAdd( pAbc, "Various",      "exdc_set",      Abc_CommandExdcSet,          1 );
-    Cmd_CommandAdd( pAbc, "Various",      "care_set",      Abc_CommandCareSet,          1 );
-    Cmd_CommandAdd( pAbc, "Various",      "cut",           Abc_CommandCut,              0 );
-    Cmd_CommandAdd( pAbc, "Various",      "espresso",      Abc_CommandEspresso,         1 );
-    Cmd_CommandAdd( pAbc, "Various",      "gen",           Abc_CommandGen,              0 );
-    Cmd_CommandAdd( pAbc, "Various",      "genfsm",        Abc_CommandGenFsm,           0 );
-    Cmd_CommandAdd( pAbc, "Various",      "cover",         Abc_CommandCover,            1 );
-    Cmd_CommandAdd( pAbc, "Various",      "double",        Abc_CommandDouble,           1 );
-    Cmd_CommandAdd( pAbc, "Various",      "inter",         Abc_CommandInter,            1 );
-    Cmd_CommandAdd( pAbc, "Various",      "bb2wb",         Abc_CommandBb2Wb,            0 );
-    Cmd_CommandAdd( pAbc, "Various",      "outdec",        Abc_CommandOutdec,           1 );
-    Cmd_CommandAdd( pAbc, "Various",      "nodedup",       Abc_CommandNodeDup,          1 );
-    Cmd_CommandAdd( pAbc, "Various",      "testcolor",     Abc_CommandTestColor,        0 );
-    Cmd_CommandAdd( pAbc, "Various",      "test",          Abc_CommandTest,             0 );
-//    Cmd_CommandAdd( pAbc, "Various",      "qbf_solve",     Abc_CommandTest,               0 );
-
-    Cmd_CommandAdd( pAbc, "Various",      "qvar",          Abc_CommandQuaVar,           1 );
-    Cmd_CommandAdd( pAbc, "Various",      "qrel",          Abc_CommandQuaRel,           1 );
-    Cmd_CommandAdd( pAbc, "Various",      "qreach",        Abc_CommandQuaReach,         1 );
-    Cmd_CommandAdd( pAbc, "Various",      "senseinput",    Abc_CommandSenseInput,       1 );
-    Cmd_CommandAdd( pAbc, "Various",      "npnload",       Abc_CommandNpnLoad,          0 );
-    Cmd_CommandAdd( pAbc, "Various",      "npnsave",       Abc_CommandNpnSave,          0 );
-
-    Cmd_CommandAdd( pAbc, "Various",      "send_aig",      Abc_CommandSendAig,          0 );
-    Cmd_CommandAdd( pAbc, "Various",      "send_status",   Abc_CommandSendStatus,       0 );
-
-    Cmd_CommandAdd( pAbc, "New AIG",      "istrash",       Abc_CommandIStrash,          1 );
-    Cmd_CommandAdd( pAbc, "New AIG",      "icut",          Abc_CommandICut,             0 );
-    Cmd_CommandAdd( pAbc, "New AIG",      "irw",           Abc_CommandIRewrite,         1 );
-    Cmd_CommandAdd( pAbc, "New AIG",      "drw",           Abc_CommandDRewrite,         1 );
-    Cmd_CommandAdd( pAbc, "New AIG",      "drf",           Abc_CommandDRefactor,        1 );
-    Cmd_CommandAdd( pAbc, "New AIG",      "dc2",           Abc_CommandDc2,              1 );
-    Cmd_CommandAdd( pAbc, "New AIG",      "dchoice",       Abc_CommandDChoice,          1 );
-    Cmd_CommandAdd( pAbc, "New AIG",      "dch",           Abc_CommandDch,              1 );
-    Cmd_CommandAdd( pAbc, "New AIG",      "drwsat",        Abc_CommandDrwsat,           1 );
-    Cmd_CommandAdd( pAbc, "New AIG",      "irws",          Abc_CommandIRewriteSeq,      1 );
-    Cmd_CommandAdd( pAbc, "New AIG",      "iresyn",        Abc_CommandIResyn,           1 );
-    Cmd_CommandAdd( pAbc, "New AIG",      "isat",          Abc_CommandISat,             1 );
-    Cmd_CommandAdd( pAbc, "New AIG",      "ifraig",        Abc_CommandIFraig,           1 );
-    Cmd_CommandAdd( pAbc, "New AIG",      "dfraig",        Abc_CommandDFraig,           1 );
-    Cmd_CommandAdd( pAbc, "New AIG",      "csweep",        Abc_CommandCSweep,           1 );
-//    Cmd_CommandAdd( pAbc, "New AIG",      "haig",          Abc_CommandHaig,             1 );
-    Cmd_CommandAdd( pAbc, "New AIG",      "qbf",           Abc_CommandQbf,              0 );
-
-    Cmd_CommandAdd( pAbc, "Fraiging",     "fraig",         Abc_CommandFraig,            1 );
-    Cmd_CommandAdd( pAbc, "Fraiging",     "fraig_trust",   Abc_CommandFraigTrust,       1 );
-    Cmd_CommandAdd( pAbc, "Fraiging",     "fraig_store",   Abc_CommandFraigStore,       0 );
-    Cmd_CommandAdd( pAbc, "Fraiging",     "fraig_restore", Abc_CommandFraigRestore,     1 );
-    Cmd_CommandAdd( pAbc, "Fraiging",     "fraig_clean",   Abc_CommandFraigClean,       0 );
-    Cmd_CommandAdd( pAbc, "Fraiging",     "fraig_sweep",   Abc_CommandFraigSweep,       1 );
-    Cmd_CommandAdd( pAbc, "Fraiging",     "dress",         Abc_CommandFraigDress,       1 );
-
-    Cmd_CommandAdd( pAbc, "Choicing",     "rec_start3",    Abc_CommandRecStart3,        0 );
-    Cmd_CommandAdd( pAbc, "Choicing",     "rec_stop3",     Abc_CommandRecStop3,         0 );
-    Cmd_CommandAdd( pAbc, "Choicing",     "rec_ps3",       Abc_CommandRecPs3,           0 );
-    Cmd_CommandAdd( pAbc, "Choicing",     "rec_add3",      Abc_CommandRecAdd3,          0 );
-    Cmd_CommandAdd( pAbc, "Choicing",     "rec_dump3",     Abc_CommandRecDump3,         0 );
-    Cmd_CommandAdd( pAbc, "Choicing",     "rec_merge3",    Abc_CommandRecMerge3,        0 );
-
-    Cmd_CommandAdd( pAbc, "SC mapping",   "map",           Abc_CommandMap,              1 );
-    Cmd_CommandAdd( pAbc, "SC mapping",   "amap",          Abc_CommandAmap,             1 );
-    Cmd_CommandAdd( pAbc, "SC mapping",   "unmap",         Abc_CommandUnmap,            1 );
-    Cmd_CommandAdd( pAbc, "SC mapping",   "attach",        Abc_CommandAttach,           1 );
-    Cmd_CommandAdd( pAbc, "SC mapping",   "superc",        Abc_CommandSuperChoice,      1 );
-    Cmd_CommandAdd( pAbc, "SC mapping",   "supercl",       Abc_CommandSuperChoiceLut,   1 );
-
-//    Cmd_CommandAdd( pAbc, "FPGA mapping", "fpga",          Abc_CommandFpga,             1 );
-//    Cmd_CommandAdd( pAbc, "FPGA mapping", "ffpga",         Abc_CommandFpgaFast,         1 );
-    Cmd_CommandAdd( pAbc, "FPGA mapping", "if",            Abc_CommandIf,               1 );
-    Cmd_CommandAdd( pAbc, "FPGA mapping", "ifif",          Abc_CommandIfif,             1 );
-
-    Cmd_CommandAdd( pAbc, "DSD manager",  "dsd_save",      Abc_CommandDsdSave,          0 );
-    Cmd_CommandAdd( pAbc, "DSD manager",  "dsd_load",      Abc_CommandDsdLoad,          0 );
-    Cmd_CommandAdd( pAbc, "DSD manager",  "dsd_free",      Abc_CommandDsdFree,          0 );
-    Cmd_CommandAdd( pAbc, "DSD manager",  "dsd_ps",        Abc_CommandDsdPs,            0 );
-    Cmd_CommandAdd( pAbc, "DSD manager",  "dsd_tune",      Abc_CommandDsdTune,          0 );
-    Cmd_CommandAdd( pAbc, "DSD manager",  "dsd_merge",     Abc_CommandDsdMerge,         0 );
-    Cmd_CommandAdd( pAbc, "DSD manager",  "dsd_clean",     Abc_CommandDsdClean,         0 );
-
-//    Cmd_CommandAdd( pAbc, "Sequential",   "scut",          Abc_CommandScut,             0 );
-    Cmd_CommandAdd( pAbc, "Sequential",   "init",          Abc_CommandInit,             1 );
-    Cmd_CommandAdd( pAbc, "Sequential",   "zero",          Abc_CommandZero,             1 );
-    Cmd_CommandAdd( pAbc, "Sequential",   "undc",          Abc_CommandUndc,             1 );
-    Cmd_CommandAdd( pAbc, "Sequential",   "onehot",        Abc_CommandOneHot,           1 );
-//    Cmd_CommandAdd( pAbc, "Sequential",   "pipe",          Abc_CommandPipe,             1 );
-    Cmd_CommandAdd( pAbc, "Sequential",   "retime",        Abc_CommandRetime,           1 );
-    Cmd_CommandAdd( pAbc, "Sequential",   "dretime",       Abc_CommandDRetime,          1 );
-    Cmd_CommandAdd( pAbc, "Sequential",   "fretime",       Abc_CommandFlowRetime,       1 );
-    Cmd_CommandAdd( pAbc, "Sequential",   "cretime",       Abc_CommandCRetime,          1 );
-//    Cmd_CommandAdd( pAbc, "Sequential",   "sfpga",         Abc_CommandSeqFpga,          1 );
-//    Cmd_CommandAdd( pAbc, "Sequential",   "smap",          Abc_CommandSeqMap,           1 );
-    Cmd_CommandAdd( pAbc, "Sequential",   "ssweep",        Abc_CommandSeqSweep,         1 );
-    Cmd_CommandAdd( pAbc, "Sequential",   "scorr",         Abc_CommandSeqSweep2,        1 );
-    Cmd_CommandAdd( pAbc, "Sequential",   "testssw",       Abc_CommandTestSeqSweep,     0 );
-    Cmd_CommandAdd( pAbc, "Sequential",   "testscorr",     Abc_CommandTestScorr,        0 );
-    Cmd_CommandAdd( pAbc, "Sequential",   "lcorr",         Abc_CommandLcorr,            1 );
-    Cmd_CommandAdd( pAbc, "Sequential",   "scleanup",      Abc_CommandSeqCleanup,       1 );
-    Cmd_CommandAdd( pAbc, "Sequential",   "cycle",         Abc_CommandCycle,            1 );
-    Cmd_CommandAdd( pAbc, "Sequential",   "xsim",          Abc_CommandXsim,             0 );
-    Cmd_CommandAdd( pAbc, "Sequential",   "sim",           Abc_CommandSim,              0 );
-    Cmd_CommandAdd( pAbc, "Sequential",   "sim3",          Abc_CommandSim3,             0 );
-    Cmd_CommandAdd( pAbc, "Sequential",   "phase",         Abc_CommandDarPhase,         1 );
-    Cmd_CommandAdd( pAbc, "Sequential",   "synch",         Abc_CommandSynch,            1 );
-    Cmd_CommandAdd( pAbc, "Sequential",   "clockgate",     Abc_CommandClockGate,        1 );
-    Cmd_CommandAdd( pAbc, "Sequential",   "extwin",        Abc_CommandExtWin,           1 );
-    Cmd_CommandAdd( pAbc, "Sequential",   "inswin",        Abc_CommandInsWin,           1 );
-    Cmd_CommandAdd( pAbc, "Sequential",   "permute",       Abc_CommandPermute,          1 );
-    Cmd_CommandAdd( pAbc, "Sequential",   "unpermute",     Abc_CommandUnpermute,        1 );
-    Cmd_CommandAdd( pAbc, "Sequential",   "cubeenum",      Abc_CommandCubeEnum,         0 );
-
-    Cmd_CommandAdd( pAbc, "Verification", "cec",           Abc_CommandCec,              0 );
-    Cmd_CommandAdd( pAbc, "Verification", "dcec",          Abc_CommandDCec,             0 );
-    Cmd_CommandAdd( pAbc, "Verification", "dsec",          Abc_CommandDSec,             0 );
-    Cmd_CommandAdd( pAbc, "Verification", "dprove",        Abc_CommandDProve,           0 );
-    Cmd_CommandAdd( pAbc, "Verification", "absec",         Abc_CommandAbSec,            0 );
-    Cmd_CommandAdd( pAbc, "Verification", "simsec",        Abc_CommandSimSec,           0 );
-    Cmd_CommandAdd( pAbc, "Verification", "match",         Abc_CommandMatch,            0 );
-    Cmd_CommandAdd( pAbc, "Verification", "sat",           Abc_CommandSat,              0 );
-    Cmd_CommandAdd( pAbc, "Verification", "dsat",          Abc_CommandDSat,             0 );
-    Cmd_CommandAdd( pAbc, "Verification", "psat",          Abc_CommandPSat,             0 );
-    Cmd_CommandAdd( pAbc, "Verification", "prove",         Abc_CommandProve,            1 );
-    Cmd_CommandAdd( pAbc, "Verification", "iprove",        Abc_CommandIProve,           1 );
-    Cmd_CommandAdd( pAbc, "Verification", "debug",         Abc_CommandDebug,            0 );
-    Cmd_CommandAdd( pAbc, "Verification", "bmc",           Abc_CommandBmc,              0 );
-    Cmd_CommandAdd( pAbc, "Verification", "bmc2",          Abc_CommandBmc2,             0 );
-    Cmd_CommandAdd( pAbc, "Verification", "bmc3",          Abc_CommandBmc3,             1 );
-    Cmd_CommandAdd( pAbc, "Verification", "int",           Abc_CommandBmcInter,         1 );
-    Cmd_CommandAdd( pAbc, "Verification", "indcut",        Abc_CommandIndcut,           0 );
-    Cmd_CommandAdd( pAbc, "Verification", "enlarge",       Abc_CommandEnlarge,          1 );
-    Cmd_CommandAdd( pAbc, "Verification", "tempor",        Abc_CommandTempor,           1 );
-    Cmd_CommandAdd( pAbc, "Verification", "ind",           Abc_CommandInduction,        0 );
-    Cmd_CommandAdd( pAbc, "Verification", "constr",        Abc_CommandConstr,           0 );
-    Cmd_CommandAdd( pAbc, "Verification", "unfold",        Abc_CommandUnfold,           1 );
-    Cmd_CommandAdd( pAbc, "Verification", "fold",          Abc_CommandFold,             1 );
-    Cmd_CommandAdd( pAbc, "Verification", "unfold2",       Abc_CommandUnfold2,          1 );    // jlong 
-    Cmd_CommandAdd( pAbc, "Verification", "fold2",         Abc_CommandFold2,            1 );    // jlong 
-    Cmd_CommandAdd( pAbc, "Verification", "bm",            Abc_CommandBm,               1 );
-    Cmd_CommandAdd( pAbc, "Verification", "bm2",           Abc_CommandBm2,              1 );
-    Cmd_CommandAdd( pAbc, "Verification", "saucy3",        Abc_CommandSaucy,            1 );
-    Cmd_CommandAdd( pAbc, "Verification", "testcex",       Abc_CommandTestCex,          0 );
-    Cmd_CommandAdd( pAbc, "Verification", "pdr",           Abc_CommandPdr,              0 );
-    Cmd_CommandAdd( pAbc, "Verification", "reconcile",     Abc_CommandReconcile,        1 );
-    Cmd_CommandAdd( pAbc, "Verification", "cexsave",       Abc_CommandCexSave,          0 );
-    Cmd_CommandAdd( pAbc, "Verification", "cexload",       Abc_CommandCexLoad,          0 );
-    Cmd_CommandAdd( pAbc, "Verification", "cexcut",        Abc_CommandCexCut,           0 );
-    Cmd_CommandAdd( pAbc, "Verification", "cexmerge",      Abc_CommandCexMerge,         0 );
-//    Cmd_CommandAdd( pAbc, "Verification", "cexmin",        Abc_CommandCexMin,           0 );
-    Cmd_CommandAdd( pAbc, "Verification", "dualrail",      Abc_CommandDualRail,         1 );
-    Cmd_CommandAdd( pAbc, "Verification", "blockpo",       Abc_CommandBlockPo,          1 );
-    Cmd_CommandAdd( pAbc, "Verification", "iso",           Abc_CommandIso,              1 );
-
-    Cmd_CommandAdd( pAbc, "ABC9",         "&get",          Abc_CommandAbc9Get,          0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&put",          Abc_CommandAbc9Put,          0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&save",         Abc_CommandAbc9Save,         0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&load",         Abc_CommandAbc9Load,         0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&r",            Abc_CommandAbc9Read,         0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&read_blif",    Abc_CommandAbc9ReadBlif,     0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&read_cblif",   Abc_CommandAbc9ReadCBlif,    0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&read_stg",     Abc_CommandAbc9ReadStg,      0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&w",            Abc_CommandAbc9Write,        0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&ps",           Abc_CommandAbc9Ps,           0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&pfan",         Abc_CommandAbc9PFan,         0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&psig",         Abc_CommandAbc9PSig,         0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&status",       Abc_CommandAbc9Status,       0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&mux_profile",  Abc_CommandAbc9MuxProfile,   0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&show",         Abc_CommandAbc9Show,         0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&st",           Abc_CommandAbc9Strash,       0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&topand",       Abc_CommandAbc9Topand,       0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&add1hot",      Abc_CommandAbc9Add1Hot,      0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&cof",          Abc_CommandAbc9Cof,          0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&trim",         Abc_CommandAbc9Trim,         0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&dfs",          Abc_CommandAbc9Dfs,          0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&sim",          Abc_CommandAbc9Sim,          0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&sim3",         Abc_CommandAbc9Sim3,         0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&resim",        Abc_CommandAbc9Resim,        0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&speci",        Abc_CommandAbc9SpecI,        0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&equiv",        Abc_CommandAbc9Equiv,        0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&equiv2",       Abc_CommandAbc9Equiv2,       0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&equiv3",       Abc_CommandAbc9Equiv3,       0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&semi",         Abc_CommandAbc9Semi,         0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&times",        Abc_CommandAbc9Times,        0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&frames",       Abc_CommandAbc9Frames,       0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&retime",       Abc_CommandAbc9Retime,       0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&enable",       Abc_CommandAbc9Enable,       0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&dc2",          Abc_CommandAbc9Dc2,          0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&dsd",          Abc_CommandAbc9Dsd,          0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&bidec",        Abc_CommandAbc9Bidec,        0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&shrink",       Abc_CommandAbc9Shrink,       0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&fx",           Abc_CommandAbc9Fx,           0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&b",            Abc_CommandAbc9Balance,      0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&blut",         Abc_CommandAbc9BalanceLut,   0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&syn2",         Abc_CommandAbc9Syn2,         0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&syn3",         Abc_CommandAbc9Syn3,         0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&syn4",         Abc_CommandAbc9Syn4,         0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&synch2",       Abc_CommandAbc9Synch2,       0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&false",        Abc_CommandAbc9False,        0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&miter",        Abc_CommandAbc9Miter,        0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&miter2",       Abc_CommandAbc9Miter2,       0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&append",       Abc_CommandAbc9Append,       0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&scl",          Abc_CommandAbc9Scl,          0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&lcorr",        Abc_CommandAbc9Lcorr,        0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&scorr",        Abc_CommandAbc9Scorr,        0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&choice",       Abc_CommandAbc9Choice,       0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&sat",          Abc_CommandAbc9Sat,          0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&fraig",        Abc_CommandAbc9Fraig,        0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&cfraig",       Abc_CommandAbc9CFraig,       0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&srm",          Abc_CommandAbc9Srm,          0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&srm2",         Abc_CommandAbc9Srm2,         0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&filter",       Abc_CommandAbc9Filter,       0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&reduce",       Abc_CommandAbc9Reduce,       0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&equiv_mark",   Abc_CommandAbc9EquivMark,    0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&equiv_filter", Abc_CommandAbc9EquivFilter,  0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&cec",          Abc_CommandAbc9Cec,          0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&verify",       Abc_CommandAbc9Verify,       0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&sweep",        Abc_CommandAbc9Sweep,        0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&force",        Abc_CommandAbc9Force,        0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&embed",        Abc_CommandAbc9Embed,        0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&sopb",         Abc_CommandAbc9Sopb,         0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&dsdb",         Abc_CommandAbc9Dsdb,         0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&flow",         Abc_CommandAbc9Flow,         0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&if",           Abc_CommandAbc9If,           0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&iff",          Abc_CommandAbc9Iff,          0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&if2",          Abc_CommandAbc9If2,          0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&jf",           Abc_CommandAbc9Jf,           0 );
-#ifdef ABC_USE_PTHREADS
-    Cmd_CommandAdd( pAbc, "ABC9",         "&kf",           Abc_CommandAbc9Kf,           0 );
-#endif
-    Cmd_CommandAdd( pAbc, "ABC9",         "&lf",           Abc_CommandAbc9Lf,           0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&mf",           Abc_CommandAbc9Mf,           0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&nf",           Abc_CommandAbc9Nf,           0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&unmap",        Abc_CommandAbc9Unmap,        0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&struct",       Abc_CommandAbc9Struct,       0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&trace",        Abc_CommandAbc9Trace,        0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&speedup",      Abc_CommandAbc9Speedup,      0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&era",          Abc_CommandAbc9Era,          0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&dch",          Abc_CommandAbc9Dch,          0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&rpm",          Abc_CommandAbc9Rpm,          0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&back_reach",   Abc_CommandAbc9BackReach,    0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&posplit",      Abc_CommandAbc9Posplit,      0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&reachm",       Abc_CommandAbc9ReachM,       0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&reachp",       Abc_CommandAbc9ReachP,       0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&reachn",       Abc_CommandAbc9ReachN,       0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&reachy",       Abc_CommandAbc9ReachY,       0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&undo",         Abc_CommandAbc9Undo,         0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&iso",          Abc_CommandAbc9Iso,          0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&cexinfo",      Abc_CommandAbc9CexInfo,      0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&cycle",        Abc_CommandAbc9Cycle,        0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&cone",         Abc_CommandAbc9Cone,         0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&slice",        Abc_CommandAbc9Slice,        0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&popart",       Abc_CommandAbc9PoPart,       0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&gprove",       Abc_CommandAbc9GroupProve,   0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&mprove",       Abc_CommandAbc9MultiProve,   0 );
-#ifdef ABC_USE_PTHREADS
-    Cmd_CommandAdd( pAbc, "ABC9",         "&splitprove",   Abc_CommandAbc9SplitProve,   0 );
-#endif
-    Cmd_CommandAdd( pAbc, "ABC9",         "&bmc",          Abc_CommandAbc9Bmc,          0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&bcore",        Abc_CommandAbc9BCore,        0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&icheck",       Abc_CommandAbc9ICheck,       0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&sattest",      Abc_CommandAbc9SatTest,      0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&fftest",       Abc_CommandAbc9FFTest,       0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&inse",         Abc_CommandAbc9Inse,         0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&maxi",         Abc_CommandAbc9Maxi,         0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&bmci",         Abc_CommandAbc9Bmci,         0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&poxsim",       Abc_CommandAbc9PoXsim,       0 );
-    Cmd_CommandAdd( pAbc, "ABC9",         "&demiter",      Abc_CommandAbc9Demiter,      0 );
-//    Cmd_CommandAdd( pAbc, "ABC9",         "&popart2",      Abc_CommandAbc9PoPart2,      0 );
-//    Cmd_CommandAdd( pAbc, "ABC9",         "&cexcut",       Abc_CommandAbc9CexCut,       0 );
-//    Cmd_CommandAdd( pAbc, "ABC9",         "&cexmerge",     Abc_CommandAbc9CexMerge,     0 );
-//    Cmd_CommandAdd( pAbc, "ABC9",         "&cexmin",       Abc_CommandAbc9CexMin,       0 );
-
-    Cmd_CommandAdd( pAbc, "Abstraction",  "&abs_derive",   Abc_CommandAbc9AbsDerive,    0 );
-    Cmd_CommandAdd( pAbc, "Abstraction",  "&abs_refine",   Abc_CommandAbc9AbsRefine,    0 );
-    Cmd_CommandAdd( pAbc, "Abstraction",  "&gla_derive",   Abc_CommandAbc9GlaDerive,    0 );
-    Cmd_CommandAdd( pAbc, "Abstraction",  "&gla_refine",   Abc_CommandAbc9GlaRefine,    0 );
-    Cmd_CommandAdd( pAbc, "Abstraction",  "&gla_shrink",   Abc_CommandAbc9GlaShrink,    0 );
-    Cmd_CommandAdd( pAbc, "Abstraction",  "&gla",          Abc_CommandAbc9Gla,          0 );
-    Cmd_CommandAdd( pAbc, "Abstraction",  "&vta",          Abc_CommandAbc9Vta,          0 );
-    Cmd_CommandAdd( pAbc, "Abstraction",  "&vta_gla",      Abc_CommandAbc9Vta2Gla,      0 );
-    Cmd_CommandAdd( pAbc, "Abstraction",  "&gla_vta",      Abc_CommandAbc9Gla2Vta,      0 );
-    Cmd_CommandAdd( pAbc, "Abstraction",  "&fla_gla",      Abc_CommandAbc9Fla2Gla,      0 );
-    Cmd_CommandAdd( pAbc, "Abstraction",  "&gla_fla",      Abc_CommandAbc9Gla2Fla,      0 );
-
-    Cmd_CommandAdd( pAbc, "Liveness",     "l2s",           Abc_CommandAbcLivenessToSafety,        0 );
-    Cmd_CommandAdd( pAbc, "Liveness",     "l2ssim",        Abc_CommandAbcLivenessToSafetySim,     0 );
-    Cmd_CommandAdd( pAbc, "Liveness",     "l3s",           Abc_CommandAbcLivenessToSafetyWithLTL, 0 );
-    Cmd_CommandAdd( pAbc, "Liveness",     "kcs",           Abc_CommandCS_kLiveness,               0 );
-    Cmd_CommandAdd( pAbc, "Liveness",     "nck",           Abc_CommandNChooseK,                   0 );
-
-    Cmd_CommandAdd( pAbc, "ABC9",         "&test",         Abc_CommandAbc9Test,         0 );
-    {
-//        extern Mf_ManTruthCount();
-//        Mf_ManTruthCount();
-    }
-
-    {
-        extern void Dar_LibStart();
-        Dar_LibStart();
-    }
-    {
-//        extern void Dau_DsdTest();
-//        Dau_DsdTest();
-//        extern void If_ManSatTest();
-//        If_ManSatTest();
-    }
-
-    if ( Sdm_ManCanRead() )
-        Sdm_ManRead();
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-void Abc_End( Abc_Frame_t * pAbc )
-{
-    extern Abc_Frame_t * Abc_FrameGetGlobalFrame();
-    Abc_FrameClearDesign();
-    Cnf_ManFree();
-    {
-        extern int Abc_NtkCompareAndSaveBest( Abc_Ntk_t * pNtk );
-        Abc_NtkCompareAndSaveBest( NULL );
-    }
-    {
-        extern void Dar_LibStop();
-        Dar_LibStop();
-    }
-    {
-        extern void Aig_RManQuit();
-        Aig_RManQuit();
-    }
-    {
-        extern void Npn_ManClean();
-        Npn_ManClean();
-    }
-    {
-        extern void Sdm_ManQuit();
-        Sdm_ManQuit();
-    }
-    Abc_NtkFraigStoreClean();
-    if ( Abc_FrameGetGlobalFrame()->pGia )
-        Gia_ManStop( Abc_FrameGetGlobalFrame()->pGia );
-    if ( Abc_FrameGetGlobalFrame()->pGia2 )
-        Gia_ManStop( Abc_FrameGetGlobalFrame()->pGia2 );
-    if ( Abc_FrameGetGlobalFrame()->pGiaBest )
-        Gia_ManStop( Abc_FrameGetGlobalFrame()->pGiaBest );
-    if ( Abc_NtkRecIsRunning3() )
-        Abc_NtkRecStop3();
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandPrintStats( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int fFactor;
-    int fSaveBest;
-    int fDumpResult;
-    int fUseLutLib;
-    int fPrintTime;
-    int fPrintMuxes;
-    int fPower;
-    int fGlitch;
-    int fSkipBuf;
-    int c;
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-
-    // set the defaults
-    fFactor   = 0;
-    fSaveBest = 0;
-    fDumpResult = 0;
-    fUseLutLib = 0;
-    fPrintTime = 0;
-    fPrintMuxes = 0;
-    fPower = 0;
-    fGlitch = 0;
-    fSkipBuf = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "fbdltmpgsh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'f':
-            fFactor ^= 1;
-            break;
-        case 'b':
-            fSaveBest ^= 1;
-            break;
-        case 'd':
-            fDumpResult ^= 1;
-            break;
-        case 'l':
-            fUseLutLib ^= 1;
-            break;
-        case 't':
-            fPrintTime ^= 1;
-            break;
-        case 'm':
-            fPrintMuxes ^= 1;
-            break;
-        case 'p':
-            fPower ^= 1;
-            break;
-        case 'g':
-            fGlitch ^= 1;
-            break;
-        case 's':
-            fSkipBuf ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsLogic(pNtk) && fUseLutLib )
-    {
-        Abc_Print( -1, "Cannot print LUT delay for a non-logic network.\n" );
-        return 1;
-    }
-    Abc_NtkPrintStats( pNtk, fFactor, fSaveBest, fDumpResult, fUseLutLib, fPrintMuxes, fPower, fGlitch, fSkipBuf );
-    if ( fPrintTime )
-    {
-        pAbc->TimeTotal += pAbc->TimeCommand;
-        Abc_Print( 1, "elapse: %3.2f seconds, total: %3.2f seconds\n", pAbc->TimeCommand, pAbc->TimeTotal );
-        pAbc->TimeCommand = 0.0;
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: print_stats [-fbdltmpgsh]\n" );
-    Abc_Print( -2, "\t        prints the network statistics\n" );
-    Abc_Print( -2, "\t-f    : toggles printing the literal count in the factored forms [default = %s]\n", fFactor? "yes": "no" );
-    Abc_Print( -2, "\t-b    : toggles saving the best logic network in \"best.blif\" [default = %s]\n", fSaveBest? "yes": "no" );
-    Abc_Print( -2, "\t-d    : toggles dumping network into file \"<input_file_name>_dump.blif\" [default = %s]\n", fDumpResult? "yes": "no" );
-    Abc_Print( -2, "\t-l    : toggles printing delay of LUT mapping using LUT library [default = %s]\n", fSaveBest? "yes": "no" );
-    Abc_Print( -2, "\t-t    : toggles printing runtime statistics [default = %s]\n", fPrintTime? "yes": "no" );
-    Abc_Print( -2, "\t-m    : toggles printing MUX statistics [default = %s]\n", fPrintMuxes? "yes": "no" );
-    Abc_Print( -2, "\t-p    : toggles printing power dissipation due to switching [default = %s]\n", fPower? "yes": "no" );
-    Abc_Print( -2, "\t-g    : toggles printing percentage of increased power due to glitching [default = %s]\n", fGlitch? "yes": "no" );
-    Abc_Print( -2, "\t-s    : toggles not counting single-output nodes as nodes [default = %s]\n", fSkipBuf? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandPrintExdc( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkTemp;
-    double Percentage;
-    int fShort;
-    int c;
-    int fPrintDc;
-    extern double Abc_NtkSpacePercentage( Abc_Obj_t * pNode );
-    pNtk = Abc_FrameReadNtk(pAbc);
-
-    // set the defaults
-    fShort  = 1;
-    fPrintDc = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "sdh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 's':
-            fShort ^= 1;
-            break;
-        case 'd':
-            fPrintDc ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( pNtk->pExdc == NULL )
-    {
-        Abc_Print( -1, "Network has no EXDC.\n" );
-        return 1;
-    }
-
-    if ( fPrintDc )
-    {
-        if ( !Abc_NtkIsStrash(pNtk->pExdc) )
-        {
-            pNtkTemp = Abc_NtkStrash(pNtk->pExdc, 0, 0, 0);
-            Percentage = Abc_NtkSpacePercentage( Abc_ObjChild0( Abc_NtkPo(pNtkTemp, 0) ) );
-            Abc_NtkDelete( pNtkTemp );
-        }
-        else
-            Percentage = Abc_NtkSpacePercentage( Abc_ObjChild0( Abc_NtkPo(pNtk->pExdc, 0) ) );
-
-        Abc_Print( 1, "EXDC network statistics: " );
-        Abc_Print( 1, "(" );
-        if ( Percentage > 0.05 && Percentage < 99.95 )
-            Abc_Print( 1, "%.2f", Percentage );
-        else if ( Percentage > 0.000005 && Percentage < 99.999995 )
-            Abc_Print( 1, "%.6f", Percentage );
-        else
-            Abc_Print( 1, "%f", Percentage );
-        Abc_Print( 1, " %% don't-cares)\n" );
-    }
-    else
-        Abc_Print( 1, "EXDC network statistics: \n" );
-    Abc_NtkPrintStats( pNtk->pExdc, 0, 0, 0, 0, 0, 0, 0, 0 );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: print_exdc [-dh]\n" );
-    Abc_Print( -2, "\t        prints the EXDC network statistics\n" );
-    Abc_Print( -2, "\t-d    : toggles printing don't-care percentage [default = %s]\n", fPrintDc? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandPrintIo( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    Abc_Obj_t * pNode;
-    int c, fPrintFlops = 1;
-
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "fh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'f':
-            fPrintFlops ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( argc > globalUtilOptind + 1 )
-    {
-        Abc_Print( -1, "Wrong number of auguments.\n" );
-        goto usage;
-    }
-
-    if ( argc == globalUtilOptind + 1 )
-    {
-        pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
-        if ( pNode == NULL )
-        {
-            Abc_Print( -1, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
-            return 1;
-        }
-        Abc_NodePrintFanio( stdout, pNode );
-        return 0;
-    }
-    // print the nodes
-    Abc_NtkPrintIo( stdout, pNtk, fPrintFlops );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: print_io [-fh] <node>\n" );
-    Abc_Print( -2, "\t        prints the PIs/POs/flops or fanins/fanouts of a node\n" );
-    Abc_Print( -2, "\t-f    : toggles printing flops [default = %s]\n", fPrintFlops? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    Abc_Print( -2, "\tnode  : the node to print fanins/fanouts\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandPrintLatch( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int fPrintSccs;
-    extern void Abc_NtkPrintSccs( Abc_Ntk_t * pNtk, int fVerbose );
-
-    // set defaults
-    fPrintSccs = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "sh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 's':
-            fPrintSccs ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    // print the nodes
-    Abc_NtkPrintLatch( stdout, pNtk );
-    if ( fPrintSccs )
-        Abc_NtkPrintSccs( pNtk, 0 );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: print_latch [-sh]\n" );
-    Abc_Print( -2, "\t        prints information about latches\n" );
-    Abc_Print( -2, "\t-s    : toggles printing SCCs of registers [default = %s]\n", fPrintSccs? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandPrintFanio( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int fUsePis   = 0;
-    int fMffc     = 0;
-    int fVerbose  = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "imvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'i':
-            fUsePis ^= 1;
-            break;
-        case 'm':
-            fMffc ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    // print the nodes
-    if ( fVerbose )
-        Abc_NtkPrintFanio( stdout, pNtk, fUsePis );
-    else
-        Abc_NtkPrintFanioNew( stdout, pNtk, fMffc );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: print_fanio [-imvh]\n" );
-    Abc_Print( -2, "\t        prints the statistics about fanins/fanouts of all nodes\n" );
-    Abc_Print( -2, "\t-i    : toggles considering fanouts of primary inputs only [default = %s]\n", fUsePis? "yes": "no" );
-    Abc_Print( -2, "\t-m    : toggles printing MFFC sizes instead of fanouts [default = %s]\n", fMffc? "yes": "no" );
-    Abc_Print( -2, "\t-v    : toggles verbose way of printing the stats [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandPrintMffc( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    extern void Abc_NtkPrintMffc( FILE * pFile, Abc_Ntk_t * pNtk );
-
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    // print the nodes
-    Abc_NtkPrintMffc( stdout, pNtk );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: print_mffc [-h]\n" );
-    Abc_Print( -2, "\t        prints the MFFC of each node in the network\n" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandPrintFactor( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    Abc_Obj_t * pNode;
-    int c;
-    int fUseRealNames;
-
-    // set defaults
-    fUseRealNames = 1;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "nh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'n':
-            fUseRealNames ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsSopLogic(pNtk) )
-    {
-        Abc_Print( -1, "Printing factored forms can be done for SOP networks.\n" );
-        return 1;
-    }
-
-    if ( argc > globalUtilOptind + 1 )
-    {
-        Abc_Print( -1, "Wrong number of auguments.\n" );
-        goto usage;
-    }
-
-    if ( argc == globalUtilOptind + 1 )
-    {
-        pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
-        if ( pNode == NULL )
-        {
-            Abc_Print( -1, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
-            return 1;
-        }
-        Abc_NodePrintFactor( stdout, pNode, fUseRealNames );
-        return 0;
-    }
-    // print the nodes
-    Abc_NtkPrintFactor( stdout, pNtk, fUseRealNames );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: print_factor [-nh] <node>\n" );
-    Abc_Print( -2, "\t        prints the factored forms of nodes\n" );
-    Abc_Print( -2, "\t-n    : toggles real/dummy fanin names [default = %s]\n", fUseRealNames? "real": "dummy" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    Abc_Print( -2, "\tnode  : (optional) one node to consider\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandPrintLevel( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    Abc_Obj_t * pNode;
-    int c;
-    int fListNodes;
-    int fProfile;
-    int fVerbose;
-
-    // set defaults
-    fListNodes = 0;
-    fProfile   = 1;
-    fVerbose   = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "npvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'n':
-            fListNodes ^= 1;
-            break;
-        case 'p':
-            fProfile ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( !fProfile && !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for AIGs (run \"strash\").\n" );
-        return 1;
-    }
-
-    if ( argc > globalUtilOptind + 1 )
-    {
-        Abc_Print( -1, "Wrong number of auguments.\n" );
-        goto usage;
-    }
-
-    if ( argc == globalUtilOptind + 1 )
-    {
-        pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
-        if ( pNode == NULL )
-        {
-            Abc_Print( -1, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
-            return 1;
-        }
-        Abc_NodePrintLevel( stdout, pNode );
-        return 0;
-    }
-    // process all COs
-    Abc_NtkPrintLevel( stdout, pNtk, fProfile, fListNodes, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: print_level [-npvh] <node>\n" );
-    Abc_Print( -2, "\t        prints information about node level and cone size\n" );
-    Abc_Print( -2, "\t-n    : toggles printing nodes by levels [default = %s]\n", fListNodes? "yes": "no" );
-    Abc_Print( -2, "\t-p    : toggles printing level profile [default = %s]\n", fProfile? "yes": "no" );
-    Abc_Print( -2, "\t-v    : enable verbose output [default = %s].\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    Abc_Print( -2, "\tnode  : (optional) one node to consider\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandPrintSupport( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Vec_Ptr_t * vSuppFun;
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int fStruct;
-    int fVerbose;
-    int fVeryVerbose;
-    extern Vec_Ptr_t * Sim_ComputeFunSupp( Abc_Ntk_t * pNtk, int fVerbose );
-    extern void Abc_NtkPrintStrSupports( Abc_Ntk_t * pNtk, int fMatrix );
-
-    // set defaults
-    fStruct = 1;
-    fVerbose = 0;
-    fVeryVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "svwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 's':
-            fStruct ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'w':
-            fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    // print support information
-    if ( fStruct )
-    {
-        Abc_NtkPrintStrSupports( pNtk, fVeryVerbose );
-        return 0;
-    }
-
-    if ( !Abc_NtkIsComb(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for combinational networks (run \"comb\").\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for AIGs (run \"strash\").\n" );
-        return 1;
-    }
-    vSuppFun = Sim_ComputeFunSupp( pNtk, fVerbose );
-    ABC_FREE( vSuppFun->pArray[0] );
-    Vec_PtrFree( vSuppFun );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: print_supp [-svwh]\n" );
-    Abc_Print( -2, "\t        prints the supports of the CO nodes\n" );
-    Abc_Print( -2, "\t-s    : toggle printing structural support only [default = %s].\n", fStruct? "yes": "no" );
-    Abc_Print( -2, "\t-v    : enable verbose output [default = %s].\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w    : enable printing CI/CO dependency matrix [default = %s].\n", fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandPrintSymms( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int fUseBdds;
-    int fNaive;
-    int fReorder;
-    int fVerbose;
-    extern void Abc_NtkSymmetries( Abc_Ntk_t * pNtk, int fUseBdds, int fNaive, int fReorder, int fVerbose );
-
-    // set defaults
-    fUseBdds = 0;
-    fNaive   = 0;
-    fReorder = 1;
-    fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "bnrvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'b':
-            fUseBdds ^= 1;
-            break;
-        case 'n':
-            fNaive ^= 1;
-            break;
-        case 'r':
-            fReorder ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsComb(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for combinational networks (run \"comb\").\n" );
-        return 1;
-    }
-    if ( Abc_NtkIsStrash(pNtk) )
-        Abc_NtkSymmetries( pNtk, fUseBdds, fNaive, fReorder, fVerbose );
-    else
-    {
-        pNtk = Abc_NtkStrash( pNtk, 0, 0, 0 );
-        Abc_NtkSymmetries( pNtk, fUseBdds, fNaive, fReorder, fVerbose );
-        Abc_NtkDelete( pNtk );
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: print_symm [-bnrvh]\n" );
-    Abc_Print( -2, "\t         computes symmetries of the PO functions\n" );
-    Abc_Print( -2, "\t-b     : toggle BDD-based or SAT-based computations [default = %s].\n", fUseBdds? "BDD": "SAT" );
-    Abc_Print( -2, "\t-n     : enable naive BDD-based computation [default = %s].\n", fNaive? "yes": "no" );
-    Abc_Print( -2, "\t-r     : enable dynamic BDD variable reordering [default = %s].\n", fReorder? "yes": "no" );
-    Abc_Print( -2, "\t-v     : enable verbose output [default = %s].\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandPrintUnate( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int fUseBdds;
-    int fUseNaive;
-    int fVerbose;
-    extern void Abc_NtkPrintUnate( Abc_Ntk_t * pNtk, int fUseBdds, int fUseNaive, int fVerbose );
-
-    // set defaults
-    fUseBdds  = 1;
-    fUseNaive = 0;
-    fVerbose  = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "bnvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'b':
-            fUseBdds ^= 1;
-            break;
-        case 'n':
-            fUseNaive ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for AIGs (run \"strash\").\n" );
-        return 1;
-    }
-    Abc_NtkPrintUnate( pNtk, fUseBdds, fUseNaive, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: print_unate [-bnvh]\n" );
-    Abc_Print( -2, "\t         computes unate variables of the PO functions\n" );
-    Abc_Print( -2, "\t-b     : toggle BDD-based or SAT-based computations [default = %s].\n", fUseBdds? "BDD": "SAT" );
-    Abc_Print( -2, "\t-n     : toggle naive BDD-based computation [default = %s].\n", fUseNaive? "yes": "no" );
-    Abc_Print( -2, "\t-v     : enable verbose output [default = %s].\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandPrintAuto( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int Output;
-    int fNaive;
-    int fVerbose;
-    extern void Abc_NtkAutoPrint( Abc_Ntk_t * pNtk, int Output, int fNaive, int fVerbose );
-
-    // set defaults
-    Output   = -1;
-    fNaive   = 0;
-    fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Onvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'O':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-O\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            Output = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( Output < 0 )
-                goto usage;
-            break;
-        case 'n':
-            fNaive ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for AIGs (run \"strash\").\n" );
-        return 1;
-    }
-
-
-    Abc_NtkAutoPrint( pNtk, Output, fNaive, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: print_auto [-O <num>] [-nvh]\n" );
-    Abc_Print( -2, "\t           computes autosymmetries of the PO functions\n" );
-    Abc_Print( -2, "\t-O <num> : (optional) the 0-based number of the output [default = all]\n");
-    Abc_Print( -2, "\t-n       : enable naive BDD-based computation [default = %s].\n", fNaive? "yes": "no" );
-    Abc_Print( -2, "\t-v       : enable verbose output [default = %s].\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandPrintKMap( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    Abc_Obj_t * pNode;
-    int c;
-    int fUseRealNames;
-
-    extern void Abc_NodePrintKMap( Abc_Obj_t * pNode, int fUseRealNames );
-
-    // set defaults
-    fUseRealNames = 1;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "nh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'n':
-            fUseRealNames ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( argc == globalUtilOptind + 2 )
-    {
-        Abc_NtkShow6VarFunc( argv[globalUtilOptind], argv[globalUtilOptind+1] );
-        return 0;
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsLogic(pNtk) )
-    {
-        Abc_Print( -1, "Visualization of Karnaugh maps works for logic networks.\n" );
-        return 1;
-    }
-    if ( argc > globalUtilOptind + 1 )
-    {
-        Abc_Print( -1, "Wrong number of auguments.\n" );
-        goto usage;
-    }
-    if ( argc == globalUtilOptind )
-    {
-        pNode = Abc_ObjFanin0( Abc_NtkPo(pNtk, 0) );
-        if ( !Abc_ObjIsNode(pNode) )
-        {
-            Abc_Print( -1, "The driver \"%s\" of the first PO is not an internal node.\n", Abc_ObjName(pNode) );
-            return 1;
-        }
-    }
-    else
-    {
-        pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
-        if ( pNode == NULL )
-        {
-            Abc_Print( -1, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
-            return 1;
-        }
-    }
-    Abc_NtkToBdd(pNtk);
-    Abc_NodePrintKMap( pNode, fUseRealNames );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: print_kmap [-nh] <node>\n" );
-    Abc_Print( -2, "\t        shows the truth table of the node\n" );
-    Abc_Print( -2, "\t-n    : toggles real/dummy fanin names [default = %s]\n", fUseRealNames? "real": "dummy" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    Abc_Print( -2, "\t<node>: the node to consider (default = the driver of the first PO)\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandPrintGates( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int fUseLibrary;
-
-    extern void Abc_NtkPrintGates( Abc_Ntk_t * pNtk, int fUseLibrary );
-
-    // set defaults
-    fUseLibrary = 1;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "lh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'l':
-            fUseLibrary ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( Abc_NtkHasAig(pNtk) )
-    {
-        Abc_Print( -1, "Printing gates does not work for AIGs and sequential AIGs.\n" );
-        return 1;
-    }
-
-    Abc_NtkPrintGates( pNtk, fUseLibrary );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: print_gates [-lh]\n" );
-    Abc_Print( -2, "\t        prints statistics about gates used in the network\n" );
-    Abc_Print( -2, "\t-l    : used library gate names (if mapped) [default = %s]\n", fUseLibrary? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandPrintSharing( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int fUseLibrary;
-
-    extern void Abc_NtkPrintSharing( Abc_Ntk_t * pNtk );
-
-    // set defaults
-    fUseLibrary = 1;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "lh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'l':
-            fUseLibrary ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    Abc_NtkPrintSharing( pNtk );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: print_sharing [-h]\n" );
-    Abc_Print( -2, "\t        prints the number of shared nodes in the TFI cones of the COs\n" );
-//    Abc_Print( -2, "\t-l    : used library gate names (if mapped) [default = %s]\n", fUseLibrary? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandPrintXCut( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int fUseLibrary;
-
-    extern int Abc_NtkCrossCut( Abc_Ntk_t * pNtk );
-
-    // set defaults
-    fUseLibrary = 1;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "lh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'l':
-            fUseLibrary ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    Abc_NtkCrossCut( pNtk );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: print_xcut [-h]\n" );
-    Abc_Print( -2, "\t        prints the size of the cross cut of the current network\n" );
-//    Abc_Print( -2, "\t-l    : used library gate names (if mapped) [default = %s]\n", fUseLibrary? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandPrintDsd( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int fCofactor;
-    int nCofLevel;
-    int fProfile;
-    int fPrintDec;
-
-    extern void Kit_DsdTest( unsigned * pTruth, int nVars );
-    extern void Kit_DsdPrintCofactors( unsigned * pTruth, int nVars, int nCofLevel, int fVerbose );
-    extern void Dau_DecTrySets( word * p, int nVars, int fVerbose );
-
-    // set defaults
-    nCofLevel = 1;
-    fCofactor = 0;
-    fProfile  = 0;
-    fPrintDec = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Npcdh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nCofLevel = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nCofLevel < 0 )
-                goto usage;
-            break;
-        case 'p':
-            fProfile ^= 1;
-            break;
-        case 'c':
-            fCofactor ^= 1;
-            break;
-        case 'd':
-            fPrintDec ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    // get the truth table of the first output
-    if ( !Abc_NtkIsLogic(pNtk) )
-    {
-        Abc_Print( -1, "Currently works only for logic networks.\n" );
-        return 1;
-    }
-    Abc_NtkToAig( pNtk );
-    // convert it to truth table
-    {
-        Abc_Obj_t * pObj = Abc_ObjFanin0( Abc_NtkPo(pNtk, 0) );
-        Vec_Int_t * vMemory;
-        unsigned * pTruth;
-        if ( !Abc_ObjIsNode(pObj) )
-        {
-            Abc_Print( -1, "The fanin of the first PO node does not have a logic function.\n" );
-            return 1;
-        }
-        if ( Abc_ObjFaninNum(pObj) > 16 )
-        {
-            Abc_Print( -1, "Currently works only for up to 16 inputs.\n" );
-            return 1;
-        }
-        vMemory = Vec_IntAlloc(0);
-        pTruth = Hop_ManConvertAigToTruth( (Hop_Man_t *)pNtk->pManFunc, Hop_Regular((Hop_Obj_t *)pObj->pData), Abc_ObjFaninNum(pObj), vMemory, 0 );
-        if ( Hop_IsComplement((Hop_Obj_t *)pObj->pData) )
-            Extra_TruthNot( pTruth, pTruth, Abc_ObjFaninNum(pObj) );
-//        Extra_PrintBinary( stdout, pTruth, 1 << Abc_ObjFaninNum(pObj) );
-//        Abc_Print( -1, "\n" );
-        if ( fPrintDec )//&&Abc_ObjFaninNum(pObj) <= 6 )
-        {
-            word * pTruthW = (word *)pTruth;
-            if ( Abc_ObjFaninNum(pObj) < 6 )
-                pTruthW[0] = Abc_Tt6Stretch( pTruthW[0], Abc_ObjFaninNum(pObj) );
-            Dau_DecTrySets( (word *)pTruth, Abc_ObjFaninNum(pObj), 1 );
-        }
-        if ( fProfile )
-            Kit_TruthPrintProfile( pTruth, Abc_ObjFaninNum(pObj) );
-        else if ( fCofactor )
-            Kit_DsdPrintCofactors( pTruth, Abc_ObjFaninNum(pObj), nCofLevel, 1 );
-        else
-            Kit_DsdTest( pTruth, Abc_ObjFaninNum(pObj) );
-        Vec_IntFree( vMemory );
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: print_dsd [-pcdh] [-N <num>]\n" );
-    Abc_Print( -2, "\t           print DSD formula for a single-output function with less than 16 variables\n" );
-    Abc_Print( -2, "\t-p       : toggle printing profile [default = %s]\n", fProfile? "yes": "no" );
-    Abc_Print( -2, "\t-c       : toggle recursive cofactoring [default = %s]\n", fCofactor? "yes": "no" );
-    Abc_Print( -2, "\t-d       : toggle printing decompositions [default = %s]\n", fPrintDec? "yes": "no" );
-    Abc_Print( -2, "\t-N <num> : the number of levels to cofactor [default = %d]\n", nCofLevel );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandPrintCone( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int fUseLibrary;
-
-    // set defaults
-    fUseLibrary = 1;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "lh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'l':
-            fUseLibrary ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( Abc_NtkLatchNum(pNtk) == 0 )
-    {
-        Abc_Print( -1, "The network is combinational.\n" );
-        return 1;
-    }
-    Abc_NtkDarPrintCone( pNtk );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: print_cone [-h]\n" );
-    Abc_Print( -2, "\t        prints cones of influence info for each primary output\n" );
-//    Abc_Print( -2, "\t-l    : used library gate names (if mapped) [default = %s]\n", fUseLibrary? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandPrintMiter( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int fUseLibrary;
-
-    extern void Abc_NtkPrintMiter( Abc_Ntk_t * pNtk );
-
-    // set defaults
-    fUseLibrary = 1;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "lh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'l':
-            fUseLibrary ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "The network is should be structurally hashed.\n" );
-        return 1;
-    }
-    Abc_NtkPrintMiter( pNtk );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: print_miter [-h]\n" );
-    Abc_Print( -2, "\t        prints the status of the miter\n" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandPrintStatus( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    int c, fShort = 1;
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "sh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 's':
-            fShort ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    Abc_Print( 1,"Status = %d  Frames = %d   ", pAbc->Status, pAbc->nFrames );
-    if ( pAbc->pCex == NULL && pAbc->vCexVec == NULL )
-        Abc_Print( 1,"Cex is not defined.\n" );
-    else
-    {
-        if ( pAbc->pCex )
-            Abc_CexPrintStats( pAbc->pCex );
-        if ( pAbc->vCexVec )
-        {
-            Abc_Cex_t * pTemp;
-            int nCexes = 0;
-            int Counter = 0;
-            printf( "\n" );
-            Vec_PtrForEachEntry( Abc_Cex_t *, pAbc->vCexVec, pTemp, c )
-            {
-                if ( pTemp == (void *)(ABC_PTRINT_T)1 )
-                {
-                    Counter++;
-                    continue;
-                }
-                if ( pTemp )
-                {
-                    printf( "%4d : ", ++nCexes );
-                    Abc_CexPrintStats( pTemp );
-                }
-            }
-            if ( Counter )
-                printf( "In total, %d (out of %d) outputs are \"sat\" but CEXes are not recorded.\n", Counter, Vec_PtrSize(pAbc->vCexVec) );
-        }
-    }
-    if ( pAbc->vStatuses )
-    {
-        if ( fShort )
-        {
-            printf( "Status array contains %d SAT, %d UNSAT, and %d UNDEC entries (out of %d).", 
-                Vec_IntCountEntry(pAbc->vStatuses, 0), Vec_IntCountEntry(pAbc->vStatuses, 1), 
-                Vec_IntCountEntry(pAbc->vStatuses, -1), Vec_IntSize(pAbc->vStatuses) );
-        }
-        else
-        {
-            int i, Entry;
-            Vec_IntForEachEntry( pAbc->vStatuses, Entry, i )
-                printf( "%d=%d  ", i, Entry );
-        }
-        printf( "\n" );
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: print_status [-sh]\n" );
-    Abc_Print( -2, "\t        prints verification status\n" );
-    Abc_Print( -2, "\t-s    : toggle using short print-out [default = %s]\n", fShort? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandPrintDelay( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    Abc_Obj_t * pObjIn = NULL, * pObjOut = NULL;
-    int c;
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsMappedLogic(pNtk) )
-    {
-        Abc_Print( -1, "Delay trace works only for network mapped into standard cells.\n" );
-        return 1;
-    }
-    if ( argc > globalUtilOptind + 2 )
-    {
-        Abc_Print( -1, "Wrong number of auguments.\n" );
-        goto usage;
-    }
-    // collect the first name (PO name)
-    if ( argc >= globalUtilOptind + 1 )
-    {
-        int Num = Nm_ManFindIdByName( pNtk->pManName, argv[globalUtilOptind], ABC_OBJ_PO );
-        if ( Num < 0 )
-            Num = Nm_ManFindIdByName( pNtk->pManName, argv[globalUtilOptind], ABC_OBJ_BI );
-        if ( Num >= 0 )
-            pObjOut = Abc_NtkObj( pNtk, Num );
-        if ( pObjOut == NULL )
-        {
-            Abc_Print( 1, "Cannot find combinational output \"%s\".\n", argv[globalUtilOptind] );
-            return 1;
-        }
-    }
-    // collect the second name (PI name)
-    if ( argc == globalUtilOptind + 2 )
-    {
-        int Num = Nm_ManFindIdByName( pNtk->pManName, argv[globalUtilOptind+1], ABC_OBJ_PI );
-        if ( Num < 0 )
-            Num = Nm_ManFindIdByName( pNtk->pManName, argv[globalUtilOptind+1], ABC_OBJ_BO );
-        if ( Num >= 0 )
-            pObjIn = Abc_NtkObj( pNtk, Num );
-        if ( pObjIn == NULL )
-        {
-            Abc_Print( 1, "Cannot find combinational input \"%s\".\n", argv[globalUtilOptind+1] );
-            return 1;
-        }
-    }
-    Abc_NtkDelayTrace( pNtk, pObjOut, pObjIn, 1 );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: print_delay [-h] <CO_name> <CI_name>\n" );
-    Abc_Print( -2, "\t            prints one critical path of the mapped network\n" );
-    Abc_Print( -2, "\t-h        : print the command usage\n");
-    Abc_Print( -2, "\t<CO_name> : (optional) the sink of the critical path (primary output or flop input)\n");
-    Abc_Print( -2, "\t<CI_name> : (optional) the source of the critical path (primary input or flop output)\n");
-    Abc_Print( -2, "\t            (if CO and/or CI are not given, uses the most critical ones)\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandShow( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int fSeq;
-    int fGateNames;
-    int fUseReverse;
-    int fFlopDep;
-    extern void Abc_NtkShow( Abc_Ntk_t * pNtk, int fGateNames, int fSeq, int fUseReverse );
-    extern void Abc_NtkShowFlopDependency( Abc_Ntk_t * pNtk );
-
-    // set defaults
-    fSeq        = 0;
-    fGateNames  = 0;
-    fUseReverse = 1;
-    fFlopDep    = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "rsgfh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'r':
-            fUseReverse ^= 1;
-            break;
-        case 's':
-            fSeq ^= 1;
-            break;
-        case 'g':
-            fGateNames ^= 1;
-            break;
-        case 'f':
-            fFlopDep ^= 1;
-            break;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( fFlopDep )
-        Abc_NtkShowFlopDependency( pNtk );
-    else
-        Abc_NtkShow( pNtk, fGateNames, fSeq, fUseReverse );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: show [-srgfh]\n" );
-    Abc_Print( -2, "       visualizes the network structure using DOT and GSVIEW\n" );
-#ifdef WIN32
-    Abc_Print( -2, "       \"dot.exe\" and \"gsview32.exe\" should be set in the paths\n" );
-    Abc_Print( -2, "       (\"gsview32.exe\" may be in \"C:\\Program Files\\Ghostgum\\gsview\\\")\n" );
-#endif
-    Abc_Print( -2, "\t-s    : toggles visualization of sequential networks [default = %s].\n", fSeq? "yes": "no" );
-    Abc_Print( -2, "\t-r    : toggles ordering nodes in reverse order [default = %s].\n", fUseReverse? "yes": "no" );
-    Abc_Print( -2, "\t-g    : toggles printing gate names for mapped network [default = %s].\n", fGateNames? "yes": "no" );
-    Abc_Print( -2, "\t-f    : toggles visualizing flop dependency graph [default = %s].\n", fFlopDep? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandShowBdd( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    Abc_Obj_t * pNode;
-    int c;
-    extern void Abc_NodeShowBdd( Abc_Obj_t * pNode );
-
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsBddLogic(pNtk) )
-    {
-        Abc_Print( -1, "Visualizing BDDs can only be done for logic BDD networks (run \"bdd\").\n" );
-        return 1;
-    }
-
-    if ( argc > globalUtilOptind + 1 )
-    {
-        Abc_Print( -1, "Wrong number of auguments.\n" );
-        goto usage;
-    }
-    if ( argc == globalUtilOptind )
-    {
-        pNode = Abc_ObjFanin0( Abc_NtkPo(pNtk, 0) );
-        if ( !Abc_ObjIsNode(pNode) )
-        {
-            Abc_Print( -1, "The driver \"%s\" of the first PO is not an internal node.\n", Abc_ObjName(pNode) );
-            return 1;
-        }
-    }
-    else
-    {
-        pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
-        if ( pNode == NULL )
-        {
-            Abc_Print( -1, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
-            return 1;
-        }
-    }
-    Abc_NodeShowBdd( pNode );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: show_bdd [-h] <node>\n" );
-    Abc_Print( -2, "       visualizes the BDD of a node using DOT and GSVIEW\n" );
-#ifdef WIN32
-    Abc_Print( -2, "       \"dot.exe\" and \"gsview32.exe\" should be set in the paths\n" );
-    Abc_Print( -2, "       (\"gsview32.exe\" may be in \"C:\\Program Files\\Ghostgum\\gsview\\\")\n" );
-#endif
-    Abc_Print( -2, "\t<node>: the node to consider [default = the driver of the first PO]\n");
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandShowCut( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    Abc_Obj_t * pNode;
-    int c;
-    int nNodeSizeMax;
-    int nConeSizeMax;
-    extern void Abc_NodeShowCut( Abc_Obj_t * pNode, int nNodeSizeMax, int nConeSizeMax );
-
-    // set defaults
-    nNodeSizeMax = 10;
-    nConeSizeMax = ABC_INFINITY;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "NCh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nNodeSizeMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nNodeSizeMax < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nConeSizeMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nConeSizeMax < 0 )
-                goto usage;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Visualizing cuts only works for AIGs (run \"strash\").\n" );
-        return 1;
-    }
-    if ( argc != globalUtilOptind + 1 )
-    {
-        Abc_Print( -1, "Wrong number of auguments.\n" );
-        goto usage;
-    }
-
-    pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
-    if ( pNode == NULL )
-    {
-        Abc_Print( -1, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
-        return 1;
-    }
-    Abc_NodeShowCut( pNode, nNodeSizeMax, nConeSizeMax );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: show_cut [-N <num>] [-C <num>] [-h] <node>\n" );
-    Abc_Print( -2, "             visualizes the cut of a node using DOT and GSVIEW\n" );
-#ifdef WIN32
-    Abc_Print( -2, "             \"dot.exe\" and \"gsview32.exe\" should be set in the paths\n" );
-    Abc_Print( -2, "             (\"gsview32.exe\" may be in \"C:\\Program Files\\Ghostgum\\gsview\\\")\n" );
-#endif
-    Abc_Print( -2, "\t-N <num> : the max size of the cut to be computed [default = %d]\n", nNodeSizeMax );
-    Abc_Print( -2, "\t-C <num> : the max support of the containing cone [default = %d]\n", nConeSizeMax );
-    Abc_Print( -2, "\t<node>   : the node to consider\n");
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandCollapse( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int fVerbose;
-    int fBddSizeMax;
-    int fDualRail;
-    int fReorder;
-    int c;
-    pNtk = Abc_FrameReadNtk(pAbc);
-
-    // set defaults
-    fVerbose = 0;
-    fReorder = 1;
-    fDualRail = 0;
-    fBddSizeMax = ABC_INFINITY;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Brdvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'B':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            fBddSizeMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( fBddSizeMax < 0 )
-                goto usage;
-            break;
-        case 'd':
-            fDualRail ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'r':
-            fReorder ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsLogic(pNtk) && !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Can only collapse a logic network or an AIG.\n" );
-        return 1;
-    }
-
-    // get the new network
-    if ( Abc_NtkIsStrash(pNtk) )
-        pNtkRes = Abc_NtkCollapse( pNtk, fBddSizeMax, fDualRail, fReorder, fVerbose );
-    else
-    {
-        pNtk = Abc_NtkStrash( pNtk, 0, 0, 0 );
-        pNtkRes = Abc_NtkCollapse( pNtk, fBddSizeMax, fDualRail, fReorder, fVerbose );
-        Abc_NtkDelete( pNtk );
-    }
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Collapsing has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: collapse [-B <num>] [-rdvh]\n" );
-    Abc_Print( -2, "\t          collapses the network by constructing global BDDs\n" );
-    Abc_Print( -2, "\t-B <num>: limit on live BDD nodes during collapsing [default = %d]\n", fBddSizeMax );
-    Abc_Print( -2, "\t-r      : toggles dynamic variable reordering [default = %s]\n", fReorder? "yes": "no" );
-    Abc_Print( -2, "\t-d      : toggles dual-rail collapsing mode [default = %s]\n", fDualRail? "yes": "no" );
-    Abc_Print( -2, "\t-v      : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h      : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandStrash( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    Abc_Obj_t * pObj;
-    int c;
-    int fAllNodes;
-    int fRecord;
-    int fCleanup;
-    int fComplOuts;
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    fAllNodes = 0;
-    fCleanup  = 1;
-    fRecord   = 0;
-    fComplOuts= 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "acrih" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'a':
-            fAllNodes ^= 1;
-            break;
-        case 'c':
-            fCleanup ^= 1;
-            break;
-        case 'r':
-            fRecord ^= 1;
-            break;
-        case 'i':
-            fComplOuts ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    // get the new network
-    pNtkRes = Abc_NtkStrash( pNtk, fAllNodes, fCleanup, fRecord );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Strashing has failed.\n" );
-        return 1;
-    }
-    if ( fComplOuts )
-    Abc_NtkForEachPo( pNtkRes, pObj, c )
-        Abc_ObjXorFaninC( pObj, 0 );
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: strash [-acrih]\n" );
-    Abc_Print( -2, "\t        transforms combinational logic into an AIG\n" );
-    Abc_Print( -2, "\t-a    : toggles between using all nodes and DFS nodes [default = %s]\n", fAllNodes? "all": "DFS" );
-    Abc_Print( -2, "\t-c    : toggles cleanup to remove the dagling AIG nodes [default = %s]\n", fCleanup? "all": "DFS" );
-    Abc_Print( -2, "\t-r    : toggles using the record of AIG subgraphs [default = %s]\n", fRecord? "yes": "no" );
-    Abc_Print( -2, "\t-i    : toggles complementing the POs of the AIG [default = %s]\n", fComplOuts? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandBalance( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes, * pNtkTemp;
-    int c;
-    int fDuplicate;
-    int fSelective;
-    int fUpdateLevel;
-    int fExor;
-    int fVerbose;
-    pNtk = Abc_FrameReadNtk(pAbc);
-
-    // set defaults
-    fDuplicate   = 0;
-    fSelective   = 0;
-    fUpdateLevel = 1;
-    fExor        = 0;
-    fVerbose     = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "ldsxvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'l':
-            fUpdateLevel ^= 1;
-            break;
-        case 'd':
-            fDuplicate ^= 1;
-            break;
-        case 's':
-            fSelective ^= 1;
-            break;
-        case 'x':
-            fExor ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    // get the new network
-    if ( Abc_NtkIsStrash(pNtk) )
-    {
-        if ( fExor )
-            pNtkRes = Abc_NtkBalanceExor( pNtk, fUpdateLevel, fVerbose );
-        else
-            pNtkRes = Abc_NtkBalance( pNtk, fDuplicate, fSelective, fUpdateLevel );
-    }
-    else
-    {
-        pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
-        if ( pNtkTemp == NULL )
-        {
-            Abc_Print( -1, "Strashing before balancing has failed.\n" );
-            return 1;
-        }
-        if ( fExor )
-            pNtkRes = Abc_NtkBalanceExor( pNtkTemp, fUpdateLevel, fVerbose );
-        else
-            pNtkRes = Abc_NtkBalance( pNtkTemp, fDuplicate, fSelective, fUpdateLevel );
-        Abc_NtkDelete( pNtkTemp );
-    }
-
-    // check if balancing worked
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Balancing has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: balance [-ldsxvh]\n" );
-    Abc_Print( -2, "\t        transforms the current network into a well-balanced AIG\n" );
-    Abc_Print( -2, "\t-l    : toggle minimizing the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
-    Abc_Print( -2, "\t-d    : toggle duplication of logic [default = %s]\n", fDuplicate? "yes": "no" );
-    Abc_Print( -2, "\t-s    : toggle duplication on the critical paths [default = %s]\n", fSelective? "yes": "no" );
-    Abc_Print( -2, "\t-x    : toggle balancing multi-input EXORs [default = %s]\n", fExor? "yes": "no" );
-    Abc_Print( -2, "\t-v    : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandMuxStruct( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c;
-    int fVerbose;
-
-    extern Abc_Ntk_t * Abc_NtkMuxRestructure( Abc_Ntk_t * pNtk, int fVerbose );
-    pNtk = Abc_FrameReadNtk(pAbc);
-
-    // set defaults
-    fVerbose     = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    // get the new network
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Does not work for a logic network.\n" );
-        return 1;
-    }
-    // check if balancing worked
-//    pNtkRes = Abc_NtkMuxRestructure( pNtk, fVerbose );
-    pNtkRes = NULL;
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "MUX restructuring has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: mux_struct [-vh]\n" );
-    Abc_Print( -2, "\t        performs MUX restructuring of the current network\n" );
-    Abc_Print( -2, "\t-v    : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandMulti( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int nThresh, nFaninMax, c;
-    int fCnf;
-    int fMulti;
-    int fSimple;
-    int fFactor;
-    extern Abc_Ntk_t * Abc_NtkMulti( Abc_Ntk_t * pNtk, int nThresh, int nFaninMax, int fCnf, int fMulti, int fSimple, int fFactor );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-
-    // set defaults
-    nThresh   =  1;
-    nFaninMax = 20;
-    fCnf      =  0;
-    fMulti    =  1;
-    fSimple   =  0;
-    fFactor   =  0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "TFmcsfh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nThresh = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nThresh < 0 )
-                goto usage;
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFaninMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFaninMax < 0 )
-                goto usage;
-            break;
-        case 'c':
-            fCnf ^= 1;
-            break;
-        case 'm':
-            fMulti ^= 1;
-            break;
-        case 's':
-            fSimple ^= 1;
-            break;
-        case 'f':
-            fFactor ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Cannot renode a network that is not an AIG (run \"strash\").\n" );
-        return 1;
-    }
-
-    // get the new network
-    pNtkRes = Abc_NtkMulti( pNtk, nThresh, nFaninMax, fCnf, fMulti, fSimple, fFactor );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Renoding has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: multi [-TF <num>] [-msfch]\n" );
-    Abc_Print( -2, "\t          transforms an AIG into a logic network by creating larger nodes\n" );
-    Abc_Print( -2, "\t-F <num>: the maximum fanin size after renoding [default = %d]\n", nFaninMax );
-    Abc_Print( -2, "\t-T <num>: the threshold for AIG node duplication [default = %d]\n", nThresh );
-    Abc_Print( -2, "\t          (an AIG node is the root of a new node after renoding\n" );
-    Abc_Print( -2, "\t          if this leads to duplication of no more than %d AIG nodes,\n", nThresh );
-    Abc_Print( -2, "\t          that is, if [(numFanouts(Node)-1) * size(MFFC(Node))] <= %d)\n", nThresh );
-    Abc_Print( -2, "\t-m      : creates multi-input AND graph [default = %s]\n", fMulti? "yes": "no" );
-    Abc_Print( -2, "\t-s      : creates a simple AIG (no renoding) [default = %s]\n", fSimple? "yes": "no" );
-    Abc_Print( -2, "\t-f      : creates a factor-cut network [default = %s]\n", fFactor? "yes": "no" );
-    Abc_Print( -2, "\t-c      : performs renoding to derive the CNF [default = %s]\n", fCnf? "yes": "no" );
-    Abc_Print( -2, "\t-h      : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandRenode( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int nLutSize, nCutsMax, c;
-    int nFlowIters, nAreaIters;
-    int fArea;
-    int fUseBdds;
-    int fUseSops;
-    int fUseCnfs;
-    int fUseMv;
-    int fVerbose;
-    extern Abc_Ntk_t * Abc_NtkRenode( Abc_Ntk_t * pNtk, int nLutSize, int nCutsMax, int nFlowIters, int nAreaIters, int fArea, int fUseBdds, int fUseSops, int fUseCnfs, int fUseMv, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-
-    // set defaults
-    nLutSize   =  8;
-    nCutsMax   =  4;
-    nFlowIters =  1;
-    nAreaIters =  1;
-    fArea      =  0;
-    fUseBdds   =  0;
-    fUseSops   =  0;
-    fUseCnfs   =  0;
-    fUseMv     =  0;
-    fVerbose   =  0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "KCFAabscivh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nLutSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nLutSize < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nCutsMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nCutsMax < 0 )
-                goto usage;
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            nFlowIters = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFlowIters < 0 )
-                goto usage;
-            break;
-        case 'A':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-A\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            nAreaIters = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nAreaIters < 0 )
-                goto usage;
-            break;
-        case 'a':
-            fArea ^= 1;
-            break;
-        case 'b':
-            fUseBdds ^= 1;
-            break;
-        case 's':
-            fUseSops ^= 1;
-            break;
-        case 'c':
-            fUseCnfs ^= 1;
-            break;
-        case 'i':
-            fUseMv ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( fUseBdds + fUseSops + fUseCnfs + fUseMv > 1 )
-    {
-        Abc_Print( -1, "Cannot optimize two parameters at the same time.\n" );
-        return 1;
-    }
-
-    if ( nLutSize < 2 || nLutSize > IF_MAX_FUNC_LUTSIZE )
-    {
-        Abc_Print( -1, "Incorrect LUT size (%d).\n", nLutSize );
-        return 1;
-    }
-
-    if ( nCutsMax < 1 || nCutsMax >= (1<<12) )
-    {
-        Abc_Print( -1, "Incorrect number of cuts.\n" );
-        return 1;
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Cannot renode a network that is not an AIG (run \"strash\").\n" );
-        return 1;
-    }
-
-    // get the new network
-    pNtkRes = Abc_NtkRenode( pNtk, nLutSize, nCutsMax, nFlowIters, nAreaIters, fArea, fUseBdds, fUseSops, fUseCnfs, fUseMv, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Renoding has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: renode [-KCFA <num>] [-sbciav]\n" );
-    Abc_Print( -2, "\t          transforms the AIG into a logic network with larger nodes\n" );
-    Abc_Print( -2, "\t          while minimizing the number of FF literals of the node SOPs\n" );
-    Abc_Print( -2, "\t-K <num>: the max cut size for renoding (2 < num < %d) [default = %d]\n", IF_MAX_FUNC_LUTSIZE+1, nLutSize );
-    Abc_Print( -2, "\t-C <num>: the max number of cuts used at a node (0 < num < 2^12) [default = %d]\n", nCutsMax );
-    Abc_Print( -2, "\t-F <num>: the number of area flow recovery iterations (num >= 0) [default = %d]\n", nFlowIters );
-    Abc_Print( -2, "\t-A <num>: the number of exact area recovery iterations (num >= 0) [default = %d]\n", nAreaIters );
-    Abc_Print( -2, "\t-s      : toggles minimizing SOP cubes instead of FF lits [default = %s]\n", fUseSops? "yes": "no" );
-    Abc_Print( -2, "\t-b      : toggles minimizing BDD nodes instead of FF lits [default = %s]\n", fUseBdds? "yes": "no" );
-    Abc_Print( -2, "\t-c      : toggles minimizing CNF clauses instead of FF lits [default = %s]\n", fUseCnfs? "yes": "no" );
-    Abc_Print( -2, "\t-i      : toggles minimizing MV-SOP instead of FF lits [default = %s]\n", fUseMv? "yes": "no" );
-    Abc_Print( -2, "\t-a      : toggles area-oriented mapping [default = %s]\n", fArea? "yes": "no" );
-    Abc_Print( -2, "\t-v      : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h      : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandCleanup( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c;
-    int fCleanupPis;
-    int fCleanupPos;
-    int fVerbose;
-
-    extern Abc_Ntk_t * Abc_NtkDarCleanupAig( Abc_Ntk_t * pNtk, int fCleanupPis, int fCleanupPos, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-
-    // set defaults
-    fCleanupPis = 1;
-    fCleanupPos = 1;
-    fVerbose    = 1;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "iovh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'i':
-            fCleanupPis ^= 1;
-            break;
-        case 'o':
-            fCleanupPos ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( Abc_NtkIsStrash(pNtk) )
-    {
-        if ( !fCleanupPos && !fCleanupPos )
-        {
-            Abc_Print( -1, "Cleanup for PIs and POs is not enabled.\n" );
-            pNtkRes = Abc_NtkDup( pNtk );
-        }
-        else
-            pNtkRes = Abc_NtkDarCleanupAig( pNtk, fCleanupPis, fCleanupPos, fVerbose );
-    }
-    else
-    {
-        Abc_NtkCleanup( pNtk, fVerbose );
-        pNtkRes = Abc_NtkDup( pNtk );
-    }
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Cleanup has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: cleanup [-iovh]\n" );
-    Abc_Print( -2, "\t        for logic networks, removes dangling combinatinal logic\n" );
-    Abc_Print( -2, "\t        for AIGs, removes PIs w/o fanout and POs driven by const-0\n" );
-    Abc_Print( -2, "\t-i    : toggles removing PIs without fanout [default = %s]\n", fCleanupPis? "yes": "no" );
-    Abc_Print( -2, "\t-o    : toggles removing POs with const-0 drivers [default = %s]\n", fCleanupPos? "yes": "no" );
-    Abc_Print( -2, "\t-v    : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int fSingle = 0;
-    int fVerbose = 0;
-
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "svh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 's':
-            fSingle ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsLogic(pNtk) )
-    {
-        Abc_Print( -1, "The classical (SIS-like) sweep can only be performed on a logic network.\n" );
-        return 1;
-    }
-    // modify the current network
-    if ( fSingle )
-        Abc_NtkSweepBufsInvs( pNtk, fVerbose );
-    else
-        Abc_NtkSweep( pNtk, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: sweep [-svh]\n" );
-    Abc_Print( -2, "\t        removes dangling nodes; propagates constant, buffers, inverters\n" );
-    Abc_Print( -2, "\t-s    : toggle sweeping buffers/inverters only [default = %s]\n", fSingle? "yes": "no" );
-    Abc_Print( -2, "\t-v    : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandFastExtract( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern int Abc_NtkFxPerform( Abc_Ntk_t * pNtk, int nNewNodesMax, int nLitCountMax, int fVerbose, int fVeryVerbose );
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    Fxu_Data_t Params, * p = &Params;
-    int c, fNewAlgo = 1;
-    // set the defaults
-    Abc_NtkSetDefaultFxParams( p );
-    Extra_UtilGetoptReset();
-    while ( (c = Extra_UtilGetopt(argc, argv, "SDNWMsdzcnvwh")) != EOF )
-    {
-        switch (c)
-        {
-            case 'S':
-                if ( globalUtilOptind >= argc )
-                {
-                    Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
-                    goto usage;
-                }
-                p->nSingleMax = atoi(argv[globalUtilOptind]);
-                globalUtilOptind++;
-                if ( p->nSingleMax < 0 )
-                    goto usage;
-                break;
-            case 'D':
-                if ( globalUtilOptind >= argc )
-                {
-                    Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
-                    goto usage;
-                }
-                p->nPairsMax = atoi(argv[globalUtilOptind]);
-                globalUtilOptind++;
-                if ( p->nPairsMax < 0 )
-                    goto usage;
-                break;
-            case 'N':
-                if ( globalUtilOptind >= argc )
-                {
-                    Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                    goto usage;
-                }
-                p->nNodesExt = atoi(argv[globalUtilOptind]);
-                globalUtilOptind++;
-                if ( p->nNodesExt < 0 )
-                    goto usage;
-                break;
-            case 'W':
-                if ( globalUtilOptind >= argc )
-                {
-                    Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
-                    goto usage;
-                }
-                p->WeightMin = atoi(argv[globalUtilOptind]);
-                globalUtilOptind++;
-                if ( p->WeightMin < 0 )
-                    goto usage;
-                break;
-            case 'M':
-                if ( globalUtilOptind >= argc )
-                {
-                    Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
-                    goto usage;
-                }
-                p->LitCountMax = atoi(argv[globalUtilOptind]);
-                globalUtilOptind++;
-                if ( p->LitCountMax < 0 )
-                    goto usage;
-                break;
-            case 's':
-                p->fOnlyS ^= 1;
-                break;
-            case 'd':
-                p->fOnlyD ^= 1;
-                break;
-            case 'z':
-                p->fUse0 ^= 1;
-                break;
-            case 'c':
-                p->fUseCompl ^= 1;
-                break;
-            case 'n':
-                fNewAlgo ^= 1;
-                break;
-            case 'v':
-                p->fVerbose ^= 1;
-                break;
-            case 'w':
-                p->fVeryVerbose ^= 1;
-                break;
-            case 'h':
-                goto usage;
-                break;
-            default:
-                goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( Abc_NtkNodeNum(pNtk) == 0 )
-    {
-        Abc_Print( -1, "The network does not have internal nodes.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsLogic(pNtk) )
-    {
-        Abc_Print( -1, "Fast extract can only be applied to a logic network (run \"renode\" or \"if\").\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsSopLogic(pNtk) )
-    {
-        Abc_Print( -1, "Fast extract can only be applied to a logic network with SOP local functions (run \"bdd; sop\").\n" );
-        return 1;
-    }
-
-    // the nodes to be merged are linked into the special linked list
-    if ( fNewAlgo )
-        Abc_NtkFxPerform( pNtk, p->nNodesExt, p->LitCountMax, p->fVerbose, p->fVeryVerbose );
-    else
-        Abc_NtkFastExtract( pNtk, p );
-    Abc_NtkFxuFreeInfo( p );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: fx [-SDNWM <num>] [-sdzcnvwh]\n");
-    Abc_Print( -2, "\t           performs unate fast extract on the current network\n");
-    Abc_Print( -2, "\t-S <num> : max number of single-cube divisors to consider [default = %d]\n", p->nSingleMax );
-    Abc_Print( -2, "\t-D <num> : max number of double-cube divisors to consider [default = %d]\n", p->nPairsMax );
-    Abc_Print( -2, "\t-N <num> : max number of divisors to extract during this run [default = %d]\n", p->nNodesExt );
-    Abc_Print( -2, "\t-W <num> : lower bound on the weight of divisors to extract [default = %d]\n", p->WeightMin );
-    Abc_Print( -2, "\t-M <num> : upper bound on literal count of divisors to extract [default = %d]\n", p->LitCountMax );
-    Abc_Print( -2, "\t-s       : use only single-cube divisors [default = %s]\n", p->fOnlyS? "yes": "no" );
-    Abc_Print( -2, "\t-d       : use only double-cube divisors [default = %s]\n", p->fOnlyD? "yes": "no" );
-    Abc_Print( -2, "\t-z       : use zero-weight divisors [default = %s]\n", p->fUse0? "yes": "no" );
-    Abc_Print( -2, "\t-c       : use complement in the binary case [default = %s]\n", p->fUseCompl? "yes": "no" );
-    Abc_Print( -2, "\t-n       : use new implementation of fast extract [default = %s]\n", fNewAlgo? "yes": "no" );
-    Abc_Print( -2, "\t-v       : print verbose information [default = %s]\n", p->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w       : print additional information [default = %s]\n", p->fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandEliminate( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int ElimValue;
-    int nMaxSize;
-    int nIterMax;
-    int fGreedy;
-    int fReverse;
-    int fVerbose;
-    int c;
-    extern int Abc_NtkEliminate( Abc_Ntk_t * pNtk, int nMaxSize, int fReverse, int fVerbose );
-    extern int Abc_NtkEliminate1( Abc_Ntk_t * pNtk, int ElimValue, int nMaxSize, int nIterMax, int fReverse, int fVerbose );
-
-    // set the defaults
-    ElimValue = -1;
-    nMaxSize  = 12;
-    nIterMax  =  1;
-    fGreedy   =  0;
-    fReverse  =  0;
-    fVerbose  =  0;
-    Extra_UtilGetoptReset();
-    while ( (c = Extra_UtilGetopt(argc, argv, "VNIgrvh")) != EOF )
-    {
-        switch (c)
-        {
-            case 'V':
-                if ( globalUtilOptind >= argc )
-                {
-                    Abc_Print( -1, "Command line switch \"-V\" should be followed by an integer that is -1 or larger.\n" );
-                    goto usage;
-                }
-                ElimValue = atoi(argv[globalUtilOptind]);
-                globalUtilOptind++;
-                if ( ElimValue < -1 )
-                    goto usage;
-                break;
-            case 'N':
-                if ( globalUtilOptind >= argc )
-                {
-                    Abc_Print( -1, "Command line switch \"-N\" should be followed by a positive integer.\n" );
-                    goto usage;
-                }
-                nMaxSize = atoi(argv[globalUtilOptind]);
-                globalUtilOptind++;
-                if ( nMaxSize <= 0 )
-                    goto usage;
-                break;
-            case 'I':
-                if ( globalUtilOptind >= argc )
-                {
-                    Abc_Print( -1, "Command line switch \"-I\" should be followed by a positive integer.\n" );
-                    goto usage;
-                }
-                nIterMax = atoi(argv[globalUtilOptind]);
-                globalUtilOptind++;
-                if ( nIterMax <= 0 )
-                    goto usage;
-                break;
-            case 'g':
-                fGreedy ^= 1;
-                break;
-            case 'r':
-                fReverse ^= 1;
-                break;
-            case 'v':
-                fVerbose ^= 1;
-                break;
-            case 'h':
-                goto usage;
-                break;
-            default:
-                goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( Abc_NtkNodeNum(pNtk) == 0 )
-    {
-        Abc_Print( -1, "The network does not have internal nodes.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsLogic(pNtk) )
-    {
-        Abc_Print( -1, "This command can only be applied to a logic network (run \"renode\" or \"if\").\n" );
-        return 1;
-    }
-
-    if ( fGreedy )
-        Abc_NtkEliminate( pNtk, nMaxSize, fReverse, fVerbose );
-    else
-        Abc_NtkEliminate1( pNtk, ElimValue, nMaxSize, nIterMax, fReverse, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: eliminate [-VNI <num>] [-grvh]\n");
-    Abc_Print( -2, "\t           traditional \"eliminate -1\", which collapses the node into its fanout\n");
-    Abc_Print( -2, "\t           if the node's variable appears in the fanout's factored form only once\n");
-    Abc_Print( -2, "\t-V <num> : the \"value\" parameter used by \"eliminate\" in SIS [default = %d]\n", ElimValue );
-    Abc_Print( -2, "\t-N <num> : the maximum node support after collapsing [default = %d]\n", nMaxSize );
-    Abc_Print( -2, "\t-I <num> : the maximum number of iterations [default = %d]\n", nIterMax );
-    Abc_Print( -2, "\t-g       : toggle using greedy eliminate (without \"value\") [default = %s]\n", fGreedy? "yes": "no" );
-    Abc_Print( -2, "\t-r       : use the reverse topological order [default = %s]\n", fReverse? "yes": "no" );
-    Abc_Print( -2, "\t-v       : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandDisjoint( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes, * pNtkNew;
-    int fGlobal, fRecursive, fVerbose, fPrint, fShort, c;
-
-    extern Abc_Ntk_t * Abc_NtkDsdGlobal( Abc_Ntk_t * pNtk, int fVerbose, int fPrint, int fShort );
-    extern int         Abc_NtkDsdLocal( Abc_Ntk_t * pNtk, int fVerbose, int fRecursive );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    fGlobal    = 1;
-    fRecursive = 0;
-    fVerbose   = 0;
-    fPrint     = 0;
-    fShort     = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "grvpsh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-            case 'g':
-                fGlobal ^= 1;
-                break;
-            case 'r':
-                fRecursive ^= 1;
-                break;
-            case 'v':
-                fVerbose ^= 1;
-                break;
-            case 'p':
-                fPrint ^= 1;
-                break;
-            case 's':
-                fShort ^= 1;
-                break;
-            case 'h':
-                goto usage;
-                break;
-            default:
-                goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( fGlobal )
-    {
-//        Abc_Print( 0, "Performing DSD of global functions of the network.\n" );
-        // get the new network
-        if ( !Abc_NtkIsStrash(pNtk) )
-        {
-            pNtkNew = Abc_NtkStrash( pNtk, 0, 0, 0 );
-            pNtkRes = Abc_NtkDsdGlobal( pNtkNew, fVerbose, fPrint, fShort );
-            Abc_NtkDelete( pNtkNew );
-        }
-        else
-        {
-            pNtkRes = Abc_NtkDsdGlobal( pNtk, fVerbose, fPrint, fShort );
-        }
-        if ( pNtkRes == NULL )
-        {
-            Abc_Print( -1, "Global DSD has failed.\n" );
-            return 1;
-        }
-        // replace the current network
-        Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    }
-    else if ( fRecursive )
-    {
-        if ( !Abc_NtkIsBddLogic( pNtk ) )
-        {
-            Abc_Print( -1, "This command is only applicable to logic BDD networks.\n" );
-            return 1;
-        }
-        if ( fVerbose )
-            Abc_Print( 1, "Performing recursive DSD and MUX decomposition of local functions.\n" );
-        if ( !Abc_NtkDsdLocal( pNtk, fVerbose, fRecursive ) )
-            Abc_Print( -1, "Recursive DSD has failed.\n" );
-    }
-    else
-    {
-        if ( !Abc_NtkIsBddLogic( pNtk ) )
-        {
-            Abc_Print( -1, "This command is only applicable to logic BDD networks (run \"bdd\").\n" );
-            return 1;
-        }
-        if ( fVerbose )
-            Abc_Print( 1, "Performing simple non-recursive DSD of local functions.\n" );
-        if ( !Abc_NtkDsdLocal( pNtk, fVerbose, fRecursive ) )
-            Abc_Print( -1, "Simple DSD of local functions has failed.\n" );
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: dsd [-grvpsh]\n" );
-    Abc_Print( -2, "\t     decomposes the network using disjoint-support decomposition\n" );
-    Abc_Print( -2, "\t-g     : toggle DSD of global and local functions [default = %s]\n", fGlobal? "global": "local" );
-    Abc_Print( -2, "\t-r     : toggle recursive DSD/MUX and simple DSD [default = %s]\n", fRecursive? "recursive DSD/MUX": "simple DSD" );
-    Abc_Print( -2, "\t-v     : prints DSD statistics and runtime [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-p     : prints DSD structure to the standard output [default = %s]\n", fPrint? "yes": "no" );
-    Abc_Print( -2, "\t-s     : use short PI names when printing DSD structure [default = %s]\n", fShort? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandSparsify( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Abc_Ntk_t * Abc_NtkSparsify( Abc_Ntk_t * pNtk, int nPerc, int fVerbose );
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc), * pNtkNew;
-    int nPerc, fVerbose, c;
-    // set defaults
-    nPerc      = 10;
-    fVerbose   =  0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Nvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-            case 'N':
-                if ( globalUtilOptind >= argc )
-                {
-                    Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                    goto usage;
-                }
-                nPerc = atoi(argv[globalUtilOptind]);
-                globalUtilOptind++;
-                if ( nPerc < 1 || nPerc > 100 )
-                    goto usage;
-                break;
-            case 'v':
-                fVerbose ^= 1;
-                break;
-            case 'h':
-                goto usage;
-                break;
-            default:
-                goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsBddLogic( pNtk ) )
-    {
-        Abc_Print( -1, "This command is only applicable to logic BDD networks (run \"bdd\").\n" );
-        return 1;
-    }
-    if ( Abc_NtkCiNum(pNtk) > 16 )
-    {
-        Abc_Print( -1, "The number of primary inputs is more than 16.\n" );
-        return 1;
-    }
-    pNtkNew = Abc_NtkSparsify( pNtk, nPerc, fVerbose );
-    if ( pNtkNew == NULL )
-    {
-        Abc_Print( -1, "Command has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkNew );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: sparsify [-N num] [-vh]\n" );
-    Abc_Print( -2, "\t           creates incompletely-specified function\n" );
-    Abc_Print( -2, "\t-N <num> : the percentage of on-set and off-set minterms (1 <= num <= 100) [default = %d]\n", nPerc );
-    Abc_Print( -2, "\t-v       : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandLutpack( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    Lpk_Par_t Pars, * pPars = &Pars;
-    int c;
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    memset( pPars, 0, sizeof(Lpk_Par_t) );
-    pPars->nLutsMax     =  4; // (N) the maximum number of LUTs in the structure
-    pPars->nLutsOver    =  3; // (Q) the maximum number of LUTs not in the MFFC
-    pPars->nVarsShared  =  0; // (S) the maximum number of shared variables (crossbars)
-    pPars->nGrowthLevel =  0; // (L) the maximum number of increased levels
-    pPars->fSatur       =  1;
-    pPars->fZeroCost    =  0;
-    pPars->fFirst       =  0;
-    pPars->fOldAlgo     =  0;
-    pPars->fVerbose     =  0;
-    pPars->fVeryVerbose =  0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "NQSLszfovwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nLutsMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nLutsMax < 2 || pPars->nLutsMax > 8 )
-                goto usage;
-            break;
-        case 'Q':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-Q\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nLutsOver = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nLutsOver < 0 || pPars->nLutsOver > 8 )
-                goto usage;
-            break;
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nVarsShared = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nVarsShared < 0 || pPars->nVarsShared > 4 )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nGrowthLevel = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nGrowthLevel < 0 || pPars->nGrowthLevel > ABC_INFINITY )
-                goto usage;
-            break;
-        case 's':
-            pPars->fSatur ^= 1;
-            break;
-        case 'z':
-            pPars->fZeroCost ^= 1;
-            break;
-        case 'f':
-            pPars->fFirst ^= 1;
-            break;
-        case 'o':
-            pPars->fOldAlgo ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'w':
-            pPars->fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsLogic(pNtk) )
-    {
-        Abc_Print( -1, "This command can only be applied to a logic network.\n" );
-        return 1;
-    }
-    if ( pPars->nVarsShared < 0 || pPars->nVarsShared > 3 )
-    {
-        Abc_Print( -1, "The number of shared variables (%d) is not in the range 0 <= S <= 3.\n", pPars->nVarsShared );
-        return 1;
-    }
-
-    // modify the current network
-    if ( !Lpk_Resynthesize( pNtk, pPars ) )
-    {
-        Abc_Print( -1, "Resynthesis has failed.\n" );
-        return 1;
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: lutpack [-NQSL <num>] [-szfovwh]\n" );
-    Abc_Print( -2, "\t           performs \"rewriting\" for LUT network;\n" );
-    Abc_Print( -2, "\t           determines LUT size as the max fanin count of a node;\n" );
-    Abc_Print( -2, "\t           if the network is not LUT-mapped, packs it into 6-LUTs\n" );
-    Abc_Print( -2, "\t           (there is another command for resynthesis after LUT mapping, \"imfs\")\n" );
-    Abc_Print( -2, "\t-N <num> : the max number of LUTs in the structure (2 <= num) [default = %d]\n", pPars->nLutsMax );
-    Abc_Print( -2, "\t-Q <num> : the max number of LUTs not in MFFC (0 <= num) [default = %d]\n", pPars->nLutsOver );
-    Abc_Print( -2, "\t-S <num> : the max number of LUT inputs shared (0 <= num <= 3) [default = %d]\n", pPars->nVarsShared );
-    Abc_Print( -2, "\t-L <num> : max level increase after resynthesis (0 <= num) [default = %d]\n", pPars->nGrowthLevel );
-    Abc_Print( -2, "\t-s       : toggle iteration till saturation [default = %s]\n", pPars->fSatur? "yes": "no" );
-    Abc_Print( -2, "\t-z       : toggle zero-cost replacements [default = %s]\n", pPars->fZeroCost? "yes": "no" );
-    Abc_Print( -2, "\t-f       : toggle using only first node and first cut [default = %s]\n", pPars->fFirst? "yes": "no" );
-    Abc_Print( -2, "\t-o       : toggle using old implementation [default = %s]\n", pPars->fOldAlgo? "yes": "no" );
-    Abc_Print( -2, "\t-v       : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w       : toggle detailed printout of decomposed functions [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandLutmin( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c;
-    int nLutSize;
-    int fVerbose;
-    extern Abc_Ntk_t * Abc_NtkLutmin( Abc_Ntk_t * pNtk, int nLutSize, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    nLutSize = 4;
-    fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Kvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nLutSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    // modify the current network
-    pNtkRes = Abc_NtkLutmin( pNtk, nLutSize, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "The command has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: lutmin [-K <num>] [-vh]\n" );
-    Abc_Print( -2, "\t           perform FPGA mapping while minimizing the LUT count\n" );
-    Abc_Print( -2, "\t           as described in the paper T. Sasao and A. Mishchenko:\n" );
-    Abc_Print( -2, "\t           \"On the number of LUTs to implement logic functions\".\n" );
-    Abc_Print( -2, "\t-K <num> : the LUT size to use for the mapping (2 <= num) [default = %d]\n", nLutSize );
-    Abc_Print( -2, "\t-v       : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-#if 0
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandImfs( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    Res_Par_t Pars, * pPars = &Pars;
-    int c;
-
-    // set defaults
-    pPars->nWindow      = 62;
-    pPars->nCands       =  5;
-    pPars->nSimWords    =  4;
-    pPars->nGrowthLevel =  0;
-    pPars->fArea        =  0;
-    pPars->fVerbose     =  0;
-    pPars->fVeryVerbose =  0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "WSCLavwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nWindow = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nWindow < 1 || pPars->nWindow > 99 )
-                goto usage;
-            break;
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nSimWords = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nSimWords < 1 || pPars->nSimWords > 256 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nCands = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nCands < 0 || pPars->nCands > ABC_INFINITY )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nGrowthLevel = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nGrowthLevel < 0 || pPars->nGrowthLevel > ABC_INFINITY )
-                goto usage;
-            break;
-        case 'a':
-            pPars->fArea ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'w':
-            pPars->fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsLogic(pNtk) )
-    {
-        Abc_Print( -1, "This command can only be applied to a logic network.\n" );
-        return 1;
-    }
-
-    // modify the current network
-    if ( !Abc_NtkResynthesize( pNtk, pPars ) )
-    {
-        Abc_Print( -1, "Resynthesis has failed.\n" );
-        return 1;
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: imfs [-W <NM>] [-LCS <num>] [-avwh]\n" );
-    Abc_Print( -2, "\t           performs resubstitution-based resynthesis with interpolation\n" );
-    Abc_Print( -2, "\t           (there is another command for resynthesis after LUT mapping, \"lutpack\")\n" );
-    Abc_Print( -2, "\t-W <NM>  : fanin/fanout levels (NxM) of the window (00 <= NM <= 99) [default = %d%d]\n", pPars->nWindow/10, pPars->nWindow%10 );
-    Abc_Print( -2, "\t-C <num> : the max number of resub candidates (1 <= n) [default = %d]\n", pPars->nCands );
-    Abc_Print( -2, "\t-S <num> : the number of simulation words (1 <= n <= 256) [default = %d]\n", pPars->nSimWords );
-    Abc_Print( -2, "\t-L <num> : the max increase in node level after resynthesis (0 <= num) [default = %d]\n", pPars->nGrowthLevel );
-    Abc_Print( -2, "\t-a       : toggle optimization for area only [default = %s]\n", pPars->fArea? "yes": "no" );
-    Abc_Print( -2, "\t-v       : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w       : toggle printout subgraph statistics [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-#endif
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandMfs( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    Mfs_Par_t Pars, * pPars = &Pars;
-    int c;
-    // set defaults
-    Abc_NtkMfsParsDefault( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "WFDMLCdraestpgvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nWinTfoLevs = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nWinTfoLevs < 0 )
-                goto usage;
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nFanoutsMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nFanoutsMax < 0 )
-                goto usage;
-            break;
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nDepthMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nDepthMax < 0 )
-                goto usage;
-            break;
-        case 'M':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nWinMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nWinMax < 0 )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nGrowthLevel = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nGrowthLevel < 0 || pPars->nGrowthLevel > ABC_INFINITY )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nBTLimit < 0 )
-                goto usage;
-            break;
-        case 'd':
-            pPars->fRrOnly ^= 1;
-            break;
-        case 'r':
-            pPars->fResub ^= 1;
-            break;
-        case 'a':
-            pPars->fArea ^= 1;
-            break;
-        case 'e':
-            pPars->fMoreEffort ^= 1;
-            break;
-        case 's':
-            pPars->fSwapEdge ^= 1;
-            break;
-        case 't':
-            pPars->fOneHotness ^= 1;
-            break;
-        case 'p':
-            pPars->fPower ^= 1;
-            break;
-        case 'g':
-            pPars->fGiaSat ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'w':
-            pPars->fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsLogic(pNtk) )
-    {
-        Abc_Print( -1, "This command can only be applied to a logic network.\n" );
-        return 1;
-    }
-
-    // modify the current network
-    if ( !Abc_NtkMfs( pNtk, pPars ) )
-    {
-        Abc_Print( -1, "Resynthesis has failed.\n" );
-        return 1;
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: mfs [-WFDMLC <num>] [-draestpgvh]\n" );
-    Abc_Print( -2, "\t           performs don't-care-based optimization of logic networks\n" );
-    Abc_Print( -2, "\t-W <num> : the number of levels in the TFO cone (0 <= num) [default = %d]\n", pPars->nWinTfoLevs );
-    Abc_Print( -2, "\t-F <num> : the max number of fanouts to skip (1 <= num) [default = %d]\n", pPars->nFanoutsMax );
-    Abc_Print( -2, "\t-D <num> : the max depth nodes to try (0 = no limit) [default = %d]\n", pPars->nDepthMax );
-    Abc_Print( -2, "\t-M <num> : the max node count of windows to consider (0 = no limit) [default = %d]\n", pPars->nWinMax );
-    Abc_Print( -2, "\t-L <num> : the max increase in node level after resynthesis (0 <= num) [default = %d]\n", pPars->nGrowthLevel );
-    Abc_Print( -2, "\t-C <num> : the max number of conflicts in one SAT run (0 = no limit) [default = %d]\n", pPars->nBTLimit );
-    Abc_Print( -2, "\t-d       : toggle performing redundancy removal [default = %s]\n", pPars->fRrOnly? "yes": "no" );
-    Abc_Print( -2, "\t-r       : toggle resubstitution and dc-minimization [default = %s]\n", pPars->fResub? "resub": "dc-min" );
-    Abc_Print( -2, "\t-a       : toggle minimizing area or area+edges [default = %s]\n", pPars->fArea? "area": "area+edges" );
-    Abc_Print( -2, "\t-e       : toggle high-effort resubstitution [default = %s]\n", pPars->fMoreEffort? "yes": "no" );
-    Abc_Print( -2, "\t-s       : toggle evaluation of edge swapping [default = %s]\n", pPars->fSwapEdge? "yes": "no" );
-    Abc_Print( -2, "\t-t       : toggle using artificial one-hotness conditions [default = %s]\n", pPars->fOneHotness? "yes": "no" );
-    Abc_Print( -2, "\t-p       : toggle power-aware optimization [default = %s]\n", pPars->fPower? "yes": "no" );
-    Abc_Print( -2, "\t-g       : toggle using new SAT solver [default = %s]\n", pPars->fGiaSat? "yes": "no" );
-    Abc_Print( -2, "\t-v       : toggle printing optimization summary [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w       : toggle printing detailed stats for each node [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandMfs2( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern int Abc_NtkPerformMfs( Abc_Ntk_t * pNtk, Sfm_Par_t * pPars );
-    extern int Abc_NtkMfsAfterICheck( Abc_Ntk_t * p, int nFrames, int nFramesAdd, Vec_Int_t * vFlops, Sfm_Par_t * pPars );
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    Sfm_Par_t Pars, * pPars = &Pars;
-    int c, fIndDCs = 0, fUseAllFfs = 0, nFramesAdd = 0;
-    // set defaults
-    Sfm_ParSetDefault( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "WFDMLCZNIdaeijvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nTfoLevMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nTfoLevMax < 0 )
-                goto usage;
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nFanoutMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nFanoutMax < 0 )
-                goto usage;
-            break;
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nDepthMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nDepthMax < 0 )
-                goto usage;
-            break;
-        case 'M':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nWinSizeMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nWinSizeMax < 0 )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nGrowthLevel = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nGrowthLevel < -ABC_INFINITY || pPars->nGrowthLevel > ABC_INFINITY )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nBTLimit < 0 )
-                goto usage;
-            break;
-        case 'Z':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-Z\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nFirstFixed = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nFirstFixed < 0 )
-                goto usage;
-            break;
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nNodesMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nNodesMax < 0 )
-                goto usage;
-            break;
-        case 'I':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFramesAdd = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFramesAdd < 0 )
-                goto usage;
-            break;
-        case 'd':
-            pPars->fRrOnly ^= 1;
-            break;
-        case 'a':
-            pPars->fArea ^= 1;
-            break;
-        case 'e':
-            pPars->fMoreEffort ^= 1;
-            break;
-        case 'i':
-            fIndDCs ^= 1;
-            break;
-        case 'j':
-            fUseAllFfs ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'w':
-            pPars->fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsLogic(pNtk) )
-    {
-        Abc_Print( -1, "This command can only be applied to a logic network.\n" );
-        return 1;
-    }
-    if ( fIndDCs )
-    {
-        if ( fUseAllFfs )
-        {
-            pAbc->nIndFrames = 1;
-            Vec_IntFreeP( &pAbc->vIndFlops );
-            pAbc->vIndFlops = Vec_IntAlloc( Abc_NtkLatchNum(pNtk) );
-            Vec_IntFill( pAbc->vIndFlops, Abc_NtkLatchNum(pNtk), 1 );
-        }
-        if ( pAbc->nIndFrames <= 0 )
-        {
-            Abc_Print( -1, "The number of k-inductive frames is not specified.\n" );
-            return 0;
-        }
-        if ( pAbc->vIndFlops == NULL )
-        {
-            Abc_Print( -1, "The set of k-inductive flops is not specified.\n" );
-            return 0;
-        }
-        if ( Vec_IntSize(pAbc->vIndFlops) != Abc_NtkLatchNum(pNtk) )
-        {
-            Abc_Print( -1, "The saved flop count (%d) does not match that of the current network (%d).\n", 
-                Vec_IntSize(pAbc->vIndFlops), Abc_NtkLatchNum(pNtk) );
-            return 0;
-        }
-        // modify the current network
-        if ( !Abc_NtkMfsAfterICheck( pNtk, pAbc->nIndFrames, nFramesAdd, pAbc->vIndFlops, pPars ) )
-        {
-            Abc_Print( -1, "Resynthesis has failed.\n" );
-            return 1;
-        }
-        if ( fUseAllFfs )
-        {
-            pAbc->nIndFrames = 0;
-            Vec_IntFreeP( &pAbc->vIndFlops );
-        }
-    }
-    else
-    {
-        // modify the current network
-        if ( !Abc_NtkPerformMfs( pNtk, pPars ) )
-        {
-            Abc_Print( -1, "Resynthesis has failed.\n" );
-            return 1;
-        }
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: mfs2 [-WFDMLCZNI <num>] [-daeijvwh]\n" );
-    Abc_Print( -2, "\t           performs don't-care-based optimization of logic networks\n" );
-    Abc_Print( -2, "\t-W <num> : the number of levels in the TFO cone (0 <= num) [default = %d]\n",             pPars->nTfoLevMax );
-    Abc_Print( -2, "\t-F <num> : the max number of fanouts to skip (1 <= num) [default = %d]\n",                pPars->nFanoutMax );
-    Abc_Print( -2, "\t-D <num> : the max depth nodes to try (0 = no limit) [default = %d]\n",                   pPars->nDepthMax );
-    Abc_Print( -2, "\t-M <num> : the max node count of windows to consider (0 = no limit) [default = %d]\n",    pPars->nWinSizeMax );
-    Abc_Print( -2, "\t-L <num> : the max increase in node level after resynthesis (0 <= num) [default = %d]\n", pPars->nGrowthLevel );
-    Abc_Print( -2, "\t-C <num> : the max number of conflicts in one SAT run (0 = no limit) [default = %d]\n",   pPars->nBTLimit );
-    Abc_Print( -2, "\t-Z <num> : treat the first <num> logic nodes as fixed (0 = none) [default = %d]\n",       pPars->nFirstFixed );
-    Abc_Print( -2, "\t-N <num> : the max number of nodes to try (0 = all) [default = %d]\n",                    pPars->nNodesMax );
-    Abc_Print( -2, "\t-d       : toggle performing redundancy removal [default = %s]\n",                        pPars->fRrOnly? "yes": "no" );
-    Abc_Print( -2, "\t-a       : toggle minimizing area or area+edges [default = %s]\n",                        pPars->fArea? "area": "area+edges" );
-    Abc_Print( -2, "\t-e       : toggle high-effort resubstitution [default = %s]\n",                           pPars->fMoreEffort? "yes": "no" );
-    Abc_Print( -2, "\t-i       : toggle using inductive don't-cares [default = %s]\n",                          fIndDCs? "yes": "no" );
-    Abc_Print( -2, "\t-j       : toggle using all flops when \"-i\" is enabled [default = %s]\n",               fUseAllFfs? "yes": "no" );
-    Abc_Print( -2, "\t-I       : the number of additional frames inserted [default = %d]\n",                    nFramesAdd );
-    Abc_Print( -2, "\t-v       : toggle printing optimization summary [default = %s]\n",                        pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w       : toggle printing detailed stats for each node [default = %s]\n",                pPars->fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandTrace( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int fUseLutLib;
-    int fVerbose;
-    extern void Abc_NtkDelayTracePrint( Abc_Ntk_t * pNtk, int fUseLutLib, int fVerbose );
-
-    // set defaults
-    fUseLutLib = 0;
-    fVerbose   = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "lvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'l':
-            fUseLutLib ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsLogic(pNtk) )
-    {
-        Abc_Print( -1, "This command can only be applied to a logic network.\n" );
-        return 1;
-    }
-
-    // modify the current network
-    Abc_NtkDelayTracePrint( pNtk, fUseLutLib, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: trace [-lvh]\n" );
-    Abc_Print( -2, "\t           performs delay trace of LUT-mapped network\n" );
-    Abc_Print( -2, "\t-l       : toggle using unit- or LUT-library-delay model [default = %s]\n", fUseLutLib? "lib": "unit" );
-    Abc_Print( -2, "\t-v       : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandSpeedup( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c;
-    int fUseLutLib;
-    int Percentage;
-    int Degree;
-    int fVerbose;
-    int fVeryVerbose;
-    extern Abc_Ntk_t * Abc_NtkSpeedup( Abc_Ntk_t * pNtk, int fUseLutLib, int Percentage, int Degree, int fVerbose, int fVeryVerbose );
-    pNtk = Abc_FrameReadNtk(pAbc);
-
-    // set defaults
-    fUseLutLib = 0;
-    Percentage = 5;
-    Degree     = 2;
-    fVerbose   = 0;
-    fVeryVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "PNlvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'P':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            Percentage = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( Percentage < 1 || Percentage > 100 )
-                goto usage;
-            break;
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            Degree = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( Degree < 1 || Degree > 5 )
-                goto usage;
-            break;
-        case 'l':
-            fUseLutLib ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'w':
-            fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsLogic(pNtk) )
-    {
-        Abc_Print( -1, "This command can only be applied to a logic network.\n" );
-        return 1;
-    }
-
-    // modify the current network
-    pNtkRes = Abc_NtkSpeedup( pNtk, fUseLutLib, Percentage, Degree, fVerbose, fVeryVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "The command has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: speedup [-PN <num>] [-lvwh]\n" );
-    Abc_Print( -2, "\t           transforms LUT-mapped network into an AIG with choices;\n" );
-    Abc_Print( -2, "\t           the choices are added to speedup the next round of mapping\n" );
-    Abc_Print( -2, "\t-P <num> : delay delta defining critical path for library model [default = %d%%]\n", Percentage );
-    Abc_Print( -2, "\t-N <num> : the max critical path degree for resynthesis (0 < num < 6) [default = %d]\n", Degree );
-    Abc_Print( -2, "\t-l       : toggle using unit- or LUT-library-delay model [default = %s]\n", fUseLutLib? "lib" : "unit" );
-    Abc_Print( -2, "\t-v       : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w       : toggle printing detailed stats for each node [default = %s]\n", fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandPowerdown( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c;
-    int fUseLutLib;
-    int Percentage;
-    int Degree;
-    int fVerbose;
-    int fVeryVerbose;
-    extern Abc_Ntk_t * Abc_NtkPowerdown( Abc_Ntk_t * pNtk, int fUseLutLib, int Percentage, int Degree, int fVerbose, int fVeryVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    fUseLutLib = 0;
-    Percentage =10;
-    Degree     = 2;
-    fVerbose   = 0;
-    fVeryVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "PNlvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'P':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            Percentage = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( Percentage < 1 || Percentage > 100 )
-                goto usage;
-            break;
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            Degree = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( Degree < 1 || Degree > 5 )
-                goto usage;
-            break;
-        case 'l':
-            fUseLutLib ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'w':
-            fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsLogic(pNtk) )
-    {
-        Abc_Print( -1, "This command can only be applied to a logic network.\n" );
-        return 1;
-    }
-
-    // modify the current network
-    pNtkRes = Abc_NtkPowerdown( pNtk, fUseLutLib, Percentage, Degree, fVerbose, fVeryVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "The command has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: powerdown [-PN <num>] [-vwh]\n" );
-    Abc_Print( -2, "\t           transforms LUT-mapped network into an AIG with choices;\n" );
-    Abc_Print( -2, "\t           the choices are added to power down the next round of mapping\n" );
-    Abc_Print( -2, "\t-P <num> : switching propability delta defining power critical edges [default = %d%%]\n", Percentage );
-    Abc_Print( -2, "\t           (e.g. 5% means hot wires switch with probability: 0.45 <= p <= 0.50 (max)\n" );
-    Abc_Print( -2, "\t-N <num> : the max critical path degree for resynthesis (0 < num < 6) [default = %d]\n", Degree );
-//    Abc_Print( -2, "\t-l       : toggle using unit- or LUT-library-delay model [default = %s]\n", fUseLutLib? "lib" : "unit" );
-    Abc_Print( -2, "\t-v       : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w       : toggle printing detailed stats for each node [default = %s]\n", fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAddBuffs( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Abc_Ntk_t * Abc_NtkAddBuffs( Abc_Ntk_t * pNtk, int fDirect, int fReverse, int nImprove, int fVerbose );
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    Abc_Ntk_t * pNtkRes;
-    int fDirect;
-    int fReverse;
-    int nImprove;
-    int c, fVerbose;
-
-    fDirect  = 0;
-    fReverse = 0;
-    nImprove = 1000;
-    fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Idrvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'I':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-I\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            nImprove = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nImprove < 0 )
-                goto usage;
-            break;
-        case 'd':
-            fDirect ^= 1;
-            break;
-        case 'r':
-            fReverse ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsLogic(pNtk) )
-    {
-        Abc_Print( -1, "This command can only be applied to a logic network.\n" );
-        return 1;
-    }
-
-    // modify the current network
-    pNtkRes = Abc_NtkAddBuffs( pNtk, fDirect, fReverse, nImprove, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "The command has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: addbuffs [-I num] [-drvh]\n" );
-    Abc_Print( -2, "\t           adds buffers to create balanced CI/CO paths\n" );
-    Abc_Print( -2, "\t-I <num> : the number of refinement iterations [default = %d]\n", nImprove );
-    Abc_Print( -2, "\t-d       : toggle using only CI-to-CO levelized order [default = %s]\n", fDirect? "yes": "no" );
-    Abc_Print( -2, "\t-r       : toggle using only CO-to-C1 levelized order [default = %s]\n", fReverse? "yes": "no" );
-    Abc_Print( -2, "\t-v       : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-#if 0
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandMerge( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    Nwk_LMPars_t Pars, * pPars = &Pars;
-    Vec_Int_t * vResult;
-    int c;
-    extern Vec_Int_t * Abc_NtkLutMerge( Abc_Ntk_t * pNtk, Nwk_LMPars_t * pPars );
-    // set defaults
-    memset( pPars, 0, sizeof(Nwk_LMPars_t) );
-    pPars->nMaxLutSize    = 5;   // the max LUT size for merging (N=5)
-    pPars->nMaxSuppSize   = 5;   // the max total support size after merging (S=5)
-    pPars->nMaxDistance   = 3;   // the max number of nodes separating LUTs
-    pPars->nMaxLevelDiff  = 2;   // the max difference in levels
-    pPars->nMaxFanout     = 100; // the max number of fanouts to traverse
-    pPars->fUseDiffSupp   = 0;   // enables the use of nodes with different support
-    pPars->fUseTfiTfo     = 0;   // enables the use of TFO/TFO nodes as candidates
-    pPars->fVeryVerbose   = 0;   // enables additional verbose output
-    pPars->fVerbose       = 1;   // enables verbose output
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "NSDLFscvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nMaxLutSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nMaxLutSize < 2 )
-                goto usage;
-            break;
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nMaxSuppSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nMaxSuppSize < 2 )
-                goto usage;
-            break;
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nMaxDistance = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nMaxDistance < 2 )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nMaxLevelDiff = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nMaxLevelDiff < 2 )
-                goto usage;
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nMaxFanout = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nMaxFanout < 2 )
-                goto usage;
-            break;
-        case 's':
-            pPars->fUseDiffSupp ^= 1;
-            break;
-        case 'c':
-            pPars->fUseTfiTfo ^= 1;
-            break;
-        case 'w':
-            pPars->fVeryVerbose ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL || !Abc_NtkIsLogic(pNtk) )
-    {
-        Abc_Print( -1, "Abc_CommandMerge(): There is no mapped network to merge LUTs.\n" );
-        return 1;
-    }
-
-    vResult = Abc_NtkLutMerge( pNtk, pPars );
-    Vec_IntFree( vResult );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: merge [-NSDLF <num>] [-scwvh]\n" );
-    Abc_Print( -2, "\t           creates pairs of topologically-related LUTs\n" );
-    Abc_Print( -2, "\t-N <num> : the max LUT size for merging (1 < num) [default = %d]\n", pPars->nMaxLutSize );
-    Abc_Print( -2, "\t-S <num> : the max total support size after merging (1 < num) [default = %d]\n", pPars->nMaxSuppSize );
-    Abc_Print( -2, "\t-D <num> : the max distance in terms of LUTs (0 < num) [default = %d]\n", pPars->nMaxDistance );
-    Abc_Print( -2, "\t-L <num> : the max difference in levels (0 <= num) [default = %d]\n", pPars->nMaxLevelDiff );
-    Abc_Print( -2, "\t-F <num> : the max number of fanouts to stop traversal (0 < num) [default = %d]\n", pPars->nMaxFanout );
-    Abc_Print( -2, "\t-s       : toggle the use of nodes without support overlap [default = %s]\n", pPars->fUseDiffSupp? "yes" : "no" );
-    Abc_Print( -2, "\t-c       : toggle the use of TFI/TFO nodes as candidates [default = %s]\n", pPars->fUseTfiTfo? "yes" : "no" );
-    Abc_Print( -2, "\t-w       : toggle printing detailed stats for each node [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-v       : toggle printing optimization summary [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-#endif
-
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandTestDec( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern int Abc_DecTest( char * pFileName, int DecType, int nVarNum, int fVerbose );
-    char * pFileName;
-    int c;
-    int fVerbose = 0;
-    int DecType = 0;
-    int nVarNum = -1;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "ANvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'A':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-A\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            DecType = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( DecType < 0 )
-                goto usage;
-            break;
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nVarNum = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nVarNum < 0 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( argc != globalUtilOptind + 1 )
-    {
-        Abc_Print( 1,"Input file is not given.\n" );
-        return 0;
-    }
-    if ( nVarNum >= 0 && nVarNum < 6 )
-    {
-        Abc_Print( 1,"The number of variables cannot be less than 6.\n" );
-        return 0;
-    }
-    // get the output file name
-    pFileName = argv[globalUtilOptind];
-    // call the testbench
-    Abc_DecTest( pFileName, DecType, nVarNum, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: testdec [-AN <num>] [-vh] <file>\n" );
-    Abc_Print( -2, "\t           testbench for Boolean decomposition algorithms\n" );
-    Abc_Print( -2, "\t-A <num> : decomposition algorithm [default = %d]\n", DecType );
-    Abc_Print( -2, "\t               0: none (reading and writing the file)\n" );
-    Abc_Print( -2, "\t               1: algebraic factoring applied to ISOP\n" );
-    Abc_Print( -2, "\t               2: bi-decomposition with cofactoring\n" );
-    Abc_Print( -2, "\t               3: disjoint-support decomposition with cofactoring\n" );
-    Abc_Print( -2, "\t               4: updated disjoint-support decomposition with cofactoring\n" );
-    Abc_Print( -2, "\t               5: enumerating decomposable variable sets\n" );
-    Abc_Print( -2, "\t-N <num> : the number of support variables (binary files only) [default = unused]\n" );
-    Abc_Print( -2, "\t-v       : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    Abc_Print( -2, "\t<file>   : a text file with truth tables in hexadecimal, listed one per line,\n");
-    Abc_Print( -2, "\t           or a binary file with an array of truth tables (in this case,\n");
-    Abc_Print( -2, "\t           -N <num> is required to determine how many functions are stored)\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandTestNpn( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern int Abc_NpnTest( char * pFileName, int NpnType, int nVarNum, int fDumpRes, int fBinary, int fVerbose );
-    char * pFileName;
-    int c;
-    int fVerbose = 0;
-    int NpnType = 0;
-    int nVarNum = -1;
-    int fDumpRes = 0;
-    int fBinary = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "ANdbvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'A':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-A\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            NpnType = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( NpnType < 0 )
-                goto usage;
-            break;
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nVarNum = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nVarNum < 0 )
-                goto usage;
-            break;
-        case 'd':
-            fDumpRes ^= 1;
-            break;
-        case 'b':
-            fBinary ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( argc != globalUtilOptind + 1 )
-    {
-        Abc_Print( 1,"Input file is not given.\n" );
-        return 0;
-    }
-    if ( nVarNum >= 0 && nVarNum < 6 )
-    {
-        Abc_Print( 1,"The number of variables cannot be less than 6.\n" );
-        return 0;
-    }
-    // get the output file name
-    pFileName = argv[globalUtilOptind];
-    // call the testbench
-    Abc_NpnTest( pFileName, NpnType, nVarNum, fDumpRes, fBinary, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: testnpn [-AN <num>] [-dbvh] <file>\n" );
-    Abc_Print( -2, "\t           testbench for computing (semi-)canonical forms\n" );
-    Abc_Print( -2, "\t           of completely-specified Boolean functions up to 16 varibles\n" );
-    Abc_Print( -2, "\t-A <num> : semi-caninical form computation algorithm [default = %d]\n", NpnType );
-    Abc_Print( -2, "\t               0: uniqifying truth tables\n" );
-    Abc_Print( -2, "\t               1: exact NPN canonical form by brute-force enumeration\n" );
-    Abc_Print( -2, "\t               2: semi-canonical form by counting 1s in cofactors\n" );
-    Abc_Print( -2, "\t               3: Jake's hybrid semi-canonical form (fast)\n" );
-    Abc_Print( -2, "\t               4: Jake's hybrid semi-canonical form (high-effort)\n" );
-    Abc_Print( -2, "\t               5: new fast hybrid semi-canonical form\n" );
-    Abc_Print( -2, "\t               6: new phase canonical form\n" );
-    Abc_Print( -2, "\t-N <num> : the number of support variables (binary files only) [default = unused]\n" );
-    Abc_Print( -2, "\t-d       : toggle dumping resulting functions into a file [default = %s]\n", fDumpRes? "yes": "no" );
-    Abc_Print( -2, "\t-b       : toggle dumping in binary format [default = %s]\n", fBinary? "yes": "no" );
-    Abc_Print( -2, "\t-v       : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    Abc_Print( -2, "\t<file>   : a text file with truth tables in hexadecimal, listed one per line,\n");
-    Abc_Print( -2, "\t           or a binary file with an array of truth tables (in this case,\n");
-    Abc_Print( -2, "\t           -N <num> is required to determine how many functions are stored)\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandTestRPO(Abc_Frame_t * pAbc, int argc, char ** argv) {
-    extern int Abc_RpoTest(char * pFileName, int nVarNum, int nThreshold, int fVerbose);
-    char * pFileName;
-    int c;
-    int nVarNum = -1;
-    int fVerbose = 0;
-    int nThreshold = -1;
-    Extra_UtilGetoptReset();
-    while ((c = Extra_UtilGetopt(argc, argv, "TNvh")) != EOF) {
-        switch (c) {
-            case 'N':
-                if (globalUtilOptind >= argc) {
-                    Abc_Print(-1, "Command line switch \"-N\" should be followed by an integer.\n");
-                    goto usage;
-                }
-                nVarNum = atoi(argv[globalUtilOptind]);
-                globalUtilOptind++;
-                if (nVarNum < 0)
-                    goto usage;
-                break;
-            case 'T':
-                if (globalUtilOptind >= argc) {
-                    Abc_Print(-1, "Command line switch \"-T\" should be followed by an integer.\n");
-                    goto usage;
-                }
-                nThreshold = atoi(argv[globalUtilOptind]);
-                globalUtilOptind++;
-                if (nThreshold < 0)
-                    goto usage;
-                break;
-            case 'v':
-                fVerbose ^= 1;
-                break;
-            case 'h':
-                goto usage;
-            default:
-                goto usage;
-        }
-    }
-    if (argc != globalUtilOptind + 1) 
-    {
-        Abc_Print(1, "Input file is not given.\n");
-        goto usage;
-    }
-    // get the output file name
-    pFileName = argv[globalUtilOptind];
-    // call the testbench
-    Abc_RpoTest( pFileName, nVarNum, nThreshold, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print(-2, "usage: testrpo [-NT <num>] [-vh] <file>\n");
-    Abc_Print(-2, "\t           RPO algorithm developed and implemented by Mayler G. A. Martins,\n");
-    Abc_Print(-2, "\t           Vinicius Callegaro, Renato P. Ribas and Andre' I. Reis\n");
-    Abc_Print(-2, "\t           at Federal University of Rio Grande do Sul, Porto Alegre, Brazil\n");
-    Abc_Print(-2, "\t-N <num> : the number of support variables (binary files only) [default = unused]\n");
-    Abc_Print(-2, "\t-T <num> : the number of recursions accepted before abort [default = INFINITE]\n");
-    Abc_Print(-2, "\t-v       : toggle verbose printout [default = %s]\n", fVerbose ? "yes" : "no");
-    Abc_Print(-2, "\t-h       : print the command usage\n");
-    Abc_Print(-2, "\t<file>   : a text file with truth tables in hexadecimal, listed one per line,\n");
-    Abc_Print(-2, "\t           or a binary file with an array of truth tables (in this case,\n");
-    Abc_Print(-2, "\t           -N <num> is required to determine how many functions are stored)\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandRewrite( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int fUpdateLevel;
-    int fPrecompute;
-    int fUseZeros;
-    int fVerbose;
-    int fVeryVerbose;
-    int fPlaceEnable;
-    // external functions
-    extern void Rwr_Precompute();
-
-    // set defaults
-    fUpdateLevel = 1;
-    fPrecompute  = 0;
-    fUseZeros    = 0;
-    fVerbose     = 0;
-    fVeryVerbose = 0;
-    fPlaceEnable = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "lxzvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'l':
-            fUpdateLevel ^= 1;
-            break;
-        case 'x':
-            fPrecompute ^= 1;
-            break;
-        case 'z':
-            fUseZeros ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'w':
-            fVeryVerbose ^= 1;
-            break;
-        case 'p':
-            fPlaceEnable ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( fPrecompute )
-    {
-        Rwr_Precompute();
-        return 0;
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command can only be applied to an AIG (run \"strash\").\n" );
-        return 1;
-    }
-    if ( Abc_NtkGetChoiceNum(pNtk) )
-    {
-        Abc_Print( -1, "AIG resynthesis cannot be applied to AIGs with choice nodes.\n" );
-        return 1;
-    }
-
-    // modify the current network
-    if ( !Abc_NtkRewrite( pNtk, fUpdateLevel, fUseZeros, fVerbose, fVeryVerbose, fPlaceEnable ) )
-    {
-        Abc_Print( -1, "Rewriting has failed.\n" );
-        return 1;
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: rewrite [-lzvwh]\n" );
-    Abc_Print( -2, "\t         performs technology-independent rewriting of the AIG\n" );
-    Abc_Print( -2, "\t-l     : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
-    Abc_Print( -2, "\t-z     : toggle using zero-cost replacements [default = %s]\n", fUseZeros? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w     : toggle printout subgraph statistics [default = %s]\n", fVeryVerbose? "yes": "no" );
-//    Abc_Print( -2, "\t-p     : toggle placement-aware rewriting [default = %s]\n", fPlaceEnable? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandRefactor( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int nNodeSizeMax;
-    int nConeSizeMax;
-    int fUpdateLevel;
-    int fUseZeros;
-    int fUseDcs;
-    int fVerbose;
-    extern int Abc_NtkRefactor( Abc_Ntk_t * pNtk, int nNodeSizeMax, int nConeSizeMax, int fUpdateLevel, int fUseZeros, int fUseDcs, int fVerbose );
-
-    // set defaults
-    nNodeSizeMax = 10;
-    nConeSizeMax = 16;
-    fUpdateLevel =  1;
-    fUseZeros    =  0;
-    fUseDcs      =  0;
-    fVerbose     =  0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "NClzdvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nNodeSizeMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nNodeSizeMax < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nConeSizeMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nConeSizeMax < 0 )
-                goto usage;
-            break;
-        case 'l':
-            fUpdateLevel ^= 1;
-            break;
-        case 'z':
-            fUseZeros ^= 1;
-            break;
-        case 'd':
-            fUseDcs ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command can only be applied to an AIG (run \"strash\").\n" );
-        return 1;
-    }
-    if ( Abc_NtkGetChoiceNum(pNtk) )
-    {
-        Abc_Print( -1, "AIG resynthesis cannot be applied to AIGs with choice nodes.\n" );
-        return 1;
-    }
-
-    if ( fUseDcs && nNodeSizeMax >= nConeSizeMax )
-    {
-        Abc_Print( -1, "For don't-care to work, containing cone should be larger than collapsed node.\n" );
-        return 1;
-    }
-
-    // modify the current network
-    if ( !Abc_NtkRefactor( pNtk, nNodeSizeMax, nConeSizeMax, fUpdateLevel, fUseZeros, fUseDcs, fVerbose ) )
-    {
-        Abc_Print( -1, "Refactoring has failed.\n" );
-        return 1;
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: refactor [-NC <num>] [-lzdvh]\n" );
-    Abc_Print( -2, "\t           performs technology-independent refactoring of the AIG\n" );
-    Abc_Print( -2, "\t-N <num> : the max support of the collapsed node [default = %d]\n", nNodeSizeMax );
-    Abc_Print( -2, "\t-C <num> : the max support of the containing cone [default = %d]\n", nConeSizeMax );
-    Abc_Print( -2, "\t-l       : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
-    Abc_Print( -2, "\t-z       : toggle using zero-cost replacements [default = %s]\n", fUseZeros? "yes": "no" );
-    Abc_Print( -2, "\t-d       : toggle using don't-cares [default = %s]\n", fUseDcs? "yes": "no" );
-    Abc_Print( -2, "\t-v       : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandRestructure( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int nCutsMax;
-    int fUpdateLevel;
-    int fUseZeros;
-    int fVerbose;
-    extern int Abc_NtkRestructure( Abc_Ntk_t * pNtk, int nCutsMax, int fUpdateLevel, int fUseZeros, int fVerbose );
-
-    // set defaults
-    nCutsMax      =  5;
-    fUpdateLevel =  0;
-    fUseZeros    =  0;
-    fVerbose     =  0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Klzvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nCutsMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nCutsMax < 0 )
-                goto usage;
-            break;
-        case 'l':
-            fUpdateLevel ^= 1;
-            break;
-        case 'z':
-            fUseZeros ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( nCutsMax < 4 || nCutsMax > CUT_SIZE_MAX )
-    {
-        Abc_Print( -1, "Can only compute the cuts for %d <= K <= %d.\n", 4, CUT_SIZE_MAX );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command can only be applied to an AIG (run \"strash\").\n" );
-        return 1;
-    }
-    if ( Abc_NtkGetChoiceNum(pNtk) )
-    {
-        Abc_Print( -1, "AIG resynthesis cannot be applied to AIGs with choice nodes.\n" );
-        return 1;
-    }
-
-    // modify the current network
-    if ( !Abc_NtkRestructure( pNtk, nCutsMax, fUpdateLevel, fUseZeros, fVerbose ) )
-    {
-        Abc_Print( -1, "Refactoring has failed.\n" );
-        return 1;
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: restructure [-K <num>] [-lzvh]\n" );
-    Abc_Print( -2, "\t           performs technology-independent restructuring of the AIG\n" );
-    Abc_Print( -2, "\t-K <num> : the max cut size (%d <= num <= %d) [default = %d]\n",   CUT_SIZE_MIN, CUT_SIZE_MAX, nCutsMax );
-    Abc_Print( -2, "\t-l       : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
-    Abc_Print( -2, "\t-z       : toggle using zero-cost replacements [default = %s]\n", fUseZeros? "yes": "no" );
-    Abc_Print( -2, "\t-v       : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandResubstitute( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int RS_CUT_MIN =  4;
-    int RS_CUT_MAX = 16;
-    int c;
-    int nCutsMax;
-    int nNodesMax;
-    int nLevelsOdc;
-    int fUpdateLevel;
-    int fUseZeros;
-    int fVerbose;
-    int fVeryVerbose;
-    extern int Abc_NtkResubstitute( Abc_Ntk_t * pNtk, int nCutsMax, int nNodesMax, int nLevelsOdc, int fUpdateLevel, int fVerbose, int fVeryVerbose );
-
-    // set defaults
-    nCutsMax     =  8;
-    nNodesMax    =  1;
-    nLevelsOdc   =  0;
-    fUpdateLevel =  1;
-    fUseZeros    =  0;
-    fVerbose     =  0;
-    fVeryVerbose =  0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "KNFlzvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nCutsMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nCutsMax < 0 )
-                goto usage;
-            break;
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nNodesMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nNodesMax < 0 )
-                goto usage;
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nLevelsOdc = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nLevelsOdc < 0 )
-                goto usage;
-            break;
-        case 'l':
-            fUpdateLevel ^= 1;
-            break;
-        case 'z':
-            fUseZeros ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'w':
-            fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( nCutsMax < RS_CUT_MIN || nCutsMax > RS_CUT_MAX )
-    {
-        Abc_Print( -1, "Can only compute cuts for %d <= K <= %d.\n", RS_CUT_MIN, RS_CUT_MAX );
-        return 1;
-    }
-    if ( nNodesMax < 0 || nNodesMax > 3 )
-    {
-        Abc_Print( -1, "Can only resubstitute at most 3 nodes.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command can only be applied to an AIG (run \"strash\").\n" );
-        return 1;
-    }
-    if ( Abc_NtkGetChoiceNum(pNtk) )
-    {
-        Abc_Print( -1, "AIG resynthesis cannot be applied to AIGs with choice nodes.\n" );
-        return 1;
-    }
-
-    // modify the current network
-    if ( !Abc_NtkResubstitute( pNtk, nCutsMax, nNodesMax, nLevelsOdc, fUpdateLevel, fVerbose, fVeryVerbose ) )
-    {
-        Abc_Print( -1, "Refactoring has failed.\n" );
-        return 1;
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: resub [-KN <num>] [-lzvwh]\n" );
-    Abc_Print( -2, "\t           performs technology-independent restructuring of the AIG\n" );
-    Abc_Print( -2, "\t-K <num> : the max cut size (%d <= num <= %d) [default = %d]\n", RS_CUT_MIN, RS_CUT_MAX, nCutsMax );
-    Abc_Print( -2, "\t-N <num> : the max number of nodes to add (0 <= num <= 3) [default = %d]\n", nNodesMax );
-    Abc_Print( -2, "\t-F <num> : the number of fanout levels for ODC computation [default = %d]\n", nLevelsOdc );
-    Abc_Print( -2, "\t-l       : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
-    Abc_Print( -2, "\t-z       : toggle using zero-cost replacements [default = %s]\n", fUseZeros? "yes": "no" );
-    Abc_Print( -2, "\t-v       : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w       : toggle verbose printout of ODC computation [default = %s]\n", fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandRr( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c, Window;
-    int nFaninLevels;
-    int nFanoutLevels;
-    int fUseFanouts;
-    int fVerbose;
-    extern int Abc_NtkRR( Abc_Ntk_t * pNtk, int nFaninLevels, int nFanoutLevels, int fUseFanouts, int fVerbose );
-
-    // set defaults
-    nFaninLevels  = 3;
-    nFanoutLevels = 3;
-    fUseFanouts   = 0;
-    fVerbose      = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Wfvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            Window = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( Window < 0 )
-                goto usage;
-            nFaninLevels  = Window / 10;
-            nFanoutLevels = Window % 10;
-            break;
-        case 'f':
-            fUseFanouts ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command can only be applied to an AIG (run \"strash\").\n" );
-        return 1;
-    }
-    if ( Abc_NtkGetChoiceNum(pNtk) )
-    {
-        Abc_Print( -1, "AIG resynthesis cannot be applied to AIGs with choice nodes.\n" );
-        return 1;
-    }
-
-    // modify the current network
-    if ( !Abc_NtkRR( pNtk, nFaninLevels, nFanoutLevels, fUseFanouts, fVerbose ) )
-    {
-        Abc_Print( -1, "Redundancy removal has failed.\n" );
-        return 1;
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: rr [-W NM] [-fvh]\n" );
-    Abc_Print( -2, "\t         removes combinational redundancies in the current network\n" );
-    Abc_Print( -2, "\t-W NM  : window size: TFI (N) and TFO (M) logic levels [default = %d%d]\n", nFaninLevels, nFanoutLevels );
-    Abc_Print( -2, "\t-f     : toggle RR w.r.t. fanouts [default = %s]\n", fUseFanouts? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandCascade( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c, nLutSize;
-    int fCheck;
-    int fVerbose;
-    extern Abc_Ntk_t * Abc_NtkCascade( Abc_Ntk_t * pNtk, int nLutSize, int fCheck, int fVerbose );
-    pNtk = Abc_FrameReadNtk(pAbc);
-
-    // set defaults
-    nLutSize = 12;
-    fCheck   = 0;
-    fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Kcvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nLutSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nLutSize < 0 )
-                goto usage;
-            break;
-        case 'c':
-            fCheck ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsLogic(pNtk) && !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Can only collapse a logic network or an AIG.\n" );
-        return 1;
-    }
-
-    // get the new network
-    if ( Abc_NtkIsStrash(pNtk) )
-        pNtkRes = Abc_NtkCascade( pNtk, nLutSize, fCheck, fVerbose );
-    else
-    {
-        pNtk = Abc_NtkStrash( pNtk, 0, 0, 0 );
-        pNtkRes = Abc_NtkCascade( pNtk, nLutSize, fCheck, fVerbose );
-        Abc_NtkDelete( pNtk );
-    }
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Cascade synthesis has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: cascade [-K <num>] [-cvh]\n" );
-    Abc_Print( -2, "\t           performs LUT cascade synthesis for the current network\n" );
-    Abc_Print( -2, "\t-K <num> : the number of LUT inputs [default = %d]\n", nLutSize );
-    Abc_Print( -2, "\t-c       : check equivalence after synthesis [default = %s]\n", fCheck? "yes": "no" );
-    Abc_Print( -2, "\t-v       : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    Abc_Print( -2, "\t           \n");
-    Abc_Print( -2, "  A lookup-table cascade is a programmable architecture developed by\n");
-    Abc_Print( -2, "  Professor Tsutomu Sasao (sasao@cse.kyutech.ac.jp) at Kyushu Institute\n");
-    Abc_Print( -2, "  of Technology. This work received Takeda Techno-Entrepreneurship Award:\n");
-    Abc_Print( -2, "  http://www.lsi-cad.com/sasao/photo/takeda.html\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandExtract( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Abc_Ntk_t * Abc_NtkShareXor( Abc_Ntk_t * pNtk, int nMultiSize, int fAnd, int fVerbose );
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c, nMultiSize, fAnd, fVerbose;
-    pNtk = Abc_FrameReadNtk(pAbc);
-
-    // set defaults
-    nMultiSize = 3;
-    fAnd       = 0;
-    fVerbose   = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Kavh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nMultiSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nMultiSize < 0 )
-                goto usage;
-            break;
-        case 'a':
-            fAnd ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Can only collapse a logic network or an AIG.\n" );
-        return 1;
-    }
-    // get the new network
-    pNtkRes = Abc_NtkShareXor( pNtk, nMultiSize, fAnd, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Cascade synthesis has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: extract [-K <num>] [-avh]\n" );
-    Abc_Print( -2, "\t           extracts shared logic from multi-input gates\n" );
-    Abc_Print( -2, "\t-K <num> : the minimum gate size to consider for extraction [default = %d]\n", nMultiSize );
-    Abc_Print( -2, "\t-a       : toggle multi-input XOR vs multi-input AND [default = %s]\n", fAnd? "AND": "XOR" );
-    Abc_Print( -2, "\t-v       : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandVarMin( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern void Abc_SuppTest( int nOnes, int nVars, int fUseSimple, int fCheck, int fVerbose );
-    extern void Abc_SuppReadMinTest( char * pFileName );
-    int nOnes      =  4;
-    int nVars      = 20;
-    int fUseSimple =  0;
-    int fCheck     =  0;
-    int fVerbose   =  0;
-    int c;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "MNocvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'M':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nOnes = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nOnes < 0 )
-                goto usage;
-            break;
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nVars = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nVars < 0 )
-                goto usage;
-            break;
-        case 'o':
-            fUseSimple ^= 1;
-            break;
-        case 'c':
-            fCheck ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    // get the file name
-    if ( argc == globalUtilOptind + 1 )
-    {
-        Abc_SuppReadMinTest( argv[globalUtilOptind] );
-        return 0;
-    }
-    Abc_SuppTest( nOnes, nVars, fUseSimple, fCheck, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: varmin [-MN <num>] [-ocvh]\n" );
-    Abc_Print( -2, "\t           performs support minimization\n" );
-    Abc_Print( -2, "\t-M <num> : the number of ones in the combination [default = %d]\n", nOnes );
-    Abc_Print( -2, "\t-N <num> : the number of variables in the problem [default = %d]\n", nVars );
-    Abc_Print( -2, "\t-o       : toggle computing reduced difference matrix [default = %s]\n", fUseSimple? "yes": "no" );
-    Abc_Print( -2, "\t-c       : toggle verifying the final result [default = %s]\n", fCheck? "yes": "no" );
-    Abc_Print( -2, "\t-v       : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandLogic( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c;
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsStrash( pNtk ) )
-    {
-        Abc_Print( -1, "This command is only applicable to strashed networks.\n" );
-        return 1;
-    }
-
-    // get the new network
-    pNtkRes = Abc_NtkToLogic( pNtk );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Converting to a logic network has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: logic [-h]\n" );
-    Abc_Print( -2, "\t        transforms an AIG into a logic network with SOPs\n" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandComb( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c;
-    int fRemoveLatches;
-    int nLatchesToAdd;
-    extern void Abc_NtkMakeSeq( Abc_Ntk_t * pNtk, int nLatchesToAdd );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    fRemoveLatches = 0;
-    nLatchesToAdd = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Llh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nLatchesToAdd = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nLatchesToAdd < 0 )
-                goto usage;
-            break;
-        case 'l':
-            fRemoveLatches ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( Abc_NtkIsComb(pNtk) && nLatchesToAdd == 0 )
-    {
-        Abc_Print( -1, "The network is already combinational.\n" );
-        return 0;
-    }
-    if ( !Abc_NtkIsComb(pNtk) && nLatchesToAdd != 0 )
-    {
-        Abc_Print( -1, "The network is already combinational.\n" );
-        return 0;
-    }
-
-    // get the new network
-    pNtkRes = Abc_NtkDup( pNtk );
-    if ( nLatchesToAdd )
-        Abc_NtkMakeSeq( pNtkRes, nLatchesToAdd );
-    else
-        Abc_NtkMakeComb( pNtkRes, fRemoveLatches );
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: comb [-L <num>] [-lh]\n" );
-    Abc_Print( -2, "\t           converts comb network into seq, and vice versa\n" );
-    Abc_Print( -2, "\t-L <num> : number of latches to add to comb network (0 = do not add) [default = %d]\n", nLatchesToAdd );
-    Abc_Print( -2, "\t-l       : toggle converting latches to PIs/POs or removing them [default = %s]\n", fRemoveLatches? "remove": "convert" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandMiter( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    char Buffer[32];
-    Abc_Ntk_t * pNtk, * pNtk1, * pNtk2, * pNtkRes;
-    int fDelete1, fDelete2;
-    char ** pArgvNew;
-    int nArgcNew;
-    int c;
-    int fCheck;
-    int fComb;
-    int fImplic;
-    int fMulti;
-    int nPartSize;
-    int fTrans;
-    int fIgnoreNames;
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-
-    // set defaults
-    fComb  = 0;
-    fCheck = 1;
-    fImplic = 0;
-    fMulti = 0;
-    nPartSize = 0;
-    fTrans = 0;
-    fIgnoreNames = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Pcmitnh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'P':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nPartSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nPartSize < 0 )
-                goto usage;
-            break;
-        case 'c':
-            fComb ^= 1;
-            break;
-        case 'm':
-            fMulti ^= 1;
-            break;
-        case 'i':
-            fImplic ^= 1;
-            break;
-        case 't':
-            fTrans ^= 1;
-            break;
-        case 'n':
-            fIgnoreNames ^= 1;
-            break;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( fTrans )
-    {
-        if ( (Abc_NtkPoNum(pNtk) & 1) == 1 )
-        {
-            Abc_Print( -1, "Abc_CommandMiter(): The number of outputs should be even.\n" );
-            return 0;
-        }
-        // replace the current network
-        pNtkRes = Abc_NtkDupTransformMiter( pNtk );
-        Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-        Abc_Print( 1, "The miter (current network) is transformed by XORing POs pair-wise.\n" );
-        return 0;
-    }
-
-    pArgvNew = argv + globalUtilOptind;
-    nArgcNew = argc - globalUtilOptind;
-    if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
-        return 1;
-
-    if ( fIgnoreNames )
-    {
-        if ( !fDelete1 )
-        {
-            pNtk1 = Abc_NtkStrash( pNtk1, 0, 1, 0 );
-            fDelete1 = 1;
-        }
-        if ( !fDelete2 )
-        {
-            pNtk2 = Abc_NtkStrash( pNtk2, 0, 1, 0 );
-            fDelete2 = 1;
-        }
-        Abc_NtkShortNames( pNtk1 );
-        Abc_NtkShortNames( pNtk2 );
-    }
-    // compute the miter
-    pNtkRes = Abc_NtkMiter( pNtk1, pNtk2, fComb, nPartSize, fImplic, fMulti );
-    if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
-    if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
-
-    // get the new network
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Miter computation has failed.\n" );
-        return 0;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    if ( nPartSize == 0 )
-        strcpy( Buffer, "unused" );
-    else
-        sprintf(Buffer, "%d", nPartSize );
-    Abc_Print( -2, "usage: miter [-P <num>] [-cimtnh] <file1> <file2>\n" );
-    Abc_Print( -2, "\t           computes the miter of the two circuits\n" );
-    Abc_Print( -2, "\t-P <num> : output partition size [default = %s]\n", Buffer );
-    Abc_Print( -2, "\t-c       : toggles deriving combinational miter (latches as POs) [default = %s]\n", fComb? "yes": "no" );
-    Abc_Print( -2, "\t-i       : toggles deriving implication miter (file1 => file2) [default = %s]\n", fImplic? "yes": "no" );
-    Abc_Print( -2, "\t-m       : toggles creating multi-output miter [default = %s]\n", fMulti? "yes": "no" );
-    Abc_Print( -2, "\t-t       : toggle XORing pair-wise POs of the miter [default = %s]\n", fTrans? "yes": "no" );
-    Abc_Print( -2, "\t-n       : toggle ignoring names when matching CIs/COs [default = %s]\n", fIgnoreNames? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    Abc_Print( -2, "\tfile1    : (optional) the file with the first network\n");
-    Abc_Print( -2, "\tfile2    : (optional) the file with the second network\n");
-    Abc_Print( -2, "\t           if no files are given, uses the current network and its spec\n");
-    Abc_Print( -2, "\t           if one file is given, uses the current network and the file\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandDemiter( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c, fDual, fVerbose;
-    extern int Abc_NtkDarDemiter( Abc_Ntk_t * pNtk );
-    extern int Abc_NtkDarDemiterDual( Abc_Ntk_t * pNtk, int fVerbose );
-    // set defaults
-    fDual = 0;
-    fVerbose = 1;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "dvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'd':
-            fDual ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "The network is not strashed.\n" );
-        return 1;
-    }
-
-    if ( fDual )
-    {
-        if ( (Abc_NtkPoNum(pNtk) & 1) )
-        {
-            Abc_Print( -1, "The number of POs should be even.\n" );
-            return 0;
-        }
-        if ( !Abc_NtkDarDemiterDual( pNtk, fVerbose ) )
-        {
-            Abc_Print( -1, "Demitering has failed.\n" );
-            return 1;
-        }
-        return 0;
-    }
-/*
-    if ( Abc_NtkPoNum(pNtk) != 1 )
-    {
-        Abc_Print( -1, "The network is not a single-output miter.\n" );
-        return 1;
-    }
-    if ( !Abc_NodeIsExorType(Abc_ObjFanin0(Abc_NtkPo(pNtk,0))) )
-    {
-        Abc_Print( -1, "The miter's PO is not an EXOR.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkDemiter( pNtk ) )
-    {
-        Abc_Print( -1, "Demitering has failed.\n" );
-        return 1;
-    }
-*/
-    // get the new network
-    if ( !Abc_NtkDarDemiter( pNtk ) )
-    {
-        Abc_Print( -1, "Demitering has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-//    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: demiter [-dvh]\n" );
-    Abc_Print( -2, "\t        splits sequential miter into two circuits\n" );
-    Abc_Print( -2, "\t-d    : expects a dual-output miter (without XORs) [default = %s]\n", fDual? "yes": "no" );
-    Abc_Print( -2, "\t-v    : toggles outputting verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandOrPos( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);//, * pNtkRes;
-    int fReverse = 0;
-    int fComb = 0;
-    int fXor = 0;
-    int c;
-    extern int Abc_NtkCombinePos( Abc_Ntk_t * pNtk, int fAnd, int fXor );
-
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "rxh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'r':
-            fReverse ^= 1;
-            break;
-        case 'x':
-            fXor ^= 1;
-            break;
-        case 'c':
-            fComb ^= 1;
-            break;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "The network is not strashed.\n" );
-        return 1;
-    }
-    // get the new network
-    if ( fReverse )
-    {
-        extern Aig_Man_t * Abc_NtkToDarBmc( Abc_Ntk_t * pNtk, Vec_Int_t ** pvMap );
-        Aig_Man_t * pMan = Abc_NtkToDarBmc( pNtk, NULL );
-        Abc_Ntk_t * pNtkRes = Abc_NtkFromAigPhase( pMan );
-        Aig_ManStop( pMan );
-        // perform expansion
-        if ( Abc_NtkPoNum(pNtk) != Abc_NtkPoNum(pNtkRes) )
-            Abc_Print( 1,"Expanded %d outputs into %d outputs using OR decomposition.\n", Abc_NtkPoNum(pNtk), Abc_NtkPoNum(pNtkRes) );
-        else
-            Abc_Print( 1,"The output(s) cannot be structurally decomposed.\n" );
-        // clear counter-example
-        if ( pAbc->pCex )
-            ABC_FREE( pAbc->pCex );
-        // replace the current network
-        ABC_FREE( pNtkRes->pName );
-        pNtkRes->pName = Extra_UtilStrsav(pNtk->pName);
-        Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    }
-    else
-    {
-        if ( !Abc_NtkCombinePos( pNtk, 0, fXor ) )
-        {
-            Abc_Print( -1, "ORing the POs has failed.\n" );
-            return 1;
-        }
-        // update counter-example
-        if ( pAbc->pCex )
-            pAbc->pCex->iPo = 0;
-        // replace the current network
-    //    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: orpos [-rxh]\n" );
-    Abc_Print( -2, "\t        creates single-output miter by ORing the POs of the current network\n" );
-    Abc_Print( -2, "\t-r    : performs the reverse transform (OR decomposition) [default = %s]\n", fReverse? "yes": "no" );
-    Abc_Print( -2, "\t-x    : toggles combining the PO using XOR [default = %s]\n", fXor? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAndPos( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);//, * pNtkRes;
-    int fComb = 0;
-    int c;
-
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'c':
-            fComb ^= 1;
-            break;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "The network is not strashed.\n" );
-        return 1;
-    }
-
-    if ( Abc_NtkPoNum(pNtk) == 1 )
-    {
-        Abc_Print( -1, "The network already has one PO.\n" );
-        return 1;
-    }
-
-    if ( Abc_NtkLatchNum(pNtk) )
-    {
-        Abc_Print( -1, "The miter has latches. ORing is not performed.\n" );
-        return 1;
-    }
-
-    // get the new network
-    if ( !Abc_NtkCombinePos( pNtk, 1, 0 ) )
-    {
-        Abc_Print( -1, "ANDing the POs has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-//    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: andpos [-h]\n" );
-    Abc_Print( -2, "\t        creates single-output miter by ANDing the POs of the current network\n" );
-//    Abc_Print( -2, "\t-c    : computes combinational miter (latches as POs) [default = %s]\n", fComb? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandZeroPo( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);//, * pNtkRes = NULL;
-    int c, iOutput = -1;
-    int fSkipSweep = 0;
-    int fUseConst1 = 0;
-    extern void Abc_NtkDropOneOutput( Abc_Ntk_t * pNtk, int iOutput, int fSkipSweep, int fUseConst1 );
-
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Nsoh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            iOutput = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( iOutput < 0 )
-                goto usage;
-            break;
-        case 's':
-            fSkipSweep ^= 1;
-            break;
-        case 'o':
-            fUseConst1 ^= 1;
-            break;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "The network is not strashed.\n" );
-        return 1;
-    }
-    if ( iOutput < 0 )
-    {
-        Abc_Print( -1, "The output index is not specified.\n" );
-        return 1;
-    }
-    if ( iOutput >= Abc_NtkPoNum(pNtk) )
-    {
-        Abc_Print( -1, "The output index is larger than the allowed POs.\n" );
-        return 1;
-    }
-
-    // get the new network
-//    pNtkRes = Abc_NtkDup( pNtk );
-//    Abc_NtkDropOneOutput( pNtkRes, iOutput );
-//    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    Abc_NtkDropOneOutput( pNtk, iOutput, fSkipSweep, fUseConst1 );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: zeropo [-N <num>] [-soh]\n" );
-    Abc_Print( -2, "\t           replaces the PO driver by constant 0\n" );
-    Abc_Print( -2, "\t-N <num> : the zero-based index of the PO to replace [default = %d]\n", iOutput );
-    Abc_Print( -2, "\t-s       : performs comb sweep after removimg a PO [default = %s]\n", !fSkipSweep? "yes": "no" );
-    Abc_Print( -2, "\t-o       : toggles using const 1 instead of const 0 [default = %s]\n", fUseConst1? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandSwapPos( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc), * pNtkRes;
-    int c, iOutput = -1;
-    extern void Abc_NtkSwapOneOutput( Abc_Ntk_t * pNtk, int iOutput );
-
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Nh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            iOutput = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( iOutput < 0 )
-                goto usage;
-            break;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "The network is not strashed.\n" );
-        return 1;
-    }
-    if ( iOutput < 0 )
-    {
-        Abc_Print( -1, "The output index is not specified.\n" );
-        return 1;
-    }
-    if ( iOutput >= Abc_NtkPoNum(pNtk) )
-    {
-        Abc_Print( -1, "The output index is larger than the allowed POs.\n" );
-        return 1;
-    }
-
-    // get the new network
-    pNtkRes = Abc_NtkDup( pNtk );
-    Abc_NtkSwapOneOutput( pNtkRes, iOutput );
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: swappos [-N <num>] [-h]\n" );
-    Abc_Print( -2, "\t           swap the 0-th PO with the <num>-th PO\n" );
-    Abc_Print( -2, "\t-N <num> : the zero-based index of the PO to swap [default = %d]\n", iOutput );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandRemovePo( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);//, * pNtkRes = NULL;
-    int c, iOutput = -1;
-    int fRemoveConst0 = 1;
-    extern void Abc_NtkRemovePo( Abc_Ntk_t * pNtk, int iOutput, int fRemoveConst0 );
-
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Nzh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            iOutput = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( iOutput < 0 )
-                goto usage;
-            break;
-        case 'z':
-            fRemoveConst0 ^= 1;
-            break;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "The network is not strashed.\n" );
-        return 1;
-    }
-    if ( iOutput < 0 )
-    {
-        Abc_Print( -1, "The output index is not specified.\n" );
-        return 1;
-    }
-    if ( iOutput >= Abc_NtkPoNum(pNtk) )
-    {
-        Abc_Print( -1, "The output index is larger than the allowed POs.\n" );
-        return 1;
-    }
-
-    // get the new network
-//    pNtkRes = Abc_NtkDup( pNtk );
-//    Abc_NtkRemovePo( pNtkRes, iOutput );
-//    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    Abc_NtkRemovePo( pNtk, iOutput, fRemoveConst0 );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: removepo [-N <num>] [-zh]\n" );
-    Abc_Print( -2, "\t           remove PO with number <num> if it is const0\n" );
-    Abc_Print( -2, "\t-N <num> : the zero-based index of the PO to remove [default = %d]\n", iOutput );
-    Abc_Print( -2, "\t-z       : toggle removing const1 instead of const0 [default = %s]\n", fRemoveConst0? "const0": "const1" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandDropSat( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern void Abc_NtkDropSatOutputs( Abc_Ntk_t * pNtk, Vec_Ptr_t * vCexes, int fVerbose );
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc), * pNtkRes = NULL;
-    int fNoSweep = 0;
-    int c, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "svh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 's':
-            fNoSweep ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for AIGs (run \"strash\").\n" );
-        return 1;
-    }
-    if ( pAbc->vCexVec == NULL )
-    {
-        Abc_Print( -1, "CEX array is not defined. Run \"bmc3 -az\", \"sim3 -az\", or \"pdr -az\".\n" );
-        return 1;
-    }
-    if ( Vec_PtrSize(pAbc->vCexVec) != Abc_NtkPoNum(pNtk) )
-    {
-        Abc_Print( -1, "CEX array size (%d) does not match the number of outputs (%d).\n", Vec_PtrSize(pAbc->vCexVec), Abc_NtkPoNum(pNtk) );
-        return 1;
-    }
-    Abc_NtkDropSatOutputs( pNtk, pAbc->vCexVec, fVerbose );
-    if ( !fNoSweep )
-    {
-        pNtkRes = Abc_NtkDarLatchSweep( pNtk, 1, 1, 1, 0, -1, -1, 0, 0 );
-        if ( pNtkRes == NULL )
-        {
-            Abc_Print( -1, "Removing SAT outputs has failed.\n" );
-            return 1;
-        }
-        Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: dropsat [-sh]\n" );
-    Abc_Print( -2, "\t         replaces satisfiable POs by constant 0 and cleans up the AIG\n" );
-    Abc_Print( -2, "\t-s     : toggles skipping sequential sweep [default = %s]\n", fNoSweep? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAddPi( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc), * pNtkRes;
-    int c;
-
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    // get the new network
-    pNtkRes = Abc_NtkDup( pNtk );
-    if ( Abc_NtkPiNum(pNtkRes) == 0 )
-    {
-        Abc_Obj_t * pObj = Abc_NtkCreatePi( pNtkRes );
-        Abc_ObjAssignName( pObj, "dummy_pi", NULL );
-        Abc_NtkOrderCisCos( pNtkRes );
-    }
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: addpi [-h]\n" );
-    Abc_Print( -2, "\t         if the network has no PIs, add one dummy PI\n" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAppend( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtk2;
-    char * FileName;
-    int fComb = 0;
-    int c;
-    pNtk = Abc_FrameReadNtk(pAbc);
-
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'c':
-            fComb ^= 1;
-            break;
-        default:
-            goto usage;
-        }
-    }
-
-    // get the second network
-    if ( argc != globalUtilOptind + 1 )
-    {
-        Abc_Print( -1, "The network to append is not given.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "The base network should be strashed for the appending to work.\n" );
-        return 1;
-    }
-
-    // read the second network
-    FileName = argv[globalUtilOptind];
-    pNtk2 = Io_Read( FileName, Io_ReadFileType(FileName), 1, 0 );
-    if ( pNtk2 == NULL )
-        return 1;
-
-    // check if the second network is combinational
-    if ( Abc_NtkLatchNum(pNtk2) )
-    {
-        Abc_NtkDelete( pNtk2 );
-        Abc_Print( -1, "The second network has latches. Appending does not work for such networks.\n" );
-        return 0;
-    }
-
-    // get the new network
-    if ( !Abc_NtkAppend( pNtk, pNtk2, 1 ) )
-    {
-        Abc_NtkDelete( pNtk2 );
-        Abc_Print( -1, "Appending the networks failed.\n" );
-        return 1;
-    }
-    Abc_NtkDelete( pNtk2 );
-    // sweep dangling logic
-    Abc_AigCleanup( (Abc_Aig_t *)pNtk->pManFunc );
-    // replace the current network
-//    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: append [-h] <file>\n" );
-    Abc_Print( -2, "\t         appends a combinational network on top of the current network\n" );
-//    Abc_Print( -2, "\t-c     : computes combinational miter (latches as POs) [default = %s]\n", fComb? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\t<file> : file name with the second network\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandPutOnTop( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Abc_Ntk_t * Abc_NtkPutOnTop( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtk2 );
-
-    Abc_Ntk_t * pNtk, * pNtk2, * pNtkRes;
-    char * FileName;
-    int fComb = 0;
-    int c;
-    pNtk = Abc_FrameReadNtk(pAbc);
-
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'c':
-            fComb ^= 1;
-            break;
-        default:
-            goto usage;
-        }
-    }
-
-    // get the second network
-    if ( argc != globalUtilOptind + 1 )
-    {
-        Abc_Print( -1, "The network to append is not given.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsLogic(pNtk) )
-    {
-        Abc_Print( -1, "The base network should be in the logic form.\n" );
-        return 1;
-    }
-
-    // check if the second network is combinational
-    if ( Abc_NtkLatchNum(pNtk) )
-    {
-        Abc_Print( -1, "The current network has latches. This command does not work for such networks.\n" );
-        return 0;
-    }
-
-    // read the second network
-    FileName = argv[globalUtilOptind];
-    pNtk2 = Io_Read( FileName, Io_ReadFileType(FileName), 1, 0 );
-    if ( pNtk2 == NULL )
-        return 1;
-
-    // check if the second network is combinational
-    if ( Abc_NtkLatchNum(pNtk2) )
-    {
-        Abc_NtkDelete( pNtk2 );
-        Abc_Print( -1, "The second network has latches. This command does not work for such networks.\n" );
-        return 0;
-    }
-    // compare inputs/outputs
-    if ( Abc_NtkPoNum(pNtk) != Abc_NtkPiNum(pNtk2) )
-    {
-        Abc_NtkDelete( pNtk2 );
-        Abc_Print( -1, "The PO count (%d) of the first network is not equal to PI count (%d) of the second network.\n", Abc_NtkPoNum(pNtk), Abc_NtkPiNum(pNtk2) );
-        return 0;
-    }
-
-    // get the new network
-    pNtkRes = Abc_NtkPutOnTop( pNtk, pNtk2 );
-    Abc_NtkDelete( pNtk2 );
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: putontop [-h] <file>\n" );
-    Abc_Print( -2, "\t         connects PIs of network in <file> to POs of current network\n" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\t<file> : file name with the second network\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandFrames( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkTemp, * pNtkRes;
-    int nFrames;
-    int fInitial;
-    int fVerbose;
-    int c;
-    pNtk = Abc_FrameReadNtk(pAbc);
-
-    // set defaults
-    nFrames  = 5;
-    fInitial = 0;
-    fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Fivh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFrames = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFrames <= 0 )
-                goto usage;
-            break;
-        case 'i':
-            fInitial ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    // get the new network
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
-        pNtkRes  = Abc_NtkFrames( pNtkTemp, nFrames, fInitial, fVerbose );
-        Abc_NtkDelete( pNtkTemp );
-    }
-    else
-        pNtkRes  = Abc_NtkFrames( pNtk, nFrames, fInitial, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Unrolling the network has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: frames [-F <num>] [-ivh]\n" );
-    Abc_Print( -2, "\t           unrolls the network for a number of time frames\n" );
-    Abc_Print( -2, "\t-F <num> : the number of frames to unroll [default = %d]\n", nFrames );
-    Abc_Print( -2, "\t-i       : toggles initializing the first frame [default = %s]\n", fInitial? "yes": "no" );
-    Abc_Print( -2, "\t-v       : toggles outputting verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandDFrames( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkTemp, * pNtkRes;
-    int nPrefix;
-    int nFrames;
-    int fInitial;
-    int fVerbose;
-    int c;
-
-    extern Abc_Ntk_t * Abc_NtkDarFrames( Abc_Ntk_t * pNtk, int nPrefix, int nFrames, int fInitial, int fVerbose );
-    pNtk = Abc_FrameReadNtk(pAbc);
-
-    // set defaults
-    nPrefix  = 5;
-    nFrames  = 5;
-    fInitial = 0;
-    fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "NFivh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nPrefix = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nPrefix <= 0 )
-                goto usage;
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFrames = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFrames <= 0 )
-                goto usage;
-            break;
-        case 'i':
-            fInitial ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( nPrefix > nFrames )
-    {
-        Abc_Print( -1, "Prefix (%d) cannot be more than the number of frames (%d).\n", nPrefix, nFrames );
-        return 1;
-    }
-
-    // get the new network
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
-        pNtkRes  = Abc_NtkDarFrames( pNtkTemp, nPrefix, nFrames, fInitial, fVerbose );
-        Abc_NtkDelete( pNtkTemp );
-    }
-    else
-        pNtkRes  = Abc_NtkDarFrames( pNtk, nPrefix, nFrames, fInitial, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Unrolling the network has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: dframes [-NF <num>] [-ivh]\n" );
-    Abc_Print( -2, "\t         unrolls the network with simplification\n" );
-    Abc_Print( -2, "\t-N num : the number of frames to use as prefix [default = %d]\n", nPrefix );
-    Abc_Print( -2, "\t-F num : the number of frames to unroll [default = %d]\n", nFrames );
-    Abc_Print( -2, "\t-i     : toggles initializing the first frame [default = %s]\n", fInitial? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggles outputting verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandSop( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int fDirect;
-    int c;
-
-    // set defaults
-    fDirect = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'd':
-            fDirect ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsLogic(pNtk) )
-    {
-        Abc_Print( -1, "Converting to SOP is possible only for logic networks.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkToSop(pNtk, fDirect) )
-    {
-        Abc_Print( -1, "Converting to SOP has failed.\n" );
-        return 1;
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: sop [-dh]\n" );
-    Abc_Print( -2, "\t         converts node functions to SOP\n" );
-    Abc_Print( -2, "\t-d     : toggles using both phases or only positive [default = %s]\n", fDirect? "direct": "both" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandBdd( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int fReorder = 1;
-    int c;
-
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "rh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'r':
-            fReorder ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsLogic(pNtk) )
-    {
-        Abc_Print( -1, "Converting to BDD is possible only for logic networks.\n" );
-        return 1;
-    }
-    if ( Abc_NtkIsBddLogic(pNtk) )
-    {
-        Abc_Print( -1, "The logic network is already in the BDD form.\n" );
-        return 0;
-    }
-    if ( !Abc_NtkToBdd(pNtk) )
-    {
-        Abc_Print( -1, "Converting to BDD has failed.\n" );
-        return 1;
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: bdd [-rh]\n" );
-    Abc_Print( -2, "\t         converts node functions to BDD\n" );
-    Abc_Print( -2, "\t-r     : toggles enabling dynamic variable reordering [default = %s]\n", fReorder? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAig( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsLogic(pNtk) )
-    {
-        Abc_Print( -1, "Converting to AIG is possible only for logic networks.\n" );
-        return 1;
-    }
-    if ( Abc_NtkIsAigLogic(pNtk) )
-    {
-        Abc_Print( -1, "The logic network is already in the AIG form.\n" );
-        return 0;
-    }
-    if ( !Abc_NtkToAig(pNtk) )
-    {
-        Abc_Print( -1, "Converting to AIG has failed.\n" );
-        return 1;
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: aig [-h]\n" );
-    Abc_Print( -2, "\t         converts node functions to AIG\n" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandReorder( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int fVerbose;
-    extern void Abc_NtkBddReorder( Abc_Ntk_t * pNtk, int fVerbose );
-
-    // set defaults
-    fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    // get the new network
-    if ( !Abc_NtkIsBddLogic(pNtk) )
-    {
-        Abc_Print( -1, "Variable reordering is possible when node functions are BDDs (run \"bdd\").\n" );
-        return 1;
-    }
-    Abc_NtkBddReorder( pNtk, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: reorder [-vh]\n" );
-    Abc_Print( -2, "\t         reorders local functions of the nodes using sifting\n" );
-    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandBidec( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int fVerbose;
-    extern void Abc_NtkBidecResyn( Abc_Ntk_t * pNtk, int fVerbose );
-
-    // set defaults
-    fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    // get the new network
-    if ( !Abc_NtkIsAigLogic(pNtk) )
-    {
-        Abc_Print( -1, "Bi-decomposition only works when node functions are AIGs (run \"aig\").\n" );
-        return 1;
-    }
-    Abc_NtkBidecResyn( pNtk, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: bidec [-vh]\n" );
-    Abc_Print( -2, "\t         applies bi-decomposition to local functions of the nodes\n" );
-    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandOrder( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    FILE * pFile;
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    char * pFileName;
-    int c;
-    int fReverse;
-    int fVerbose;
-    extern void Abc_NtkImplementCiOrder( Abc_Ntk_t * pNtk, char * pFileName, int fReverse, int fVerbose );
-    extern void Abc_NtkFindCiOrder( Abc_Ntk_t * pNtk, int fReverse, int fVerbose );
-
-    // set defaults
-    fReverse = 0;
-    fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "rvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'r':
-            fReverse ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-//    if ( Abc_NtkLatchNum(pNtk) > 0 )
-//    {
-//        Abc_Print( -1, "Currently this procedure does not work for sequential networks.\n" );
-//        return 1;
-//    }
-
-    // if the var order file is given, implement this order
-    pFileName = NULL;
-    if ( argc == globalUtilOptind + 1 )
-    {
-        pFileName = argv[globalUtilOptind];
-        pFile = fopen( pFileName, "r" );
-        if ( pFile == NULL )
-        {
-            Abc_Print( -1, "Cannot open file \"%s\" with the BDD variable order.\n", pFileName );
-            return 1;
-        }
-        fclose( pFile );
-    }
-    if ( pFileName )
-        Abc_NtkImplementCiOrder( pNtk, pFileName, fReverse, fVerbose );
-    else
-        Abc_NtkFindCiOrder( pNtk, fReverse, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: order [-rvh] <file>\n" );
-    Abc_Print( -2, "\t         computes a good static CI variable order\n" );
-    Abc_Print( -2, "\t-r     : toggle reverse ordering [default = %s]\n", fReverse? "yes": "no" );
-    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\t<file> : (optional) file with the given variable order\n" );
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandMuxes( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c;
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsBddLogic(pNtk) )
-    {
-        Abc_Print( -1, "Only a BDD logic network can be converted to MUXes.\n" );
-        return 1;
-    }
-
-    // get the new network
-    pNtkRes = Abc_NtkBddToMuxes( pNtk );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Converting to MUXes has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: muxes [-h]\n" );
-    Abc_Print( -2, "\t        converts the current network into a network derived by\n" );
-    Abc_Print( -2, "\t        replacing all nodes by DAGs isomorphic to the local BDDs\n" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandCubes( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Abc_Ntk_t * Abc_NtkSopToCubes( Abc_Ntk_t * pNtk );
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c;
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsSopLogic(pNtk) )
-    {
-        Abc_Print( -1, "Only a SOP logic network can be transformed into cubes.\n" );
-        return 1;
-    }
-
-    // get the new network
-    pNtkRes = Abc_NtkSopToCubes( pNtk );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Converting to cubes has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: cubes [-h]\n" );
-    Abc_Print( -2, "\t        converts the current network into a network derived by creating\n" );
-    Abc_Print( -2, "\t        a separate node for each product and sum in the local SOPs\n" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandSplitSop( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Abc_Ntk_t * Abc_NtkSplitSop( Abc_Ntk_t * pNtk, int nCubesMax, int fVerbose );
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c, fVerbose = 0, nCubesMax = 100;
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Nvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nCubesMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nCubesMax < 0 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsSopLogic(pNtk) )
-    {
-        Abc_Print( -1, "Only a SOP logic network can be transformed into cubes.\n" );
-        return 1;
-    }
-
-    // get the new network
-    pNtkRes = Abc_NtkSplitSop( pNtk, nCubesMax, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Converting to cubes has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: splitsop [-N num] [-vh]\n" );
-    Abc_Print( -2, "\t         splits nodes whose SOP size is larger than the given one\n" );
-    Abc_Print( -2, "\t-N num : the maximum number of cubes after splitting [default = %d]\n", nCubesMax );
-    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandExtSeqDcs( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int fVerbose;
-    extern int Abc_NtkExtractSequentialDcs( Abc_Ntk_t * pNet, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( Abc_NtkLatchNum(pNtk) == 0 )
-    {
-        Abc_Print( -1, "The current network has no latches.\n" );
-        return 0;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Extracting sequential don't-cares works only for AIGs (run \"strash\").\n" );
-        return 0;
-    }
-    if ( !Abc_NtkExtractSequentialDcs( pNtk, fVerbose ) )
-    {
-        Abc_Print( -1, "Extracting sequential don't-cares has failed.\n" );
-        return 1;
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: ext_seq_dcs [-vh]\n" );
-    Abc_Print( -2, "\t         create EXDC network using unreachable states\n" );
-    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandReach( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Saig_ParBbr_t Pars, * pPars = &Pars;
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    char * pLogFileName = NULL;
-
-    extern int Abc_NtkDarReach( Abc_Ntk_t * pNtk, Saig_ParBbr_t * pPars );
-
-    // set defaults
-    Bbr_ManSetDefaultParams( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "TBFLproyvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->TimeLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->TimeLimit < 0 )
-                goto usage;
-            break;
-        case 'B':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nBddMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nBddMax < 0 )
-                goto usage;
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nIterMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nIterMax < 0 )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by a file name.\n" );
-                goto usage;
-            }
-            pLogFileName = argv[globalUtilOptind];
-            globalUtilOptind++;
-            break;
-        case 'p':
-            pPars->fPartition ^= 1;
-            break;
-        case 'r':
-            pPars->fReorder ^= 1;
-            break;
-        case 'o':
-            pPars->fReorderImage ^= 1;
-            break;
-        case 'y':
-            pPars->fSkipOutCheck ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( Abc_NtkLatchNum(pNtk) == 0 )
-    {
-        Abc_Print( -1, "The current network has no latches.\n" );
-        return 0;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Reachability analysis works only for AIGs (run \"strash\").\n" );
-        return 1;
-    }
-    pAbc->Status  = Abc_NtkDarReach( pNtk, pPars );
-    pAbc->nFrames = pPars->iFrame;
-    Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
-    if ( pLogFileName )
-        Abc_NtkWriteLogFile( pLogFileName, pAbc->pCex, pAbc->Status, pAbc->nFrames, "reach" );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: reach [-TBF num] [-L file] [-proyvh]\n" );
-    Abc_Print( -2, "\t         verifies sequential miter using BDD-based reachability\n" );
-    Abc_Print( -2, "\t-T num : approximate time limit in seconds (0=infinite) [default = %d]\n", pPars->TimeLimit );
-    Abc_Print( -2, "\t-B num : max number of nodes in the intermediate BDDs [default = %d]\n", pPars->nBddMax );
-    Abc_Print( -2, "\t-F num : max number of reachability iterations [default = %d]\n", pPars->nIterMax );
-    Abc_Print( -2, "\t-L file: the log file name [default = %s]\n", pLogFileName ? pLogFileName : "no logging" );
-    Abc_Print( -2, "\t-p     : enable partitioned image computation [default = %s]\n", pPars->fPartition? "yes": "no" );
-    Abc_Print( -2, "\t-r     : enable dynamic BDD variable reordering [default = %s]\n", pPars->fReorder? "yes": "no" );
-    Abc_Print( -2, "\t-o     : toggles BDD variable reordering during image computation [default = %s]\n", pPars->fReorderImage? "yes": "no" );
-    Abc_Print( -2, "\t-y     : skip checking property outputs [default = %s]\n", pPars->fSkipOutCheck? "yes": "no" );
-    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandCone( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    Abc_Obj_t * pNode, * pNodeCo;
-    int c;
-    int fUseAllCis;
-    int fUseMffc;
-    int fSeq;
-    int Output;
-    int nRange;
-
-    extern Abc_Ntk_t * Abc_NtkMakeOnePo( Abc_Ntk_t * pNtk, int Output, int nRange );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    fUseAllCis = 0;
-    fUseMffc = 0;
-    fSeq = 0;
-    Output = -1;
-    nRange = -1;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "ORmash" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'O':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-O\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            Output = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( Output < 0 )
-                goto usage;
-            break;
-        case 'R':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nRange = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nRange < 0 )
-                goto usage;
-            break;
-        case 'm':
-            fUseMffc ^= 1;
-            break;
-        case 'a':
-            fUseAllCis ^= 1;
-            break;
-        case 's':
-            fSeq ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsLogic(pNtk) && !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Currently can only be applied to the logic network or an AIG.\n" );
-        return 1;
-    }
-
-    if ( argc > globalUtilOptind + 1 )
-    {
-        Abc_Print( -1, "Wrong number of auguments.\n" );
-        goto usage;
-    }
-
-    pNodeCo = NULL;
-    if ( argc == globalUtilOptind + 1 )
-    {
-        pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
-        if ( pNode == NULL )
-        {
-            Abc_Print( -1, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
-            return 1;
-        }
-        if ( fUseMffc )
-            pNtkRes = Abc_NtkCreateMffc( pNtk, pNode, argv[globalUtilOptind] );
-        else
-            pNtkRes = Abc_NtkCreateCone( pNtk, pNode, argv[globalUtilOptind], fUseAllCis );
-    }
-    else
-    {
-        if ( Output == -1 )
-        {
-            Abc_Print( -1, "The node is not specified.\n" );
-            return 1;
-        }
-        if ( Output >= Abc_NtkCoNum(pNtk) )
-        {
-            Abc_Print( -1, "The 0-based output number (%d) is larger than the number of outputs (%d).\n", Output, Abc_NtkCoNum(pNtk) );
-            return 1;
-        }
-        pNodeCo = Abc_NtkCo( pNtk, Output );
-        if ( fSeq )
-            pNtkRes = Abc_NtkMakeOnePo( pNtk, Output, nRange );
-        else if ( fUseMffc )
-            pNtkRes = Abc_NtkCreateMffc( pNtk, Abc_ObjFanin0(pNodeCo), Abc_ObjName(pNodeCo) );
-        else
-            pNtkRes = Abc_NtkCreateCone( pNtk, Abc_ObjFanin0(pNodeCo), Abc_ObjName(pNodeCo), fUseAllCis );
-    }
-    if ( pNodeCo && Abc_ObjFaninC0(pNodeCo) && !fSeq )
-    {
-        Abc_NtkPo(pNtkRes, 0)->fCompl0  ^= 1;
-//        Abc_Print( -1, "The extracted cone represents the complement function of the CO.\n" );
-    }
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Writing the logic cone of one node has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: cone [-OR num] [-amsh] <name>\n" );
-    Abc_Print( -2, "\t         replaces the current network by one logic cone\n" );
-    Abc_Print( -2, "\t-a     : toggle keeping all CIs or structral support only [default = %s]\n", fUseAllCis? "all": "structural" );
-    Abc_Print( -2, "\t-m     : toggle keeping only MFFC or complete TFI cone [default = %s]\n", fUseMffc? "MFFC": "TFI cone" );
-    Abc_Print( -2, "\t-s     : toggle comb or sequential cone (works with \"-O num\") [default = %s]\n", fSeq? "seq": "comb" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\t-O num : (optional) the 0-based number of the CO to extract\n");
-    Abc_Print( -2, "\t-R num : (optional) the number of outputs to extract\n");
-    Abc_Print( -2, "\tname   : (optional) the name of the node to extract\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandNode( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    Abc_Obj_t * pNode;
-    int c;
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-       case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsLogic(pNtk) )
-    {
-        Abc_Print( -1, "Currently can only be applied to a logic network.\n" );
-        return 1;
-    }
-
-    if ( argc != globalUtilOptind + 1 )
-    {
-        Abc_Print( -1, "Wrong number of auguments.\n" );
-        goto usage;
-    }
-
-    pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
-    if ( pNode == NULL )
-    {
-        Abc_Print( -1, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
-        return 1;
-    }
-
-    pNtkRes = Abc_NtkCreateFromNode( pNtk, pNode );
-//    pNtkRes = Abc_NtkDeriveFromBdd( pNtk->pManFunc, pNode->pData, NULL, NULL );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Splitting one node has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: node [-h] <name>\n" );
-    Abc_Print( -2, "\t         replaces the current network by the network composed of one node\n" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\tname   : the node name\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandTopmost( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c, nLevels;
-    extern Abc_Ntk_t * Abc_NtkTopmost( Abc_Ntk_t * pNtk, int nLevels );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    nLevels = 10;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Nh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nLevels = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nLevels < 0 )
-                goto usage;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
-        return 0;
-    }
-
-    if ( Abc_NtkLatchNum(pNtk) > 0 )
-    {
-        Abc_Print( -1, "Currently can only works for combinational circuits.\n" );
-        return 0;
-    }
-    if ( Abc_NtkPoNum(pNtk) != 1 )
-    {
-        Abc_Print( -1, "Currently expects a single-output miter.\n" );
-        return 0;
-    }
-
-    pNtkRes = Abc_NtkTopmost( pNtk, nLevels );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "The command has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: topmost [-N num] [-h]\n" );
-    Abc_Print( -2, "\t         replaces the current network by several of its topmost levels\n" );
-    Abc_Print( -2, "\t-N num : max number of levels [default = %d]\n", nLevels );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\tname   : the node name\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandTopAnd( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c;
-    extern Abc_Ntk_t * Abc_NtkTopAnd( Abc_Ntk_t * pNtk );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
-        return 0;
-    }
-
-    if ( Abc_NtkLatchNum(pNtk) > 0 )
-    {
-        Abc_Print( -1, "Currently can only works for combinational circuits.\n" );
-        return 0;
-    }
-    if ( Abc_NtkPoNum(pNtk) != 1 )
-    {
-        Abc_Print( -1, "Currently expects a single-output miter.\n" );
-        return 0;
-    }
-    if ( Abc_ObjFaninC0(Abc_NtkPo(pNtk, 0)) )
-    {
-        Abc_Print( -1, "The PO driver is complemented. AND-decomposition is impossible.\n" );
-        return 0;
-    }
-    if ( !Abc_ObjIsNode(Abc_ObjChild0(Abc_NtkPo(pNtk, 0))) )
-    {
-        Abc_Print( -1, "The PO driver is not a node. AND-decomposition is impossible.\n" );
-        return 0;
-    }
-    pNtkRes = Abc_NtkTopAnd( pNtk );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "The command has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: topand [-h]\n" );
-    Abc_Print( -2, "\t         performs AND-decomposition of single-output combinational miter\n" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\tname   : the node name\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandTrim( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    Gia_Man_t * pGia, * pNew;
-    Aig_Man_t * pAig;
-    int c;
-    pNtk = Abc_FrameReadNtk(pAbc);
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Nh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Trimming works only for AIGs (run \"strash\").\n" );
-        return 1;
-    }
-    // convert to GIA
-    pAig = Abc_NtkToDar( pNtk, 0, 1 );
-    pGia = Gia_ManFromAigSimple( pAig );
-    Aig_ManStop( pAig );
-    // perform trimming
-    pNew = Gia_ManDupTrimmed( pGia, 1, 1, 0, -1 );
-    Gia_ManStop( pGia );
-    // convert back
-    pAig = Gia_ManToAigSimple( pNew );
-    Gia_ManStop( pNew );
-    pNtkRes = Abc_NtkFromAigPhase( pAig );
-    Aig_ManStop( pAig );
-    // duplicate the name and the spec
-    ABC_FREE( pNtkRes->pName );
-    ABC_FREE( pNtkRes->pSpec );
-    pNtkRes->pName = Extra_UtilStrsav(pNtk->pName);
-    pNtkRes->pSpec = Extra_UtilStrsav(pNtk->pSpec);
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: trim [-h]\n" );
-    Abc_Print( -2, "\t         removes POs fed by constants and PIs w/o fanout\n" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandShortNames( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    Abc_NtkShortNames( pNtk );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: short_names [-h]\n" );
-    Abc_Print( -2, "\t         replaces PI/PO/latch names by short char strings\n" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandMoveNames( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-	extern void Abc_NtkMoveNames( Abc_Ntk_t * pNtk, Abc_Ntk_t * pOld );
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-	Abc_Ntk_t * pNtk2;
-	char * FileName;
-    int c;
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    // get the second network
-    if ( argc != globalUtilOptind + 1 )
-    {
-        Abc_Print( -1, "The network to take names from is not given.\n" );
-        return 1;
-    }
-
-    // read the second network
-    FileName = argv[globalUtilOptind];
-    pNtk2 = Io_Read( FileName, Io_ReadFileType(FileName), 1, 0 );
-    if ( pNtk2 == NULL )
-        return 1;
-
-    // compare inputs/outputs
-    if ( Abc_NtkPiNum(pNtk) != Abc_NtkPiNum(pNtk2) )
-    {
-        Abc_NtkDelete( pNtk2 );
-        Abc_Print( -1, "The PI count (%d) of the first network is not equal to PI count (%d) of the second network.\n", Abc_NtkPiNum(pNtk), Abc_NtkPiNum(pNtk2) );
-        return 0;
-    }
-    // compare inputs/outputs
-    if ( Abc_NtkPoNum(pNtk) != Abc_NtkPoNum(pNtk2) )
-    {
-        Abc_NtkDelete( pNtk2 );
-        Abc_Print( -1, "The PO count (%d) of the first network is not equal to PO count (%d) of the second network.\n", Abc_NtkPoNum(pNtk), Abc_NtkPoNum(pNtk2) );
-        return 0;
-    }
-    // compare inputs/outputs
-    if ( Abc_NtkLatchNum(pNtk) != Abc_NtkLatchNum(pNtk2) )
-    {
-        Abc_NtkDelete( pNtk2 );
-        Abc_Print( -1, "The flop count (%d) of the first network is not equal to flop count (%d) of the second network.\n", Abc_NtkLatchNum(pNtk), Abc_NtkLatchNum(pNtk2) );
-        return 0;
-    }
-    Abc_NtkMoveNames( pNtk, pNtk2 );
-    Abc_NtkDelete( pNtk2 );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: move_names [-h] <file>\n" );
-    Abc_Print( -2, "\t         moves PI/PO/latch names from the other network\n" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\t<file> : file with network that has required names\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandExdcFree( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c;
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( pNtk->pExdc == NULL )
-    {
-        Abc_Print( -1, "The network has no EXDC.\n" );
-        return 1;
-    }
-
-    Abc_NtkDelete( pNtk->pExdc );
-    pNtk->pExdc = NULL;
-
-    // replace the current network
-    pNtkRes = Abc_NtkDup( pNtk );
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: exdc_free [-h]\n" );
-    Abc_Print( -2, "\t         frees the EXDC network of the current network\n" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandExdcGet( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c;
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( pNtk->pExdc == NULL )
-    {
-        Abc_Print( -1, "The network has no EXDC.\n" );
-        return 1;
-    }
-
-    // replace the current network
-    pNtkRes = Abc_NtkDup( pNtk->pExdc );
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: exdc_get [-h]\n" );
-    Abc_Print( -2, "\t         replaces the current network by the EXDC of the current network\n" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandExdcSet( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    FILE * pFile;
-    Abc_Ntk_t * pNtk, * pNtkNew, * pNtkRes;
-    char * FileName;
-    int c;
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( argc != globalUtilOptind + 1 )
-    {
-        goto usage;
-    }
-
-    // get the input file name
-    FileName = argv[globalUtilOptind];
-    if ( (pFile = fopen( FileName, "r" )) == NULL )
-    {
-        Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
-        if ( (FileName = Extra_FileGetSimilarName( FileName, ".mv", ".blif", ".pla", ".eqn", ".bench" )) )
-            Abc_Print( 1, "Did you mean \"%s\"?", FileName );
-        Abc_Print( 1, "\n" );
-        return 1;
-    }
-    fclose( pFile );
-
-    // set the new network
-    pNtkNew = Io_Read( FileName, Io_ReadFileType(FileName), 1, 0 );
-    if ( pNtkNew == NULL )
-    {
-        Abc_Print( -1, "Reading network from file has failed.\n" );
-        return 1;
-    }
-
-    // replace the EXDC
-    if ( pNtk->pExdc )
-    {
-        Abc_NtkDelete( pNtk->pExdc );
-        pNtk->pExdc = NULL;
-    }
-    pNtkRes = Abc_NtkDup( pNtk );
-    pNtkRes->pExdc = pNtkNew;
-
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: exdc_set [-h] <file>\n" );
-    Abc_Print( -2, "\t         sets the network from file as EXDC for the current network\n" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\t<file> : file with the new EXDC network\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandCareSet( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    FILE * pFile;
-    Abc_Ntk_t * pNtk, * pNtkNew, * pNtkRes;
-    char * FileName;
-    int c;
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( argc != globalUtilOptind + 1 )
-    {
-        goto usage;
-    }
-
-    // get the input file name
-    FileName = argv[globalUtilOptind];
-    if ( (pFile = fopen( FileName, "r" )) == NULL )
-    {
-        Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
-        if ( (FileName = Extra_FileGetSimilarName( FileName, ".mv", ".blif", ".pla", ".eqn", ".bench" )) )
-            Abc_Print( 1, "Did you mean \"%s\"?", FileName );
-        Abc_Print( 1, "\n" );
-        return 1;
-    }
-    fclose( pFile );
-
-    // set the new network
-    pNtkNew = Io_Read( FileName, Io_ReadFileType(FileName), 1, 0 );
-    if ( pNtkNew == NULL )
-    {
-        Abc_Print( -1, "Reading network from file has failed.\n" );
-        return 1;
-    }
-
-    // replace the EXDC
-    if ( pNtk->pExcare )
-    {
-        Abc_NtkDelete( (Abc_Ntk_t *)pNtk->pExcare );
-        pNtk->pExcare = NULL;
-    }
-    pNtkRes = Abc_NtkDup( pNtk );
-    pNtkRes->pExcare = pNtkNew;
-
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: care_set [-h] <file>\n" );
-    Abc_Print( -2, "\t         sets the network from file as a care for the current network\n" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\t<file> : file with the new care network\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandCut( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Cut_Params_t Params, * pParams = &Params;
-    Cut_Man_t * pCutMan;
-    Cut_Oracle_t * pCutOracle = NULL;
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int fOracle;
-    extern Cut_Man_t * Abc_NtkCuts( Abc_Ntk_t * pNtk, Cut_Params_t * pParams );
-    extern void Abc_NtkCutsOracle( Abc_Ntk_t * pNtk, Cut_Oracle_t * pCutOracle );
-
-    // set defaults
-    fOracle = 0;
-    memset( pParams, 0, sizeof(Cut_Params_t) );
-    pParams->nVarsMax    = 5;     // the max cut size ("k" of the k-feasible cuts)
-    pParams->nKeepMax    = 1000;  // the max number of cuts kept at a node
-    pParams->fTruth      = 1;     // compute truth tables
-    pParams->fFilter     = 1;     // filter dominated cuts
-    pParams->fDrop       = 0;     // drop cuts on the fly
-    pParams->fDag        = 1;     // compute DAG cuts
-    pParams->fTree       = 0;     // compute tree cuts
-    pParams->fGlobal     = 0;     // compute global cuts
-    pParams->fLocal      = 0;     // compute local cuts
-    pParams->fFancy      = 0;     // compute something fancy
-    pParams->fRecordAig  = 1;     // compute something fancy
-    pParams->fMap        = 0;     // compute mapping delay
-    pParams->fAdjust     = 0;     // removes useless fanouts
-    pParams->fNpnSave    = 0;     // enables dumping truth tables
-    pParams->fVerbose    = 0;     // the verbosiness flag
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "KMtfdxyglzamjvosh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pParams->nVarsMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pParams->nVarsMax < 0 )
-                goto usage;
-            break;
-        case 'M':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pParams->nKeepMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pParams->nKeepMax < 0 )
-                goto usage;
-            break;
-        case 't':
-            pParams->fTruth ^= 1;
-            break;
-        case 'f':
-            pParams->fFilter ^= 1;
-            break;
-        case 'd':
-            pParams->fDrop ^= 1;
-            break;
-        case 'x':
-            pParams->fDag ^= 1;
-            break;
-        case 'y':
-            pParams->fTree ^= 1;
-            break;
-        case 'g':
-            pParams->fGlobal ^= 1;
-            break;
-        case 'l':
-            pParams->fLocal ^= 1;
-            break;
-        case 'z':
-            pParams->fFancy ^= 1;
-            break;
-        case 'a':
-            pParams->fRecordAig ^= 1;
-            break;
-        case 'm':
-            pParams->fMap ^= 1;
-            break;
-        case 'j':
-            pParams->fAdjust ^= 1;
-            break;
-        case 'v':
-            pParams->fVerbose ^= 1;
-            break;
-        case 'o':
-            fOracle ^= 1;
-            break;
-        case 's':
-            pParams->fNpnSave ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Cut computation is available only for AIGs (run \"strash\").\n" );
-        return 1;
-    }
-    if ( pParams->nVarsMax < CUT_SIZE_MIN || pParams->nVarsMax > CUT_SIZE_MAX )
-    {
-        Abc_Print( -1, "Can only compute the cuts for %d <= K <= %d.\n", CUT_SIZE_MIN, CUT_SIZE_MAX );
-        return 1;
-    }
-    if ( pParams->fDag && pParams->fTree )
-    {
-        Abc_Print( -1, "Cannot compute both DAG cuts and tree cuts at the same time.\n" );
-        return 1;
-    }
-
-    if ( pParams->fNpnSave )
-    {
-        pParams->nVarsMax = 6;
-        pParams->fTruth = 1;
-    }
-
-    if ( fOracle )
-        pParams->fRecord = 1;
-    pCutMan = Abc_NtkCuts( pNtk, pParams );
-    if ( fOracle )
-        pCutOracle = Cut_OracleStart( pCutMan );
-    Cut_ManStop( pCutMan );
-    if ( fOracle )
-    {
-        assert(pCutOracle);
-        Abc_NtkCutsOracle( pNtk, pCutOracle );
-        Cut_OracleStop( pCutOracle );
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: cut [-K num] [-M num] [-tfdcovamjsvh]\n" );
-    Abc_Print( -2, "\t         computes k-feasible cuts for the AIG\n" );
-    Abc_Print( -2, "\t-K num : max number of leaves (%d <= num <= %d) [default = %d]\n",     CUT_SIZE_MIN, CUT_SIZE_MAX, pParams->nVarsMax );
-    Abc_Print( -2, "\t-M num : max number of cuts stored at a node [default = %d]\n",        pParams->nKeepMax );
-    Abc_Print( -2, "\t-t     : toggle truth table computation [default = %s]\n",             pParams->fTruth?   "yes": "no" );
-    Abc_Print( -2, "\t-f     : toggle filtering of duplicated/dominated [default = %s]\n",   pParams->fFilter?  "yes": "no" );
-    Abc_Print( -2, "\t-d     : toggle dropping when fanouts are done [default = %s]\n",      pParams->fDrop?    "yes": "no" );
-    Abc_Print( -2, "\t-x     : toggle computing only DAG cuts [default = %s]\n",             pParams->fDag?     "yes": "no" );
-    Abc_Print( -2, "\t-y     : toggle computing only tree cuts [default = %s]\n",            pParams->fTree?    "yes": "no" );
-    Abc_Print( -2, "\t-g     : toggle computing only global cuts [default = %s]\n",          pParams->fGlobal?  "yes": "no" );
-    Abc_Print( -2, "\t-l     : toggle computing only local cuts [default = %s]\n",           pParams->fLocal?   "yes": "no" );
-    Abc_Print( -2, "\t-z     : toggle fancy computations [default = %s]\n",                  pParams->fFancy?   "yes": "no" );
-    Abc_Print( -2, "\t-a     : toggle recording cut functions [default = %s]\n",             pParams->fRecordAig?"yes": "no" );
-    Abc_Print( -2, "\t-m     : toggle delay-oriented FPGA mapping [default = %s]\n",         pParams->fMap?     "yes": "no" );
-    Abc_Print( -2, "\t-j     : toggle removing fanouts due to XOR/MUX [default = %s]\n",     pParams->fAdjust?  "yes": "no" );
-    Abc_Print( -2, "\t-s     : toggle creating library of 6-var functions [default = %s]\n", pParams->fNpnSave?  "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n",        pParams->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandScut( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Cut_Params_t Params, * pParams = &Params;
-    Cut_Man_t * pCutMan;
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    extern Cut_Man_t * Abc_NtkSeqCuts( Abc_Ntk_t * pNtk, Cut_Params_t * pParams );
-
-    // set defaults
-    memset( pParams, 0, sizeof(Cut_Params_t) );
-    pParams->nVarsMax  = 5;     // the max cut size ("k" of the k-feasible cuts)
-    pParams->nKeepMax  = 1000;  // the max number of cuts kept at a node
-    pParams->fTruth    = 0;     // compute truth tables
-    pParams->fFilter   = 1;     // filter dominated cuts
-    pParams->fSeq      = 1;     // compute sequential cuts
-    pParams->fVerbose  = 0;     // the verbosiness flag
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "KMtvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pParams->nVarsMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pParams->nVarsMax < 0 )
-                goto usage;
-            break;
-        case 'M':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pParams->nKeepMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pParams->nKeepMax < 0 )
-                goto usage;
-            break;
-        case 't':
-            pParams->fTruth ^= 1;
-            break;
-        case 'v':
-            pParams->fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-/*
-    if ( !Abc_NtkIsSeq(pNtk) )
-    {
-        Abc_Print( -1, "Sequential cuts can be computed for sequential AIGs (run \"seq\").\n" );
-        return 1;
-    }
-*/
-    if ( pParams->nVarsMax < CUT_SIZE_MIN || pParams->nVarsMax > CUT_SIZE_MAX )
-    {
-        Abc_Print( -1, "Can only compute the cuts for %d <= K <= %d.\n", CUT_SIZE_MIN, CUT_SIZE_MAX );
-        return 1;
-    }
-
-    pCutMan = Abc_NtkSeqCuts( pNtk, pParams );
-    Cut_ManStop( pCutMan );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: scut [-K num] [-M num] [-tvh]\n" );
-    Abc_Print( -2, "\t         computes k-feasible cuts for the sequential AIG\n" );
-    Abc_Print( -2, "\t-K num : max number of leaves (%d <= num <= %d) [default = %d]\n",   CUT_SIZE_MIN, CUT_SIZE_MAX, pParams->nVarsMax );
-    Abc_Print( -2, "\t-M num : max number of cuts stored at a node [default = %d]\n",      pParams->nKeepMax );
-    Abc_Print( -2, "\t-t     : toggle truth table computation [default = %s]\n",           pParams->fTruth?   "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n",      pParams->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandEspresso( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int fVerbose;
-    extern void Abc_NtkEspresso( Abc_Ntk_t * pNtk, int fVerbose );
-
-    if ( argc == 2 && !strcmp(argv[1], "-h") )
-    {
-        Abc_Print( -2, "The espresso command is currently disabled.\n" );
-        return 1;
-    }
-
-    Abc_Print( -1, "This command is currently disabled.\n" );
-    return 0;
-
-    // set defaults
-    fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsLogic(pNtk) )
-    {
-        Abc_Print( -1, "SOP minimization is possible for logic networks (run \"renode\").\n" );
-        return 1;
-    }
-//    Abc_NtkEspresso( pNtk, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: espresso [-vh]\n" );
-    Abc_Print( -2, "\t         minimizes SOPs of the local functions using Espresso\n" );
-    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandGen( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-//    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int nVars;    // the number of variables
-    int nLutSize = -1; // the size of LUTs
-    int nLuts = -1;    // the number of LUTs
-    int fAdder;
-    int fSorter;
-    int fMesh;
-    int fMulti;
-    int fFpga;
-    int fOneHot;
-    int fRandom;
-    int fVerbose;
-    char * FileName;
-    char Command[1000];
-    extern void Abc_GenAdder( char * pFileName, int nVars );
-    extern void Abc_GenSorter( char * pFileName, int nVars );
-    extern void Abc_GenMesh( char * pFileName, int nVars );
-    extern void Abc_GenMulti( char * pFileName, int nVars );
-    extern void Abc_GenFpga( char * pFileName, int nLutSize, int nLuts, int nVars );
-    extern void Abc_GenOneHot( char * pFileName, int nVars );
-    extern void Abc_GenRandom( char * pFileName, int nPis );
-
-    // set defaults
-    nVars = 8;
-    fAdder = 0;
-    fSorter = 0;
-    fMesh = 0;
-    fMulti = 0;
-    fFpga = 0;
-    fOneHot = 0;
-    fRandom = 0;
-    fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "NKLasemftrvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nVars = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nVars < 0 )
-                goto usage;
-            break;
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nLutSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nLutSize < 0 )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nLuts = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nLuts < 0 )
-                goto usage;
-            break;
-        case 'a':
-            fAdder ^= 1;
-            break;
-        case 's':
-            fSorter ^= 1;
-            break;
-        case 'e':
-            fMesh ^= 1;
-            break;
-        case 'm':
-            fMulti ^= 1;
-            break;
-        case 'f':
-            fFpga ^= 1;
-            break;
-        case 't':
-            fOneHot ^= 1;
-            break;
-        case 'r':
-            fRandom ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( argc != globalUtilOptind + 1 )
-    {
-        goto usage;
-    }
-    if ( nVars < 1 )
-    {
-        Abc_Print( -1, "The number of variables should be a positive integer.\n" );
-        return 0;
-    }
-    // get the input file name
-    FileName = argv[globalUtilOptind];
-    if ( fAdder )
-        Abc_GenAdder( FileName, nVars );
-    else if ( fSorter )
-        Abc_GenSorter( FileName, nVars );
-    else if ( fMesh )
-        Abc_GenMesh( FileName, nVars );
-    else if ( fMulti )
-        Abc_GenMulti( FileName, nVars );
-    else if ( fFpga )
-        Abc_GenFpga( FileName, nLutSize, nLuts, nVars );
-//        Abc_GenFpga( FileName, 2, 2, 3 );
-//        Abc_GenFpga( FileName, 3, 2, 5 );
-    else if ( fOneHot )
-        Abc_GenOneHot( FileName, nVars );
-    else if ( fRandom )
-        Abc_GenRandom( FileName, nVars );
-    else
-    {
-        Abc_Print( -1, "Type of circuit is not specified.\n" );
-        return 0;
-    }
-    // read the file just produced
-    sprintf(Command, "read %s", FileName );
-    Cmd_CommandExecute( pAbc, Command );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: gen [-NKL num] [-asemftrvh] <file>\n" );
-    Abc_Print( -2, "\t         generates simple circuits\n" );
-    Abc_Print( -2, "\t-N num : the number of variables [default = %d]\n", nVars );
-    Abc_Print( -2, "\t-K num : the LUT size (to be used with switch -f) [default = %d]\n", nLutSize );
-    Abc_Print( -2, "\t-L num : the LUT count (to be used with switch -f) [default = %d]\n", nLuts );
-    Abc_Print( -2, "\t-a     : generate ripple-carry adder [default = %s]\n", fAdder? "yes": "no" );
-    Abc_Print( -2, "\t-s     : generate a sorter [default = %s]\n", fSorter? "yes": "no" );
-    Abc_Print( -2, "\t-e     : generate a mesh [default = %s]\n", fMesh? "yes": "no" );
-    Abc_Print( -2, "\t-m     : generate a multiplier [default = %s]\n", fMulti? "yes": "no" );
-    Abc_Print( -2, "\t-f     : generate a LUT FPGA structure [default = %s]\n", fFpga? "yes": "no" );
-    Abc_Print( -2, "\t-t     : generate one-hotness conditions [default = %s]\n", fOneHot? "yes": "no" );
-    Abc_Print( -2, "\t-r     : generate random single-output function [default = %s]\n", fRandom? "yes": "no" );
-    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\t<file> : output file name\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandGenFsm( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern void Abc_GenFsm( char * pFileName, int nIns, int nOuts, int nStates, int nLines, int ProbI, int ProbO );
-    int c, nIns, nOuts, nStates, nLines, ProbI, ProbO, fVerbose;
-    char * FileName;
-    // set defaults
-    nIns     =   30;
-    nOuts    =    1;
-    nStates  =   20;
-    nLines   =  100;
-    ProbI    =   10;
-    ProbO    =  100;
-    fVerbose =    0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "IOSLPQvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'I':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nIns = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nIns < 0 )
-                goto usage;
-            break;
-        case 'O':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-O\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nOuts = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nOuts < 0 )
-                goto usage;
-            break;
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nStates = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nStates < 0 )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nLines = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nLines < 0 )
-                goto usage;
-            break;
-        case 'P':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            ProbI = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( ProbI < 0 )
-                goto usage;
-            break;
-        case 'Q':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-Q\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            ProbO = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( ProbO < 0 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( argc != globalUtilOptind + 1 )
-    {
-        goto usage;
-    }
-    if ( nIns < 1 || nStates < 1 || nLines < 1 || ProbI < 1 || ProbO < 1 )
-    {
-        Abc_Print( -1, "The number of inputs. states, lines, and probablity should be positive integers.\n" );
-        goto usage;
-    }
-    // get the input file name
-    FileName = argv[globalUtilOptind];
-    Abc_GenFsm( FileName, nIns, nOuts, nStates, nLines, ProbI, ProbO );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: genfsm [-IOSLPQ num] [-vh] <file>\n" );
-    Abc_Print( -2, "\t         generates random FSM in KISS format\n" );
-    Abc_Print( -2, "\t-I num : the number of input variables [default = %d]\n", nIns );
-    Abc_Print( -2, "\t-O num : the number of output variables [default = %d]\n", nOuts );
-    Abc_Print( -2, "\t-S num : the number of state variables [default = %d]\n", nStates );
-    Abc_Print( -2, "\t-L num : the number of lines (product terms) [default = %d]\n", nLines );
-    Abc_Print( -2, "\t-P num : percentage propability of a variable present in the input cube [default = %d]\n", ProbI );
-    Abc_Print( -2, "\t-Q num : percentage propability of a variable present in the output cube [default = %d]\n", ProbO );
-    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\t<file> : output file name\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandCover( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c;
-    int fVerbose;
-    int fUseSop;
-    int fUseEsop;
-    int fUseInvs;
-    int nFaninMax;
-    pNtk = Abc_FrameReadNtk(pAbc);
-
-    // set defaults
-    fUseSop   =  1;
-    fUseEsop  =  0;
-    fVerbose  =  0;
-    fUseInvs  =  1;
-    nFaninMax =  8;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Nsxivh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFaninMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFaninMax < 0 )
-                goto usage;
-            break;
-        case 's':
-            fUseSop ^= 1;
-            break;
-        case 'x':
-            fUseEsop ^= 1;
-            break;
-        case 'i':
-            fUseInvs ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Only works for strashed networks.\n" );
-        return 1;
-    }
-
-    // run the command
-    pNtkRes = Abc_NtkSopEsopCover( pNtk, nFaninMax, fUseEsop, fUseSop, fUseInvs, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Command has failed.\n" );
-        return 0;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: cover [-N num] [-sxvh]\n" );
-    Abc_Print( -2, "\t         decomposition into a network of SOP/ESOP PLAs\n" );
-    Abc_Print( -2, "\t-N num : maximum number of inputs [default = %d]\n", nFaninMax );
-    Abc_Print( -2, "\t-s     : toggle the use of SOPs [default = %s]\n", fUseSop? "yes": "no" );
-    Abc_Print( -2, "\t-x     : toggle the use of ESOPs [default = %s]\n", fUseEsop? "yes": "no" );
-//    Abc_Print( -2, "\t-i     : toggle the use of interters [default = %s]\n", fUseInvs? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandInter( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtk1, * pNtk2, * pNtkRes = NULL;
-    char ** pArgvNew;
-    int nArgcNew;
-    int c, fDelete1, fDelete2;
-    int fRelation;
-    int fVerbose;
-    extern Abc_Ntk_t * Abc_NtkInter( Abc_Ntk_t * pNtkOn, Abc_Ntk_t * pNtkOff, int fRelation, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    fRelation = 0;
-    fVerbose  = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "rvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'r':
-            fRelation ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    pArgvNew = argv + globalUtilOptind;
-    nArgcNew = argc - globalUtilOptind;
-    if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
-        return 1;
-    if ( nArgcNew == 0 )
-    {
-        Abc_Obj_t * pObj;
-        int i;
-        Abc_Print( -1, "Deriving new circuit structure for the current network.\n" );
-        Abc_NtkForEachPo( pNtk2, pObj, i )
-            Abc_ObjXorFaninC( pObj, 0 );
-    }
-    if ( fRelation && Abc_NtkCoNum(pNtk1) != 1 )
-    {
-        Abc_Print( -1, "Computation of interplants as a relation only works for single-output functions.\n" );
-        Abc_Print( -1, "Use command \"cone\" to extract one output cone from the multi-output network.\n" );
-    }
-    else
-        pNtkRes = Abc_NtkInter( pNtk1, pNtk2, fRelation, fVerbose );
-    if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
-    if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
-
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Command has failed.\n" );
-        return 0;
-    }
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: inter [-rvh] <onset.blif> <offset.blif>\n" );
-    Abc_Print( -2, "\t         derives interpolant of two networks representing onset and offset;\n" );
-    Abc_Print( -2, "\t-r     : toggle computing interpolant as a relation [default = %s]\n", fRelation? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\t         \n" );
-    Abc_Print( -2, "\t         Comments:\n" );
-    Abc_Print( -2, "\t         \n" );
-    Abc_Print( -2, "\t         The networks given on the command line should have the same CIs/COs.\n" );
-    Abc_Print( -2, "\t         If only one network is given on the command line, this network\n" );
-    Abc_Print( -2, "\t         is assumed to be the offset, while the current network is the onset.\n" );
-    Abc_Print( -2, "\t         If no network is given on the command line, the current network is\n" );
-    Abc_Print( -2, "\t         assumed to be the onset and its complement is taken to be the offset.\n" );
-    Abc_Print( -2, "\t         The resulting interpolant is stored as the current network.\n" );
-    Abc_Print( -2, "\t         To verify that the interpolant agrees with the onset and the offset,\n" );
-    Abc_Print( -2, "\t         save it in file \"inter.blif\" and run the following:\n" );
-    Abc_Print( -2, "\t         (a) \"miter -i <onset.blif> <inter.blif>; iprove\"\n" );
-    Abc_Print( -2, "\t         (b) \"miter -i <inter.blif> <offset_inv.blif>; iprove\"\n" );
-    Abc_Print( -2, "\t         where <offset_inv.blif> is the network derived by complementing the\n" );
-    Abc_Print( -2, "\t         outputs of <offset.blif>: \"r <offset.blif>; st -i; w <offset_inv.blif>\"\n" );
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandDouble( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c;
-    int nFrames;
-    int fVerbose;
-    extern Abc_Ntk_t * Abc_NtkDouble( Abc_Ntk_t * pNtk );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    nFrames    = 50;
-    fVerbose   =  0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFrames = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFrames < 0 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsSopLogic(pNtk) )
-    {
-        Abc_Print( -1, "Only works for logic SOP networks.\n" );
-        return 1;
-    }
-
-    pNtkRes = Abc_NtkDouble( pNtk );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Command has failed.\n" );
-        return 0;
-    }
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: double [-vh]\n" );
-    Abc_Print( -2, "\t         puts together two parallel copies of the current network\n" );
-//    Abc_Print( -2, "\t-F num : the number of frames to simulate [default = %d]\n", nFrames );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandBb2Wb( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern void Abc_NtkConvertBb2Wb( char * pFileNameIn, char * pFileNameOut, int fSeq, int fVerbose );
-    int c;
-    int fSeq;
-    int fVerbose;
-    // set defaults
-    fSeq = 0;
-    fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "svh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 's':
-            fSeq ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        default:
-            goto usage;
-        }
-    }
-    if ( argc != globalUtilOptind + 2 )
-    {
-        Abc_Print( -1, "Expecting two files names on the command line.\n" );
-        goto usage;
-    }
-    Abc_NtkConvertBb2Wb( argv[globalUtilOptind], argv[globalUtilOptind+1], fSeq, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: bb2wb [-svh] <file_in> <file_out>\n" );
-    Abc_Print( -2, "\t             replaces black boxes by white boxes with AND functions\n" );
-    Abc_Print( -2, "\t             (file names should have standard extensions, e.g. \"blif\")\n" );
-    Abc_Print( -2, "\t-s         : toggle using sequential white boxes [default = %s]\n", fSeq? "yes": "no" );
-    Abc_Print( -2, "\t-v         : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h         : print the command usage\n");
-    Abc_Print( -2, "\t<file_in>  : input file with design containing black boxes\n");
-    Abc_Print( -2, "\t<file_out> : output file with design containing white boxes\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandOutdec( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Abc_Ntk_t * Abc_NtkDarOutdec( Abc_Ntk_t * pNtk, int nLits, int fVerbose );
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    Abc_Ntk_t * pNtkRes;
-    int c, nLits = 1;
-    int fVerbose = 0;
-
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Lvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nLits = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nLits < 1 || nLits > 2 )
-            {
-                Abc_Print( 1,"Currently, command \"outdec\" works for 1-lit and 2-lit primes only.\n" );
-                goto usage;
-            }
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Only works for strashed networks.\n" );
-        return 1;
-    }
-    pNtkRes = Abc_NtkDarOutdec( pNtk, nLits, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Command has failed.\n" );
-        return 0;
-    }
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: outdec [-Lvh]\n" );
-    Abc_Print( -2, "\t         performs prime decomposition of the first output\n" );
-    Abc_Print( -2, "\t-L num : the number of literals in the primes [default = %d]\n", nLits );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandNodeDup( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Abc_Ntk_t * Abc_NtkNodeDup( Abc_Ntk_t * pNtk, int nLimit, int fVerbose );
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    Abc_Ntk_t * pNtkRes;
-    int c, nLimit = 30;
-    int fVerbose = 0;
-
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Nvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Only works for logic networks.\n" );
-        return 1;
-    }
-    if ( nLimit < 2 )
-    {
-        Abc_Print( -1, "The fanout limit should be more than 1.\n" );
-        return 1;
-    }
-    pNtkRes = Abc_NtkNodeDup( pNtk, nLimit, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Command has failed.\n" );
-        return 0;
-    }
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: nodedup [-Nvh]\n" );
-    Abc_Print( -2, "\t         duplicates internal nodes with high fanout\n" );
-    Abc_Print( -2, "\t-N num : the number of fanouts to start duplication [default = %d]\n", nLimit );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandTestColor( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern void Abc_ColorTest();
-    Abc_ColorTest();
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-//    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int nCutMax      =  1;
-    int nLeafMax     =  4;
-    int nDivMax      =  2;
-    int nDecMax      = 20;
-    int nNumOnes     =  4;
-    int fNewAlgo     =  0;
-    int fNewOrder    =  0;
-    int fVerbose     =  0;
-    int fVeryVerbose =  0;
-    int c;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "CKDNMaovwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nCutMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nCutMax < 0 )
-                goto usage;
-            break;
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nLeafMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nLeafMax < 0 )
-                goto usage;
-            break;
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nDivMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nDivMax < 0 )
-                goto usage;
-            break;
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nDecMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nDecMax < 0 )
-                goto usage;
-            break;
-        case 'M':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nNumOnes = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nNumOnes < 0 )
-                goto usage;
-            break;
-        case 'a':
-            fNewAlgo ^= 1;
-            break;
-        case 'o':
-            fNewOrder ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'w':
-            fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-/*
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for logic networks.\n" );
-        return 1;
-    }
-*/
-/*
-    if ( Abc_NtkLatchNum(pNtk) == 0 )
-    {
-        Abc_Print( -1, "Only works for sequential networks.\n" );
-        return 1;
-    }
-*/
-
-/*
-    if ( pNtk )
-    {
-        extern Abc_Ntk_t * Au_ManPerformTest( Abc_Ntk_t * p, int nCutMax, int nLeafMax, int nDivMax, int nDecMax, int fVerbose, int fVeryVerbose );
-        Abc_Ntk_t * pNtkRes = Au_ManPerformTest( pNtk, nCutMax, nLeafMax, nDivMax, nDecMax, fVerbose, fVeryVerbose );
-        if ( pNtkRes == NULL )
-        {
-            Abc_Print( -1, "Command has failed.\n" );
-            return 1;
-        }
-        Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    }
-*/
-/*
-    if ( pNtk )
-    {
-        Aig_Man_t * pAig = Abc_NtkToDar( pNtk, 0, 1 );
-        Saig_ManBmcTerSimTestPo( pAig );
-        Aig_ManStop( pAig );
-    }
-*/
-/*
-    if ( !Abc_NtkIsTopo(pNtk) )
-    {
-        Abc_Print( -1, "Current network is not in a topological order.\n" );
-        return 1;
-    }
-*/
-//    if ( pNtk )
-//        Abc_NtkMakeLegit( pNtk ); 
-    {
-//        extern void Ifd_ManDsdTest();
-//        Ifd_ManDsdTest();
-    }
-/*
-    {
-        extern void Abc_EnumerateCubeStates();
-        extern void Abc_EnumerateCubeStatesZdd();
-        if ( fNewAlgo )
-            Abc_EnumerateCubeStatesZdd();
-        else
-            Abc_EnumerateCubeStates();
-        return 0;
-    }
-*/
-    {
-//        extern void Abc_EnumerateFuncs( int nDecMax, int nDivMax, int fVerbose );
-//        Abc_EnumerateFuncs( nDecMax, nDivMax, fVerbose );
-    }
-/*
-    if ( fNewAlgo )
-    {
-        extern void Abc_SuppTest( int nOnes, int nVars, int fUseSimple, int fCheck, int fVerbose );
-        Abc_SuppTest( nNumOnes, nDecMax, fNewOrder, 0, fVerbose );
-    }
-    else
-    {
-        extern void Bmc_EcoMiterTest();
-        Bmc_EcoMiterTest();
-    }
-*/
-
-    {
-//        extern void Nf_ManPrepareLibraryTest();
-//        Nf_ManPrepareLibraryTest();
-//        return 0;
-    }
-/*
-    if ( pNtk )
-    {
-//        extern Abc_Ntk_t * Abc_NtkBarBufsOnOffTest( Abc_Ntk_t * pNtk );
-//        Abc_Ntk_t * pNtkRes = Abc_NtkBarBufsOnOffTest( pNtk );
-        extern Abc_Ntk_t * Abc_NtkPcmTest( Abc_Ntk_t * pNtk, int fNewAlgo, int fVerbose );
-//        extern Abc_Ntk_t * Abc_NtkPcmTestAig( Abc_Ntk_t * pNtk, int fVerbose );
-        Abc_Ntk_t * pNtkRes;
-//        if ( Abc_NtkIsLogic(pNtk) )
-            pNtkRes = Abc_NtkPcmTest( pNtk, fNewAlgo, fVerbose );
-//        else
-//            pNtkRes = Abc_NtkPcmTestAig( pNtk, fVerbose );
-        if ( pNtkRes == NULL )
-        {
-            Abc_Print( -1, "Command has failed.\n" );
-            return 1;
-        }
-        Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    }
-*/
-    return 0;
-usage:
-    Abc_Print( -2, "usage: test [-CKDNM] [-aovwh] <file_name>\n" );
-    Abc_Print( -2, "\t         testbench for new procedures\n" );
-    Abc_Print( -2, "\t-C num : the max number of cuts [default = %d]\n", nCutMax );
-    Abc_Print( -2, "\t-K num : the max number of leaves [default = %d]\n", nLeafMax );
-    Abc_Print( -2, "\t-D num : the max number of divisors [default = %d]\n", nDivMax );
-    Abc_Print( -2, "\t-N num : the max number of node inputs [default = %d]\n", nDecMax );
-    Abc_Print( -2, "\t-M num : the max number of ones in the vector [default = %d]\n", nNumOnes );
-    Abc_Print( -2, "\t-a     : toggle using new algorithm [default = %s]\n", fNewAlgo? "yes": "no" );
-    Abc_Print( -2, "\t-o     : toggle using new ordering [default = %s]\n", fNewOrder? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w     : toggle printing very verbose information [default = %s]\n", fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandQuaVar( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c, iVar, fUniv, fVerbose, RetValue;
-    extern int Abc_NtkQuantify( Abc_Ntk_t * pNtk, int fUniv, int iVar, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    iVar = 0;
-    fUniv = 0;
-    fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Iuvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'I':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            iVar = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( iVar < 0 )
-                goto usage;
-            break;
-        case 'u':
-            fUniv ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( Abc_NtkGetChoiceNum( pNtk ) )
-    {
-        Abc_Print( -1, "This command cannot be applied to an AIG with choice nodes.\n" );
-        return 1;
-    }
-
-    // get the strashed network
-    pNtkRes = Abc_NtkStrash( pNtk, 0, 1, 0 );
-    RetValue = Abc_NtkQuantify( pNtkRes, fUniv, iVar, fVerbose );
-    // clean temporary storage for the cofactors
-    Abc_NtkCleanData( pNtkRes );
-    Abc_AigCleanup( (Abc_Aig_t *)pNtkRes->pManFunc );
-    // check the result
-    if ( !RetValue )
-    {
-        Abc_Print( -1, "Command has failed.\n" );
-        return 0;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: qvar [-I num] [-uvh]\n" );
-    Abc_Print( -2, "\t         quantifies one variable using the AIG\n" );
-    Abc_Print( -2, "\t-I num : the zero-based index of a variable to quantify [default = %d]\n", iVar );
-    Abc_Print( -2, "\t-u     : toggle universal quantification [default = %s]\n", fUniv? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandQuaRel( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c, iVar, fInputs, fVerbose;
-    extern Abc_Ntk_t * Abc_NtkTransRel( Abc_Ntk_t * pNtk, int fInputs, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    iVar = 0;
-    fInputs = 1;
-    fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Iqvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'I':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            iVar = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( iVar < 0 )
-                goto usage;
-            break;
-        case 'q':
-            fInputs ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( Abc_NtkGetChoiceNum( pNtk ) )
-    {
-        Abc_Print( -1, "This command cannot be applied to an AIG with choice nodes.\n" );
-        return 1;
-    }
-    if ( Abc_NtkIsComb(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for sequential circuits.\n" );
-        return 1;
-    }
-
-    // get the strashed network
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        pNtk = Abc_NtkStrash( pNtk, 0, 1, 0 );
-        pNtkRes = Abc_NtkTransRel( pNtk, fInputs, fVerbose );
-        Abc_NtkDelete( pNtk );
-    }
-    else
-        pNtkRes = Abc_NtkTransRel( pNtk, fInputs, fVerbose );
-    // check if the result is available
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Command has failed.\n" );
-        return 0;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: qrel [-qvh]\n" );
-    Abc_Print( -2, "\t         computes transition relation of the sequential network\n" );
-//    Abc_Print( -2, "\t-I num : the zero-based index of a variable to quantify [default = %d]\n", iVar );
-    Abc_Print( -2, "\t-q     : perform quantification of inputs [default = %s]\n", fInputs? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandQuaReach( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c, nIters, fVerbose;
-    extern Abc_Ntk_t * Abc_NtkReachability( Abc_Ntk_t * pNtk, int nIters, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    nIters   = 256;
-    fVerbose =   0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Ivh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'I':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nIters = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nIters < 0 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( Abc_NtkGetChoiceNum( pNtk ) )
-    {
-        Abc_Print( -1, "This command cannot be applied to an AIG with choice nodes.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsComb(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for combinational transition relations.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for strashed networks.\n" );
-        return 1;
-    }
-    if ( Abc_NtkPoNum(pNtk) > 1 )
-    {
-        Abc_Print( -1, "The transition relation should have one output.\n" );
-        return 1;
-    }
-    if ( Abc_NtkPiNum(pNtk) % 2 != 0 )
-    {
-        Abc_Print( -1, "The transition relation should have an even number of inputs.\n" );
-        return 1;
-    }
-
-    pNtkRes = Abc_NtkReachability( pNtk, nIters, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Command has failed.\n" );
-        return 0;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: qreach [-I num] [-vh]\n" );
-    Abc_Print( -2, "\t         computes unreachable states using AIG-based quantification\n" );
-    Abc_Print( -2, "\t         assumes that the current network is a transition relation\n" );
-    Abc_Print( -2, "\t         assumes that the initial state is composed of all zeros\n" );
-    Abc_Print( -2, "\t-I num : the number of image computations to perform [default = %d]\n", nIters );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandSenseInput( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    Vec_Int_t * vResult;
-    int c, nConfLim, fVerbose;
-
-    extern Vec_Int_t * Abc_NtkSensitivity( Abc_Ntk_t * pNtk, int nConfLim, int fVerbose );
-    // set defaults
-    nConfLim   = 1000;
-    fVerbose   =    1;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Cvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nConfLim = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nConfLim < 0 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( Abc_NtkGetChoiceNum( pNtk ) )
-    {
-        Abc_Print( -1, "This command cannot be applied to an AIG with choice nodes.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsComb(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for combinational transition relations.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for strashed networks.\n" );
-        return 1;
-    }
-    if ( Abc_NtkPoNum(pNtk) < 2 )
-    {
-        Abc_Print( -1, "The network should have at least two outputs.\n" );
-        return 1;
-    }
-
-    vResult = Abc_NtkSensitivity( pNtk, nConfLim, fVerbose );
-    Vec_IntFree( vResult );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: senseinput [-C num] [-vh]\n" );
-    Abc_Print( -2, "\t         computes sensitivity of POs to PIs under constraint\n" );
-    Abc_Print( -2, "\t         constraint should be represented as the last PO\n" );
-    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", nConfLim );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandIStrash( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes, * pNtkTemp;
-    int c;
-    extern Abc_Ntk_t * Abc_NtkIvyStrash( Abc_Ntk_t * pNtk );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        pNtkTemp = Abc_NtkStrash( pNtk, 0, 1, 0 );
-        pNtkRes = Abc_NtkIvyStrash( pNtkTemp );
-        Abc_NtkDelete( pNtkTemp );
-    }
-    else
-        pNtkRes = Abc_NtkIvyStrash( pNtk );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Command has failed.\n" );
-        return 0;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: istrash [-h]\n" );
-    Abc_Print( -2, "\t         perform sequential structural hashing\n" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandICut( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c, nInputs;
-    extern void Abc_NtkIvyCuts( Abc_Ntk_t * pNtk, int nInputs );
-
-    // set defaults
-    nInputs = 5;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Kh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nInputs = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nInputs < 0 )
-                goto usage;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for strashed networks.\n" );
-        return 1;
-    }
-
-    Abc_NtkIvyCuts( pNtk, nInputs );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: icut [-K num] [-h]\n" );
-    Abc_Print( -2, "\t         computes sequential cuts of the given size\n" );
-    Abc_Print( -2, "\t-K num : the number of cut inputs (2 <= num <= 6) [default = %d]\n", nInputs );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandIRewrite( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c, fUpdateLevel, fUseZeroCost, fVerbose;
-    extern Abc_Ntk_t * Abc_NtkIvyRewrite( Abc_Ntk_t * pNtk, int fUpdateLevel, int fUseZeroCost, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    fUpdateLevel = 1;
-    fUseZeroCost = 0;
-    fVerbose     = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "lzvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'l':
-            fUpdateLevel ^= 1;
-            break;
-        case 'z':
-            fUseZeroCost ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for strashed networks.\n" );
-        return 1;
-    }
-
-    pNtkRes = Abc_NtkIvyRewrite( pNtk, fUpdateLevel, fUseZeroCost, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Command has failed.\n" );
-        return 0;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: irw [-lzvh]\n" );
-    Abc_Print( -2, "\t         perform combinational AIG rewriting\n" );
-    Abc_Print( -2, "\t-l     : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
-    Abc_Print( -2, "\t-z     : toggle using zero-cost replacements [default = %s]\n", fUseZeroCost? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandDRewrite( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    Dar_RwrPar_t Pars, * pPars = &Pars;
-    int c;
-
-    extern Abc_Ntk_t * Abc_NtkDRewrite( Abc_Ntk_t * pNtk, Dar_RwrPar_t * pPars );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    Dar_ManDefaultRwrParams( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "CNflzrvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nCutsMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nCutsMax < 0 )
-                goto usage;
-            break;
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nSubgMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nSubgMax < 0 )
-                goto usage;
-            break;
-        case 'f':
-            pPars->fFanout ^= 1;
-            break;
-        case 'l':
-            pPars->fUpdateLevel ^= 1;
-            break;
-        case 'z':
-            pPars->fUseZeros ^= 1;
-            break;
-        case 'r':
-            pPars->fRecycle ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'w':
-            pPars->fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for strashed networks.\n" );
-        return 1;
-    }
-    pNtkRes = Abc_NtkDRewrite( pNtk, pPars );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Command has failed.\n" );
-        return 0;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: drw [-C num] [-N num] [-lfzrvwh]\n" );
-    Abc_Print( -2, "\t         performs combinational AIG rewriting\n" );
-    Abc_Print( -2, "\t-C num : the max number of cuts at a node [default = %d]\n", pPars->nCutsMax );
-    Abc_Print( -2, "\t-N num : the max number of subgraphs tried [default = %d]\n", pPars->nSubgMax );
-    Abc_Print( -2, "\t-l     : toggle preserving the number of levels [default = %s]\n", pPars->fUpdateLevel? "yes": "no" );
-    Abc_Print( -2, "\t-f     : toggle representing fanouts [default = %s]\n", pPars->fFanout? "yes": "no" );
-    Abc_Print( -2, "\t-z     : toggle using zero-cost replacements [default = %s]\n", pPars->fUseZeros? "yes": "no" );
-    Abc_Print( -2, "\t-r     : toggle using cut recycling [default = %s]\n", pPars->fRecycle? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w     : toggle very verbose printout [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandDRefactor( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    Dar_RefPar_t Pars, * pPars = &Pars;
-    int c;
-
-    extern Abc_Ntk_t * Abc_NtkDRefactor( Abc_Ntk_t * pNtk, Dar_RefPar_t * pPars );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    Dar_ManDefaultRefParams( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "MKCelzvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'M':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nMffcMin = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nMffcMin < 0 )
-                goto usage;
-            break;
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nLeafMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nLeafMax < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nCutsMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nCutsMax < 0 )
-                goto usage;
-            break;
-        case 'e':
-            pPars->fExtend ^= 1;
-            break;
-        case 'l':
-            pPars->fUpdateLevel ^= 1;
-            break;
-        case 'z':
-            pPars->fUseZeros ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'w':
-            pPars->fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for strashed networks.\n" );
-        return 1;
-    }
-    if ( pPars->nLeafMax < 4 || pPars->nLeafMax > 15 )
-    {
-        Abc_Print( -1, "This command only works for cut sizes 4 <= K <= 15.\n" );
-        return 1;
-    }
-    pNtkRes = Abc_NtkDRefactor( pNtk, pPars );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Command has failed.\n" );
-        return 0;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: drf [-M num] [-K num] [-C num] [-elzvwh]\n" );
-    Abc_Print( -2, "\t         performs combinational AIG refactoring\n" );
-    Abc_Print( -2, "\t-M num : the min MFFC size to attempt refactoring [default = %d]\n", pPars->nMffcMin );
-    Abc_Print( -2, "\t-K num : the max number of cuts leaves [default = %d]\n", pPars->nLeafMax );
-    Abc_Print( -2, "\t-C num : the max number of cuts to try at a node [default = %d]\n", pPars->nCutsMax );
-    Abc_Print( -2, "\t-e     : toggle extending tbe cut below MFFC [default = %s]\n", pPars->fExtend? "yes": "no" );
-    Abc_Print( -2, "\t-l     : toggle preserving the number of levels [default = %s]\n", pPars->fUpdateLevel? "yes": "no" );
-    Abc_Print( -2, "\t-z     : toggle using zero-cost replacements [default = %s]\n", pPars->fUseZeros? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w     : toggle very verbose printout [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandDc2( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int fBalance, fVerbose, fUpdateLevel, fFanout, fPower, c;
-
-    extern Abc_Ntk_t * Abc_NtkDC2( Abc_Ntk_t * pNtk, int fBalance, int fUpdateLevel, int fFanout, int fPower, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    fBalance     = 0;
-    fVerbose     = 0;
-    fUpdateLevel = 0;
-    fFanout      = 1;
-    fPower       = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "blfpvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'b':
-            fBalance ^= 1;
-            break;
-        case 'l':
-            fUpdateLevel ^= 1;
-            break;
-        case 'f':
-            fFanout ^= 1;
-            break;
-        case 'p':
-            fPower ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for strashed networks.\n" );
-        return 1;
-    }
-    pNtkRes = Abc_NtkDC2( pNtk, fBalance, fUpdateLevel, fFanout, fPower, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Command has failed.\n" );
-        return 0;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: dc2 [-blfpvh]\n" );
-    Abc_Print( -2, "\t         performs combinational AIG optimization\n" );
-    Abc_Print( -2, "\t-b     : toggle internal balancing [default = %s]\n", fBalance? "yes": "no" );
-    Abc_Print( -2, "\t-l     : toggle updating level [default = %s]\n", fUpdateLevel? "yes": "no" );
-    Abc_Print( -2, "\t-f     : toggle representing fanouts [default = %s]\n", fFanout? "yes": "no" );
-    Abc_Print( -2, "\t-p     : toggle power-aware rewriting [default = %s]\n", fPower? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandDChoice( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int fBalance, fVerbose, fUpdateLevel, fConstruct, c;
-    int nConfMax, nLevelMax;
-
-    extern Abc_Ntk_t * Abc_NtkDChoice( Abc_Ntk_t * pNtk, int fBalance, int fUpdateLevel, int fConstruct, int nConfMax, int nLevelMax, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    fBalance     = 1;
-    fUpdateLevel = 1;
-    fConstruct   = 0;
-    nConfMax     = 1000;
-    nLevelMax    = 0;
-    fVerbose     = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "CLblcvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nConfMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nConfMax < 0 )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nLevelMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nLevelMax < 0 )
-                goto usage;
-            break;
-        case 'b':
-            fBalance ^= 1;
-            break;
-        case 'l':
-            fUpdateLevel ^= 1;
-            break;
-        case 'c':
-            fConstruct ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for strashed networks.\n" );
-        return 1;
-    }
-    pNtkRes = Abc_NtkDChoice( pNtk, fBalance, fUpdateLevel, fConstruct, nConfMax, nLevelMax, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Command has failed.\n" );
-        return 0;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: dchoice [-C num] [-L num] [-blcvh]\n" );
-    Abc_Print( -2, "\t         performs partitioned choicing using new AIG package\n" );
-    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", nConfMax );
-    Abc_Print( -2, "\t-L num : the max level of nodes to consider (0 = not used) [default = %d]\n", nLevelMax );
-    Abc_Print( -2, "\t-b     : toggle internal balancing [default = %s]\n", fBalance? "yes": "no" );
-    Abc_Print( -2, "\t-l     : toggle updating level [default = %s]\n", fUpdateLevel? "yes": "no" );
-    Abc_Print( -2, "\t-c     : toggle constructive computation of choices [default = %s]\n", fConstruct? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandDch( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Dch_Pars_t Pars, * pPars = &Pars;
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c;
-    extern Abc_Ntk_t * Abc_NtkDch( Abc_Ntk_t * pNtk, Dch_Pars_t * pPars );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    Dch_ManSetDefaultParams( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "WCSsptgcfrvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nWords = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nWords < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nBTLimit < 0 )
-                goto usage;
-            break;
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nSatVarMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nSatVarMax < 0 )
-                goto usage;
-            break;
-        case 's':
-            pPars->fSynthesis ^= 1;
-            break;
-        case 'p':
-            pPars->fPower ^= 1;
-            break;
-        case 't':
-            pPars->fSimulateTfo ^= 1;
-            break;
-        case 'g':
-            pPars->fUseGia ^= 1;
-            break;
-        case 'c':
-            pPars->fUseCSat ^= 1;
-            break;
-        case 'f':
-            pPars->fLightSynth ^= 1;
-            break;
-        case 'r':
-            pPars->fSkipRedSupp ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for strashed networks.\n" );
-        return 1;
-    }
-    pNtkRes = Abc_NtkDch( pNtk, pPars );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Command has failed.\n" );
-        return 0;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: dch [-WCS num] [-sptgcfrvh]\n" );
-    Abc_Print( -2, "\t         computes structural choices using a new approach\n" );
-    Abc_Print( -2, "\t-W num : the max number of simulation words [default = %d]\n", pPars->nWords );
-    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
-    Abc_Print( -2, "\t-S num : the max number of SAT variables [default = %d]\n", pPars->nSatVarMax );
-    Abc_Print( -2, "\t-s     : toggle synthesizing three snapshots [default = %s]\n", pPars->fSynthesis? "yes": "no" );
-    Abc_Print( -2, "\t-p     : toggle power-aware rewriting [default = %s]\n", pPars->fPower? "yes": "no" );
-    Abc_Print( -2, "\t-t     : toggle simulation of the TFO classes [default = %s]\n", pPars->fSimulateTfo? "yes": "no" );
-    Abc_Print( -2, "\t-g     : toggle using GIA to prove equivalences [default = %s]\n", pPars->fUseGia? "yes": "no" );
-    Abc_Print( -2, "\t-c     : toggle using circuit-based SAT vs. MiniSat [default = %s]\n", pPars->fUseCSat? "yes": "no" );
-    Abc_Print( -2, "\t-f     : toggle using faster logic synthesis [default = %s]\n", pPars->fLightSynth? "yes": "no" );
-    Abc_Print( -2, "\t-r     : toggle skipping choices with redundant support [default = %s]\n", pPars->fSkipRedSupp? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandDrwsat( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int fBalance, fVerbose, c;
-
-    extern Abc_Ntk_t * Abc_NtkDrwsat( Abc_Ntk_t * pNtk, int fBalance, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    fBalance = 0;
-    fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "bvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'b':
-            fBalance ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for strashed networks.\n" );
-        return 1;
-    }
-    pNtkRes = Abc_NtkDrwsat( pNtk, fBalance, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Command has failed.\n" );
-        return 0;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: drwsat [-bvh]\n" );
-    Abc_Print( -2, "\t         performs combinational AIG optimization for SAT\n" );
-    Abc_Print( -2, "\t-b     : toggle internal balancing [default = %s]\n", fBalance? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandIRewriteSeq( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c, fUpdateLevel, fUseZeroCost, fVerbose;
-    extern Abc_Ntk_t * Abc_NtkIvyRewriteSeq( Abc_Ntk_t * pNtk, int fUseZeroCost, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    fUpdateLevel = 0;
-    fUseZeroCost = 0;
-    fVerbose     = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "lzvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'l':
-            fUpdateLevel ^= 1;
-            break;
-        case 'z':
-            fUseZeroCost ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for strashed networks.\n" );
-        return 1;
-    }
-
-    pNtkRes = Abc_NtkIvyRewriteSeq( pNtk, fUseZeroCost, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Command has failed.\n" );
-        return 0;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: irws [-zvh]\n" );
-    Abc_Print( -2, "\t         perform sequential AIG rewriting\n" );
-//    Abc_Print( -2, "\t-l     : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
-    Abc_Print( -2, "\t-z     : toggle using zero-cost replacements [default = %s]\n", fUseZeroCost? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandIResyn( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c, fUpdateLevel, fVerbose;
-    extern Abc_Ntk_t * Abc_NtkIvyResyn( Abc_Ntk_t * pNtk, int fUpdateLevel, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    fUpdateLevel = 1;
-    fVerbose     = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "lzvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'l':
-            fUpdateLevel ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for strashed networks.\n" );
-        return 1;
-    }
-
-    pNtkRes = Abc_NtkIvyResyn( pNtk, fUpdateLevel, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Command has failed.\n" );
-        return 0;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: iresyn [-lvh]\n" );
-    Abc_Print( -2, "\t         performs combinational resynthesis\n" );
-    Abc_Print( -2, "\t-l     : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandISat( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c, fUpdateLevel, fVerbose;
-    int nConfLimit;
-
-    extern Abc_Ntk_t * Abc_NtkIvySat( Abc_Ntk_t * pNtk, int nConfLimit, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    nConfLimit   = 100000;
-    fUpdateLevel = 1;
-    fVerbose     = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Clzvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nConfLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nConfLimit < 0 )
-                goto usage;
-            break;
-        case 'l':
-            fUpdateLevel ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for strashed networks.\n" );
-        return 1;
-    }
-
-    pNtkRes = Abc_NtkIvySat( pNtk, nConfLimit, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Command has failed.\n" );
-        return 0;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: isat [-C num] [-vh]\n" );
-    Abc_Print( -2, "\t         tries to prove the miter constant 0\n" );
-    Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n",    nConfLimit );
-//    Abc_Print( -2, "\t-l     : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandIFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c, fProve, fVerbose, fDoSparse;
-    int nConfLimit;
-    int nPartSize;
-    int nLevelMax;
-
-    extern Abc_Ntk_t * Abc_NtkIvyFraig( Abc_Ntk_t * pNtk, int nConfLimit, int fDoSparse, int fProve, int fTransfer, int fVerbose );
-    extern Abc_Ntk_t * Abc_NtkDarFraigPart( Abc_Ntk_t * pNtk, int nPartSize, int nConfLimit, int nLevelMax, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    nPartSize    = 0;
-    nLevelMax    = 0;
-    nConfLimit   = 100;
-    fDoSparse    = 0;
-    fProve       = 0;
-    fVerbose     = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "PCLspvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'P':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nPartSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nPartSize < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nConfLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nConfLimit < 0 )
-                goto usage;
-            break;
-         case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nLevelMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nLevelMax < 0 )
-                goto usage;
-            break;
-        case 's':
-            fDoSparse ^= 1;
-            break;
-        case 'p':
-            fProve ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for strashed networks.\n" );
-        return 1;
-    }
-
-    if ( nPartSize > 0 )
-        pNtkRes = Abc_NtkDarFraigPart( pNtk, nPartSize, nConfLimit, nLevelMax, fVerbose );
-    else
-        pNtkRes = Abc_NtkIvyFraig( pNtk, nConfLimit, fDoSparse, fProve, 0, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Command has failed.\n" );
-        return 0;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: ifraig [-P num] [-C num] [-L num] [-spvh]\n" );
-    Abc_Print( -2, "\t         performs fraiging using a new method\n" );
-    Abc_Print( -2, "\t-P num : partition size (0 = partitioning is not used) [default = %d]\n", nPartSize );
-    Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
-    Abc_Print( -2, "\t-L num : limit on node level to fraig (0 = fraig all nodes) [default = %d]\n", nLevelMax );
-    Abc_Print( -2, "\t-s     : toggle considering sparse functions [default = %s]\n", fDoSparse? "yes": "no" );
-    Abc_Print( -2, "\t-p     : toggle proving the miter outputs [default = %s]\n", fProve? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandDFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c, nConfLimit, fDoSparse, fProve, fSpeculate, fChoicing, fVerbose;
-
-    extern Abc_Ntk_t * Abc_NtkDarFraig( Abc_Ntk_t * pNtk, int nConfLimit, int fDoSparse, int fProve, int fTransfer, int fSpeculate, int fChoicing, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    nConfLimit   = 100;
-    fDoSparse    = 1;
-    fProve       = 0;
-    fSpeculate   = 0;
-    fChoicing    = 0;
-    fVerbose     = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Csprcvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nConfLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nConfLimit < 0 )
-                goto usage;
-            break;
-        case 's':
-            fDoSparse ^= 1;
-            break;
-        case 'p':
-            fProve ^= 1;
-            break;
-        case 'r':
-            fSpeculate ^= 1;
-            break;
-        case 'c':
-            fChoicing ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for strashed networks.\n" );
-        return 1;
-    }
-
-    pNtkRes = Abc_NtkDarFraig( pNtk, nConfLimit, fDoSparse, fProve, 0, fSpeculate, fChoicing, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Command has failed.\n" );
-        return 0;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: dfraig [-C num] [-sprcvh]\n" );
-    Abc_Print( -2, "\t         performs fraiging using a new method\n" );
-    Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
-    Abc_Print( -2, "\t-s     : toggle considering sparse functions [default = %s]\n", fDoSparse? "yes": "no" );
-    Abc_Print( -2, "\t-p     : toggle proving the miter outputs [default = %s]\n", fProve? "yes": "no" );
-    Abc_Print( -2, "\t-r     : toggle speculative reduction [default = %s]\n", fSpeculate? "yes": "no" );
-    Abc_Print( -2, "\t-c     : toggle accumulation of choices [default = %s]\n", fChoicing? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandCSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c, nCutsMax, nLeafMax, fVerbose;
-
-    extern Abc_Ntk_t * Abc_NtkCSweep( Abc_Ntk_t * pNtk, int nCutsMax, int nLeafMax, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    nCutsMax  =  8;
-    nLeafMax  =  6;
-    fVerbose  =  0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "CKvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nCutsMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nCutsMax < 0 )
-                goto usage;
-            break;
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nLeafMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nLeafMax < 0 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( nCutsMax < 2 )
-    {
-        Abc_Print( -1, "The number of cuts cannot be less than 2.\n" );
-        return 1;
-    }
-
-    if ( nLeafMax < 3 || nLeafMax > 16 )
-    {
-        Abc_Print( -1, "The number of leaves is infeasible.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for strashed networks.\n" );
-        return 1;
-    }
-
-    pNtkRes = Abc_NtkCSweep( pNtk, nCutsMax, nLeafMax, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Command has failed.\n" );
-        return 0;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: csweep [-C num] [-K num] [-vh]\n" );
-    Abc_Print( -2, "\t         performs cut sweeping using a new method\n" );
-    Abc_Print( -2, "\t-C num : limit on the number of cuts (C >= 2) [default = %d]\n", nCutsMax );
-    Abc_Print( -2, "\t-K num : limit on the cut size (3 <= K <= 16) [default = %d]\n", nLeafMax );
-    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandIProve( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Prove_Params_t Params, * pParams = &Params;
-    Abc_Ntk_t * pNtk, * pNtkTemp;
-    int c, RetValue, iOut = -1;
-    abctime clk;
-
-    extern int Abc_NtkIvyProve( Abc_Ntk_t ** ppNtk, void * pPars );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    Prove_ParamsSetDefault( pParams );
-    pParams->fUseRewriting = 1;
-    pParams->fVerbose      = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "NCFGLIrfbvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pParams->nItersMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pParams->nItersMax < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pParams->nMiteringLimitStart = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pParams->nMiteringLimitStart < 0 )
-                goto usage;
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pParams->nFraigingLimitStart = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pParams->nFraigingLimitStart < 0 )
-                goto usage;
-            break;
-        case 'G':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-G\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pParams->nFraigingLimitMulti = (float)atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pParams->nFraigingLimitMulti < 0 )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pParams->nMiteringLimitLast = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pParams->nMiteringLimitLast < 0 )
-                goto usage;
-            break;
-        case 'I':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pParams->nTotalInspectLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pParams->nTotalInspectLimit < 0 )
-                goto usage;
-            break;
-        case 'r':
-            pParams->fUseRewriting ^= 1;
-            break;
-        case 'f':
-            pParams->fUseFraiging ^= 1;
-            break;
-        case 'b':
-            pParams->fUseBdds ^= 1;
-            break;
-        case 'v':
-            pParams->fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( Abc_NtkLatchNum(pNtk) > 0 )
-    {
-        Abc_Print( -1, "The network has registers. Use \"dprove\".\n" );
-        return 1;
-    }
-
-    clk = Abc_Clock();
-
-    if ( Abc_NtkIsStrash(pNtk) )
-        pNtkTemp = Abc_NtkDup( pNtk );
-    else
-        pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
-
-    RetValue = Abc_NtkIvyProve( &pNtkTemp, pParams );
-
-    // verify that the pattern is correct
-    if ( RetValue == 0 )
-    {
-        Abc_Obj_t * pObj;
-        int i;
-        int * pSimInfo = Abc_NtkVerifySimulatePattern( pNtk, pNtkTemp->pModel );
-        Abc_NtkForEachCo( pNtk, pObj, i )
-            if ( pSimInfo[i] == 1 )
-            {
-                iOut = i;
-                break;
-            }
-        if ( i == Abc_NtkCoNum(pNtk) )
-            Abc_Print( 1, "ERROR in Abc_NtkMiterProve(): Generated counter-example is invalid.\n" );
-        ABC_FREE( pSimInfo );
-    }
-    pAbc->Status = RetValue;
-    if ( RetValue == -1 )
-        Abc_Print( 1, "UNDECIDED      " );
-    else if ( RetValue == 0 )
-        Abc_Print( 1, "SATISFIABLE (output = %d) ", iOut );
-    else
-        Abc_Print( 1, "UNSATISFIABLE  " );
-    //Abc_Print( -1, "\n" );
-
-    Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkTemp );
-    // update counter example
-    if ( RetValue == 0 && Abc_NtkLatchNum(pNtkTemp) == 0 )
-    {
-        Abc_Cex_t * pCex = Abc_CexDeriveFromCombModel( pNtkTemp->pModel, Abc_NtkPiNum(pNtkTemp), 0, iOut );
-        Abc_FrameReplaceCex( pAbc, &pCex );
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: iprove [-NCFGLI num] [-rfbvh]\n" );
-    Abc_Print( -2, "\t         performs CEC using a new method\n" );
-    Abc_Print( -2, "\t-N num : max number of iterations [default = %d]\n", pParams->nItersMax );
-    Abc_Print( -2, "\t-C num : max starting number of conflicts in mitering [default = %d]\n", pParams->nMiteringLimitStart );
-    Abc_Print( -2, "\t-F num : max starting number of conflicts in fraiging [default = %d]\n", pParams->nFraigingLimitStart );
-    Abc_Print( -2, "\t-G num : multiplicative coefficient for fraiging [default = %d]\n", (int)pParams->nFraigingLimitMulti );
-    Abc_Print( -2, "\t-L num : max last-gasp number of conflicts in mitering [default = %d]\n", pParams->nMiteringLimitLast );
-    Abc_Print( -2, "\t-I num : max number of clause inspections in all SAT calls [default = %d]\n", (int)pParams->nTotalInspectLimit );
-    Abc_Print( -2, "\t-r     : toggle the use of rewriting [default = %s]\n", pParams->fUseRewriting? "yes": "no" );
-    Abc_Print( -2, "\t-f     : toggle the use of FRAIGing [default = %s]\n", pParams->fUseFraiging? "yes": "no" );
-    Abc_Print( -2, "\t-b     : toggle the use of BDDs [default = %s]\n", pParams->fUseBdds? "yes": "no" );
-    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", pParams->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-/*
-int Abc_CommandHaig( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    FILE * stdout, * pErr;
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c;
-    int nIters;
-    int nSteps;
-    int fRetimingOnly;
-    int fAddBugs;
-    int fUseCnf;
-    int fVerbose;
-
-    extern Abc_Ntk_t * Abc_NtkDarHaigRecord( Abc_Ntk_t * pNtk, int nIters, int nSteps, int fRetimingOnly, int fAddBugs, int fUseCnf, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-
-
-
-    // set defaults
-    nIters        = 3;
-    nSteps        = 3000;
-    fRetimingOnly = 0;
-    fAddBugs      = 0;
-    fUseCnf       = 0;
-    fVerbose      = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "ISrbcvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'I':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-I\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            nIters = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nIters < 0 )
-                goto usage;
-            break;
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            nSteps = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nSteps < 0 )
-                goto usage;
-            break;
-        case 'r':
-            fRetimingOnly ^= 1;
-            break;
-        case 'b':
-            fAddBugs ^= 1;
-            break;
-        case 'c':
-            fUseCnf ^= 1;
-            break;
-        case 'v':
-            fUseCnf ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for strashed networks.\n" );
-        return 1;
-    }
-
-    pNtkRes = Abc_NtkDarHaigRecord( pNtk, nIters, nSteps, fRetimingOnly, fAddBugs, fUseCnf, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Command has failed.\n" );
-        return 0;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: haig [-IS num] [-rbcvh]\n" );
-    Abc_Print( -2, "\t         run a few rounds of comb+seq synthesis to test HAIG recording\n" );
-    Abc_Print( -2, "\t         the current network is set to be the result of synthesis performed\n" );
-    Abc_Print( -2, "\t         (this network can be verified using command \"dsec\")\n" );
-    Abc_Print( -2, "\t         HAIG is written out into the file \"haig.blif\"\n" );
-    Abc_Print( -2, "\t         (this HAIG can be proved using \"r haig.blif; st; dprove -abc -F 16\")\n" );
-    Abc_Print( -2, "\t-I num : the number of rounds of comb+seq synthesis [default = %d]\n", nIters );
-    Abc_Print( -2, "\t-S num : the number of forward retiming moves performed [default = %d]\n", nSteps );
-    Abc_Print( -2, "\t-r     : toggle the use of retiming only [default = %s]\n", fRetimingOnly? "yes": "no" );
-    Abc_Print( -2, "\t-b     : toggle bug insertion [default = %s]\n", fAddBugs? "yes": "no" );
-    Abc_Print( -2, "\t-c     : enable CNF-based proof (no speculative reduction) [default = %s]\n", fUseCnf? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-*/
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandQbf( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int nPars;
-    int nIters;
-    int fDumpCnf;
-    int fVerbose;
-
-    extern void Abc_NtkQbf( Abc_Ntk_t * pNtk, int nPars, int nIters, int fDumpCnf, int fVerbose );
-    // set defaults
-    nPars    =  -1;
-    nIters   = 500;
-    fDumpCnf =   0;
-    fVerbose =   1;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "PIdvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'P':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nPars = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nPars < 0 )
-                goto usage;
-            break;
-        case 'I':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nIters = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nIters < 0 )
-                goto usage;
-            break;
-        case 'd':
-            fDumpCnf ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsComb(pNtk) )
-    {
-        Abc_Print( -1, "Works only for combinational networks.\n" );
-        return 1;
-    }
-    if ( Abc_NtkPoNum(pNtk) != 1 )
-    {
-        Abc_Print( -1, "The miter should have one primary output.\n" );
-        return 1;
-    }
-    if ( !(nPars > 0 && nPars < Abc_NtkPiNum(pNtk)) )
-    {
-        Abc_Print( -1, "The number of paramter variables is invalid (should be > 0 and < PI num).\n" );
-        return 1;
-    }
-    if ( Abc_NtkIsStrash(pNtk) )
-        Abc_NtkQbf( pNtk, nPars, nIters, fDumpCnf, fVerbose );
-    else
-    {
-        pNtk = Abc_NtkStrash( pNtk, 0, 1, 0 );
-        Abc_NtkQbf( pNtk, nPars, nIters, fDumpCnf, fVerbose );
-        Abc_NtkDelete( pNtk );
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: qbf [-PI num] [-dvh]\n" );
-    Abc_Print( -2, "\t         solves QBF problem EpVxM(p,x)\n" );
-    Abc_Print( -2, "\t-P num : number of parameters p (should be the first PIs) [default = %d]\n", nPars );
-    Abc_Print( -2, "\t-I num : quit after the given iteration even if unsolved [default = %d]\n", nIters );
-    Abc_Print( -2, "\t-d     : toggle dumping QDIMACS file instead of solving [default = %s]\n", fDumpCnf? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandNpnLoad( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern void Npn_ManLoad( char * pFileName );
-    char * pFileName;
-    int c;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( argc != globalUtilOptind + 1 )
-        goto usage;
-    pFileName = argv[globalUtilOptind];
-    Npn_ManLoad( pFileName );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: npnload <filename>\n" );
-    Abc_Print( -2, "\t         loads previously saved 6-input function library from file\n" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-               
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandNpnSave( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern void Npn_ManSave( char * pFileName );
-    char * pFileName;
-    int c;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( argc != globalUtilOptind + 1 )
-        goto usage;
-    pFileName = argv[globalUtilOptind];
-    Npn_ManSave( pFileName );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: npnsave <filename>\n" );
-    Abc_Print( -2, "\t         saves current 6-input function library into file\n" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-               
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandSendAig( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-//    const int BRIDGE_NETLIST = 106;
-//    const int BRIDGE_ABS_NETLIST = 107;
-
-    int c, fAndSpace = 1, fAbsNetlist = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "ah" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'a':
-            fAndSpace ^= 1;
-            break;
-        case 'b':
-            fAbsNetlist ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( !Abc_FrameIsBridgeMode() )
-    {
-        Abc_Print( -1, "The bridge mode is not available.\n" );
-        return 1;
-    }
-    if ( fAndSpace )
-    {
-        if ( pAbc->pGia == NULL )
-        {
-            Abc_Print( -1, "There is no AIG in the &-space.\n" );
-            return 1;
-        }
-        Gia_ManToBridgeAbsNetlist( stdout, pAbc->pGia, fAbsNetlist ? BRIDGE_ABS_NETLIST : BRIDGE_NETLIST );
-    }
-    else
-    {
-        Aig_Man_t * pAig;
-        Gia_Man_t * pGia;
-        if ( pAbc->pNtkCur == NULL )
-        {
-            Abc_Print( -1, "There is no network in the main-space.\n" );
-            return 1;
-        }
-        if ( !Abc_NtkIsStrash(pAbc->pNtkCur) )
-        {
-            Abc_Print( -1, "The main-space network is not an AIG.\n" );
-            return 1;
-        }
-        pAig = Abc_NtkToDar( pAbc->pNtkCur, 0, 1 );
-        pGia = Gia_ManFromAig( pAig );
-        Aig_ManStop( pAig );
-        Gia_ManToBridgeAbsNetlist( stdout, pGia, fAbsNetlist ? BRIDGE_ABS_NETLIST : BRIDGE_NETLIST  );
-        Gia_ManStop( pGia );
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: send_aig -a\n" );
-    Abc_Print( -2, "\t         sends current AIG to the bridge\n" );
-    Abc_Print( -2, "\t-a     : toggle sending AIG from &-space [default = %s]\n", fAndSpace? "yes": "no" );
-    Abc_Print( -2, "\t-b     : toggle sending netlist tagged as \"abstraction\". [default = %s]\n", fAbsNetlist? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-               
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandSendStatus( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern int Gia_ManToBridgeResult( FILE * pFile, int Result, Abc_Cex_t * pCex, int iPoProved );
-    int c;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( !Abc_FrameIsBridgeMode() )
-    {
-        Abc_Print( -1, "The bridge mode is not available.\n" );
-        return 1;
-    }
-    if ( pAbc->Status == 0 && pAbc->pCex == NULL )
-    {
-        Abc_Print( -1, "Status is \"sat\", but current CEX is not available.\n" );
-        return 1;
-    }
-    Gia_ManToBridgeResult( stdout, pAbc->Status, pAbc->pCex, 0 );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: send_status\n" );
-    Abc_Print( -2, "\t         sends current status to the bridge\n" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    char Buffer[100];
-    Fraig_Params_t Params, * pParams = &Params;
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int fAllNodes;
-    int fExdc;
-    int c;
-    int fPartition = 0;
-    extern void Abc_NtkFraigPartitionedTime( Abc_Ntk_t * pNtk, void * pParams );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    fExdc     = 0;
-    fAllNodes = 0;
-    memset( pParams, 0, sizeof(Fraig_Params_t) );
-    pParams->nPatsRand  = 2048; // the number of words of random simulation info
-    pParams->nPatsDyna  = 2048; // the number of words of dynamic simulation info
-    pParams->nBTLimit   =  100; // the max number of backtracks to perform
-    pParams->fFuncRed   =    1; // performs only one level hashing
-    pParams->fFeedBack  =    1; // enables solver feedback
-    pParams->fDist1Pats =    1; // enables distance-1 patterns
-    pParams->fDoSparse  =    1; // performs equiv tests for sparse functions
-    pParams->fChoicing  =    0; // enables recording structural choices
-    pParams->fTryProve  =    0; // tries to solve the final miter
-    pParams->fVerbose   =    0; // the verbosiness flag
-    pParams->fVerboseP  =    0; // the verbosiness flag
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "RDCrscptvaeh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'R':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pParams->nPatsRand = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pParams->nPatsRand < 0 )
-                goto usage;
-            break;
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pParams->nPatsDyna = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pParams->nPatsDyna < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pParams->nBTLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pParams->nBTLimit < 0 )
-                goto usage;
-            break;
-
-        case 'r':
-            pParams->fFuncRed ^= 1;
-            break;
-        case 's':
-            pParams->fDoSparse ^= 1;
-            break;
-        case 'c':
-            pParams->fChoicing ^= 1;
-            break;
-        case 'p':
-            pParams->fTryProve ^= 1;
-            break;
-        case 'v':
-            pParams->fVerbose ^= 1;
-            break;
-        case 't':
-            fPartition ^= 1;
-            break;
-        case 'a':
-            fAllNodes ^= 1;
-            break;
-        case 'e':
-            fExdc ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsLogic(pNtk) && !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Can only fraig a logic network or an AIG.\n" );
-        return 1;
-    }
-
-    // report the proof
-    pParams->fVerboseP = pParams->fTryProve;
-
-    // get the new network
-    if ( fPartition )
-    {
-        pNtkRes = Abc_NtkDup( pNtk );
-        if ( Abc_NtkIsStrash(pNtk) )
-            Abc_NtkFraigPartitionedTime( pNtk, &Params );
-        else
-        {
-            pNtk = Abc_NtkStrash( pNtk, fAllNodes, !fAllNodes, 0 );
-            Abc_NtkFraigPartitionedTime( pNtk, &Params );
-            Abc_NtkDelete( pNtk );
-        }
-    }
-    else
-    {
-        if ( Abc_NtkIsStrash(pNtk) )
-            pNtkRes = Abc_NtkFraig( pNtk, &Params, fAllNodes, fExdc );
-        else
-        {
-            pNtk = Abc_NtkStrash( pNtk, fAllNodes, !fAllNodes, 0 );
-            pNtkRes = Abc_NtkFraig( pNtk, &Params, fAllNodes, fExdc );
-            Abc_NtkDelete( pNtk );
-        }
-    }
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Fraiging has failed.\n" );
-        return 1;
-    }
-
-    if ( pParams->fTryProve ) // report the result
-        Abc_NtkMiterReport( pNtkRes );
-
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    sprintf(Buffer, "%d", pParams->nBTLimit );
-    Abc_Print( -2, "usage: fraig [-R num] [-D num] [-C num] [-rscpvtah]\n" );
-    Abc_Print( -2, "\t         transforms a logic network into a functionally reduced AIG\n" );
-    Abc_Print( -2, "\t         (known bugs: takes an UNSAT miter and returns a SAT one)\n");
-    Abc_Print( -2, "\t         (there are newer fraiging commands, \"ifraig\" and \"dfraig\")\n" );
-    Abc_Print( -2, "\t-R num : number of random patterns (127 < num < 32769) [default = %d]\n",     pParams->nPatsRand );
-    Abc_Print( -2, "\t-D num : number of systematic patterns (127 < num < 32769) [default = %d]\n", pParams->nPatsDyna );
-    Abc_Print( -2, "\t-C num : number of backtracks for one SAT problem [default = %s]\n",    pParams->nBTLimit==-1? "infinity" : Buffer );
-    Abc_Print( -2, "\t-r     : toggle functional reduction [default = %s]\n",                 pParams->fFuncRed? "yes": "no" );
-    Abc_Print( -2, "\t-s     : toggle considering sparse functions [default = %s]\n",         pParams->fDoSparse? "yes": "no" );
-    Abc_Print( -2, "\t-c     : toggle accumulation of choices [default = %s]\n",              pParams->fChoicing? "yes": "no" );
-    Abc_Print( -2, "\t-p     : toggle proving the miter outputs [default = %s]\n",              pParams->fTryProve? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n",                       pParams->fVerbose?  "yes": "no" );
-    Abc_Print( -2, "\t-e     : toggle functional sweeping using EXDC [default = %s]\n",       fExdc? "yes": "no" );
-    Abc_Print( -2, "\t-a     : toggle between all nodes and DFS nodes [default = %s]\n",      fAllNodes? "all": "dfs" );
-    Abc_Print( -2, "\t-t     : toggle using partitioned representation [default = %s]\n",     fPartition? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandFraigTrust( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c;
-    int fDuplicate;
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    fDuplicate = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'd':
-            fDuplicate ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    // get the new network
-    pNtkRes = Abc_NtkFraigTrust( pNtk );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Fraiging in the trust mode has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: fraig_trust [-h]\n" );
-    Abc_Print( -2, "\t        transforms the current network into an AIG assuming it is FRAIG with choices\n" );
-//    Abc_Print( -2, "\t-d    : toggle duplication of logic [default = %s]\n", fDuplicate? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandFraigStore( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int fDuplicate;
-
-    // set defaults
-    fDuplicate = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'd':
-            fDuplicate ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    // get the new network
-    if ( !Abc_NtkFraigStore( pNtk ) )
-    {
-        Abc_Print( -1, "Fraig storing has failed.\n" );
-        return 1;
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: fraig_store [-h]\n" );
-    Abc_Print( -2, "\t        saves the current network in the AIG database\n" );
-//    Abc_Print( -2, "\t-d    : toggle duplication of logic [default = %s]\n", fDuplicate? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandFraigRestore( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c;
-    int fDuplicate;
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    fDuplicate = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'd':
-            fDuplicate ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    // get the new network
-    pNtkRes = Abc_NtkFraigRestore();
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Fraig restoring has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: fraig_restore [-h]\n" );
-    Abc_Print( -2, "\t        makes the current network by fraiging the AIG database\n" );
-//    Abc_Print( -2, "\t-d    : toggle duplication of logic [default = %s]\n", fDuplicate? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandFraigClean( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-//    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int fDuplicate;
-    // set defaults
-    fDuplicate = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'd':
-            fDuplicate ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    Abc_NtkFraigStoreClean();
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: fraig_clean [-h]\n" );
-    Abc_Print( -2, "\t        cleans the internal FRAIG storage\n" );
-//    Abc_Print( -2, "\t-d    : toggle duplication of logic [default = %s]\n", fDuplicate? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandFraigSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int fUseInv;
-    int fExdc;
-    int fVerbose;
-    int fVeryVerbose;
-    extern int Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fExdc, int fVerbose, int fVeryVerbose );
-    // set defaults
-    fUseInv   = 1;
-    fExdc     = 0;
-    fVerbose  = 0;
-    fVeryVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "ievwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'i':
-            fUseInv ^= 1;
-            break;
-        case 'e':
-            fExdc ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'w':
-            fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Cannot sweep AIGs (use \"fraig\").\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsLogic(pNtk) )
-    {
-        Abc_Print( -1, "Transform the current network into a logic network.\n" );
-        return 1;
-    }
-    // modify the current network
-    if ( !Abc_NtkFraigSweep( pNtk, fUseInv, fExdc, fVerbose, fVeryVerbose ) )
-    {
-        Abc_Print( -1, "Sweeping has failed.\n" );
-        return 1;
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: fraig_sweep [-evwh]\n" );
-    Abc_Print( -2, "\t        performs technology-dependent sweep\n" );
-    Abc_Print( -2, "\t-e    : toggle functional sweeping using EXDC [default = %s]\n", fExdc? "yes": "no" );
-    Abc_Print( -2, "\t-v    : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w    : prints equivalence class information [default = %s]\n", fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandFraigDress( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern void Abc_NtkDress( Abc_Ntk_t * pNtk, char * pFileName, int fVerbose );
-    extern void Abc_NtkDress2( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nConflictLimit, int fVerbose );
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc), * pNtk2;
-    char * pFileName;
-    int c;
-    int nConfs;
-    int fVerbose;
-    // set defaults
-    nConfs   = 1000;
-    fVerbose =    0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Cvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nConfs = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nConfs < 0 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for logic networks.\n" );
-        return 1;
-    }
-    if ( argc != globalUtilOptind && argc != globalUtilOptind + 1 )
-        goto usage;
-    if ( argc == globalUtilOptind && Abc_NtkSpec(pNtk) == NULL )
-    {
-        Abc_Print( -1, "The current network has no spec.\n" );
-        return 1;
-    }
-    // get the input file name
-    pFileName = (argc == globalUtilOptind + 1) ? argv[globalUtilOptind] : Abc_NtkSpec(pNtk);
-    // modify the current network
-//    Abc_NtkDress( pNtk, pFileName, fVerbose );
-    pNtk2 = Io_Read( pFileName, Io_ReadFileType(pFileName), 1, 0 );
-    Abc_NtkDress2( pNtk, pNtk2, nConfs, fVerbose );
-    Abc_NtkDelete( pNtk2 );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: dress [-C num] [-vh] <file>\n" );
-    Abc_Print( -2, "\t         transfers internal node names from file to the current network\n" );
-    Abc_Print( -2, "\t<file> : network with names (if not given, the current network spec is used)\n" );
-    Abc_Print( -2, "\t-C num : the maximum number of conflicts at each node [default = %d]\n", nConfs );
-    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandRecStart3( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    char * FileName, * pTemp;
-    char ** pArgvNew;
-    int c, nArgcNew;
-    FILE * pFile;
-    Gia_Man_t * pGia = NULL;
-    int nVars = 6;
-    int nCuts = 32;
-    int fFuncOnly = 0;
-    int fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "KCfvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nVars = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nVars < 1 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nCuts = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nCuts < 1 )
-                goto usage;
-            break;
-        case 'f':
-            fFuncOnly ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( !(nVars >= 3 && nVars <= 16) )
-    {
-        Abc_Print( -1, "The range of allowed values is 3 <= K <= 16.\n" );
-        return 0;
-    }
-    if ( Abc_NtkRecIsRunning3() )
-    {
-        Abc_Print( -1, "The AIG subgraph recording is already started.\n" );
-        return 0;
-    }
-    pArgvNew = argv + globalUtilOptind;
-    nArgcNew = argc - globalUtilOptind;
-    if ( nArgcNew != 1 )
-        Abc_Print( 1, "File name is not given on the command line. Starting a new record.\n" );
-    else
-    {
-        // get the input file name
-        FileName = pArgvNew[0];
-        // fix the wrong symbol
-        for ( pTemp = FileName; *pTemp; pTemp++ )
-            if ( *pTemp == '>' )
-                *pTemp = '\\';
-        if ( (pFile = fopen( FileName, "r" )) == NULL )
-        {
-            Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
-            if ( (FileName = Extra_FileGetSimilarName( FileName, ".aig", NULL, NULL, NULL, NULL )) )
-                Abc_Print( 1, "Did you mean \"%s\"?", FileName );
-            Abc_Print( 1, "\n" );
-            return 1;
-        }
-        fclose( pFile );
-        pGia = Gia_AigerRead( FileName, 1, 0 );
-        if ( pGia == NULL )
-        {
-            Abc_Print( -1, "Reading AIGER has failed.\n" );
-            return 0;
-        }
-    }
-    Abc_NtkRecStart3( pGia, nVars, nCuts, fFuncOnly, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: rec_start3 [-K num] [-C num] [-fvh] <file>\n" );
-    Abc_Print( -2, "\t         starts recording AIG subgraphs (should be called for\n" );
-    Abc_Print( -2, "\t         an empty network or after reading in a previous record)\n" );
-    Abc_Print( -2, "\t-K num : the largest number of inputs [default = %d]\n", nVars );
-    Abc_Print( -2, "\t-C num : the max number of cuts used at a node (0 < num < 2^12) [default = %d]\n", nCuts );
-    Abc_Print( -2, "\t-f     : toggles recording functions without AIG subgraphs [default = %s]\n", fFuncOnly? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggles additional verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\t<file> : AIGER file with the library\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandRecStop3( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    int c;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( !Abc_NtkRecIsRunning3() )
-    {
-        Abc_Print( -1, "This command works only after calling \"rec_start3\".\n" );
-        return 0;
-    }
-    Abc_NtkRecStop3();
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: rec_stop3 [-h]\n" );
-    Abc_Print( -2, "\t        cleans the internal storage for AIG subgraphs\n" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandRecPs3( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    int c, fPrintLib = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "ph" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'p':
-            fPrintLib ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( !Abc_NtkRecIsRunning3() )
-    {
-        Abc_Print( -1, "This command works for AIGs only after calling \"rec_start2\".\n" );
-        return 0;
-    }
-    Abc_NtkRecPs3(fPrintLib);
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: rec_ps3 [-h]\n" );
-    Abc_Print( -2, "\t        prints statistics about the recorded AIG subgraphs\n" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandRecAdd3( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int fUseSOPB = 0;
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "gh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'g':
-            fUseSOPB = 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works for AIGs.\n" );
-        return 0;
-    }
-    if ( !Abc_NtkRecIsRunning3() )
-    {
-        Abc_Print( -1, "This command works for AIGs after calling \"rec_start2\".\n" );
-        return 0;
-    }
-    Abc_NtkRecAdd3( pNtk, fUseSOPB );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: rec_add3 [-h]\n" );
-    Abc_Print( -2, "\t        adds subgraphs from the current network to the set\n" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandRecDump3( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern void Abc_NtkRecDumpTt3( char * pFileName, int fBinary );
-    char * FileName;
-    char ** pArgvNew;
-    int nArgcNew;
-    Gia_Man_t * pGia;
-    int fAscii = 0;
-    int fBinary = 0;
-    int c;
-
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "abh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'a':
-            fAscii ^= 1;
-            break;
-        case 'b':
-            fBinary ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( !Abc_NtkRecIsRunning3() )
-    {
-        Abc_Print( -1, "The AIG subgraph recording is not started.\n" );
-        return 1;
-    }
-
-    pArgvNew = argv + globalUtilOptind;
-    nArgcNew = argc - globalUtilOptind;
-    if ( nArgcNew != 1 )
-    {
-        Abc_Print( -1, "File name is not given on the command line.\n" );
-        return 1;
-    }
-    // get the input file name
-    FileName = pArgvNew[0];
-    if ( fAscii )
-        Abc_NtkRecDumpTt3( FileName, 0 );
-    else if ( fBinary )
-        Abc_NtkRecDumpTt3( FileName, 1 );
-    else
-    {
-        pGia = Abc_NtkRecGetGia3();
-        if( pGia == NULL )
-        {
-            Abc_Print( 0, "Library AIG is not available.\n" );
-            return 1;
-        }
-        if( Gia_ManPoNum(pGia) == 0 )
-        {
-            Abc_Print( 0, "No structure in the library.\n" );
-            return 1;
-        }
-        Gia_AigerWrite( pGia, FileName, 0, 0 );
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: rec_dump3 [-abh] <file>\n" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\t-a     : toggles dumping TTs into an ASCII file [default = %s]\n", fAscii? "yes": "no" );
-    Abc_Print( -2, "\t-b     : toggles dumping TTs into a binary file [default = %s]\n", fBinary? "yes": "no" );
-    Abc_Print( -2, "\t<file> : AIGER file to write the library\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandRecMerge3( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    int c;
-    char * FileName, * pTemp;
-    char ** pArgvNew;
-    int nArgcNew;
-    FILE * pFile;
-    Gia_Man_t * pGia = NULL;
-
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( !Abc_NtkRecIsRunning3() )
-    {
-        Abc_Print( -1, "This command works for AIGs only after calling \"rec_start3\".\n" );
-        return 0;
-    }
-    pArgvNew = argv + globalUtilOptind;
-    nArgcNew = argc - globalUtilOptind;
-    if ( nArgcNew != 1 )
-    {
-        Abc_Print( -1, "File name is not given on the command line.\n" );
-        return 1;
-    }
-    else
-    {
-        // get the input file name
-        FileName = pArgvNew[0];
-        // fix the wrong symbol
-        for ( pTemp = FileName; *pTemp; pTemp++ )
-            if ( *pTemp == '>' )
-                *pTemp = '\\';
-        if ( (pFile = fopen( FileName, "r" )) == NULL )
-        {
-            Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
-            if ( (FileName = Extra_FileGetSimilarName( FileName, ".aig", NULL, NULL, NULL, NULL )) )
-                Abc_Print( 1, "Did you mean \"%s\"?", FileName );
-            Abc_Print( 1, "\n" );
-            return 1;
-        }
-        fclose( pFile );
-        pGia = Gia_AigerRead( FileName, 1, 0 );
-        if ( pGia == NULL )
-        {
-            Abc_Print( -1, "Reading AIGER has failed.\n" );
-            return 0;
-        }
-    }
-    Abc_NtkRecLibMerge3(pGia);
-    Gia_ManStop( pGia );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: rec_merge3 [-h] <file>\n" );
-    Abc_Print( -2, "\t         merge libraries\n" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\t<file> : AIGER file with the library\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandMap( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    char Buffer[100];
-    double DelayTarget;
-    double AreaMulti;
-    double DelayMulti;
-    float LogFan = 0;
-    float Slew = 0; // choose based on the library
-    float Gain = 250;
-    int nGatesMin = 4;
-    int fAreaOnly;
-    int fRecovery;
-    int fSweep;
-    int fSwitching;
-    int fVerbose;
-    int c;
-    extern Abc_Ntk_t * Abc_NtkMap( Abc_Ntk_t * pNtk, double DelayTarget, double AreaMulti, double DelayMulti, float LogFan, float Slew, float Gain, int nGatesMin, int fRecovery, int fSwitching, int fVerbose );
-    extern int Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fExdc, int fVerbose, int fVeryVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    DelayTarget =-1;
-    AreaMulti   = 0;
-    DelayMulti  = 0;
-    fAreaOnly   = 0;
-    fRecovery   = 1;
-    fSweep      = 0;
-    fSwitching  = 0;
-    fVerbose    = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "DABFSGMarspvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
-                goto usage;
-            }
-            DelayTarget = (float)atof(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( DelayTarget <= 0.0 )
-                goto usage;
-            break;
-        case 'A':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-A\" should be followed by a floating point number.\n" );
-                goto usage;
-            }
-            AreaMulti = (float)atof(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            break;
-        case 'B':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-B\" should be followed by a floating point number.\n" );
-                goto usage;
-            }
-            DelayMulti = (float)atof(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by a floating point number.\n" );
-                goto usage;
-            }
-            LogFan = (float)atof(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( LogFan < 0.0 )
-                goto usage;
-            break;
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by a floating point number.\n" );
-                goto usage;
-            }
-            Slew = (float)atof(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( Slew <= 0.0 )
-                goto usage;
-            break;
-        case 'G':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-G\" should be followed by a floating point number.\n" );
-                goto usage;
-            }
-            Gain = (float)atof(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( Gain <= 0.0 )
-                goto usage;
-            break;
-        case 'M':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-M\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            nGatesMin = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nGatesMin < 0 ) 
-                goto usage;
-            break;
-        case 'a':
-            fAreaOnly ^= 1;
-            break;
-        case 'r':
-            fRecovery ^= 1;
-            break;
-        case 's':
-            fSweep ^= 1;
-            break;
-        case 'p':
-            fSwitching ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( fAreaOnly )
-        DelayTarget = ABC_INFINITY;
-
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        pNtk = Abc_NtkStrash( pNtk, 0, 0, 0 );
-        if ( pNtk == NULL )
-        {
-            Abc_Print( -1, "Strashing before mapping has failed.\n" );
-            return 1;
-        }
-        pNtk = Abc_NtkBalance( pNtkRes = pNtk, 0, 0, 1 );
-        Abc_NtkDelete( pNtkRes );
-        if ( pNtk == NULL )
-        {
-            Abc_Print( -1, "Balancing before mapping has failed.\n" );
-            return 1;
-        }
-        Abc_Print( 0, "The network was strashed and balanced before mapping.\n" );
-        // get the new network
-        pNtkRes = Abc_NtkMap( pNtk, DelayTarget, AreaMulti, DelayMulti, LogFan, Slew, Gain, nGatesMin, fRecovery, fSwitching, fVerbose );
-        if ( pNtkRes == NULL )
-        {
-            Abc_NtkDelete( pNtk );
-            Abc_Print( -1, "Mapping has failed.\n" );
-            return 1;
-        }
-        Abc_NtkDelete( pNtk );
-    }
-    else
-    {
-        // get the new network
-        pNtkRes = Abc_NtkMap( pNtk, DelayTarget, AreaMulti, DelayMulti, LogFan, Slew, Gain, nGatesMin, fRecovery, fSwitching, fVerbose );
-        if ( pNtkRes == NULL )
-        {
-            Abc_Print( -1, "Mapping has failed.\n" );
-            return 1;
-        }
-    }
-
-    if ( fSweep )
-    {
-        Abc_NtkFraigSweep( pNtkRes, 0, 0, 0, 0 );
-        if ( Abc_NtkHasMapping(pNtkRes) )
-        {
-            pNtkRes = Abc_NtkDupDfs( pNtk = pNtkRes );
-            Abc_NtkDelete( pNtk );
-        }
-    }
-
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    if ( DelayTarget == -1 )
-        sprintf(Buffer, "not used" );
-    else
-        sprintf(Buffer, "%.3f", DelayTarget );
-    Abc_Print( -2, "usage: map [-DABFSG float] [-M num] [-arspvh]\n" );
-    Abc_Print( -2, "\t           performs standard cell mapping of the current network\n" );
-    Abc_Print( -2, "\t-D float : sets the global required times [default = %s]\n", Buffer );
-    Abc_Print( -2, "\t-A float : \"area multiplier\" to bias gate selection [default = %.2f]\n", AreaMulti );
-    Abc_Print( -2, "\t-B float : \"delay multiplier\" to bias gate selection [default = %.2f]\n", DelayMulti );
-    Abc_Print( -2, "\t-F float : the logarithmic fanout delay parameter [default = %.2f]\n", LogFan );
-    Abc_Print( -2, "\t-S float : the slew parameter used to generate the library [default = %.2f]\n", Slew );
-    Abc_Print( -2, "\t-G float : the gain parameter used to generate the library [default = %.2f]\n", Gain );
-    Abc_Print( -2, "\t-M num   : skip gate classes whose size is less than this [default = %d]\n", nGatesMin );
-    Abc_Print( -2, "\t-a       : toggles area-only mapping [default = %s]\n", fAreaOnly? "yes": "no" );
-    Abc_Print( -2, "\t-r       : toggles area recovery [default = %s]\n", fRecovery? "yes": "no" );
-    Abc_Print( -2, "\t-s       : toggles sweep after mapping [default = %s]\n", fSweep? "yes": "no" );
-    Abc_Print( -2, "\t-p       : optimizes power by minimizing switching [default = %s]\n", fSwitching? "yes": "no" );
-    Abc_Print( -2, "\t-v       : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAmap( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Amap_Par_t Pars, * pPars = &Pars;
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int fSweep;
-    int c;
-    extern Abc_Ntk_t * Abc_NtkDarAmap( Abc_Ntk_t * pNtk, Amap_Par_t * pPars );
-    extern int Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fExdc, int fVerbose, int fVeryVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    fSweep = 0;
-    Amap_ManSetDefaultParams( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "FACEQmxisvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by a floating point number.\n" );
-                goto usage;
-            }
-            pPars->nIterFlow = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nIterFlow < 0 )
-                goto usage;
-            break;
-        case 'A':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-A\" should be followed by a floating point number.\n" );
-                goto usage;
-            }
-            pPars->nIterArea = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nIterArea < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by a floating point number.\n" );
-                goto usage;
-            }
-            pPars->nCutsMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nCutsMax < 0 )
-                goto usage;
-            break;
-        case 'E':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-E\" should be followed by a floating point number.\n" );
-                goto usage;
-            }
-            pPars->fEpsilon = (float)atof(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->fEpsilon < 0.0 || pPars->fEpsilon > 1.0 )
-                goto usage;
-            break;
-        case 'Q':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-Q\" should be followed by a floating point number.\n" );
-                goto usage;
-            }
-            pPars->fADratio = (float)atof(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->fADratio < 0.0 )
-                goto usage;
-            break;
-        case 'm':
-            pPars->fUseMuxes ^= 1;
-            break;
-        case 'x':
-            pPars->fUseXors ^= 1;
-            break;
-        case 'i':
-            pPars->fFreeInvs ^= 1;
-            break;
-        case 's':
-            fSweep ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        pNtk = Abc_NtkStrash( pNtk, 0, 0, 0 );
-        if ( pNtk == NULL )
-        {
-            Abc_Print( -1, "Strashing before mapping has failed.\n" );
-            return 1;
-        }
-        pNtk = Abc_NtkBalance( pNtkRes = pNtk, 0, 0, 1 );
-        Abc_NtkDelete( pNtkRes );
-        if ( pNtk == NULL )
-        {
-            Abc_Print( -1, "Balancing before mapping has failed.\n" );
-            return 1;
-        }
-        Abc_Print( 0, "The network was strashed and balanced before mapping.\n" );
-        // get the new network
-        pNtkRes = Abc_NtkDarAmap( pNtk, pPars );
-        if ( pNtkRes == NULL )
-        {
-            Abc_NtkDelete( pNtk );
-            Abc_Print( -1, "Mapping has failed.\n" );
-            return 1;
-        }
-        Abc_NtkDelete( pNtk );
-    }
-    else
-    {
-        // get the new network
-        pNtkRes = Abc_NtkDarAmap( pNtk, pPars );
-        if ( pNtkRes == NULL )
-        {
-            Abc_Print( -1, "Mapping has failed.\n" );
-            return 1;
-        }
-    }
-
-    if ( fSweep )
-    {
-        Abc_NtkFraigSweep( pNtkRes, 0, 0, 0, 0 );
-        if ( Abc_NtkHasMapping(pNtkRes) )
-        {
-            pNtkRes = Abc_NtkDupDfs( pNtk = pNtkRes );
-            Abc_NtkDelete( pNtk );
-        }
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: amap [-FAC <num>] [-EQ <float>] [-mxisvh]\n" );
-    Abc_Print( -2, "\t           performs standard cell mapping of the current network\n" );
-    Abc_Print( -2, "\t-F num   : the number of iterations of area flow [default = %d]\n", pPars->nIterFlow );
-    Abc_Print( -2, "\t-A num   : the number of iterations of exact area [default = %d]\n", pPars->nIterArea );
-    Abc_Print( -2, "\t-C num   : the maximum number of cuts at a node [default = %d]\n", pPars->nCutsMax );
-    Abc_Print( -2, "\t-E float : sets epsilon used for tie-breaking [default = %f]\n", pPars->fEpsilon );
-    Abc_Print( -2, "\t-Q float : area/delay preference ratio [default = %.2f (area-only)] \n", pPars->fADratio );
-    Abc_Print( -2, "\t-m       : toggles using MUX matching [default = %s]\n", pPars->fUseMuxes? "yes": "no" );
-    Abc_Print( -2, "\t-x       : toggles using XOR matching [default = %s]\n", pPars->fUseXors? "yes": "no" );
-    Abc_Print( -2, "\t-i       : toggles assuming inverters are free [default = %s]\n", pPars->fFreeInvs? "yes": "no" );
-    Abc_Print( -2, "\t-s       : toggles sweep after mapping [default = %s]\n", fSweep? "yes": "no" );
-    Abc_Print( -2, "\t-v       : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandUnmap( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkHasMapping(pNtk) )
-    {
-        Abc_Print( -1, "Cannot unmap the network that is not mapped.\n" );
-        return 1;
-    }
-
-    // get the new network
-    if ( !Abc_NtkMapToSop( pNtk ) )
-    {
-        Abc_Print( -1, "Unmapping has failed.\n" );
-        return 1;
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: unmap [-h]\n" );
-    Abc_Print( -2, "\t        replaces the library gates by the logic nodes represented using SOPs\n" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAttach( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsSopLogic(pNtk) )
-    {
-        Abc_Print( -1, "Can only attach gates if the nodes have SOP representations.\n" );
-        return 1;
-    }
-
-    // get the new network
-    if ( !Abc_NtkAttach( pNtk ) )
-    {
-        Abc_Print( -1, "Attaching gates has failed.\n" );
-        return 1;
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: attach [-h]\n" );
-    Abc_Print( -2, "\t        replaces the SOP functions by the gates from the library\n" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandSuperChoice( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c;
-    extern Abc_Ntk_t * Abc_NtkSuperChoice( Abc_Ntk_t * pNtk );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Superchoicing works only for the AIG representation (run \"strash\").\n" );
-        return 1;
-    }
-
-    // get the new network
-    pNtkRes = Abc_NtkSuperChoice( pNtk );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Superchoicing has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: superc [-h]\n" );
-    Abc_Print( -2, "\t      performs superchoicing\n" );
-    Abc_Print( -2, "\t      (accumulate: \"r file.blif; rsup; b; sc; f -ac; wb file_sc.blif\")\n" );
-    Abc_Print( -2, "\t      (map without supergate library: \"r file_sc.blif; ft; map\")\n" );
-    Abc_Print( -2, "\t-h  : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandSuperChoiceLut( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c;
-    int nLutSize;
-    int nCutSizeMax;
-    int fVerbose;
-    extern int Abc_NtkSuperChoiceLut( Abc_Ntk_t * pNtk, int nLutSize, int nCutSizeMax, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    fVerbose = 1;
-    nLutSize = 4;
-    nCutSizeMax = 10;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "KNh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            nLutSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nLutSize < 0 )
-                goto usage;
-            break;
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            nCutSizeMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nCutSizeMax < 0 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Superchoicing works only for the AIG representation (run \"strash\").\n" );
-        return 1;
-    }
-
-    // convert the network into the SOP network
-    pNtkRes = Abc_NtkToLogic( pNtk );
-
-    // get the new network
-    if ( !Abc_NtkSuperChoiceLut( pNtkRes, nLutSize, nCutSizeMax, fVerbose ) )
-    {
-        Abc_NtkDelete( pNtkRes );
-        Abc_Print( -1, "Superchoicing has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: supercl [-K num] [-N num] [-vh]\n" );
-    Abc_Print( -2, "\t        performs superchoicing for K-LUTs\n" );
-    Abc_Print( -2, "\t        (accumulate: \"r file.blif; b; scl; f -ac; wb file_sc.blif\")\n" );
-    Abc_Print( -2, "\t        (FPGA map: \"r file_sc.blif; ft; read_lut lutlibK; fpga\")\n" );
-    Abc_Print( -2, "\t-K num : the number of LUT inputs [default = %d]\n", nLutSize );
-    Abc_Print( -2, "\t-N num : the max size of the cut [default = %d]\n", nCutSizeMax );
-    Abc_Print( -2, "\t-v     : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-#if 0 
-int Abc_CommandFpga( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    char Buffer[100];
-    char LutSize[100];
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c;
-    int fRecovery;
-    int fSwitching;
-    int fLatchPaths;
-    int fVerbose;
-    int nLutSize;
-    float DelayTarget;
-
-    extern Abc_Ntk_t * Abc_NtkFpga( Abc_Ntk_t * pNtk, float DelayTarget, int fRecovery, int fSwitching, int fLatchPaths, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    fRecovery   = 1;
-    fSwitching  = 0;
-    fLatchPaths = 0;
-    fVerbose    = 0;
-    DelayTarget =-1;
-    nLutSize    =-1;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "aplvhDK" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'a':
-            fRecovery ^= 1;
-            break;
-        case 'p':
-            fSwitching ^= 1;
-            break;
-        case 'l':
-            fLatchPaths ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
-                goto usage;
-            }
-            DelayTarget = (float)atof(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( DelayTarget <= 0.0 )
-                goto usage;
-            break;
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            nLutSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nLutSize < 0 )
-                goto usage;
-            break;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    // create the new LUT library
-    if ( nLutSize >= 3 && nLutSize <= 10 )
-        Fpga_SetSimpleLutLib( nLutSize );
-/*
-    else
-    {
-        Abc_Print( -1, "Cannot perform FPGA mapping with LUT size %d.\n", nLutSize );
-        return 1;
-    }
-*/
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        // strash and balance the network
-        pNtk = Abc_NtkStrash( pNtk, 0, 0, 0 );
-        if ( pNtk == NULL )
-        {
-            Abc_Print( -1, "Strashing before FPGA mapping has failed.\n" );
-            return 1;
-        }
-        pNtk = Abc_NtkBalance( pNtkRes = pNtk, 0, 0, 1 );
-        Abc_NtkDelete( pNtkRes );
-        if ( pNtk == NULL )
-        {
-            Abc_Print( -1, "Balancing before FPGA mapping has failed.\n" );
-            return 1;
-        }
-        Abc_Print( 1, "The network was strashed and balanced before FPGA mapping.\n" );
-        // get the new network
-        pNtkRes = Abc_NtkFpga( pNtk, DelayTarget, fRecovery, fSwitching, fLatchPaths, fVerbose );
-        if ( pNtkRes == NULL )
-        {
-            Abc_NtkDelete( pNtk );
-            Abc_Print( -1, "FPGA mapping has failed.\n" );
-            return 1;
-        }
-        Abc_NtkDelete( pNtk );
-    }
-    else
-    {
-        // get the new network
-        pNtkRes = Abc_NtkFpga( pNtk, DelayTarget, fRecovery, fSwitching, fLatchPaths, fVerbose );
-        if ( pNtkRes == NULL )
-        {
-            Abc_Print( -1, "FPGA mapping has failed.\n" );
-            return 1;
-        }
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    if ( DelayTarget == -1 )
-        sprintf(Buffer, "best possible" );
-    else
-        sprintf(Buffer, "%.2f", DelayTarget );
-    if ( nLutSize == -1 )
-        sprintf(LutSize, "library" );
-    else
-        sprintf(LutSize, "%d", nLutSize );
-    Abc_Print( -2, "usage: fpga [-D float] [-K num] [-aplvh]\n" );
-    Abc_Print( -2, "\t           performs FPGA mapping of the current network\n" );
-    Abc_Print( -2, "\t-a       : toggles area recovery [default = %s]\n", fRecovery? "yes": "no" );
-    Abc_Print( -2, "\t-p       : optimizes power by minimizing switching activity [default = %s]\n", fSwitching? "yes": "no" );
-    Abc_Print( -2, "\t-l       : optimizes latch paths for delay, other paths for area [default = %s]\n", fLatchPaths? "yes": "no" );
-    Abc_Print( -2, "\t-D float : sets the required time for the mapping [default = %s]\n", Buffer );
-    Abc_Print( -2, "\t-K num   : the number of LUT inputs (2 < num < 11) [default = %s]%s\n", LutSize, (nLutSize == -1 ? " (type \"print_lut\")" : "") );
-    Abc_Print( -2, "\t-v       : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : prints the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandFpgaFast( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    char Buffer[100];
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c;
-    int fRecovery;
-    int fVerbose;
-    int nLutSize;
-    float DelayTarget;
-
-    extern Abc_Ntk_t * Abc_NtkFpgaFast( Abc_Ntk_t * pNtk, int nLutSize, int fRecovery, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    fRecovery   = 1;
-    fVerbose    = 0;
-    DelayTarget =-1;
-    nLutSize    = 5;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "avhDK" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'a':
-            fRecovery ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
-                goto usage;
-            }
-            DelayTarget = (float)atof(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( DelayTarget <= 0.0 )
-                goto usage;
-            break;
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            nLutSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nLutSize < 0 )
-                goto usage;
-            break;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        // strash and balance the network
-        pNtk = Abc_NtkStrash( pNtk, 0, 0, 0 );
-        if ( pNtk == NULL )
-        {
-            Abc_Print( -1, "Strashing before FPGA mapping has failed.\n" );
-            return 1;
-        }
-        pNtk = Abc_NtkBalance( pNtkRes = pNtk, 0, 0, 1 );
-        Abc_NtkDelete( pNtkRes );
-        if ( pNtk == NULL )
-        {
-            Abc_Print( -1, "Balancing before FPGA mapping has failed.\n" );
-            return 1;
-        }
-        Abc_Print( 1, "The network was strashed and balanced before FPGA mapping.\n" );
-        // get the new network
-        pNtkRes = Abc_NtkFpgaFast( pNtk, nLutSize, fRecovery, fVerbose );
-        if ( pNtkRes == NULL )
-        {
-            Abc_NtkDelete( pNtk );
-            Abc_Print( -1, "FPGA mapping has failed.\n" );
-            return 1;
-        }
-        Abc_NtkDelete( pNtk );
-    }
-    else
-    {
-        // get the new network
-        pNtkRes = Abc_NtkFpgaFast( pNtk, nLutSize, fRecovery, fVerbose );
-        if ( pNtkRes == NULL )
-        {
-            Abc_Print( -1, "FPGA mapping has failed.\n" );
-            return 1;
-        }
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    if ( DelayTarget == -1 )
-        sprintf(Buffer, "not used" );
-    else
-        sprintf(Buffer, "%.2f", DelayTarget );
-    Abc_Print( -2, "usage: ffpga [-K num] [-avh]\n" );
-    Abc_Print( -2, "\t           performs fast FPGA mapping of the current network\n" );
-    Abc_Print( -2, "\t-a       : toggles area recovery [default = %s]\n", fRecovery? "yes": "no" );
-//    Abc_Print( -2, "\t-D float : sets the required time for the mapping [default = %s]\n", Buffer );
-    Abc_Print( -2, "\t-K num   : the number of LUT inputs (2 < num < 32) [default = %d]\n", nLutSize );
-    Abc_Print( -2, "\t-v       : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : prints the command usage\n");
-    return 1;
-}
-#endif
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Abc_Ntk_t * Abc_NtkIf( Abc_Ntk_t * pNtk, If_Par_t * pPars );
-    char Buffer[100], LutSize[100];
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    If_Par_t Pars, * pPars = &Pars;
-    int c;
-    pNtk = Abc_FrameReadNtk(pAbc);
-    If_ManSetDefaultPars( pPars );
-    pPars->pLutLib = (If_LibLut_t *)Abc_FrameReadLibLut();
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "KCFAGNDEWSTqaflepmrsdbgxyojiktncvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nLutSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nLutSize < 0 )
-                goto usage;
-            // if the LUT size is specified, disable library
-            pPars->pLutLib = NULL;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nCutsMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nCutsMax < 0 )
-                goto usage;
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nFlowIters = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nFlowIters < 0 )
-                goto usage;
-            break;
-        case 'A':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-A\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nAreaIters = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nAreaIters < 0 )
-                goto usage;
-            break;
-        case 'G':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-G\" should be followed by a positive integer no less than 3.\n" );
-                goto usage;
-            }
-            pPars->nGateSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nGateSize < 2 )
-                goto usage;
-            break;
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by a positive integer no less than 3.\n" );
-                goto usage;
-            }
-            pPars->nNonDecLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nNonDecLimit < 2 )
-                goto usage;
-            break;
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
-                goto usage;
-            }
-            pPars->DelayTarget = (float)atof(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->DelayTarget <= 0.0 )
-                goto usage;
-            break;
-        case 'E':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-E\" should be followed by a floating point number.\n" );
-                goto usage;
-            }
-            pPars->Epsilon = (float)atof(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->Epsilon < 0.0 || pPars->Epsilon > 1.0 )
-                goto usage;
-            break;
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by a floating point number.\n" );
-                goto usage;
-            }
-            pPars->WireDelay = (float)atof(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->WireDelay < 0.0 )
-                goto usage;
-            break;
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by string.\n" );
-                goto usage;
-            }
-            pPars->pLutStruct = argv[globalUtilOptind];
-            globalUtilOptind++;
-            if ( strlen(pPars->pLutStruct) != 2 && strlen(pPars->pLutStruct) != 3 )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by a 2- or 3-char string (e.g. \"44\" or \"555\").\n" );
-                goto usage;
-            }
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by a positive integer 0,1,or 2.\n" );
-                goto usage;
-            }
-            pPars->nStructType = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nStructType < 0 || pPars->nStructType > 2 )
-                goto usage;
-            break;
-        case 'q':
-            pPars->fPreprocess ^= 1;
-            break;
-        case 'a':
-            pPars->fArea ^= 1;
-            break;
-        case 'r':
-            pPars->fExpRed ^= 1;
-            break;
-        case 'f':
-            pPars->fFancy ^= 1;
-            break;
-        case 'l':
-            pPars->fLatchPaths ^= 1;
-            break;
-        case 'e':
-            pPars->fEdge ^= 1;
-            break;
-        case 'p':
-            pPars->fPower ^= 1;
-            break;
-        case 'm':
-            pPars->fCutMin ^= 1;
-            break;
-        case 's':
-            pPars->fDelayOptLut ^= 1;
-            break;
-        case 'd':
-            pPars->fBidec ^= 1;
-            break;
-        case 'b':
-            pPars->fUseBat ^= 1;
-            break;
-        case 'g':
-            pPars->fDelayOpt ^= 1;
-            break;
-        case 'x':
-            pPars->fDsdBalance ^= 1;
-            break;
-        case 'y':
-            pPars->fUserRecLib ^= 1;
-            break;
-        case 'o':
-            pPars->fUseBuffs ^= 1;
-            break;
-        case 'j':
-            pPars->fEnableCheck07 ^= 1;
-            break;
-        case 'i':
-            pPars->fEnableCheck08 ^= 1;
-            break;
-        case 'k':
-            pPars->fEnableCheck10 ^= 1;
-            break;
-        case 't':
-            pPars->fDoAverage ^= 1;
-            break;
-        case 'n':
-            pPars->fUseDsd ^= 1;
-            break;
-        case 'c':
-            pPars->fUseTtPerm ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'h':
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( pPars->nLutSize == -1 )
-    {
-        if ( pPars->pLutLib == NULL )
-        {
-            Abc_Print( -1, "The LUT library is not given.\n" );
-            return 1;
-        }
-        pPars->nLutSize = pPars->pLutLib->LutMax;
-    }
-
-    if ( pPars->nLutSize < 2 || pPars->nLutSize > IF_MAX_LUTSIZE )
-    {
-        Abc_Print( -1, "Incorrect LUT size (%d).\n", pPars->nLutSize );
-        return 1;
-    }
-
-    if ( pPars->nCutsMax < 1 || pPars->nCutsMax >= (1<<12) )
-    {
-        Abc_Print( -1, "Incorrect number of cuts.\n" );
-        return 1;
-    }
-
-    // enable truth table computation if choices are selected
-    if ( (c = Abc_NtkGetChoiceNum( pNtk )) )
-    {
-//        if ( !Abc_FrameReadFlag("silentmode") )
-//            Abc_Print( 0, "Performing LUT mapping with %d choices.\n", c );
-        pPars->fExpRed = 0;
-    }
-
-    if ( pPars->fUseBat )
-    {
-        if ( pPars->nLutSize < 4 || pPars->nLutSize > 6 )
-        {
-            Abc_Print( -1, "This feature only works for {4,5,6}-LUTs.\n" );
-            return 1;
-        }
-        pPars->fCutMin = 1;
-    }
-
-    if ( pPars->fEnableCheck07 + pPars->fEnableCheck08 + pPars->fEnableCheck10 + (pPars->pLutStruct != NULL) > 1 )
-    {
-        Abc_Print( -1, "Only one additional check can be performed at the same time.\n" );
-        return 1;
-    }
-    if ( pPars->fEnableCheck07 )
-    {
-        if ( pPars->nLutSize < 6 || pPars->nLutSize > 7 )
-        {
-            Abc_Print( -1, "This feature only works for {6,7}-LUTs.\n" );
-            return 1;
-        }
-        pPars->pFuncCell = If_CutPerformCheck07;
-        pPars->fCutMin = 1;
-    }
-    if ( pPars->fEnableCheck08 )
-    {
-        if ( pPars->nLutSize < 6 || pPars->nLutSize > 8 )
-        {
-            Abc_Print( -1, "This feature only works for {6,7,8}-LUTs.\n" );
-            return 1;
-        }
-        pPars->pFuncCell = If_CutPerformCheck08;
-        pPars->fCutMin = 1;
-    }
-    if ( pPars->fEnableCheck10 )
-    {
-        if ( pPars->nLutSize < 6 || pPars->nLutSize > 10 )
-        {
-            Abc_Print( -1, "This feature only works for {6,7,8,9,10}-LUTs.\n" );
-            return 1;
-        }
-        pPars->pFuncCell = If_CutPerformCheck10;
-        pPars->fCutMin = 1;
-    }
-    if ( pPars->pLutStruct )
-    {
-        if ( pPars->fDsdBalance )
-        {
-            Abc_Print( -1, "Incompatible options (-S and -x).\n" );
-            return 1;
-        }
-        if ( pPars->nLutSize < 6 || pPars->nLutSize > 16 )
-        {
-            Abc_Print( -1, "This feature only works for [6;16]-LUTs.\n" );
-            return 1;
-        }
-        pPars->pFuncCell = pPars->fDelayOptLut ? NULL : If_CutPerformCheck16;
-        pPars->fCutMin = 1;
-    }
-
-    // enable truth table computation if cut minimization is selected
-    if ( pPars->fCutMin )
-    {
-        pPars->fTruth = 1;
-        pPars->fExpRed = 0;
-    }
-    // modify the subgraph recording
-    if ( pPars->fUserRecLib )
-    {
-        pPars->fTruth      =  1;
-        pPars->fCutMin     =  1;
-        pPars->fExpRed     =  0;
-        pPars->fUsePerm    =  1;
-        pPars->pLutLib     =  NULL;
-    }
-    // modify for delay optimization
-    if ( pPars->fDelayOpt || pPars->fDsdBalance || pPars->fDelayOptLut )
-    {
-        pPars->fTruth      =  1;
-        pPars->fCutMin     =  1;
-        pPars->fExpRed     =  0;
-        pPars->fUseDsd     =  pPars->fDsdBalance || pPars->fDelayOptLut;
-        pPars->pLutLib     =  NULL;
-    }
-    // modify for delay optimization
-    if ( pPars->nGateSize > 0 )
-    {
-        pPars->fTruth      =  1;
-        pPars->fCutMin     =  1;
-        pPars->fExpRed     =  0;
-        pPars->fUsePerm    =  1;
-        pPars->pLutLib     =  NULL;
-        pPars->nLutSize    =  pPars->nGateSize;
-    }
-
-    if ( pPars->fUseDsd || pPars->fUseTtPerm )
-    {
-        pPars->fTruth      =  1;
-        pPars->fCutMin     =  1;
-        pPars->fExpRed     =  0;
-    }
-
-    if ( pPars->fUseDsd )
-    {
-        int LutSize = (pPars->pLutStruct && pPars->pLutStruct[2] == 0)? pPars->pLutStruct[0] - '0' : 0;
-        If_DsdMan_t * p = (If_DsdMan_t *)Abc_FrameReadManDsd();
-        if ( pPars->pLutStruct && pPars->pLutStruct[2] != 0 )
-        {
-            printf( "DSD only works for LUT structures XY.\n" );
-            return 0;
-        }
-        if ( p && pPars->nLutSize > If_DsdManVarNum(p) )
-        {
-            printf( "DSD manager has incompatible number of variables.\n" );
-            return 0;
-        }
-        if ( p && LutSize != If_DsdManLutSize(p) && !pPars->fDsdBalance )
-        {
-            printf( "DSD manager has different LUT size.\n" );
-            return 0;
-        }
-        if ( p == NULL )
-            Abc_FrameSetManDsd( If_DsdManAlloc(pPars->nLutSize, LutSize) );
-    }
-
-    if ( pPars->fUserRecLib )
-    {
-        if ( !Abc_NtkRecIsRunning3() )
-        {
-            printf( "LMS manager is not running (use \"rec_start3\").\n" );
-            return 0;
-        }
-        if ( Abc_NtkRecInputNum3() != pPars->nLutSize )
-        {
-            printf( "The number of library inputs (%d) different from the K parameters (%d).\n", Abc_NtkRecInputNum3(), pPars->nLutSize );
-            return 0;
-        }
-    }
- 
-    // complain if truth tables are requested but the cut size is too large
-    if ( pPars->fTruth && pPars->nLutSize > IF_MAX_FUNC_LUTSIZE )
-    {
-        Abc_Print( -1, "Truth tables cannot be computed for LUT larger than %d inputs.\n", IF_MAX_FUNC_LUTSIZE );
-        return 1;
-    }
-
-    // disable cut-expansion if edge-based heuristics are selected
-//    if ( pPars->fEdge )
-//        pPars->fExpRed = 0;
-
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        // strash and balance the network
-        pNtk = Abc_NtkStrash( pNtk, 0, 0, 0 );
-        if ( pNtk == NULL )
-        {
-            Abc_Print( -1, "Strashing before FPGA mapping has failed.\n" );
-            return 1;
-        }
-        pNtk = Abc_NtkBalance( pNtkRes = pNtk, 0, 0, 1 );
-        Abc_NtkDelete( pNtkRes );
-        if ( pNtk == NULL )
-        {
-            Abc_Print( -1, "Balancing before FPGA mapping has failed.\n" );
-            return 1;
-        }
-        if ( !Abc_FrameReadFlag("silentmode") )
-            Abc_Print( 1, "The network was strashed and balanced before FPGA mapping.\n" );
-        // get the new network
-        pNtkRes = Abc_NtkIf( pNtk, pPars );
-        if ( pNtkRes == NULL )
-        {
-            Abc_NtkDelete( pNtk );
-            Abc_Print( -1, "FPGA mapping has failed.\n" );
-            return 0;
-        }
-        Abc_NtkDelete( pNtk );
-    }
-    else
-    {
-        // get the new network
-        pNtkRes = Abc_NtkIf( pNtk, pPars );
-        if ( pNtkRes == NULL )
-        {
-            Abc_Print( -1, "FPGA mapping has failed.\n" );
-            return 0;
-        }
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    if ( pPars->DelayTarget == -1 )
-        sprintf(Buffer, "best possible" );
-    else
-        sprintf(Buffer, "%.2f", pPars->DelayTarget );
-    if ( pPars->nLutSize == -1 )
-        sprintf(LutSize, "library" );
-    else
-        sprintf(LutSize, "%d", pPars->nLutSize );
-    Abc_Print( -2, "usage: if [-KCFANGT num] [-DEW float] [-S str] [-qarlepmsdbgxyojiktncvh]\n" );
-    Abc_Print( -2, "\t           performs FPGA technology mapping of the network\n" );
-    Abc_Print( -2, "\t-K num   : the number of LUT inputs (2 < num < %d) [default = %s]\n", IF_MAX_LUTSIZE+1, LutSize );
-    Abc_Print( -2, "\t-C num   : the max number of priority cuts (0 < num < 2^12) [default = %d]\n", pPars->nCutsMax );
-    Abc_Print( -2, "\t-F num   : the number of area flow recovery iterations (num >= 0) [default = %d]\n", pPars->nFlowIters );
-    Abc_Print( -2, "\t-A num   : the number of exact area recovery iterations (num >= 0) [default = %d]\n", pPars->nAreaIters );
-    Abc_Print( -2, "\t-N num   : the max size of non-decomposable nodes [default = unused]\n", pPars->nNonDecLimit );
-    Abc_Print( -2, "\t-G num   : the max AND/OR gate size for mapping (0 = unused) [default = %d]\n", pPars->nGateSize );
-    Abc_Print( -2, "\t-D float : sets the delay constraint for the mapping [default = %s]\n", Buffer );
-    Abc_Print( -2, "\t-E float : sets epsilon used for tie-breaking [default = %f]\n", pPars->Epsilon );
-    Abc_Print( -2, "\t-W float : sets wire delay between adjects LUTs [default = %f]\n", pPars->WireDelay );
-    Abc_Print( -2, "\t-S str   : string representing the LUT structure [default = %s]\n", pPars->pLutStruct ? pPars->pLutStruct : "not used" );
-    Abc_Print( -2, "\t-T num   : the type of LUT structures [default = any]\n", pPars->nStructType );
-    Abc_Print( -2, "\t-q       : toggles preprocessing using several starting points [default = %s]\n", pPars->fPreprocess? "yes": "no" );
-    Abc_Print( -2, "\t-a       : toggles area-oriented mapping [default = %s]\n", pPars->fArea? "yes": "no" );
-    Abc_Print( -2, "\t-r       : enables expansion/reduction of the best cuts [default = %s]\n", pPars->fExpRed? "yes": "no" );
-    Abc_Print( -2, "\t-l       : optimizes latch paths for delay, other paths for area [default = %s]\n", pPars->fLatchPaths? "yes": "no" );
-    Abc_Print( -2, "\t-e       : uses edge-based cut selection heuristics [default = %s]\n", pPars->fEdge? "yes": "no" );
-    Abc_Print( -2, "\t-p       : uses power-aware cut selection heuristics [default = %s]\n", pPars->fPower? "yes": "no" );
-    Abc_Print( -2, "\t-m       : enables cut minimization by removing vacuous variables [default = %s]\n", pPars->fCutMin? "yes": "no" );
-    Abc_Print( -2, "\t-s       : toggles delay-oriented mapping used with -S <NN> [default = %s]\n", pPars->fDelayOptLut? "yes": "no" );
-    Abc_Print( -2, "\t-d       : toggles deriving local AIGs using bi-decomposition [default = %s]\n", pPars->fBidec? "yes": "no" );
-    Abc_Print( -2, "\t-b       : toggles the use of one special feature [default = %s]\n", pPars->fUseBat? "yes": "no" );
-    Abc_Print( -2, "\t-g       : toggles delay optimization by SOP balancing [default = %s]\n", pPars->fDelayOpt? "yes": "no" );
-    Abc_Print( -2, "\t-x       : toggles delay optimization by DSD balancing [default = %s]\n", pPars->fDsdBalance? "yes": "no" );
-    Abc_Print( -2, "\t-y       : toggles delay optimization with recorded library [default = %s]\n", pPars->fUserRecLib? "yes": "no" );
-    Abc_Print( -2, "\t-o       : toggles using buffers to decouple combinational outputs [default = %s]\n", pPars->fUseBuffs? "yes": "no" );
-    Abc_Print( -2, "\t-j       : toggles enabling additional check [default = %s]\n", pPars->fEnableCheck07? "yes": "no" );
-    Abc_Print( -2, "\t-i       : toggles enabling additional check [default = %s]\n", pPars->fEnableCheck08? "yes": "no" );
-    Abc_Print( -2, "\t-k       : toggles enabling additional check [default = %s]\n", pPars->fEnableCheck10? "yes": "no" );
-    Abc_Print( -2, "\t-t       : toggles optimizing average rather than maximum level [default = %s]\n", pPars->fDoAverage? "yes": "no" );
-    Abc_Print( -2, "\t-n       : toggles computing DSDs of the cut functions [default = %s]\n", pPars->fUseDsd? "yes": "no" );
-    Abc_Print( -2, "\t-c       : toggles computing truth tables in a new way [default = %s]\n", pPars->fUseTtPerm? "yes": "no" );
-    Abc_Print( -2, "\t-v       : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : prints the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandIfif( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern void Abc_NtkPerformIfif( Abc_Ntk_t * pNtk, Ifif_Par_t * pPars );
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    Ifif_Par_t Pars, * pPars = &Pars;
-    int c, fError;
-
-    pPars->nLutSize     =  -1;    // the LUT size
-    pPars->pLutLib      = (If_LibLut_t *)Abc_FrameReadLibLut();       // the LUT library
-    pPars->DelayWire    = (float)0.5;    // wire delay
-    pPars->nDegree      =   0;    // structure degree
-    pPars->fCascade     =   0;    // cascade
-    pPars->fVerbose     =   0;    // verbose
-    pPars->fVeryVerbose =   0;    // verbose
-
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "DNcvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
-                goto usage;
-            }
-            pPars->DelayWire = atof(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->DelayWire < 0.0 )
-                goto usage;
-            break;
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by a floating point number.\n" );
-                goto usage;
-            }
-            pPars->nDegree = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nDegree < 0 )
-                goto usage;
-            break;
-        case 'c':
-            pPars->fCascade ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'w':
-            pPars->fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsLogic(pNtk) )
-    {
-        Abc_Print( -1, "Need mapped network.\n" );
-        return 1;
-    }
-    if ( pPars->pLutLib == NULL )
-    {
-        Abc_Print( -1, "LUT library is not given.\n" );
-        return 1;
-    }
-
-    pPars->nLutSize = Abc_NtkGetFaninMax( pNtk );
-    if ( pPars->nLutSize > pPars->pLutLib->LutMax )
-    {
-        Abc_Print( -1, "The max node size (%d) exceeds the LUT size (%d).\n", pPars->nLutSize, pPars->pLutLib->LutMax );
-        return 1;
-    }
-    if ( pPars->nLutSize < pPars->pLutLib->LutMax )
-        Abc_Print( 0, "Node size (%d) is less than LUT size (%d).\n", pPars->nLutSize, pPars->pLutLib->LutMax );
-    // check delay information
-    fError = 0;
-    for ( c = 0; c < pPars->pLutLib->LutMax; c++ )
-    {
-        pPars->pLutDelays[c] = ( pPars->pLutLib->fVarPinDelays ? pPars->pLutLib->pLutDelays[pPars->pLutLib->LutMax][c] : pPars->pLutLib->pLutDelays[pPars->pLutLib->LutMax][0] );
-        if ( pPars->DelayWire >= pPars->pLutDelays[c] )
-        {
-            fError = 1;
-            printf(" Wire delay (%.2f) exceeds pin+wire delay (%.2f) for pin %d in the LUT library.\n", pPars->DelayWire, pPars->pLutDelays[c], c );
-        }
-    }
-    if ( fError )
-        return 1;
-
-    // call the mapper
-    Abc_NtkPerformIfif( pNtk, pPars );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: ifif [-DNcvwh]\n" );
-    Abc_Print( -2, "\t           technology mapper into N-node K-LUT structures\n" );
-    Abc_Print( -2, "\t           (takes a LUT network and maps it into a delay-optimal network\n" );
-    Abc_Print( -2, "\t            of N-node K-LUT structures using the current LUT library)\n" );
-    Abc_Print( -2, "\t-D float : wire delay (should be less than the LUT delay) [default = %.2f]\n", pPars->DelayWire );
-    Abc_Print( -2, "\t-N num   : degree of the LUT structure [default = %d]\n", pPars->nDegree );
-    Abc_Print( -2, "\t-c       : toggles using LUT cascade vs LUT cluster [default = %s]\n", pPars->fCascade? "cascade": "cluster" );
-    Abc_Print( -2, "\t-v       : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w       : toggles very verbose output [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandDsdSave( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    char * FileName;
-    char ** pArgvNew;
-    int nArgcNew;
-    int c, fSecond = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "bh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'b':
-            fSecond ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    pArgvNew = argv + globalUtilOptind;
-    nArgcNew = argc - globalUtilOptind;
-    if ( nArgcNew != 1 )
-    {
-        Abc_Print( -1, "File name is not given on the command line.\n" );
-        return 1;
-    }
-    // get the input file name
-    FileName = (nArgcNew == 1) ? pArgvNew[0] : NULL;
-	if ( fSecond )
-	{
-		if ( !Abc_FrameReadManDsd2() )
-		{
-			Abc_Print( -1, "The DSD manager is not started.\n" );
-			return 1;
-		}
-		If_DsdManSave( (If_DsdMan_t *)Abc_FrameReadManDsd2(), FileName );
-	}
-	else
-	{
-		if ( !Abc_FrameReadManDsd() )
-		{
-			Abc_Print( -1, "The DSD manager is not started.\n" );
-			return 1;
-		}
-		If_DsdManSave( (If_DsdMan_t *)Abc_FrameReadManDsd(), FileName );
-	}
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: dsd_save [-bh] <file>\n" );
-    Abc_Print( -2, "\t         saves DSD manager into a file\n");
-    Abc_Print( -2, "\t-b     : toggles processing second manager [default = %s]\n", fSecond? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\t<file> : (optional) file name to write\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandDsdLoad( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    char * FileName, * pTemp;
-    char ** pArgvNew;
-    int c, nArgcNew, fSecond = 0;
-    FILE * pFile;
-    If_DsdMan_t * pDsdMan;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "bh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'b':
-            fSecond ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    pArgvNew = argv + globalUtilOptind;
-    nArgcNew = argc - globalUtilOptind;
-    if ( nArgcNew != 1 )
-    {
-        Abc_Print( -1, "File name is not given on the command line.\n" );
-        return 1;
-    }
-    // get the input file name
-    FileName = pArgvNew[0];
-    // fix the wrong symbol
-    for ( pTemp = FileName; *pTemp; pTemp++ )
-        if ( *pTemp == '>' )
-            *pTemp = '\\';
-    if ( (pFile = fopen( FileName, "r" )) == NULL )
-    {
-        Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
-        if ( (FileName = Extra_FileGetSimilarName( FileName, ".aig", NULL, NULL, NULL, NULL )) )
-            Abc_Print( 1, "Did you mean \"%s\"?", FileName );
-        Abc_Print( 1, "\n" );
-        return 1;
-    }
-    fclose( pFile );
-	if ( fSecond )
-	{
-		Abc_FrameSetManDsd2( NULL );
-		pDsdMan = If_DsdManLoad(FileName);
-		if ( pDsdMan == NULL )
-			return 1;
-		Abc_FrameSetManDsd2( pDsdMan );
-	}
-	else
-	{
-		Abc_FrameSetManDsd( NULL );
-		pDsdMan = If_DsdManLoad(FileName);
-		if ( pDsdMan == NULL )
-			return 1;
-		Abc_FrameSetManDsd( pDsdMan );
-	}
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: dsd_load [-bh] <file>\n" );
-    Abc_Print( -2, "\t         loads DSD manager from file\n");
-    Abc_Print( -2, "\t-b     : toggles processing second manager [default = %s]\n", fSecond? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\t<file> : file name to read\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandDsdFree( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    int c, fSecond = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "bh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'b':
-            fSecond ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-	if ( fSecond )
-	{
-		if ( !Abc_FrameReadManDsd2() )
-		{
-			Abc_Print( 1, "The DSD manager is not started.\n" );
-			return 0;
-		}
-		Abc_FrameSetManDsd2( NULL );
-	}
-	else
-	{
-		if ( !Abc_FrameReadManDsd() )
-		{
-			Abc_Print( 1, "The DSD manager is not started.\n" );
-			return 0;
-		}
-		Abc_FrameSetManDsd( NULL );
-	}
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: dsd_free [-bh]\n" );
-    Abc_Print( -2, "\t         deletes DSD manager\n" );
-    Abc_Print( -2, "\t-b     : toggles processing second manager [default = %s]\n", fSecond? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandDsdPs( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    int c, Number = 0, Support = 0, fOccurs = 0, fTtDump = 0, fSecond = 0, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "NSotbvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by a floating point number.\n" );
-                goto usage;
-            }
-            Number = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( Number < 0 )
-                goto usage;
-            break;
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by a floating point number.\n" );
-                goto usage;
-            }
-            Support = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( Support < 0 )
-                goto usage;
-            break;
-        case 'o':
-            fOccurs ^= 1;
-            break;
-        case 't':
-            fTtDump ^= 1;
-            break;
-        case 'b':
-            fSecond ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-	if ( fSecond )
-	{
-		if ( !Abc_FrameReadManDsd2() )
-		{
-			Abc_Print( 1, "The DSD manager is not started.\n" );
-			return 0;
-		}
-		If_DsdManPrint( (If_DsdMan_t *)Abc_FrameReadManDsd2(), NULL, Number, Support, fOccurs, fTtDump, fVerbose );
-	}
-	else
-	{
-		if ( !Abc_FrameReadManDsd() )
-		{
-			Abc_Print( 1, "The DSD manager is not started.\n" );
-			return 0;
-		}
-		If_DsdManPrint( (If_DsdMan_t *)Abc_FrameReadManDsd(), NULL, Number, Support, fOccurs, fTtDump, fVerbose );
-	}
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: dsd_ps [-NS num] [-obvh]\n" );
-    Abc_Print( -2, "\t         prints statistics of DSD manager\n" );
-    Abc_Print( -2, "\t-N num : show structures whose ID divides by N [default = %d]\n",   Number );
-    Abc_Print( -2, "\t-S num : show structures whose support size is S [default = %d]\n", Support );
-    Abc_Print( -2, "\t-o     : toggles printing occurence distribution [default = %s]\n", fOccurs? "yes": "no" );
-    Abc_Print( -2, "\t-t     : toggles dumping truth tables [default = %s]\n",            fTtDump? "yes": "no" );
-    Abc_Print( -2, "\t-b     : toggles processing second manager [default = %s]\n",       fSecond? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggles verbose output [default = %s]\n",                  fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandDsdTune( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    int c, fVerbose = 0, fFast = 0, fAdd = 0, fSpec = 0, LutSize = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Kfasvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-K\" should be followed by a floating point number.\n" );
-                goto usage;
-            }
-            LutSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( LutSize < 4 || LutSize > 6 )
-                goto usage;
-            break;
-        case 'f':
-            fFast ^= 1;
-            break;
-        case 'a':
-            fAdd ^= 1;
-            break;
-        case 's':
-            fSpec ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( !Abc_FrameReadManDsd() )
-    {
-        Abc_Print( 1, "The DSD manager is not started.\n" );
-        return 0;
-    }
-    If_DsdManTune( (If_DsdMan_t *)Abc_FrameReadManDsd(), LutSize, fFast, fAdd, fSpec, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: dsd_tune [-K num] [-fasvh]\n" );
-    Abc_Print( -2, "\t         tunes DSD manager for the given LUT size\n" );
-    Abc_Print( -2, "\t-K num : LUT size used for tuning [default = %d]\n",        LutSize );
-    Abc_Print( -2, "\t-f     : toggles using fast check [default = %s]\n",        fFast? "yes": "no" );
-    Abc_Print( -2, "\t-a     : toggles adding tuning to the current one [default = %s]\n",    fAdd? "yes": "no" );
-    Abc_Print( -2, "\t-s     : toggles using specialized check [default = %s]\n", fSpec? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggles verbose output [default = %s]\n",          fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandDsdMerge( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    char * FileName, * pTemp;
-    char ** pArgvNew;
-    int c, nArgcNew;
-    FILE * pFile;
-    If_DsdMan_t * pDsdMan;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( !Abc_FrameReadManDsd() )
-    {
-        Abc_Print( 1, "The DSD manager is not started.\n" );
-        return 0;
-    }
-    pArgvNew = argv + globalUtilOptind;
-    nArgcNew = argc - globalUtilOptind;
-    if ( nArgcNew != 1 )
-    {
-        Abc_Print( -1, "File name is not given on the command line.\n" );
-        return 1;
-    }
-    // get the input file name
-    FileName = pArgvNew[0];
-    // fix the wrong symbol
-    for ( pTemp = FileName; *pTemp; pTemp++ )
-        if ( *pTemp == '>' )
-            *pTemp = '\\';
-    if ( (pFile = fopen( FileName, "r" )) == NULL )
-    {
-        Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
-        if ( (FileName = Extra_FileGetSimilarName( FileName, ".aig", NULL, NULL, NULL, NULL )) )
-            Abc_Print( 1, "Did you mean \"%s\"?", FileName );
-        Abc_Print( 1, "\n" );
-        return 1;
-    }
-    fclose( pFile );
-    pDsdMan = If_DsdManLoad(FileName);
-    if ( pDsdMan == NULL )
-        return 1;
-    If_DsdManMerge( (If_DsdMan_t *)Abc_FrameReadManDsd(), pDsdMan );
-    If_DsdManFree( pDsdMan, 0 );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: dsd_merge [-h] <file>\n" );
-    Abc_Print( -2, "\t         merges DSD manager from file with the current one\n");
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\t<file> : file name to read\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandDsdClean( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    int c, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( !Abc_FrameReadManDsd() )
-    {
-        Abc_Print( 1, "The DSD manager is not started.\n" );
-        return 0;
-    }
-    If_DsdManClean( (If_DsdMan_t *)Abc_FrameReadManDsd(), fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: dsd_clean [-K num] [-vh]\n" );
-    Abc_Print( -2, "\t         cleans the occurrence counters\n" );
-    Abc_Print( -2, "\t-v     : toggles verbose output [default = %s]\n",          fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandInit( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    Abc_Obj_t * pObj;
-    int c, i;
-    int fZeros;
-    int fOnes;
-    int fRandom;
-    int fDontCare;
-    char * pInitStr;
-    // set defaults
-    fZeros    = 0;
-    fOnes     = 0;
-    fRandom   = 0;
-    fDontCare = 0;
-    pInitStr  = NULL;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Szordh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by a file name.\n" );
-                goto usage;
-            }
-            pInitStr = argv[globalUtilOptind];
-            globalUtilOptind++;
-            break;
-        case 'z':
-            fZeros ^= 1;
-            break;
-        case 'o':
-            fOnes ^= 1;
-            break;
-        case 'r':
-            fRandom ^= 1;
-            break;
-        case 'd':
-            fDontCare ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( Abc_NtkIsComb(pNtk) )
-    {
-        Abc_Print( -1, "The current network is combinational.\n" );
-        return 0;
-    }
-
-    if ( pInitStr != NULL )
-    {
-        if ( (int)strlen(pInitStr) != Abc_NtkLatchNum(pNtk) )
-        {
-            Abc_Print( -1, "The length of init string (%d) differs from the number of flops (%d).\n", strlen(pInitStr), Abc_NtkLatchNum(pNtk) );
-            return 1;
-        }
-        Abc_NtkForEachLatch( pNtk, pObj, i )
-            if ( pInitStr[i] == '0' )
-                Abc_LatchSetInit0( pObj );
-            else if ( pInitStr[i] == '1' )
-                Abc_LatchSetInit1( pObj );
-            else 
-                Abc_LatchSetInitDc( pObj );
-        return 0;
-    }
-
-    if ( fZeros )
-    {
-        Abc_NtkForEachLatch( pNtk, pObj, i )
-            Abc_LatchSetInit0( pObj );
-    }
-    else if ( fOnes )
-    {
-        Abc_NtkForEachLatch( pNtk, pObj, i )
-            Abc_LatchSetInit1( pObj );
-    }
-    else if ( fRandom )
-    {
-        srand( time(NULL) );
-        Abc_NtkForEachLatch( pNtk, pObj, i )
-            if ( rand() & 1 )
-                Abc_LatchSetInit1( pObj );
-            else
-                Abc_LatchSetInit0( pObj );
-    }
-    else if ( fDontCare )
-    {
-        Abc_NtkForEachLatch( pNtk, pObj, i )
-            Abc_LatchSetInitDc( pObj );
-    }
-    else
-        Abc_Print( -1, "The initial states remain unchanged.\n" );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: init [-zordh] [-S <init_string>]\n" );
-    Abc_Print( -2, "\t         resets initial states of all latches\n" );
-    Abc_Print( -2, "\t-z     : set zeros initial states [default = %s]\n", fZeros? "yes": "no" );
-    Abc_Print( -2, "\t-o     : set ones initial states [default = %s]\n", fOnes? "yes": "no" );
-    Abc_Print( -2, "\t-d     : set don't-care initial states [default = %s]\n", fDontCare? "yes": "no" );
-    Abc_Print( -2, "\t-r     : set random initial states [default = %s]\n", fRandom? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\t-S str : (optional) initial state  [default = unused]\n" );
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandZero( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c;
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( Abc_NtkIsComb(pNtk) )
-    {
-        Abc_Print( -1, "The current network is combinational.\n" );
-        return 0;
-    }
-
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for AIGs.\n" );
-        return 0;
-    }
-
-    // get the new network
-    pNtkRes = Abc_NtkRestrashZero( pNtk, 0 );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Converting to sequential AIG has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: zero [-h]\n" );
-    Abc_Print( -2, "\t        converts latches to have const-0 initial value\n" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandUndc( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c, fUseCex = 0;
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'c':
-            fUseCex ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( fUseCex )
-    {
-        char * pInit; 
-        Abc_Cex_t * pTemp;
-        int k, nFlopsX = 0;
-        if ( pAbc->pCex == NULL )
-        {
-            Abc_Print( -1, "Current CEX is not available.\n" );
-            return 1;
-        }
-        pInit = Abc_NtkCollectLatchValuesStr( pAbc->pNtkCur );
-        // count the number of X-valued flops
-        for ( k = 0; k < Abc_NtkLatchNum(pAbc->pNtkCur); k++ )
-            nFlopsX += (int)(pInit[k] == 'x');
-        // compare this value
-        if ( Abc_NtkPiNum(pNtk) + nFlopsX != pAbc->pCex->nPis )
-        {
-            Abc_Print( -1, "The number of PIs (%d) plus X-valued flops (%d) in the original network does not match the number of PIs in the current CEX (%d).\n", 
-                Abc_NtkPiNum(pNtk), Abc_NtkLatchNum(pNtk), pAbc->pCex->nPis );
-            return 1;
-        }
-        pAbc->pCex = Abc_CexTransformUndc( pTemp = pAbc->pCex, pInit );
-        assert( pAbc->pCex->nPis == Abc_NtkPiNum(pAbc->pNtkCur) );
-        assert( pAbc->pCex->nRegs == Abc_NtkLatchNum(pAbc->pNtkCur) );
-        Abc_CexFree( pTemp );
-        ABC_FREE( pInit );
-        return 0;
-    }
-
-    if ( Abc_NtkIsComb(pNtk) )
-    {
-        Abc_Print( -1, "The current network is combinational.\n" );
-        return 0;
-    }
-
-    if ( !Abc_NtkIsLogic(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for logic networks.\n" );
-        return 0;
-    }
-
-    // get the new network
-    Abc_NtkConvertDcLatches( pNtk );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: undc [-ch]\n" );
-    Abc_Print( -2, "\t        converts latches with DC init values into free PIs\n" );
-    Abc_Print( -2, "\t-c    : toggles transforming CEX after \"logic;undc;st;zero\" [default = %s]\n", fUseCex? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandOneHot( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c;
-    extern Abc_Ntk_t * Abc_NtkConvertOnehot( Abc_Ntk_t * pNtk );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( Abc_NtkIsComb(pNtk) )
-    {
-        Abc_Print( -1, "The current network is combinational.\n" );
-        return 0;
-    }
-    if ( !Abc_NtkIsLogic(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for logic networks.\n" );
-        return 0;
-    }
-    // get the new network
-    pNtkRes = Abc_NtkConvertOnehot( pNtk );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Converting to one-hot encoding has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: onehot [-h]\n" );
-    Abc_Print( -2, "\t        converts natural encoding into one-hot encoding\n" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandPipe( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int nLatches;
-    extern void Abc_NtkLatchPipe( Abc_Ntk_t * pNtk, int nLatches );
-    // set defaults
-    nLatches = 5;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Lh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            nLatches = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nLatches < 0 )
-                goto usage;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( Abc_NtkIsComb(pNtk) )
-    {
-        Abc_Print( -1, "The current network is combinational.\n" );
-        return 0;
-    }
-
-    // update the network
-    Abc_NtkLatchPipe( pNtk, nLatches );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: pipe [-L num] [-h]\n" );
-    Abc_Print( -2, "\t         inserts the given number of latches at each PI for pipelining\n" );
-    Abc_Print( -2, "\t-L num : the number of latches to insert [default = %d]\n", nLatches );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandSeq( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c;
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( Abc_NtkLatchNum(pNtk) == 0 )
-    {
-        Abc_Print( -1, "The network has no latches.\n" );
-        return 0;
-    }
-
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Conversion to sequential AIG works only for combinational AIGs (run \"strash\").\n" );
-        return 1;
-    }
-
-    // get the new network
-//    pNtkRes = Abc_NtkAigToSeq( pNtk );
-    pNtkRes = NULL;
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Converting to sequential AIG has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: seq [-h]\n" );
-    Abc_Print( -2, "\t        converts AIG into sequential AIG\n" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandUnseq( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c;
-    int fShare;
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    fShare = 1;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "sh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 's':
-            fShare ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-/*
-    if ( !Abc_NtkIsSeq(pNtk) )
-    {
-        Abc_Print( -1, "Conversion to combinational AIG works only for sequential AIG (run \"seq\").\n" );
-        return 1;
-    }
-*/
-    // share the latches on the fanout edges
-//    if ( fShare )
-//        Seq_NtkShareFanouts(pNtk);
-
-    // get the new network
-//    pNtkRes = Abc_NtkSeqToLogicSop( pNtk );
-    pNtkRes = NULL;
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Converting sequential AIG into an SOP logic network has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: unseq [-sh]\n" );
-    Abc_Print( -2, "\t        converts sequential AIG into an SOP logic network\n" );
-    Abc_Print( -2, "\t-s    : toggle sharing latches [default = %s]\n", fShare? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c, nMaxIters;
-    int fForward;
-    int fBackward;
-    int fOneStep;
-    int fVerbose;
-    int Mode;
-    int nDelayLim;
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    Mode      =  5;
-    nDelayLim =  0;
-    fForward  =  0;
-    fBackward =  0;
-    fOneStep  =  0;
-    fVerbose  =  0;
-    nMaxIters = 15;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "MDfbsvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'M':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-M\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            Mode = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( Mode < 0 )
-                goto usage;
-            break;
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            nDelayLim = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nDelayLim < 0 )
-                goto usage;
-            break;
-        case 'f':
-            fForward ^= 1;
-            break;
-        case 'b':
-            fBackward ^= 1;
-            break;
-        case 's':
-            fOneStep ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( fForward && fBackward )
-    {
-        Abc_Print( -1, "Only one switch \"-f\" or \"-b\" can be selected at a time.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkLatchNum(pNtk) )
-    {
-//        Abc_Print( -1, "The network has no latches. Retiming is not performed.\n" );
-        return 0;
-    }
-
-    if ( Mode < 0 || Mode > 6 )
-    {
-        Abc_Print( -1, "The mode (%d) is incorrect. Retiming is not performed.\n", Mode );
-        return 0;
-    }
-
-    if ( Abc_NtkIsStrash(pNtk) )
-    {
-        if ( Abc_NtkGetChoiceNum(pNtk) )
-        {
-            Abc_Print( -1, "Retiming with choice nodes is not implemented.\n" );
-            return 0;
-        }
-        // convert the network into an SOP network
-        pNtkRes = Abc_NtkToLogic( pNtk );
-        // perform the retiming
-        Abc_NtkRetime( pNtkRes, Mode, nDelayLim, fForward, fBackward, fOneStep, fVerbose );
-        // replace the current network
-        Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-        return 0;
-    }
-
-    // get the network in the SOP form
-    if ( !Abc_NtkToSop(pNtk, 0) )
-    {
-        Abc_Print( -1, "Converting to SOPs has failed.\n" );
-        return 0;
-    }
-
-    if ( !Abc_NtkIsLogic(pNtk) )
-    {
-        Abc_Print( -1, "The network is not a logic network. Retiming is not performed.\n" );
-        return 0;
-    }
-
-    // perform the retiming
-    Abc_NtkRetime( pNtk, Mode, nDelayLim, fForward, fBackward, fOneStep, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: retime [-MD num] [-fbvh]\n" );
-    Abc_Print( -2, "\t         retimes the current network using one of the algorithms:\n" );
-    Abc_Print( -2, "\t             1: most forward retiming\n" );
-    Abc_Print( -2, "\t             2: most backward retiming\n" );
-    Abc_Print( -2, "\t             3: forward and backward min-area retiming\n" );
-    Abc_Print( -2, "\t             4: forward and backward min-delay retiming\n" );
-    Abc_Print( -2, "\t             5: mode 3 followed by mode 4\n" );
-    Abc_Print( -2, "\t             6: Pan's optimum-delay retiming using binary search\n" );
-    Abc_Print( -2, "\t-M num : the retiming algorithm to use [default = %d]\n", Mode );
-    Abc_Print( -2, "\t-D num : the minimum delay target (0=unused) [default = %d]\n", nDelayLim );
-    Abc_Print( -2, "\t-f     : enables forward-only retiming in modes 3,4,5 [default = %s]\n", fForward? "yes": "no" );
-    Abc_Print( -2, "\t-b     : enables backward-only retiming in modes 3,4,5 [default = %s]\n", fBackward? "yes": "no" );
-    Abc_Print( -2, "\t-s     : enables retiming one step only in mode 4 [default = %s]\n", fOneStep? "yes": "no" );
-    Abc_Print( -2, "\t-v     : enables verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-//    Abc_Print( -2, "\t-I num : max number of iterations of l-value computation [default = %d]\n", nMaxIters );
-//    Abc_Print( -2, "\t-f     : toggle forward retiming (for AIGs) [default = %s]\n", fForward? "yes": "no" );
-//    Abc_Print( -2, "\t-b     : toggle backward retiming (for AIGs) [default = %s]\n", fBackward? "yes": "no" );
-//    Abc_Print( -2, "\t-i     : toggle computation of initial state [default = %s]\n", fInitial? "yes": "no" );
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandDRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int fMinArea;
-    int fForwardOnly;
-    int fBackwardOnly;
-    int fInitial;
-    int nStepsMax;
-    int fFastAlgo;
-    int fVerbose;
-    int c, nMaxIters;
-    extern Abc_Ntk_t * Abc_NtkDarRetime( Abc_Ntk_t * pNtk, int nStepsMax, int fVerbose );
-    extern Abc_Ntk_t * Abc_NtkDarRetimeF( Abc_Ntk_t * pNtk, int nStepsMax, int fVerbose );
-    extern Abc_Ntk_t * Abc_NtkDarRetimeMinArea( Abc_Ntk_t * pNtk, int nMaxIters, int fForwardOnly, int fBackwardOnly, int fInitial, int fVerbose );
-    extern Abc_Ntk_t * Abc_NtkDarRetimeMostFwd( Abc_Ntk_t * pNtk, int nMaxIters, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    fMinArea  = 1;
-    fForwardOnly = 0;
-    fBackwardOnly = 0;
-    fInitial = 1;
-    nStepsMax = 100000;
-    fFastAlgo = 0;
-    nMaxIters = 20;
-    fVerbose  = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "NSmfbiavh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            nMaxIters = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nMaxIters < 0 )
-                goto usage;
-            break;
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            nStepsMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nStepsMax < 0 )
-                goto usage;
-            break;
-        case 'm':
-            fMinArea ^= 1;
-            break;
-        case 'f':
-            fForwardOnly ^= 1;
-            break;
-        case 'b':
-            fBackwardOnly ^= 1;
-            break;
-        case 'i':
-            fInitial ^= 1;
-            break;
-        case 'a':
-            fFastAlgo ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkLatchNum(pNtk) )
-    {
-//        Abc_Print( -1, "The network has no latches. Retiming is not performed.\n" );
-        return 0;
-    }
-
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for structrally hashed networks. Run \"st\".\n" );
-        return 0;
-    }
-
-    // perform the retiming
-    if ( fMinArea )
-        pNtkRes = Abc_NtkDarRetimeMinArea( pNtk, nMaxIters, fForwardOnly, fBackwardOnly, fInitial, fVerbose );
-    else if ( fFastAlgo )
-        pNtkRes = Abc_NtkDarRetime( pNtk, nStepsMax, fVerbose );
-    else
-//        pNtkRes = Abc_NtkDarRetimeF( pNtk, nStepsMax, fVerbose );
-        pNtkRes = Abc_NtkDarRetimeMostFwd( pNtk, nMaxIters, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Retiming has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: dretime [-NS num] [-mfbiavh]\n" );
-    Abc_Print( -2, "\t         new implementation of min-area (or most-forward) retiming\n" );
-    Abc_Print( -2, "\t-m     : toggle min-area retiming and most-forward retiming [default = %s]\n", fMinArea? "min-area": "most-fwd" );
-    Abc_Print( -2, "\t-f     : enables forward-only retiming [default = %s]\n", fForwardOnly? "yes": "no" );
-    Abc_Print( -2, "\t-b     : enables backward-only retiming [default = %s]\n", fBackwardOnly? "yes": "no" );
-    Abc_Print( -2, "\t-i     : enables init state computation [default = %s]\n", fInitial? "yes": "no" );
-    Abc_Print( -2, "\t-N num : the max number of one-frame iterations to perform [default = %d]\n", nMaxIters );
-    Abc_Print( -2, "\t-S num : the max number of forward retiming steps to perform [default = %d]\n", nStepsMax );
-    Abc_Print( -2, "\t-a     : enables a fast most-forward algorithm [default = %s]\n", fFastAlgo? "yes": "no" );
-    Abc_Print( -2, "\t-v     : enables verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandFlowRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c, nMaxIters;
-    int fForward;
-    int fBackward;
-    int fVerbose;
-    int fComputeInit, fGuaranteeInit, fBlockConst;
-    int fFastButConservative;
-    int maxDelay;
-
-    if ( argc == 2 && !strcmp(argv[1], "-h") )
-    {
-        Abc_Print( -2, "The fretime command is temporarily disabled.\n" );
-        return 1;
-    }
-
-    Abc_Print( -1, "This command is temporarily disabled.\n" );
-    return 0;
-//    extern Abc_Ntk_t* Abc_FlowRetime_MinReg( Abc_Ntk_t * pNtk, int fVerbose,
-//                                             int fComputeInit, int fGuaranteeInit, int fBlockConst,
-//                                             int fForward, int fBackward, int nMaxIters,
-//                                             int maxDelay, int fFastButConservative);
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    fForward  =  0;
-    fFastButConservative = 0;
-    fBackward =  0;
-    fComputeInit =  1;
-    fGuaranteeInit =  0;
-    fVerbose  =  0;
-    fBlockConst  =  0;
-    nMaxIters = 999;
-    maxDelay  = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "MDfcgbkivh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'M':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-M\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            nMaxIters = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nMaxIters < 0 )
-                goto usage;
-            break;
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            maxDelay = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( maxDelay < 0 )
-                goto usage;
-           break;
-        case 'f':
-            fForward ^= 1;
-            break;
-        case 'c':
-            fFastButConservative ^= 1;
-            break;
-        case 'i':
-            fComputeInit ^= 1;
-            break;
-        case 'b':
-            fBackward ^= 1;
-            break;
-        case 'g':
-            fGuaranteeInit ^= 1;
-            break;
-        case 'k':
-            fBlockConst ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( fForward && fBackward )
-    {
-        Abc_Print( -1, "Only one switch \"-f\" or \"-b\" can be selected at a time.\n" );
-        return 1;
-    }
-
-    if ( fGuaranteeInit && !fComputeInit )
-    {
-      Abc_Print( -1, "Initial state guarantee (-g) requires initial state computation (-i).\n" );
-      return 1;
-    }
-
-    if ( !Abc_NtkLatchNum(pNtk) )
-    {
-//        Abc_Print( -1, "The network has no latches. Retiming is not performed.\n" );
-        return 0;
-    }
-
-    if ( Abc_NtkGetChoiceNum(pNtk) )
-      {
-        Abc_Print( -1, "Retiming with choice nodes is not implemented.\n" );
-        return 0;
-      }
-
-    // perform the retiming
-//    pNtkRes = Abc_FlowRetime_MinReg( pNtk, fVerbose, fComputeInit,
-//                                     fGuaranteeInit, fBlockConst,
-//                                     fForward, fBackward,
-//                                     nMaxIters, maxDelay, fFastButConservative );
-
-    if (pNtkRes != pNtk)
-      Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: fretime [-M num] [-D num] [-fbvih]\n" );
-    Abc_Print( -2, "\t         retimes the current network using flow-based algorithm\n" );
-    Abc_Print( -2, "\t-M num : the maximum number of iterations [default = %d]\n", nMaxIters );
-    Abc_Print( -2, "\t-D num : the maximum delay [default = none]\n" );
-    Abc_Print( -2, "\t-i     : enables init state computation [default = %s]\n", fComputeInit? "yes": "no" );
-    Abc_Print( -2, "\t-k     : blocks retiming over const nodes [default = %s]\n", fBlockConst? "yes": "no" );
-    Abc_Print( -2, "\t-g     : guarantees init state computation [default = %s]\n", fGuaranteeInit? "yes": "no" );
-    Abc_Print( -2, "\t-c     : very fast (but conserv.) delay constraints [default = %s]\n", fFastButConservative? "yes": "no" );
-    Abc_Print( -2, "\t-f     : enables forward-only retiming  [default = %s]\n", fForward? "yes": "no" );
-    Abc_Print( -2, "\t-b     : enables backward-only retiming [default = %s]\n", fBackward? "yes": "no" );
-    Abc_Print( -2, "\t-v     : enables verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandCRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c;
-    int fVerbose;
-    extern Abc_Ntk_t * Abc_NtkCRetime( Abc_Ntk_t * pNtk, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    fVerbose    = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Only works for logic networks.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkLatchNum(pNtk) )
-    {
-        Abc_Print( -1, "The network is combinational.\n" );
-        return 0;
-    }
-    // modify the current network
-    pNtkRes = Abc_NtkCRetime( pNtk, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Sequential cleanup has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: cretime [-vh]\n" );
-    Abc_Print( -2, "\t         performs most-forward retiming with equiv classes\n" );
-    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandSeqFpga( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkNew, * pNtkRes;
-    int c, nMaxIters;
-    int fVerbose;
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    nMaxIters = 15;
-    fVerbose  =  0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Ivh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'I':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-I\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            nMaxIters = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nMaxIters < 0 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( Abc_NtkHasAig(pNtk) )
-    {
-/*
-        // quit if there are choice nodes
-        if ( Abc_NtkGetChoiceNum(pNtk) )
-        {
-            Abc_Print( -1, "Currently cannot map/retime networks with choice nodes.\n" );
-            return 0;
-        }
-*/
-//        if ( Abc_NtkIsStrash(pNtk) )
-//            pNtkNew = Abc_NtkAigToSeq(pNtk);
-//        else
-//            pNtkNew = Abc_NtkDup(pNtk);
-        pNtkNew = NULL;
-    }
-    else
-    {
-        // strash and balance the network
-        pNtkNew = Abc_NtkStrash( pNtk, 0, 0, 0 );
-        if ( pNtkNew == NULL )
-        {
-            Abc_Print( -1, "Strashing before FPGA mapping/retiming has failed.\n" );
-            return 1;
-        }
-
-        pNtkNew = Abc_NtkBalance( pNtkRes = pNtkNew, 0, 0, 1 );
-        Abc_NtkDelete( pNtkRes );
-        if ( pNtkNew == NULL )
-        {
-            Abc_Print( -1, "Balancing before FPGA mapping has failed.\n" );
-            return 1;
-        }
-
-        // convert into a sequential AIG
-//        pNtkNew = Abc_NtkAigToSeq( pNtkRes = pNtkNew );
-        pNtkNew = NULL;
-        Abc_NtkDelete( pNtkRes );
-        if ( pNtkNew == NULL )
-        {
-            Abc_Print( -1, "Converting into a seq AIG before FPGA mapping/retiming has failed.\n" );
-            return 1;
-        }
-
-        Abc_Print( 1, "The network was strashed and balanced before FPGA mapping/retiming.\n" );
-    }
-
-    // get the new network
-//    pNtkRes = Seq_NtkFpgaMapRetime( pNtkNew, nMaxIters, fVerbose );
-    pNtkRes = NULL;
-    if ( pNtkRes == NULL )
-    {
-//        Abc_Print( -1, "Sequential FPGA mapping has failed.\n" );
-        Abc_NtkDelete( pNtkNew );
-        return 0;
-    }
-    Abc_NtkDelete( pNtkNew );
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: sfpga [-I num] [-vh]\n" );
-    Abc_Print( -2, "\t         performs integrated sequential FPGA mapping/retiming\n" );
-    Abc_Print( -2, "\t-I num : max number of iterations of l-value computation [default = %d]\n", nMaxIters );
-    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandSeqMap( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkNew, * pNtkRes;
-    int c, nMaxIters;
-    int fVerbose;
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    nMaxIters = 15;
-    fVerbose  =  0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Ivh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'I':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-I\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            nMaxIters = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nMaxIters < 0 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( Abc_NtkHasAig(pNtk) )
-    {
-/*
-        // quit if there are choice nodes
-        if ( Abc_NtkGetChoiceNum(pNtk) )
-        {
-            Abc_Print( -1, "Currently cannot map/retime networks with choice nodes.\n" );
-            return 0;
-        }
-*/
-//        if ( Abc_NtkIsStrash(pNtk) )
-//            pNtkNew = Abc_NtkAigToSeq(pNtk);
-//        else
-//            pNtkNew = Abc_NtkDup(pNtk);
-        pNtkNew = NULL;
-    }
-    else
-    {
-        // strash and balance the network
-        pNtkNew = Abc_NtkStrash( pNtk, 0, 0, 0 );
-        if ( pNtkNew == NULL )
-        {
-            Abc_Print( -1, "Strashing before SC mapping/retiming has failed.\n" );
-            return 1;
-        }
-
-        pNtkNew = Abc_NtkBalance( pNtkRes = pNtkNew, 0, 0, 1 );
-        Abc_NtkDelete( pNtkRes );
-        if ( pNtkNew == NULL )
-        {
-            Abc_Print( -1, "Balancing before SC mapping/retiming has failed.\n" );
-            return 1;
-        }
-
-        // convert into a sequential AIG
-//        pNtkNew = Abc_NtkAigToSeq( pNtkRes = pNtkNew );
-        pNtkNew = NULL;
-        Abc_NtkDelete( pNtkRes );
-        if ( pNtkNew == NULL )
-        {
-            Abc_Print( -1, "Converting into a seq AIG before SC mapping/retiming has failed.\n" );
-            return 1;
-        }
-
-        Abc_Print( -1, "The network was strashed and balanced before SC mapping/retiming.\n" );
-    }
-
-    // get the new network
-//    pNtkRes = Seq_MapRetime( pNtkNew, nMaxIters, fVerbose );
-    pNtkRes = NULL;
-    if ( pNtkRes == NULL )
-    {
-//        Abc_Print( -1, "Sequential FPGA mapping has failed.\n" );
-        Abc_NtkDelete( pNtkNew );
-        return 0;
-    }
-    Abc_NtkDelete( pNtkNew );
-
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: smap [-I num] [-vh]\n" );
-    Abc_Print( -2, "\t         performs integrated sequential standard-cell mapping/retiming\n" );
-    Abc_Print( -2, "\t-I num : max number of iterations of l-value computation [default = %d]\n", nMaxIters );
-    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandSeqSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    Fra_Ssw_t Pars, * pPars = &Pars;
-    int c;
-    extern Abc_Ntk_t * Abc_NtkDarSeqSweep( Abc_Ntk_t * pNtk, Fra_Ssw_t * pPars );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    pPars->nPartSize  = 0;
-    pPars->nOverSize  = 0;
-    pPars->nFramesP   = 0;
-    pPars->nFramesK   = 1;
-    pPars->nMaxImps   = 5000;
-    pPars->nMaxLevs   = 0;
-    pPars->fUseImps   = 0;
-    pPars->fRewrite   = 0;
-    pPars->fFraiging  = 0;
-    pPars->fLatchCorr = 0;
-    pPars->fWriteImps = 0;
-    pPars->fUse1Hot   = 0;
-    pPars->fVerbose   = 0;
-    pPars->TimeLimit  = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "PQNFILirfletvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'P':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nPartSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nPartSize < 2 )
-                goto usage;
-            break;
-        case 'Q':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-Q\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nOverSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nOverSize < 0 )
-                goto usage;
-            break;
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nFramesP = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nFramesP < 0 )
-                goto usage;
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nFramesK = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nFramesK <= 0 )
-                goto usage;
-            break;
-        case 'I':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nMaxImps = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nMaxImps <= 0 )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nMaxLevs = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nMaxLevs <= 0 )
-                goto usage;
-            break;
-        case 'i':
-            pPars->fUseImps ^= 1;
-            break;
-        case 'r':
-            pPars->fRewrite ^= 1;
-            break;
-        case 'f':
-            pPars->fFraiging ^= 1;
-            break;
-        case 'l':
-            pPars->fLatchCorr ^= 1;
-            break;
-        case 'e':
-            pPars->fWriteImps ^= 1;
-            break;
-        case 't':
-            pPars->fUse1Hot ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( Abc_NtkIsComb(pNtk) )
-    {
-        Abc_Print( -1, "The network is combinational (run \"fraig\" or \"fraig_sweep\").\n" );
-        return 0;
-    }
-
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for structrally hashed networks. Run \"st\".\n" );
-        return 0;
-    }
-
-    if ( pPars->nFramesK > 1 && pPars->fUse1Hot )
-    {
-        Abc_Print( -1, "Currrently can only use one-hotness for simple induction (K=1).\n" );
-        return 0;
-    }
-
-    if ( pPars->nFramesP && pPars->fUse1Hot )
-    {
-        Abc_Print( -1, "Currrently can only use one-hotness without prefix.\n" );
-        return 0;
-    }
-
-    // get the new network
-    pNtkRes = Abc_NtkDarSeqSweep( pNtk, pPars );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Sequential sweeping has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: ssweep [-PQNFL <num>] [-lrfetvh]\n" );
-    Abc_Print( -2, "\t         performs sequential sweep using K-step induction\n" );
-    Abc_Print( -2, "\t-P num : max partition size (0 = no partitioning) [default = %d]\n", pPars->nPartSize );
-    Abc_Print( -2, "\t-Q num : partition overlap (0 = no overlap) [default = %d]\n", pPars->nOverSize );
-    Abc_Print( -2, "\t-N num : number of time frames to use as the prefix [default = %d]\n", pPars->nFramesP );
-    Abc_Print( -2, "\t-F num : number of time frames for induction (1=simple) [default = %d]\n", pPars->nFramesK );
-    Abc_Print( -2, "\t-L num : max number of levels to consider (0=all) [default = %d]\n", pPars->nMaxLevs );
-//    Abc_Print( -2, "\t-I num : max number of implications to consider [default = %d]\n", pPars->nMaxImps );
-//    Abc_Print( -2, "\t-i     : toggle using implications [default = %s]\n", pPars->fUseImps? "yes": "no" );
-    Abc_Print( -2, "\t-l     : toggle latch correspondence only [default = %s]\n", pPars->fLatchCorr? "yes": "no" );
-    Abc_Print( -2, "\t-r     : toggle AIG rewriting [default = %s]\n", pPars->fRewrite? "yes": "no" );
-    Abc_Print( -2, "\t-f     : toggle fraiging (combinational SAT sweeping) [default = %s]\n", pPars->fFraiging? "yes": "no" );
-    Abc_Print( -2, "\t-e     : toggle writing implications as assertions [default = %s]\n", pPars->fWriteImps? "yes": "no" );
-    Abc_Print( -2, "\t-t     : toggle using one-hotness conditions [default = %s]\n", pPars->fUse1Hot? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandSeqSweep2( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    Ssw_Pars_t Pars, * pPars = &Pars;
-    int nConstrs = 0;
-    int c;
-    extern Abc_Ntk_t * Abc_NtkDarSeqSweep2( Abc_Ntk_t * pNtk, Ssw_Pars_t * pPars );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    Ssw_ManSetDefaultParams( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "PQFCLSIVMNcmplkofdseqvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'P':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nPartSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nPartSize < 2 )
-                goto usage;
-            break;
-        case 'Q':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-Q\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nOverSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nOverSize < 0 )
-                goto usage;
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nFramesK = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nFramesK <= 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nBTLimit <= 0 )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nMaxLevs = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nMaxLevs <= 0 )
-                goto usage;
-            break;
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nFramesAddSim = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nFramesAddSim < 0 )
-                goto usage;
-            break;
-        case 'I':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nItersStop = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nItersStop < 0 )
-                goto usage;
-            break;
-        case 'V':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-V\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nSatVarMax2 = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nSatVarMax2 < 0 )
-                goto usage;
-            break;
-        case 'M':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nRecycleCalls2 = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nRecycleCalls2 < 0 )
-                goto usage;
-            break;
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nConstrs = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nConstrs < 0 )
-                goto usage;
-            break;
-        case 'c':
-            pPars->fConstrs ^= 1;
-            break;
-        case 'm':
-            pPars->fMergeFull ^= 1;
-            break;
-        case 'p':
-            pPars->fPolarFlip ^= 1;
-            break;
-        case 'l':
-            pPars->fLatchCorr ^= 1;
-            break;
-        case 'k':
-            pPars->fConstCorr ^= 1;
-            break;
-        case 'o':
-            pPars->fOutputCorr ^= 1;
-            break;
-        case 'f':
-            pPars->fSemiFormal ^= 1;
-            break;
-        case 'd':
-            pPars->fDynamic ^= 1;
-            break;
-        case 's':
-            pPars->fLocalSim ^= 1;
-            break;
-        case 'e':
-            pPars->fEquivDump ^= 1;
-            break;
-        case 'q':
-            pPars->fStopWhenGone ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'w':
-            pPars->fFlopVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( Abc_NtkIsComb(pNtk) )
-    {
-        Abc_Print( -1, "The network is combinational (run \"fraig\" or \"fraig_sweep\").\n" );
-        return 0;
-    }
-
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for structrally hashed networks. Run \"st\".\n" );
-        return 0;
-    }
-
-    if ( Abc_NtkPiNum(pNtk) == 0 )
-    {
-        Abc_Print( 0, "This command works only for designs with primary inputs.\n" );
-        return 0;
-    }
-
-    // if constraints are to be used, network should have no constraints
-    if ( nConstrs > 0 )
-    {
-        if ( Abc_NtkConstrNum(pNtk) > 0 )
-        {
-            Abc_Print( -1, "The network already has %d constraints.\n", Abc_NtkConstrNum(pNtk) );
-            return 0;
-        }
-        else
-        {
-            Abc_Print( 0, "Setting the number of constraints to be %d.\n", nConstrs );
-            pNtk->nConstrs = nConstrs;
-        }
-    }
-
-    if ( pPars->fConstrs )
-    {
-        if ( Abc_NtkConstrNum(pNtk) > 0 )
-            Abc_Print( 0, "Performing scorr with %d constraints.\n", Abc_NtkConstrNum(pNtk) );
-        else
-            Abc_Print( 0, "Performing constraint-based scorr without constraints.\n" );
-    }
-
-    // get the new network
-    pNtkRes = Abc_NtkDarSeqSweep2( pNtk, pPars );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Sequential sweeping has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: scorr [-PQFCLSIVMN <num>] [-cmplkodseqvwh]\n" );
-    Abc_Print( -2, "\t         performs sequential sweep using K-step induction\n" );
-    Abc_Print( -2, "\t-P num : max partition size (0 = no partitioning) [default = %d]\n", pPars->nPartSize );
-    Abc_Print( -2, "\t-Q num : partition overlap (0 = no overlap) [default = %d]\n", pPars->nOverSize );
-    Abc_Print( -2, "\t-F num : number of time frames for induction (1=simple) [default = %d]\n", pPars->nFramesK );
-    Abc_Print( -2, "\t-C num : max number of conflicts at a node (0=inifinite) [default = %d]\n", pPars->nBTLimit );
-    Abc_Print( -2, "\t-L num : max number of levels to consider (0=all) [default = %d]\n", pPars->nMaxLevs );
-    Abc_Print( -2, "\t-N num : number of last POs treated as constraints (0=none) [default = %d]\n", pPars->fConstrs );
-    Abc_Print( -2, "\t-S num : additional simulation frames for c-examples (0=none) [default = %d]\n", pPars->nFramesAddSim );
-    Abc_Print( -2, "\t-I num : iteration number to stop and output SR-model (-1=none) [default = %d]\n", pPars->nItersStop );
-    Abc_Print( -2, "\t-V num : min var num needed to recycle the SAT solver [default = %d]\n", pPars->nSatVarMax2 );
-    Abc_Print( -2, "\t-M num : min call num needed to recycle the SAT solver [default = %d]\n", pPars->nRecycleCalls2 );
-    Abc_Print( -2, "\t-N num : set last <num> POs to be constraints (use with -c) [default = %d]\n", nConstrs );
-    Abc_Print( -2, "\t-c     : toggle using explicit constraints [default = %s]\n", pPars->fConstrs? "yes": "no" );
-    Abc_Print( -2, "\t-m     : toggle full merge if constraints are present [default = %s]\n", pPars->fMergeFull? "yes": "no" );
-    Abc_Print( -2, "\t-p     : toggle aligning polarity of SAT variables [default = %s]\n", pPars->fPolarFlip? "yes": "no" );
-    Abc_Print( -2, "\t-l     : toggle doing latch correspondence [default = %s]\n", pPars->fLatchCorr? "yes": "no" );
-    Abc_Print( -2, "\t-k     : toggle doing constant correspondence [default = %s]\n", pPars->fConstCorr? "yes": "no" );
-    Abc_Print( -2, "\t-o     : toggle doing \'PO correspondence\' [default = %s]\n", pPars->fOutputCorr? "yes": "no" );
-//    Abc_Print( -2, "\t-f     : toggle filtering using iterative BMC [default = %s]\n", pPars->fSemiFormal? "yes": "no" );
-    Abc_Print( -2, "\t-d     : toggle dynamic addition of constraints [default = %s]\n", pPars->fDynamic? "yes": "no" );
-    Abc_Print( -2, "\t-s     : toggle local simulation in the cone of influence [default = %s]\n", pPars->fLocalSim? "yes": "no" );
-    Abc_Print( -2, "\t-e     : toggle dumping disproved internal equivalences [default = %s]\n", pPars->fEquivDump? "yes": "no" );
-    Abc_Print( -2, "\t-q     : toggle quitting when PO is not a constant candidate [default = %s]\n", pPars->fStopWhenGone? "yes": "no" );
-    Abc_Print( -2, "\t-w     : toggle printout of flop equivalences [default = %s]\n", pPars->fFlopVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandTestSeqSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    char * pFileName;
-    Fra_Ssw_t Pars, * pPars = &Pars;
-    int c;
-//    extern Abc_Ntk_t * Abc_NtkDarSeqSweep( Abc_Ntk_t * pNtk, Fra_Ssw_t * pPars );
-    extern int Fra_FraigInductionTest( char * pFileName, Fra_Ssw_t * pParams );
-
-    // set defaults
-    pPars->nPartSize  = 0;
-    pPars->nOverSize  = 0;
-    pPars->nFramesP   = 0;
-    pPars->nFramesK   = 1;
-    pPars->nMaxImps   = 5000;
-    pPars->nMaxLevs   = 0;
-    pPars->fUseImps   = 0;
-    pPars->fRewrite   = 0;
-    pPars->fFraiging  = 0;
-    pPars->fLatchCorr = 0;
-    pPars->fWriteImps = 0;
-    pPars->fUse1Hot   = 0;
-    pPars->fVerbose   = 0;
-    pPars->TimeLimit  = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "PQNFILirfletvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'P':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nPartSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nPartSize < 2 )
-                goto usage;
-            break;
-        case 'Q':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-Q\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nOverSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nOverSize < 0 )
-                goto usage;
-            break;
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nFramesP = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nFramesP < 0 )
-                goto usage;
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nFramesK = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nFramesK <= 0 )
-                goto usage;
-            break;
-        case 'I':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nMaxImps = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nMaxImps <= 0 )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nMaxLevs = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nMaxLevs <= 0 )
-                goto usage;
-            break;
-        case 'i':
-            pPars->fUseImps ^= 1;
-            break;
-        case 'r':
-            pPars->fRewrite ^= 1;
-            break;
-        case 'f':
-            pPars->fFraiging ^= 1;
-            break;
-        case 'l':
-            pPars->fLatchCorr ^= 1;
-            break;
-        case 'e':
-            pPars->fWriteImps ^= 1;
-            break;
-        case 't':
-            pPars->fUse1Hot ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    // get the input file name
-    if ( argc == globalUtilOptind + 1 )
-        pFileName = argv[globalUtilOptind];
-    else
-    {
-        Abc_Print( -1, "File name should be given on the command line.\n" );
-        return 1;
-    }
-    Fra_FraigInductionTest( pFileName, pPars );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: testssw [-PQNFL num] [-lrfetvh] <file>\n" );
-    Abc_Print( -2, "\t         performs sequential sweep using K-step induction\n" );
-    Abc_Print( -2, "\t         (outputs a file with a set of pairs of equivalent nodes)\n" );
-    Abc_Print( -2, "\t-P num : max partition size (0 = no partitioning) [default = %d]\n", pPars->nPartSize );
-    Abc_Print( -2, "\t-Q num : partition overlap (0 = no overlap) [default = %d]\n", pPars->nOverSize );
-    Abc_Print( -2, "\t-N num : number of time frames to use as the prefix [default = %d]\n", pPars->nFramesP );
-    Abc_Print( -2, "\t-F num : number of time frames for induction (1=simple) [default = %d]\n", pPars->nFramesK );
-    Abc_Print( -2, "\t-L num : max number of levels to consider (0=all) [default = %d]\n", pPars->nMaxLevs );
-//    Abc_Print( -2, "\t-I num : max number of implications to consider [default = %d]\n", pPars->nMaxImps );
-//    Abc_Print( -2, "\t-i     : toggle using implications [default = %s]\n", pPars->fUseImps? "yes": "no" );
-    Abc_Print( -2, "\t-l     : toggle latch correspondence only [default = %s]\n", pPars->fLatchCorr? "yes": "no" );
-    Abc_Print( -2, "\t-r     : toggle AIG rewriting [default = %s]\n", pPars->fRewrite? "yes": "no" );
-    Abc_Print( -2, "\t-f     : toggle fraiging (combinational SAT sweeping) [default = %s]\n", pPars->fFraiging? "yes": "no" );
-    Abc_Print( -2, "\t-e     : toggle writing implications as assertions [default = %s]\n", pPars->fWriteImps? "yes": "no" );
-    Abc_Print( -2, "\t-t     : toggle using one-hotness conditions [default = %s]\n", pPars->fUse1Hot? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandTestScorr( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Abc_Ntk_t * Abc_NtkTestScorr( char * pFileNameIn, char * pFileNameOut, int nStepsMax, int nBTLimit, int fNewAlgo, int fFlopOnly, int fFfNdOnly, int fVerbose );
-
-    Abc_Ntk_t * pNtkRes;
-    int c;
-    int nConfMax;
-    int nStepsMax;
-    int fNewAlgo;
-    int fFlopOnly;
-    int fFfNdOnly;
-    int fVerbose;
-    // set defaults
-    nConfMax  = 100;
-    nStepsMax =  -1;
-    fNewAlgo  =   0;
-    fFlopOnly =   0;
-    fFfNdOnly =   0;
-    fVerbose  =   0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "CSnfsvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nConfMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nConfMax < 0 )
-                goto usage;
-            break;
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nStepsMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nStepsMax < 0 )
-                goto usage;
-            break;
-        case 'n':
-            fNewAlgo ^= 1;
-            break;
-        case 'f':
-            fFlopOnly ^= 1;
-            break;
-        case 's':
-            fFfNdOnly ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        default:
-            goto usage;
-        }
-    }
-    if ( argc != globalUtilOptind + 2 )
-    {
-        Abc_Print( -1, "Expecting two files names on the command line.\n" );
-        goto usage;
-    }
-    if ( fFlopOnly && fFfNdOnly )
-    {
-        Abc_Print( -1, "These two options (-f and -s) are incompatible.\n" );
-        goto usage;
-    }
-    // get the new network
-    pNtkRes = Abc_NtkTestScorr( argv[globalUtilOptind], argv[globalUtilOptind+1], nStepsMax, nConfMax, fNewAlgo, fFlopOnly, fFfNdOnly, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Sequential sweeping has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: testscorr [-CS num] [-nfsvh] <file_in> <file_out>\n" );
-    Abc_Print( -2, "\t             outputs the list of sequential equivalences into a file\n" );
-    Abc_Print( -2, "\t             (if <file_in> is in BENCH, init state file should be the same directory)\n" );
-    Abc_Print( -2, "\t-C num     : limit on the number of conflicts [default = %d]\n", nConfMax );
-    Abc_Print( -2, "\t-S num     : limit on refinement iterations (-1=no limit, 0=after BMC, etc) [default = %d]\n", nStepsMax );
-    Abc_Print( -2, "\t-n         : toggle between \"scorr\" and \"&scorr\" [default = %s]\n", fNewAlgo? "&scorr": "scorr" );
-    Abc_Print( -2, "\t-f         : toggle reporting only flop/flop equivs [default = %s]\n", fFlopOnly? "yes": "no" );
-    Abc_Print( -2, "\t-s         : toggle reporting only flop/flop and flop/node equivs [default = %s]\n", fFfNdOnly? "yes": "no" );
-    Abc_Print( -2, "\t-v         : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h         : print the command usage\n");
-    Abc_Print( -2, "\t<file_in>  : input file with design for sequential equivalence computation\n");
-    Abc_Print( -2, "\t<file_out> : output file with the list of pairs of equivalent signals\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandLcorr( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c;
-    int nFramesP;
-    int nConfMax;
-    int nVarsMax;
-    int fNewAlgor;
-    int fVerbose;
-    extern Abc_Ntk_t * Abc_NtkDarLcorr( Abc_Ntk_t * pNtk, int nFramesP, int nConfMax, int fVerbose );
-    extern Abc_Ntk_t * Abc_NtkDarLcorrNew( Abc_Ntk_t * pNtk, int nVarsMax, int nConfMax, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-
-
-
-    // set defaults
-    nFramesP   =     0;
-    nConfMax   =  1000;
-    nVarsMax   =  1000;
-    fNewAlgor  =     1;
-    fVerbose   =     0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "PCSnvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'P':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFramesP = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFramesP < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nConfMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nConfMax < 0 )
-                goto usage;
-            break;
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nVarsMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nVarsMax < 0 )
-                goto usage;
-            break;
-        case 'n':
-            fNewAlgor ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( Abc_NtkIsComb(pNtk) )
-    {
-        Abc_Print( -1, "The network is combinational (run \"fraig\" or \"fraig_sweep\").\n" );
-        return 0;
-    }
-
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for structrally hashed networks. Run \"st\".\n" );
-        return 0;
-    }
-
-    // get the new network
-    if ( fNewAlgor )
-        pNtkRes = Abc_NtkDarLcorrNew( pNtk, nVarsMax, nConfMax, fVerbose );
-    else
-        pNtkRes = Abc_NtkDarLcorr( pNtk, nFramesP, nConfMax, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Sequential sweeping has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: lcorr [-PCS num] [-nvh]\n" );
-    Abc_Print( -2, "\t         computes latch correspondence using 1-step induction\n" );
-    Abc_Print( -2, "\t-P num : number of time frames to use as the prefix [default = %d]\n", nFramesP );
-    Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfMax );
-    Abc_Print( -2, "\t-S num : the max number of SAT variables [default = %d]\n", nVarsMax );
-    Abc_Print( -2, "\t-n     : toggle using new algorithm [default = %s]\n", fNewAlgor? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandSeqCleanup( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int c;
-    int fLatchConst  =   1;
-    int fLatchEqual  =   1;
-    int fSaveNames   =   1;
-    int fUseMvSweep  =   0;
-    int nFramesSymb  =   1;
-    int nFramesSatur = 512;
-    int fVerbose     =   0;
-    int fVeryVerbose =   0;
-    pNtk = Abc_FrameReadNtk(pAbc);
-
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "cenmFSvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'c':
-            fLatchConst ^= 1;
-            break;
-        case 'e':
-            fLatchEqual ^= 1;
-            break;
-        case 'n':
-            fSaveNames ^= 1;
-            break;
-        case 'm':
-            fUseMvSweep ^= 1;
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFramesSymb = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFramesSymb < 0 )
-                goto usage;
-            break;
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFramesSatur = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFramesSatur < 0 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'w':
-            fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Only works for structrally hashed networks.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkLatchNum(pNtk) )
-    {
-        Abc_Print( -1, "The network is combinational.\n" );
-        return 0;
-    }
-    // modify the current network
-    pNtkRes = Abc_NtkDarLatchSweep( pNtk, fLatchConst, fLatchEqual, fSaveNames, fUseMvSweep, nFramesSymb, nFramesSatur, fVerbose, fVeryVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Sequential cleanup has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: scleanup [-cenmFSvwh]\n" );
-    Abc_Print( -2, "\t         performs sequential cleanup of the current network\n" );
-    Abc_Print( -2, "\t         by removing nodes and latches that do not feed into POs\n" );
-    Abc_Print( -2, "\t-c     : sweep stuck-at latches detected by ternary simulation [default = %s]\n", fLatchConst? "yes": "no" );
-    Abc_Print( -2, "\t-e     : merge equal latches (same data inputs and init states) [default = %s]\n", fLatchEqual? "yes": "no" );
-    Abc_Print( -2, "\t-n     : toggle preserving latch names [default = %s]\n", fSaveNames? "yes": "no" );
-    Abc_Print( -2, "\t-m     : toggle using hybrid ternary/symbolic simulation [default = %s]\n", fUseMvSweep? "yes": "no" );
-    Abc_Print( -2, "\t-F num : the number of first frames simulated symbolically [default = %d]\n", nFramesSymb );
-    Abc_Print( -2, "\t-S num : the number of frames when symbolic saturation begins [default = %d]\n", nFramesSatur );
-    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w     : toggle very verbose output [default = %s]\n", fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandCycle( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int nFrames;
-    int fUseXval;
-    int fVerbose;
-    extern void Abc_NtkCycleInitState( Abc_Ntk_t * pNtk, int nFrames, int fUseXval, int fVerbose );
-    extern void Abc_NtkCycleInitStateSop( Abc_Ntk_t * pNtk, int nFrames, int fVerbose );
-    // set defaults
-    nFrames    = 100;
-    fUseXval   =   0;
-    fVerbose   =   0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Fxvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFrames = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFrames < 0 )
-                goto usage;
-            break;
-        case 'x':
-            fUseXval ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsStrash(pNtk) && !Abc_NtkIsSopLogic(pNtk) )
-    {
-        Abc_Print( -1, "Only works for strashed networks or logic SOP networks.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkLatchNum(pNtk) )
-    {
-        Abc_Print( -1, "The network is combinational.\n" );
-        return 0;
-    }
-    if ( fUseXval && !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "X-valued simulation only works for AIGs. Run \"strash\".\n" );
-        return 0;
-    }
-    if ( fUseXval )
-        Abc_NtkCycleInitState( pNtk, nFrames, 1, fVerbose );
-    else if ( Abc_NtkIsStrash(pNtk) )
-        Abc_NtkCycleInitState( pNtk, nFrames, 0, fVerbose );
-    else
-        Abc_NtkCycleInitStateSop( pNtk, nFrames, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: cycle [-F num] [-xvh]\n" );
-    Abc_Print( -2, "\t         cycles sequential circuit for the given number of timeframes\n" );
-    Abc_Print( -2, "\t         to derive a new initial state (which may be on the envelope)\n" );
-    Abc_Print( -2, "\t-F num : the number of frames to simulate [default = %d]\n", nFrames );
-    Abc_Print( -2, "\t-x     : use x-valued primary inputs [default = %s]\n", fUseXval? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandXsim( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int nFrames;
-    int fXInputs;
-    int fXState;
-    int fVerbose;
-    extern void Abc_NtkXValueSimulate( Abc_Ntk_t * pNtk, int nFrames, int fXInputs, int fXState, int fVerbose );
-    // set defaults
-    nFrames    = 10;
-    fXInputs   =  0;
-    fXState    =  0;
-    fVerbose   =  0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Fisvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFrames = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFrames < 0 )
-                goto usage;
-            break;
-        case 'i':
-            fXInputs ^= 1;
-            break;
-        case 's':
-            fXState ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Only works for strashed networks.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkLatchNum(pNtk) )
-    {
-        Abc_Print( -1, "The network is combinational.\n" );
-        return 0;
-    }
-    Abc_NtkXValueSimulate( pNtk, nFrames, fXInputs, fXState, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: xsim [-F num] [-isvh]\n" );
-    Abc_Print( -2, "\t         performs X-valued simulation of the AIG\n" );
-    Abc_Print( -2, "\t-F num : the number of frames to simulate [default = %d]\n", nFrames );
-    Abc_Print( -2, "\t-i     : toggle X-valued representation of inputs [default = %s]\n", fXInputs? "yes": "no" );
-    Abc_Print( -2, "\t-s     : toggle X-valued representation of state [default = %s]\n", fXState? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandSim( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int fNew;
-    int fComb;
-    int nFrames;
-    int nWords;
-    int TimeOut;
-    int fMiter;
-    int fVerbose;
-    char * pFileSim;
-    extern int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, int fNew, int fMiter, int fVerbose, char * pFileSim );
-    // set defaults
-    fNew       =  0;
-    fComb      =  0;
-    nFrames    = 32;
-    nWords     =  8;
-    TimeOut    = 30;
-    fMiter     =  1;
-    fVerbose   =  0;
-    pFileSim   = NULL;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "FWTAnmvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFrames = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFrames < 0 )
-                goto usage;
-            break;
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nWords = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nWords < 0 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            TimeOut = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( TimeOut < 0 )
-                goto usage;
-            break;
-        case 'A':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-A\" should be followed by a file name.\n" );
-                goto usage;
-            }
-            pFileSim = argv[globalUtilOptind];
-            globalUtilOptind++;
-            break;
-        case 'n':
-            fNew ^= 1;
-            break;
-        case 'm':
-            fMiter ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Only works for strashed networks.\n" );
-        return 1;
-    }
-    if ( pFileSim != NULL && Abc_NtkLatchNum(pNtk) )
-    {
-        Abc_Print( -1, "Currently simulation with user-specified patterns works only for comb miters.\n" );
-        return 1;
-    }
-    ABC_FREE( pNtk->pSeqModel );
-    pAbc->Status = Abc_NtkDarSeqSim( pNtk, nFrames, nWords, TimeOut, fNew, fMiter, fVerbose, pFileSim );
-    Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: sim [-FWT num] [-A file] [-nmvh]\n" );
-    Abc_Print( -2, "\t          performs random simulation of the sequential miter\n" );
-    Abc_Print( -2, "\t-F num  : the number of frames to simulate [default = %d]\n", nFrames );
-    Abc_Print( -2, "\t-W num  : the number of words to simulate [default = %d]\n", nWords );
-    Abc_Print( -2, "\t-T num  : approximate runtime limit in seconds [default = %d]\n", TimeOut );
-    Abc_Print( -2, "\t-A file : text file name with user's patterns [default = random simulation]\n" );
-    Abc_Print( -2, "\t          (patterns are listed, one per line, as sequences of 0s and 1s)\n" );
-    Abc_Print( -2, "\t-n      : toggle new vs. old implementation [default = %s]\n", fNew? "new": "old" );
-    Abc_Print( -2, "\t-m      : toggle miter vs. any circuit [default = %s]\n", fMiter? "miter": "circuit" );
-    Abc_Print( -2, "\t-v      : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h      : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandSim3( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern int Abc_NtkDarSeqSim3( Abc_Ntk_t * pNtk, Ssw_RarPars_t * pPars );
-    Ssw_RarPars_t Pars, * pPars = &Pars;
-    Abc_Ntk_t * pNtkRes, * pNtk = Abc_FrameReadNtk(pAbc);
-    Vec_Ptr_t * vSeqModelVec; 
-    int c;
-    Ssw_RarSetDefaultParams( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "FWBRSNTGadivzh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nFrames = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nFrames < 0 )
-                goto usage;
-            break;
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nWords = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nWords < 0 )
-                goto usage;
-            break;
-        case 'B':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nBinSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nBinSize < 0 )
-                goto usage;
-            break;
-        case 'R':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nRounds = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nRounds < 0 )
-                goto usage;
-            break;
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nRestart = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nRestart < 0 )
-                goto usage;
-            break;
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nRandSeed = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nRandSeed < 0 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->TimeOut = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->TimeOut < 0 )
-                goto usage;
-            break;
-        case 'G':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-G\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->TimeOutGap = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->TimeOutGap < 0 )
-                goto usage;
-            break;
-        case 'a':
-            pPars->fSolveAll ^= 1;
-            break;
-        case 'd':
-            pPars->fDropSatOuts ^= 1;
-            break;
-        case 'i':
-            pPars->fSetLastState ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'z':
-            pPars->fNotVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Only works for strashed networks.\n" );
-        return 1;
-    }
-    if ( Abc_NtkLatchNum(pNtk) == 0 )
-    {
-        Abc_Print( -1, "Only works for sequential networks.\n" );
-        return 1;
-    }
-    ABC_FREE( pNtk->pSeqModel );
-    pAbc->Status = Abc_NtkDarSeqSim3( pNtk, pPars );
-    Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
-    vSeqModelVec = pNtk->vSeqModelVec;  pNtk->vSeqModelVec = NULL;
-    if ( pPars->fSetLastState && pAbc->pNtkCur->pData )
-    {
-        Abc_Obj_t * pObj;
-        Vec_Int_t * vInit = (Vec_Int_t *)pAbc->pNtkCur->pData;
-        pAbc->pNtkCur->pData = NULL;
-        Abc_NtkForEachLatch( pAbc->pNtkCur, pObj, c )
-            if ( Vec_IntEntry(vInit, c) )
-                Abc_LatchSetInit1( pObj );
-        Vec_IntFree( vInit );
-        pNtkRes = Abc_NtkRestrashZero( pAbc->pNtkCur, 0 );
-        if ( pNtkRes == NULL )
-        {
-            Abc_Print( -1, "Removing SAT outputs has failed.\n" );
-            return 1;
-        }
-        Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-        pNtk = Abc_FrameReadNtk(pAbc);
-    }
-    if ( pPars->fSolveAll && pPars->fDropSatOuts )
-    {
-        if ( vSeqModelVec == NULL )
-            Abc_Print( 1,"The array of counter-examples is not available.\n" );
-        else if ( Vec_PtrSize(vSeqModelVec) != Abc_NtkPoNum(pNtk) )
-            Abc_Print( 1,"The array size does not match the number of outputs.\n" );
-        else
-        {
-            extern void Abc_NtkDropSatOutputs( Abc_Ntk_t * pNtk, Vec_Ptr_t * vCexes, int fVerbose );
-            Abc_NtkDropSatOutputs( pNtk, vSeqModelVec, pPars->fVerbose );
-            pNtkRes = Abc_NtkDarLatchSweep( pNtk, 1, 1, 1, 0, -1, -1, 0, 0 );
-            if ( pNtkRes == NULL )
-            {
-                Abc_Print( -1, "Removing SAT outputs has failed.\n" );
-                return 1;
-            }
-            Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-        }
-    }
-    if ( vSeqModelVec )
-    {
-        Abc_FrameReplaceCexVec( pAbc, &vSeqModelVec );
-        pAbc->nFrames = -1;
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: sim3 [-FWBRSNTG num] [-advzh]\n" );
-    Abc_Print( -2, "\t         performs random simulation of the sequential miter\n" );
-    Abc_Print( -2, "\t-F num : the number of frames to simulate [default = %d]\n",                         pPars->nFrames );
-    Abc_Print( -2, "\t-W num : the number of words to simulate [default = %d]\n",                          pPars->nWords );
-    Abc_Print( -2, "\t-B num : the number of flops in one bin [default = %d]\n",                           pPars->nBinSize );
-    Abc_Print( -2, "\t-R num : the number of simulation rounds [default = %d]\n",                          pPars->nRounds );
-    Abc_Print( -2, "\t-S num : the number of rounds before a restart [default = %d]\n",                    pPars->nRestart );
-    Abc_Print( -2, "\t-N num : random number seed (1 <= num <= 1000) [default = %d]\n",                    pPars->nRandSeed );
-    Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n",                     pPars->TimeOut );
-    Abc_Print( -2, "\t-G num : approximate runtime gap in seconds since the last CEX [default = %d]\n",    pPars->TimeOutGap );
-    Abc_Print( -2, "\t-a     : toggle solving all outputs (do not stop when one is SAT) [default = %s]\n", pPars->fSolveAll?    "yes": "no" );
-    Abc_Print( -2, "\t-d     : toggle dropping (replacing by 0) SAT outputs [default = %s]\n",             pPars->fDropSatOuts? "yes": "no" );
-    Abc_Print( -2, "\t-i     : toggle changing init state to a last rare state [default = %s]\n",          pPars->fVerbose?     "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n",                      pPars->fVerbose?     "yes": "no" );
-    Abc_Print( -2, "\t-z     : toggle suppressing report about solved outputs [default = %s]\n",           pPars->fNotVerbose?  "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandDarPhase( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int nFrames, nPref;
-    int fIgnore;
-    int fPrint;
-    int fUpdateCex;
-    int c, fVerbose;
-    extern Abc_Ntk_t * Abc_NtkPhaseAbstract( Abc_Ntk_t * pNtk, int nFrames, int nPref, int fIgnore, int fPrint, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    nFrames     = 0;
-    nPref       = 0;
-    fIgnore     = 0;
-    fPrint      = 0;
-    fUpdateCex  = 0;
-    fVerbose    = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "FPipcvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFrames = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFrames < 0 )
-                goto usage;
-            break;
-        case 'P':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nPref = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nPref < 0 )
-                goto usage;
-            break;
-        case 'i':
-            fIgnore ^= 1;
-            break;
-        case 'p':
-            fPrint ^= 1;
-            break;
-        case 'c':
-            fUpdateCex ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Only works for structrally hashed networks.\n" );
-        return 1;
-    }
-    if ( fUpdateCex )
-    {
-        Abc_Cex_t * pCexNew;
-        if ( pAbc->pCex == NULL )
-        {
-            Abc_Print( -1, "Counter-example is not available.\n" );
-            return 1;
-        }
-        if ( pAbc->pCex->nPis % Abc_NtkPiNum(pNtk) != 0 )
-        {
-            Abc_Print( -1, "PI count of the CEX is not a multiple of PI count of the current AIG.\n" );
-            return 1;
-        }
-        pCexNew = Abc_CexTransformPhase( pAbc->pCex, Abc_NtkPiNum(pNtk), Abc_NtkPoNum(pNtk), Abc_NtkLatchNum(pNtk) );
-        {
-            Aig_Man_t * pAig = Abc_NtkToDar( pNtk, 0, 1 );
-            Gia_Man_t * pGia = Gia_ManFromAig( pAig );
-            int iPo = Gia_ManSetFailedPoCex( pGia, pCexNew );
-            Gia_ManStop( pGia );
-            Aig_ManStop( pAig );
-            if ( iPo == -1 )
-            {
-                Abc_Print( -1, "The counter-example does not fail any of the outputs of the original AIG.\n" );
-                return 1;
-            }
-        }
-        Abc_FrameReplaceCex( pAbc, &pCexNew );
-        return 0;
-    }
-    if ( !Abc_NtkLatchNum(pNtk) )
-    {
-        Abc_Print( -1, "The network is combinational.\n" );
-        return 0;
-    }
-    if ( fPrint )
-    {
-        Abc_NtkPhaseAbstract( pNtk, 0, nPref, fIgnore, 1, fVerbose );
-        return 0;
-    }
-    // modify the current network
-    pNtkRes = Abc_NtkPhaseAbstract( pNtk, nFrames, nPref, fIgnore, 0, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-//        Abc_Print( -1, "Phase abstraction has failed.\n" );
-        return 0;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: phase [-FP <num>] [-ipcvh]\n" );
-    Abc_Print( -2, "\t         performs sequential cleanup of the current network\n" );
-    Abc_Print( -2, "\t         by removing nodes and latches that do not feed into POs\n" );
-    Abc_Print( -2, "\t-F num : the number of frames to abstract [default = %d]\n", nFrames );
-    Abc_Print( -2, "\t-P num : the number of prefix frames to skip [default = %d]\n", nPref );
-    Abc_Print( -2, "\t-i     : toggle ignoring the initial state [default = %s]\n", fIgnore? "yes": "no" );
-    Abc_Print( -2, "\t-p     : toggle printing statistics about generators [default = %s]\n", fPrint? "yes": "no" );
-    Abc_Print( -2, "\t-c     : update the current CEX derived for a new AIG after \"phase\"\n" );
-    Abc_Print( -2, "\t         to match the current AIG (the one before \"phase\") [default = %s]\n", fUpdateCex? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandSynch( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtkRes, * pNtk1, * pNtk2, * pNtk;
-    char ** pArgvNew;
-    int nArgcNew;
-    int fDelete1, fDelete2;
-    int c;
-    int nWords;
-    int fVerbose;
-
-    extern Abc_Ntk_t * Abc_NtkDarSynch( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nWords, int fVerbose );
-    extern Abc_Ntk_t * Abc_NtkDarSynchOne( Abc_Ntk_t * pNtk, int nWords, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    nWords   =  32;
-    fVerbose =   1;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Wvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nWords = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nWords <= 0 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    pArgvNew = argv + globalUtilOptind;
-    nArgcNew = argc - globalUtilOptind;
-    if ( nArgcNew == 0 )
-    {
-        if ( pNtk == NULL )
-        {
-            Abc_Print( -1, "Empty network.\n" );
-            return 1;
-        }
-        pNtkRes = Abc_NtkDarSynchOne( pNtk, nWords, fVerbose );
-    }
-    else
-    {
-        if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
-            return 1;
-        if ( Abc_NtkLatchNum(pNtk1) == 0 || Abc_NtkLatchNum(pNtk2) == 0 )
-        {
-            if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
-            if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
-            Abc_Print( -1, "The network has no latches..\n" );
-            return 0;
-        }
-
-        // modify the current network
-        pNtkRes = Abc_NtkDarSynch( pNtk1, pNtk2, nWords, fVerbose );
-        if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
-        if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
-    }
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Synchronization has failed.\n" );
-        return 0;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: synch [-W <num>] [-vh] <file1> <file2>\n" );
-    Abc_Print( -2, "\t         derives and applies synchronization sequence\n" );
-    Abc_Print( -2, "\t-W num : the number of simulation words [default = %d]\n", nWords );
-    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\tfile1  : (optional) the file with the first design\n");
-    Abc_Print( -2, "\tfile2  : (optional) the file with the second design\n\n");
-    Abc_Print( -2, "\t         If no designs are given on the command line,\n" );
-    Abc_Print( -2, "\t         assumes the current network has no initial state,\n" );
-    Abc_Print( -2, "\t         derives synchronization sequence and applies it.\n\n" );
-    Abc_Print( -2, "\t         If two designs are given on the command line\n" );
-    Abc_Print( -2, "\t         assumes both of them have no initial state,\n" );
-    Abc_Print( -2, "\t         derives sequences for both designs, synchorinizes\n" );
-    Abc_Print( -2, "\t         them, and creates SEC miter comparing two designs.\n\n" );
-    Abc_Print( -2, "\t         If only one design is given on the command line,\n" );
-    Abc_Print( -2, "\t         considers the second design to be the current network,\n" );
-    Abc_Print( -2, "\t         and derives SEC miter for them, as described above.\n" );
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandClockGate( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Cgt_Par_t Pars, * pPars = &Pars;
-    Abc_Ntk_t * pNtkRes, * pNtk, * pNtkCare;
-    int c;
-
-    extern Abc_Ntk_t * Abc_NtkDarClockGate( Abc_Ntk_t * pNtk, Abc_Ntk_t * pCare, Cgt_Par_t * pPars );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    Cgt_SetDefaultParams( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "LNDCVKavwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nLevelMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nLevelMax <= 0 )
-                goto usage;
-            break;
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nCandMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nCandMax <= 0 )
-                goto usage;
-            break;
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nOdcMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nOdcMax <= 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nConfMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nConfMax <= 0 )
-                goto usage;
-            break;
-        case 'V':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-V\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nVarsMin = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nVarsMin <= 0 )
-                goto usage;
-            break;
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nFlopsMin = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nFlopsMin <= 0 )
-                goto usage;
-            break;
-        case 'a':
-            pPars->fAreaOnly ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'w':
-            pPars->fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( argc == globalUtilOptind + 1 )
-    {
-        pNtkCare = Io_Read( argv[globalUtilOptind], Io_ReadFileType(argv[globalUtilOptind]), 1, 0 );
-        if ( pNtkCare == NULL )
-        {
-            Abc_Print( -1, "Reading care network has failed.\n" );
-            return 1;
-        }
-        // modify the current network
-        pNtkRes = Abc_NtkDarClockGate( pNtk, pNtkCare, pPars );
-        Abc_NtkDelete( pNtkCare );
-    }
-    else if ( argc == globalUtilOptind )
-    {
-        pNtkRes = Abc_NtkDarClockGate( pNtk, NULL, pPars );
-    }
-    else
-    {
-        Abc_Print( -1, "Wrong number of arguments.\n" );
-        return 0;
-    }
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Clock gating has failed.\n" );
-        return 0;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: clockgate [-LNDCVK <num>] [-avwh] <file>\n" );
-    Abc_Print( -2, "\t         sequential clock gating with observability don't-cares\n" );
-    Abc_Print( -2, "\t-L num : max level number of a clock gate [default = %d]\n", pPars->nLevelMax );
-    Abc_Print( -2, "\t-N num : max number of candidates for a flop [default = %d]\n", pPars->nCandMax );
-    Abc_Print( -2, "\t-D num : max number of ODC levels to consider [default = %d]\n", pPars->nOdcMax );
-    Abc_Print( -2, "\t-C num : max number of conflicts at a node [default = %d]\n", pPars->nConfMax );
-    Abc_Print( -2, "\t-V num : min number of vars to recycle SAT solver [default = %d]\n", pPars->nVarsMin );
-    Abc_Print( -2, "\t-K num : min number of flops to recycle SAT solver [default = %d]\n", pPars->nFlopsMin );
-    Abc_Print( -2, "\t-a     : toggle minimizing area-only [default = %s]\n", pPars->fAreaOnly? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w     : toggle even more detailed output [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\tfile   : (optional) constraints for primary inputs and register outputs\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandExtWin( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtkRes, * pNtk;
-    int c;
-    int nObjId;
-    int nDist;
-    int fVerbose;
-
-    extern Abc_Ntk_t * Abc_NtkDarExtWin( Abc_Ntk_t * pNtk, int nObjId, int nDist, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    nObjId   = -1;
-    nDist    =  5;
-    fVerbose =  0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "NDvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nObjId = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nObjId <= 0 )
-                goto usage;
-            break;
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nDist = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nDist <= 0 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Only works for structrally hashed networks.\n" );
-        return 1;
-    }
-
-    if ( argc != globalUtilOptind )
-    {
-        Abc_Print( -1, "Not enough command-line arguments.\n" );
-        return 1;
-    }
-    // modify the current network
-    pNtkRes = Abc_NtkDarExtWin( pNtk, nObjId, nDist, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Extracting sequential window has failed.\n" );
-        return 0;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: extwin [-ND <num>] [-vh]\n" );
-    Abc_Print( -2, "\t         extracts sequential window from the AIG\n" );
-    Abc_Print( -2, "\t-N num : the ID of the object to use as the center [default = %d]\n", nObjId );
-    Abc_Print( -2, "\t-D num : the \"radius\" of the window [default = %d]\n", nDist );
-    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandInsWin( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtkRes, * pNtk, * pNtkCare;
-    int c;
-    int nObjId;
-    int nDist;
-    int fVerbose;
-
-    extern Abc_Ntk_t * Abc_NtkDarInsWin( Abc_Ntk_t * pNtk, Abc_Ntk_t * pWnd, int nObjId, int nDist, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    nObjId   = -1;
-    nDist    =  5;
-    fVerbose =  0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "NDvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nObjId = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nObjId <= 0 )
-                goto usage;
-            break;
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nDist = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nDist <= 0 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Only works for structrally hashed networks.\n" );
-        return 1;
-    }
-
-    if ( argc != globalUtilOptind + 1 )
-    {
-        Abc_Print( -1, "Not enough command-line arguments.\n" );
-        return 1;
-    }
-    pNtkCare = Io_Read( argv[globalUtilOptind], Io_ReadFileType(argv[globalUtilOptind]), 1, 0 );
-    if ( pNtkCare == NULL )
-    {
-        Abc_Print( -1, "Reading care network has failed.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtkCare) )
-    {
-        Abc_Ntk_t * pNtkTemp;
-        pNtkCare = Abc_NtkStrash( pNtkTemp = pNtkCare, 0, 1, 0 );
-        Abc_NtkDelete( pNtkTemp );
-    }
-    // modify the current network
-    pNtkRes = Abc_NtkDarInsWin( pNtk, pNtkCare, nObjId, nDist, fVerbose );
-    Abc_NtkDelete( pNtkCare );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Inserting sequential window has failed.\n" );
-        return 0;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: inswin [-ND <num>] [-vh] <file>\n" );
-    Abc_Print( -2, "\t         inserts sequential window into the AIG\n" );
-    Abc_Print( -2, "\t-N num : the ID of the object to use as the center [default = %d]\n", nObjId );
-    Abc_Print( -2, "\t-D num : the \"radius\" of the window [default = %d]\n", nDist );
-    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\tfile   : file with the AIG to be inserted\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandPermute( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Abc_Ntk_t * Abc_NtkRestrashRandom( Abc_Ntk_t * pNtk );
-    Abc_Ntk_t * pNtk = pAbc->pNtkCur, * pNtkRes = NULL;
-    char * pFlopPermFile = NULL;
-    int fInputs = 1;
-    int fOutputs = 1;
-    int fFlops = 1;
-    int fNodes = 1;
-    int c;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Fiofnh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by a file name.\n" );
-                goto usage;
-            }
-            pFlopPermFile = argv[globalUtilOptind];
-            globalUtilOptind++;
-            break;
-        case 'i':
-            fInputs ^= 1;
-            break;
-        case 'o':
-            fOutputs ^= 1;
-            break;
-        case 'f':
-            fFlops ^= 1;
-            break;
-        case 'n':
-            fNodes ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            Abc_Print( -2, "Unknown switch.\n");
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( fNodes && !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "To permute nodes, the network should be structurally hashed.\n" );
-        return 1;
-    }
-    if ( fNodes )
-        pNtkRes = Abc_NtkRestrashRandom( pNtk );
-    else
-        pNtkRes = Abc_NtkDup( pNtk );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Command \"permute\" has failed.\n" );
-        return 1;
-    }
-    Abc_NtkPermute( pNtkRes, fInputs, fOutputs, fFlops, pFlopPermFile );
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: permute [-iofnh] [-F filename]\n" );
-    Abc_Print( -2, "\t                performs random permutation of inputs/outputs/flops\n" );
-    Abc_Print( -2, "\t-i            : toggle permuting primary inputs [default = %s]\n", fInputs? "yes": "no" );
-    Abc_Print( -2, "\t-o            : toggle permuting primary outputs [default = %s]\n", fOutputs? "yes": "no" );
-    Abc_Print( -2, "\t-f            : toggle permuting flip-flops [default = %s]\n", fFlops? "yes": "no" );
-    Abc_Print( -2, "\t-n            : toggle deriving new topological ordering of nodes [default = %s]\n", fNodes? "yes": "no" );
-    Abc_Print( -2, "\t-h            : print the command usage\n");
-    Abc_Print( -2, "\t-F <filename> : (optional) file with the flop permutation\n" );
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandUnpermute( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = pAbc->pNtkCur, * pNtkRes = NULL;
-    int c;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            Abc_Print( -2, "Unknown switch.\n");
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    pNtkRes = Abc_NtkDup( pNtk );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Command \"unpermute\" has failed.\n" );
-        return 1;
-    }
-    Abc_NtkUnpermute( pNtkRes );
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: unpermute [-h]\n" );
-    Abc_Print( -2, "\t        restores inputs/outputs/flops before the last permutation\n" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandCubeEnum( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern void Abc_EnumerateCubeStates();
-    extern void Abc_EnumerateCubeStatesZdd();
-    int c, fZddAlgo = 0, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "zvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'z':
-            fZddAlgo ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            Abc_Print( -2, "Unknown switch.\n");
-            goto usage;
-        }
-    }
-    if ( fZddAlgo )
-        Abc_EnumerateCubeStatesZdd();
-    else
-        Abc_EnumerateCubeStates();
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: cubeenum [-vh]\n" );
-    Abc_Print( -2, "\t         enumerates reachable states of 2x2x2 cube\n" );
-    Abc_Print( -2, "\t         (http://en.wikipedia.org/wiki/Pocket_Cube)\n" );
-    Abc_Print( -2, "\t-z     : toggle using ZDD-based algorithm [default = %s]\n", fZddAlgo? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandCec( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    char Buffer[16];
-    Abc_Ntk_t * pNtk, * pNtk1, * pNtk2;
-    int fDelete1, fDelete2;
-    char ** pArgvNew;
-    int nArgcNew;
-    int c;
-    int fSat;
-    int fVerbose;
-    int nSeconds;
-    int nPartSize;
-    int nConfLimit;
-    int nInsLimit;
-    int fPartition;
-    int fIgnoreNames;
-
-    extern void Abc_NtkCecSat( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nConfLimit, int nInsLimit );
-    extern void Abc_NtkCecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds, int fVerbose );
-    extern void Abc_NtkCecFraigPart( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds, int nPartSize, int fVerbose );
-    extern void Abc_NtkCecFraigPartAuto( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    fSat     =  0;
-    fVerbose =  0;
-    nSeconds = 20;
-    nPartSize  = 0;
-    nConfLimit = 10000;
-    nInsLimit  = 0;
-    fPartition = 0;
-    fIgnoreNames = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "TCIPpsnvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nSeconds = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nSeconds < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nConfLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nConfLimit < 0 )
-                goto usage;
-            break;
-        case 'I':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nInsLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nInsLimit < 0 )
-                goto usage;
-            break;
-        case 'P':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nPartSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nPartSize < 0 )
-                goto usage;
-            break;
-        case 'p':
-            fPartition ^= 1;
-            break;
-        case 's':
-            fSat ^= 1;
-            break;
-        case 'n':
-            fIgnoreNames ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk && pNtk->vPhases != NULL )
-    {
-        Abc_Print( -1, "Cannot compare networks with phases defined.\n" );
-        return 1;
-    }
-
-    pArgvNew = argv + globalUtilOptind;
-    nArgcNew = argc - globalUtilOptind;
-    if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
-        return 1;
-
-    if ( fIgnoreNames )
-    {
-        if ( !fDelete1 )
-        {
-            pNtk1 = Abc_NtkStrash( pNtk1, 0, 1, 0 );
-            fDelete1 = 1;
-        }
-        if ( !fDelete2 )
-        {
-            pNtk2 = Abc_NtkStrash( pNtk2, 0, 1, 0 );
-            fDelete2 = 1;
-        }
-        Abc_NtkShortNames( pNtk1 );
-        Abc_NtkShortNames( pNtk2 );
-    }
-
-    // perform equivalence checking
-    if ( fPartition )
-        Abc_NtkCecFraigPartAuto( pNtk1, pNtk2, nSeconds, fVerbose );
-    else if ( nPartSize )
-        Abc_NtkCecFraigPart( pNtk1, pNtk2, nSeconds, nPartSize, fVerbose );
-    else if ( fSat )
-        Abc_NtkCecSat( pNtk1, pNtk2, nConfLimit, nInsLimit );
-    else
-        Abc_NtkCecFraig( pNtk1, pNtk2, nSeconds, fVerbose );
-
-    if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
-    if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
-    return 0;
-
-usage:
-    if ( nPartSize == 0 )
-        strcpy( Buffer, "unused" );
-    else
-        sprintf(Buffer, "%d", nPartSize );
-    Abc_Print( -2, "usage: cec [-T num] [-C num] [-I num] [-P num] [-psnvh] <file1> <file2>\n" );
-    Abc_Print( -2, "\t         performs combinational equivalence checking\n" );
-    Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", nSeconds );
-    Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n",    nConfLimit );
-    Abc_Print( -2, "\t-I num : limit on the number of clause inspections [default = %d]\n", nInsLimit );
-    Abc_Print( -2, "\t-P num : partition size for multi-output networks [default = %s]\n", Buffer );
-    Abc_Print( -2, "\t-p     : toggle automatic partitioning [default = %s]\n", fPartition? "yes": "no" );
-    Abc_Print( -2, "\t-s     : toggle \"SAT only\" and \"FRAIG + SAT\" [default = %s]\n", fSat? "SAT only": "FRAIG + SAT" );
-    Abc_Print( -2, "\t-n     : toggle ignoring names when matching CIs/COs [default = %s]\n", fIgnoreNames? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\tfile1  : (optional) the file with the first network\n");
-    Abc_Print( -2, "\tfile2  : (optional) the file with the second network\n");
-    Abc_Print( -2, "\t         if no files are given, uses the current network and its spec\n");
-    Abc_Print( -2, "\t         if one file is given, uses the current network and the file\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandDCec( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtk1, * pNtk2;
-    int fDelete1, fDelete2;
-    char ** pArgvNew;
-    int nArgcNew;
-    int c;
-    int fSat;
-    int fVerbose;
-    int nSeconds;
-    int nConfLimit;
-    int nInsLimit;
-    int fPartition;
-    int fMiter;
-
-    extern int Abc_NtkDSat( Abc_Ntk_t * pNtk, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, int nLearnedStart, int nLearnedDelta, int nLearnedPerce, int fAlignPol, int fAndOuts, int fNewSolver, int fVerbose );
-    extern int Abc_NtkDarCec( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nConfLimit, int fPartition, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    fSat     =  0;
-    fVerbose =  0;
-    nSeconds = 20;
-    nConfLimit = 10000;
-    nInsLimit  = 0;
-    fPartition = 0;
-    fMiter     = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "TCIpmsvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nSeconds = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nSeconds < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nConfLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nConfLimit < 0 )
-                goto usage;
-            break;
-        case 'I':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nInsLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nInsLimit < 0 )
-                goto usage;
-            break;
-        case 'p':
-            fPartition ^= 1;
-            break;
-        case 'm':
-            fMiter ^= 1;
-            break;
-        case 's':
-            fSat ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        default:
-            goto usage;
-        }
-    }
-
-    pArgvNew = argv + globalUtilOptind;
-    nArgcNew = argc - globalUtilOptind;
-    if ( fMiter )
-    {
-        if ( pNtk == NULL )
-        {
-            Abc_Print( -1, "Empty network.\n" );
-            return 1;
-        }
-        if ( Abc_NtkIsStrash(pNtk) )
-        {
-            pNtk1 = pNtk;
-            fDelete1 = 0;
-        }
-        else
-        {
-            pNtk1 = Abc_NtkStrash( pNtk, 0, 1, 0 );
-            fDelete1 = 1;
-        }
-        pNtk2 = NULL;
-        fDelete2 = 0;
-    }
-    else
-    {
-        if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
-            return 1;
-    }
-
-    if ( (pNtk1 && Abc_NtkLatchNum(pNtk1)) || (pNtk2 && Abc_NtkLatchNum(pNtk2)) )
-    {
-        if ( pNtk1 && fDelete1 ) Abc_NtkDelete( pNtk1 );
-        if ( pNtk2 && fDelete2 ) Abc_NtkDelete( pNtk2 );
-        Abc_Print( -1, "Currently this command only works for networks without latches. Run \"comb\".\n" );
-        return 1;
-    }
-
-    // perform equivalence checking
-    if ( fSat && fMiter )
-        Abc_NtkDSat( pNtk1, nConfLimit, nInsLimit, 0, 0, 0, 0, 0, 0, fVerbose );
-    else
-        Abc_NtkDarCec( pNtk1, pNtk2, nConfLimit, fPartition, fVerbose );
-
-    if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
-    if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: dcec [-T num] [-C num] [-I num] [-mpsvh] <file1> <file2>\n" );
-    Abc_Print( -2, "\t         performs combinational equivalence checking\n" );
-    Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", nSeconds );
-    Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n",    nConfLimit );
-    Abc_Print( -2, "\t-I num : limit on the number of clause inspections [default = %d]\n", nInsLimit );
-    Abc_Print( -2, "\t-m     : toggle working on two networks or a miter [default = %s]\n", fMiter? "miter": "two networks" );
-    Abc_Print( -2, "\t-p     : toggle automatic partitioning [default = %s]\n", fPartition? "yes": "no" );
-    Abc_Print( -2, "\t-s     : toggle \"SAT only\" (miter) or \"FRAIG + SAT\" [default = %s]\n", fSat? "SAT only": "FRAIG + SAT" );
-    Abc_Print( -2, "\t-v     : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\tfile1  : (optional) the file with the first network\n");
-    Abc_Print( -2, "\tfile2  : (optional) the file with the second network\n");
-    Abc_Print( -2, "\t         if no files are given, uses the current network and its spec\n");
-    Abc_Print( -2, "\t         if one file is given, uses the current network and the file\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandDSec( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Fra_Sec_t SecPar, * pSecPar = &SecPar;
-    Abc_Ntk_t * pNtk, * pNtk1, * pNtk2;
-    int fDelete1, fDelete2;
-    char ** pArgvNew;
-    int nArgcNew;
-    int c;
-    int fIgnoreNames;
-
-    extern void Fra_SecSetDefaultParams( Fra_Sec_t * p );
-    extern int Abc_NtkDarSec( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, Fra_Sec_t * p );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    Fra_SecSetDefaultParams( pSecPar );
-    pSecPar->TimeLimit = 0;
-    fIgnoreNames = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "FTarmfnwvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pSecPar->nFramesMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pSecPar->nFramesMax < 0 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pSecPar->TimeLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pSecPar->TimeLimit < 0 )
-                goto usage;
-            break;
-        case 'a':
-            pSecPar->fPhaseAbstract ^= 1;
-            break;
-        case 'r':
-            pSecPar->fRetimeFirst ^= 1;
-            break;
-        case 'm':
-            pSecPar->fRetimeRegs ^= 1;
-            break;
-        case 'f':
-            pSecPar->fFraiging ^= 1;
-            break;
-        case 'n':
-            fIgnoreNames ^= 1;
-            break;
-        case 'w':
-            pSecPar->fVeryVerbose ^= 1;
-            break;
-        case 'v':
-            pSecPar->fVerbose ^= 1;
-            break;
-        default:
-            goto usage;
-        }
-    }
-
-    pArgvNew = argv + globalUtilOptind;
-    nArgcNew = argc - globalUtilOptind;
-    if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
-        return 1;
-    if ( Abc_NtkLatchNum(pNtk1) == 0 || Abc_NtkLatchNum(pNtk2) == 0 )
-    {
-        if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
-        if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
-        Abc_Print( -1, "The network has no latches. Used combinational command \"cec\".\n" );
-        return 0;
-    }
-
-    if ( fIgnoreNames )
-    {
-        if ( !fDelete1 )
-        {
-            pNtk1 = Abc_NtkStrash( pNtk1, 0, 1, 0 );
-            fDelete1 = 1;
-        }
-        if ( !fDelete2 )
-        {
-            pNtk2 = Abc_NtkStrash( pNtk2, 0, 1, 0 );
-            fDelete2 = 1;
-        }
-        Abc_NtkShortNames( pNtk1 );
-        Abc_NtkShortNames( pNtk2 );
-    }
-
-    // perform verification
-    Abc_NtkDarSec( pNtk1, pNtk2, pSecPar );
-
-    if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
-    if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: dsec [-F num] [-T num] [-armfnwvh] <file1> <file2>\n" );
-    Abc_Print( -2, "\t         performs inductive sequential equivalence checking\n" );
-    Abc_Print( -2, "\t-F num : the limit on the depth of induction [default = %d]\n", pSecPar->nFramesMax );
-    Abc_Print( -2, "\t-T num : the approximate runtime limit (in seconds) [default = %d]\n", pSecPar->TimeLimit );
-    Abc_Print( -2, "\t-a     : toggles the use of phase abstraction [default = %s]\n", pSecPar->fPhaseAbstract? "yes": "no" );
-    Abc_Print( -2, "\t-r     : toggles forward retiming at the beginning [default = %s]\n", pSecPar->fRetimeFirst? "yes": "no" );
-    Abc_Print( -2, "\t-m     : toggles min-register retiming [default = %s]\n", pSecPar->fRetimeRegs? "yes": "no" );
-    Abc_Print( -2, "\t-f     : toggles the internal use of fraiging [default = %s]\n", pSecPar->fFraiging? "yes": "no" );
-    Abc_Print( -2, "\t-n     : toggle ignoring names when matching PIs/POs [default = %s]\n", fIgnoreNames? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggles verbose output [default = %s]\n", pSecPar->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w     : toggles additional verbose output [default = %s]\n", pSecPar->fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\tfile1  : (optional) the file with the first network\n");
-    Abc_Print( -2, "\tfile2  : (optional) the file with the second network\n");
-    Abc_Print( -2, "\t         if no files are given, uses the current network and its spec\n");
-    Abc_Print( -2, "\t         if one file is given, uses the current network and the file\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandDProve( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Fra_Sec_t SecPar, * pSecPar = &SecPar;
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    char * pLogFileName = NULL;
-    int nBmcFramesMax = 20;
-    int nBmcConfMax = 2000;
-
-    extern void Fra_SecSetDefaultParams( Fra_Sec_t * p );
-    extern int Abc_NtkDarProve( Abc_Ntk_t * pNtk, Fra_Sec_t * pSecPar, int nBmcFramesMax, int nBmcConfMax );
-    // set defaults
-    Fra_SecSetDefaultParams( pSecPar );
-//    pSecPar->TimeLimit = 300;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "cbAEFCGDVBRTLarmfijkoupwvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'c':
-            pSecPar->fTryComb ^= 1;
-            break;
-        case 'b':
-            pSecPar->fTryBmc ^= 1;
-            break;
-        case 'A':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-A\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nBmcFramesMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nBmcFramesMax < 0 )
-                goto usage;
-            break;
-        case 'E':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-E\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nBmcConfMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nBmcConfMax < 0 )
-                goto usage;
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pSecPar->nFramesMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pSecPar->nFramesMax < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pSecPar->nBTLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pSecPar->nBTLimit < 0 )
-                goto usage;
-            break;
-        case 'G':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-G\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pSecPar->nBTLimitGlobal = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pSecPar->nBTLimitGlobal < 0 )
-                goto usage;
-            break;
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pSecPar->nBTLimitInter = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pSecPar->nBTLimitInter < 0 )
-                goto usage;
-            break;
-        case 'V':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-V\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pSecPar->nBddVarsMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pSecPar->nBddVarsMax < 0 )
-                goto usage;
-            break;
-        case 'B':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pSecPar->nBddMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pSecPar->nBddMax < 0 )
-                goto usage;
-            break;
-        case 'R':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pSecPar->nBddIterMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pSecPar->nBddIterMax < 0 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pSecPar->nPdrTimeout = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pSecPar->nPdrTimeout < 0 )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by a file name.\n" );
-                goto usage;
-            }
-            pLogFileName = argv[globalUtilOptind];
-            globalUtilOptind++;
-            break;
-        case 'a':
-            pSecPar->fPhaseAbstract ^= 1;
-            break;
-        case 'r':
-            pSecPar->fRetimeFirst ^= 1;
-            break;
-        case 'm':
-            pSecPar->fRetimeRegs ^= 1;
-            break;
-        case 'f':
-            pSecPar->fFraiging ^= 1;
-            break;
-        case 'i':
-            pSecPar->fInduction ^= 1;
-            break;
-        case 'j':
-            pSecPar->fInterpolation ^= 1;
-            break;
-        case 'k':
-            pSecPar->fInterSeparate ^= 1;
-            break;
-        case 'o':
-            pSecPar->fReorderImage ^= 1;
-            break;
-        case 'u':
-            pSecPar->fReadUnsolved ^= 1;
-            break;
-        case 'p':
-            pSecPar->fUsePdr ^= 1;
-            break;
-        case 'w':
-            pSecPar->fVeryVerbose ^= 1;
-            break;
-        case 'v':
-            pSecPar->fVerbose ^= 1;
-            break;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for structrally hashed networks. Run \"st\".\n" );
-        return 0;
-    }
-
-    // perform verification
-    pAbc->Status = Abc_NtkDarProve( pNtk, pSecPar, nBmcFramesMax, nBmcConfMax );
-    Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
-    if ( pLogFileName )
-        Abc_NtkWriteLogFile( pLogFileName, pAbc->pCex, pAbc->Status, pAbc->nFrames, "dprove" );
-
-    // read back the resulting unsolved reduced sequential miter
-    if ( pSecPar->fReadUnsolved && pSecPar->nSMnumber >= 0 )
-    {
-        char FileName[100];
-        sprintf(FileName, "sm%02d.aig", pSecPar->nSMnumber );
-        pNtk = Io_Read( FileName, Io_ReadFileType(FileName), 1, 0 );
-        if ( pNtk == NULL )
-            Abc_Print( -1, "Cannot read back unsolved reduced sequential miter \"%s\",\n", FileName );
-        else
-            Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: dprove [-AEFCGDVBRT num] [-L file] [-cbarmfijoupvwh]\n" );
-    Abc_Print( -2, "\t         performs SEC on the sequential miter\n" );
-    Abc_Print( -2, "\t-A num : the limit on the depth of BMC [default = %d]\n", nBmcFramesMax );
-    Abc_Print( -2, "\t-E num : the conflict limit during BMC [default = %d]\n", nBmcConfMax );
-    Abc_Print( -2, "\t-F num : the limit on the depth of induction [default = %d]\n", pSecPar->nFramesMax );
-    Abc_Print( -2, "\t-C num : the conflict limit at a node during induction [default = %d]\n", pSecPar->nBTLimit );
-    Abc_Print( -2, "\t-G num : the global conflict limit during induction [default = %d]\n", pSecPar->nBTLimitGlobal );
-    Abc_Print( -2, "\t-D num : the conflict limit during interpolation [default = %d]\n", pSecPar->nBTLimitInter );
-    Abc_Print( -2, "\t-V num : the flop count limit for BDD-based reachablity [default = %d]\n", pSecPar->nBddVarsMax );
-    Abc_Print( -2, "\t-B num : the BDD size limit in BDD-based reachablity [default = %d]\n", pSecPar->nBddMax );
-    Abc_Print( -2, "\t-R num : the max number of reachability iterations [default = %d]\n", pSecPar->nBddIterMax );
-    Abc_Print( -2, "\t-T num : the timeout for property directed reachability [default = %d]\n", pSecPar->nPdrTimeout );
-    Abc_Print( -2, "\t-L file: the log file name [default = %s]\n", pLogFileName ? pLogFileName : "no logging" );
-    Abc_Print( -2, "\t-c     : toggles using CEC before attempting SEC [default = %s]\n", pSecPar->fTryComb? "yes": "no" );
-    Abc_Print( -2, "\t-b     : toggles using BMC before attempting SEC [default = %s]\n", pSecPar->fTryBmc? "yes": "no" );
-    Abc_Print( -2, "\t-a     : toggles the use of phase abstraction [default = %s]\n", pSecPar->fPhaseAbstract? "yes": "no" );
-    Abc_Print( -2, "\t-r     : toggles forward retiming at the beginning [default = %s]\n", pSecPar->fRetimeFirst? "yes": "no" );
-    Abc_Print( -2, "\t-m     : toggles min-register retiming [default = %s]\n", pSecPar->fRetimeRegs? "yes": "no" );
-    Abc_Print( -2, "\t-f     : toggles the internal use of fraiging [default = %s]\n", pSecPar->fFraiging? "yes": "no" );
-    Abc_Print( -2, "\t-i     : toggles the use of induction [default = %s]\n", pSecPar->fInduction? "yes": "no" );
-    Abc_Print( -2, "\t-j     : toggles the use of interpolation [default = %s]\n", pSecPar->fInterpolation? "yes": "no" );
-    Abc_Print( -2, "\t-k     : toggles applying interpolation to each output [default = %s]\n", pSecPar->fInterSeparate? "yes": "no" );
-    Abc_Print( -2, "\t-o     : toggles using BDD variable reordering during image computation [default = %s]\n", pSecPar->fReorderImage? "yes": "no" );
-    Abc_Print( -2, "\t-u     : toggles reading back unsolved reduced sequential miter [default = %s]\n", pSecPar->fReadUnsolved? "yes": "no" );
-    Abc_Print( -2, "\t-p     : toggles trying property directed reachability in the end [default = %s]\n", pSecPar->fUsePdr? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggles verbose output [default = %s]\n", pSecPar->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w     : toggles additional verbose output [default = %s]\n", pSecPar->fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\tCommand \"dprove\" can also be used for sequential synthesis (dprove -brjopu)\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbSec( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtk1, * pNtk2;
-    int fDelete1, fDelete2;
-    char ** pArgvNew;
-    int nArgcNew;
-    int fMiter, nFrames, fVerbose, c;
-
-    extern int Abc_NtkDarAbSec( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nFrames, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    fMiter   = 1;
-    nFrames  = 2;
-    fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Fmvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFrames = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFrames < 0 )
-                goto usage;
-            break;
-        case 'm':
-            fMiter ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( fMiter )
-    {
-//        pNtk = Io_Read( argv[globalUtilOptind], Io_ReadFileType(argv[globalUtilOptind]), 1, 0 );
-        if ( argc == globalUtilOptind + 1 )
-        {
-            Abc_Print( -1, "The miter cannot be given on the command line. Use \"read\".\n" );
-            return 0;
-        }
-        if ( !Abc_NtkIsStrash(pNtk) )
-        {
-            Abc_Print( -1, "The miter should be structurally hashed. Use \"st\"\n" );
-            return 0;
-        }
-        if ( Abc_NtkDarAbSec( pNtk, NULL, nFrames, fVerbose ) == 1 )
-            pAbc->Status = 1;
-        else
-            pAbc->Status = -1;
-    }
-    else
-    {
-        pArgvNew = argv + globalUtilOptind;
-        nArgcNew = argc - globalUtilOptind;
-        if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
-            return 1;
-        if ( Abc_NtkLatchNum(pNtk1) == 0 || Abc_NtkLatchNum(pNtk2) == 0 )
-        {
-            if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
-            if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
-            Abc_Print( -1, "The network has no latches. Used combinational command \"cec\".\n" );
-            return 0;
-        }
-        // perform verification
-        if ( Abc_NtkDarAbSec( pNtk1, pNtk2, nFrames, fVerbose ) == 1 )
-            pAbc->Status = 1;
-        else
-            pAbc->Status = -1;
-        if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
-        if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: absec [-F num] [-mv] <file1> <file2>\n" );
-    Abc_Print( -2, "\t         performs SEC by applying CEC to several timeframes\n" );
-    Abc_Print( -2, "\t-F num : the total number of timeframes to use [default = %d]\n", nFrames );
-    Abc_Print( -2, "\t-m     : toggles miter vs. two networks [default = %s]\n", fMiter? "miter": "two networks" );
-    Abc_Print( -2, "\t-v     : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\tfile1  : (optional) the file with the first network\n");
-    Abc_Print( -2, "\tfile2  : (optional) the file with the second network\n");
-    Abc_Print( -2, "\t         if no files are given, uses the current network and its spec\n");
-    Abc_Print( -2, "\t         if one file is given, uses the current network and the file\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandSimSec( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Ssw_Pars_t Pars, * pPars = &Pars;
-    Abc_Ntk_t * pNtk, * pNtk1, * pNtk2;
-    int fDelete1, fDelete2;
-    char ** pArgvNew;
-    int nArgcNew, c;
-    int fMiter;
-
-    extern int Abc_NtkDarSimSec( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, Ssw_Pars_t * pPars );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    fMiter = 1;
-    Ssw_ManSetDefaultParams( pPars );
-    pPars->fPartSigCorr = 1;
-    pPars->fVerbose     = 1;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "FDcymvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nFramesK = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nFramesK < 0 )
-                goto usage;
-            break;
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nIsleDist = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nIsleDist < 0 )
-                goto usage;
-            break;
-        case 'm':
-            fMiter ^= 1;
-            break;
-        case 'c':
-            pPars->fPartSigCorr ^= 1;
-            break;
-        case 'y':
-            pPars->fDumpSRInit ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( fMiter )
-    {
-//        Abc_Ntk_t * pNtkA, * pNtkB;
-        if ( !Abc_NtkIsStrash(pNtk) )
-        {
-            Abc_Print( -1, "This command works only for structrally hashed networks. Run \"st\".\n" );
-            return 0;
-        }
-        Abc_NtkDarSimSec( pNtk, NULL, pPars );
-/*
-        pNtkA = Abc_NtkDup( pNtk );
-        pNtkB = Abc_NtkDup( pNtk );
-        Abc_NtkDarSimSec( pNtkA, pNtkB, pPars );
-        Abc_NtkDelete( pNtkA );
-        Abc_NtkDelete( pNtkB );
-*/
-    }
-    else
-    {
-        pArgvNew = argv + globalUtilOptind;
-        nArgcNew = argc - globalUtilOptind;
-        if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
-            return 1;
-        if ( Abc_NtkLatchNum(pNtk1) == 0 || Abc_NtkLatchNum(pNtk2) == 0 )
-        {
-            if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
-            if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
-            Abc_Print( -1, "The network has no latches. Used combinational command \"cec\".\n" );
-            return 0;
-        }
-        // perform verification
-        Abc_NtkDarSimSec( pNtk1, pNtk2, pPars );
-        if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
-        if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: simsec [-FD num] [-mcyv] <file1> <file2>\n" );
-    Abc_Print( -2, "\t         performs SEC using structural similarity\n" );
-    Abc_Print( -2, "\t-F num : the limit on the depth of induction [default = %d]\n", pPars->nFramesK );
-    Abc_Print( -2, "\t-D num : the distance for extending islands [default = %d]\n", pPars->nIsleDist );
-    Abc_Print( -2, "\t-m     : toggles miter vs. two networks [default = %s]\n", fMiter? "miter": "two networks" );
-    Abc_Print( -2, "\t-c     : uses partial vs. full signal correspondence [default = %s]\n", pPars->fPartSigCorr? "partial": "full" );
-    Abc_Print( -2, "\t-y     : dumps speculatively reduced miter of the classes [default = %s]\n", pPars->fDumpSRInit? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\tfile1  : (optional) the file with the first network\n");
-    Abc_Print( -2, "\tfile2  : (optional) the file with the second network\n");
-    Abc_Print( -2, "\t         if no files are given, uses the current network and its spec\n");
-    Abc_Print( -2, "\t         if one file is given, uses the current network and the file\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandMatch( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtk1, * pNtk2, * pNtkRes;
-    int fDelete1, fDelete2;
-    char ** pArgvNew;
-    int nArgcNew, c;
-    int fMiter;
-    int nDist;
-    int fVerbose;
-
-    extern Abc_Ntk_t * Abc_NtkDarMatch( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nDist, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    fMiter = 0;
-    nDist = 0;
-    fVerbose = 1;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Dmvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nDist = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nDist < 0 )
-                goto usage;
-            break;
-        case 'm':
-            fMiter ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( fMiter )
-    {
-//        Abc_Ntk_t * pNtkA, * pNtkB;
-        if ( !Abc_NtkIsStrash(pNtk) )
-        {
-            Abc_Print( -1, "This command works only for structrally hashed networks. Run \"st\".\n" );
-            return 0;
-        }
-        pNtkRes = Abc_NtkDarMatch( pNtk, NULL, nDist, fVerbose );
-/*
-        pNtkA = Abc_NtkDup( pNtk );
-        pNtkB = Abc_NtkDup( pNtk );
-        Abc_NtkDarSimSec( pNtkA, pNtkB, pPars );
-        Abc_NtkDelete( pNtkA );
-        Abc_NtkDelete( pNtkB );
-*/
-    }
-    else
-    {
-        pArgvNew = argv + globalUtilOptind;
-        nArgcNew = argc - globalUtilOptind;
-        if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
-            return 1;
-        if ( Abc_NtkLatchNum(pNtk1) == 0 || Abc_NtkLatchNum(pNtk2) == 0 )
-        {
-            if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
-            if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
-            Abc_Print( -1, "The network has no latches. Used combinational command \"cec\".\n" );
-            return 0;
-        }
-        // perform verification
-        pNtkRes = Abc_NtkDarMatch( pNtk1, pNtk2, nDist, fVerbose );
-        if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
-        if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
-    }
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Matching has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: match [-D num] [-mv] <file1> <file2>\n" );
-    Abc_Print( -2, "\t         detects structural similarity using simulation\n" );
-    Abc_Print( -2, "\t         replaces the current network by the miter of differences\n" );
-    Abc_Print( -2, "\t-D num : the distance for extending differences [default = %d]\n", nDist );
-    Abc_Print( -2, "\t-m     : toggles miter vs. two networks [default = %s]\n", fMiter? "miter": "two networks" );
-    Abc_Print( -2, "\t-v     : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\tfile1  : (optional) the file with the first network\n");
-    Abc_Print( -2, "\tfile2  : (optional) the file with the second network\n");
-    Abc_Print( -2, "\t         if no files are given, uses the current network and its spec\n");
-    Abc_Print( -2, "\t         if one file is given, uses the current network and the file\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandSat( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int RetValue;
-    int fVerbose;
-    int nConfLimit;
-    int nInsLimit;
-    abctime clk;
-    // set defaults
-    fVerbose   = 0;
-    nConfLimit = 0;
-    nInsLimit  = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "CIvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nConfLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nConfLimit < 0 )
-                goto usage;
-            break;
-        case 'I':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nInsLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nInsLimit < 0 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( Abc_NtkLatchNum(pNtk) > 0 )
-    {
-        Abc_Print( -1, "Currently can only solve the miter for combinational circuits.\n" );
-        return 0;
-    }
-
-    clk = Abc_Clock();
-    if ( Abc_NtkIsStrash(pNtk) )
-    {
-        RetValue = Abc_NtkMiterSat( pNtk, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)nInsLimit, fVerbose, NULL, NULL );
-    }
-    else
-    {
-        assert( Abc_NtkIsLogic(pNtk) );
-        Abc_NtkToBdd( pNtk );
-        RetValue = Abc_NtkMiterSat( pNtk, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)nInsLimit, fVerbose, NULL, NULL );
-    }
-
-    // verify that the pattern is correct
-    if ( RetValue == 0 && Abc_NtkPoNum(pNtk) == 1 )
-    {
-        //int i;
-        //Abc_Obj_t * pObj;
-        int * pSimInfo = Abc_NtkVerifySimulatePattern( pNtk, pNtk->pModel );
-        if ( pSimInfo[0] != 1 )
-            Abc_Print( 1, "ERROR in Abc_NtkMiterSat(): Generated counter example is invalid.\n" );
-        ABC_FREE( pSimInfo );
-        /*
-        // print model
-        Abc_NtkForEachPi( pNtk, pObj, i )
-        {
-            Abc_Print( -1, "%d", (int)(pNtk->pModel[i] > 0) );
-            if ( i == 70 )
-                break;
-        }
-        Abc_Print( -1, "\n" );
-        */
-    }
-    pAbc->Status = RetValue;
-    if ( RetValue == -1 )
-        Abc_Print( 1, "UNDECIDED      " );
-    else if ( RetValue == 0 )
-        Abc_Print( 1, "SATISFIABLE    " );
-    else
-        Abc_Print( 1, "UNSATISFIABLE  " );
-    //Abc_Print( -1, "\n" );
-    Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: sat [-C num] [-I num] [-vh]\n" );
-    Abc_Print( -2, "\t         solves the combinational miter using SAT solver MiniSat-1.14\n" );
-    Abc_Print( -2, "\t         derives CNF from the current network and leave it unchanged\n" );
-    Abc_Print( -2, "\t         (there is also a newer SAT solving command \"dsat\")\n" );
-    Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n",    nConfLimit );
-    Abc_Print( -2, "\t-I num : limit on the number of inspections [default = %d]\n", nInsLimit );
-    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandDSat( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int RetValue;
-    int fAlignPol;
-    int fAndOuts;
-    int fNewSolver;
-    int fVerbose;
-    int nConfLimit;
-    int nLearnedStart;
-    int nLearnedDelta;
-    int nLearnedPerce;
-    int nInsLimit;
-    abctime clk;
-
-    extern int Abc_NtkDSat( Abc_Ntk_t * pNtk, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, int nLearnedStart, int nLearnedDelta, int nLearnedPerce, int fAlignPol, int fAndOuts, int fNewSolver, int fVerbose );
-    // set defaults
-    fAlignPol  = 0;
-    fAndOuts   = 0;
-    fNewSolver = 0;
-    fVerbose   = 0;
-    nConfLimit = 0;
-    nInsLimit  = 0;
-    nLearnedStart = 0;
-    nLearnedDelta = 0;
-    nLearnedPerce = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "CILDEpanvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nConfLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nConfLimit < 0 )
-                goto usage;
-            break;
-        case 'I':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nInsLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nInsLimit < 0 )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nLearnedStart = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nLearnedStart < 0 )
-                goto usage;
-            break;
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nLearnedDelta = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nLearnedDelta < 0 )
-                goto usage;
-            break;
-        case 'E':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-E\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nLearnedPerce = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nLearnedPerce < 0 )
-                goto usage;
-            break;
-        case 'p':
-            fAlignPol ^= 1;
-            break;
-        case 'a':
-            fAndOuts ^= 1;
-            break;
-        case 'n':
-            fNewSolver ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( argc == globalUtilOptind + 1 )
-    {
-        extern int Cnf_DataSolveFromFile( char * pFileName, int nConfLimit, int fVerbose );
-        // get the input file name
-        char * pFileName = argv[globalUtilOptind];
-        FILE * pFile = fopen( pFileName, "rb" );
-        if ( pFile == NULL )
-        {
-            printf( "Cannot open file \"%s\" for writing.\n", pFileName );
-            return 0;
-        }
-        fclose( pFile );
-        Cnf_DataSolveFromFile( pFileName, nConfLimit, fVerbose );
-        return 0;
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( Abc_NtkLatchNum(pNtk) > 0 )
-    {
-        Abc_Print( -1, "Currently can only solve the miter for combinational circuits.\n" );
-        return 0;
-    }
-
-    if ( Abc_NtkPoNum(pNtk) != 1 )
-    {
-        Abc_Print( -1, "Currently expects a single-output miter.\n" );
-        return 0;
-    }
-
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
-        return 0;
-    }
-    clk = Abc_Clock();
-    RetValue = Abc_NtkDSat( pNtk, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)nInsLimit, nLearnedStart, nLearnedDelta, nLearnedPerce, fAlignPol, fAndOuts, fNewSolver, fVerbose );
-    // verify that the pattern is correct
-    if ( RetValue == 0 && Abc_NtkPoNum(pNtk) == 1 )
-    {
-        int * pSimInfo = Abc_NtkVerifySimulatePattern( pNtk, pNtk->pModel );
-        if ( pSimInfo[0] != 1 )
-            Abc_Print( 1, "ERROR in Abc_NtkMiterSat(): Generated counter example is invalid.\n" );
-        ABC_FREE( pSimInfo );
-        pAbc->pCex = Abc_CexCreate( 0, Abc_NtkPiNum(pNtk), pNtk->pModel, 0, 0, 0 );
-    }
-    pAbc->Status = RetValue;
-    if ( RetValue == -1 )
-        Abc_Print( 1, "UNDECIDED      " );
-    else if ( RetValue == 0 )
-        Abc_Print( 1, "SATISFIABLE    " );
-    else
-        Abc_Print( 1, "UNSATISFIABLE  " );
-    //Abc_Print( -1, "\n" );
-    Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: dsat [-CILDE num] [-panvh]\n" );
-    Abc_Print( -2, "\t         solves the combinational miter using SAT solver MiniSat-1.14\n" );
-    Abc_Print( -2, "\t         derives CNF from the current network and leaves it unchanged\n" );
-    Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n",    nConfLimit );
-    Abc_Print( -2, "\t-I num : limit on the number of inspections [default = %d]\n", nInsLimit );
-    Abc_Print( -2, "\t-L num : starting value for learned clause removal [default = %d]\n", nLearnedStart );
-    Abc_Print( -2, "\t-D num : delta value for learned clause removal [default = %d]\n", nLearnedDelta );
-    Abc_Print( -2, "\t-E num : ratio percentage for learned clause removal [default = %d]\n", nLearnedPerce );
-    Abc_Print( -2, "\t-p     : align polarity of SAT variables [default = %s]\n", fAlignPol? "yes": "no" );
-    Abc_Print( -2, "\t-a     : toggle ANDing/ORing of miter outputs [default = %s]\n", fAndOuts? "ANDing": "ORing" );
-    Abc_Print( -2, "\t-n     : toggle using new solver [default = %s]\n", fNewSolver? "yes": "no" );
-    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandPSat( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int RetValue;
-    int c;
-    int nAlgo;
-    int nPartSize;
-    int nConfPart;
-    int nConfTotal;
-    int fAlignPol;
-    int fSynthesize;
-    int fVerbose;
-    abctime clk;
-
-    extern int Abc_NtkPartitionedSat( Abc_Ntk_t * pNtk, int nAlgo, int nPartSize, int nConfPart, int nConfTotal, int fAlignPol, int fSynthesize, int fVerbose );
-    // set defaults
-    nAlgo       =        0;
-    nPartSize   =    10000;
-    nConfPart   =        0;
-    nConfTotal  =  1000000;
-    fAlignPol   =        1;
-    fSynthesize =        0;
-    fVerbose    =        1;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "APCpsvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'A':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-A\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nAlgo = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nAlgo < 0 )
-                goto usage;
-            break;
-        case 'P':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nPartSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nPartSize < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nConfTotal = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nConfTotal < 0 )
-                goto usage;
-            break;
-        case 'p':
-            fAlignPol ^= 1;
-            break;
-        case 's':
-            fSynthesize ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( Abc_NtkLatchNum(pNtk) > 0 )
-    {
-        Abc_Print( -1, "Currently can only solve the miter for combinational circuits.\n" );
-        return 0;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
-        return 0;
-    }
-
-    clk = Abc_Clock();
-    RetValue = Abc_NtkPartitionedSat( pNtk, nAlgo, nPartSize, nConfPart, nConfTotal, fAlignPol, fSynthesize, fVerbose );
-    // verify that the pattern is correct
-    if ( RetValue == 0 && Abc_NtkPoNum(pNtk) == 1 )
-    {
-        //int i;
-        //Abc_Obj_t * pObj;
-        int * pSimInfo = Abc_NtkVerifySimulatePattern( pNtk, pNtk->pModel );
-        if ( pSimInfo[0] != 1 )
-            Abc_Print( 1, "ERROR in Abc_NtkMiterSat(): Generated counter example is invalid.\n" );
-        ABC_FREE( pSimInfo );
-        /*
-        // print model
-        Abc_NtkForEachPi( pNtk, pObj, i )
-        {
-            Abc_Print( -1, "%d", (int)(pNtk->pModel[i] > 0) );
-            if ( i == 70 )
-                break;
-        }
-        Abc_Print( -1, "\n" );
-        */
-    }
-
-    if ( RetValue == -1 )
-        Abc_Print( 1, "UNDECIDED      " );
-    else if ( RetValue == 0 )
-        Abc_Print( 1, "SATISFIABLE    " );
-    else
-        Abc_Print( 1, "UNSATISFIABLE  " );
-    //Abc_Print( -1, "\n" );
-    Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: psat [-APC num] [-psvh]\n" );
-    Abc_Print( -2, "\t         solves the combinational miter using partitioning\n" );
-    Abc_Print( -2, "\t         (derives CNF from the current network and leave it unchanged)\n" );
-    Abc_Print( -2, "\t         for multi-output miters, tries to prove that the AND of POs is always 0\n" );
-    Abc_Print( -2, "\t         (if POs should be ORed instead of ANDed, use command \"orpos\")\n" );
-    Abc_Print( -2, "\t-A num : partitioning algorithm [default = %d]\n", nAlgo );
-    Abc_Print( -2, "\t         0 : no partitioning\n" );
-    Abc_Print( -2, "\t         1 : partitioning by level\n" );
-    Abc_Print( -2, "\t         2 : DFS post-order\n" );
-    Abc_Print( -2, "\t         3 : DFS pre-order\n" );
-    Abc_Print( -2, "\t         4 : bit-slicing\n" );
-    Abc_Print( -2, "\t         partitions are ordered by level (high level first)\n" );
-    Abc_Print( -2, "\t-P num : limit on the partition size [default = %d]\n", nPartSize );
-    Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfTotal );
-    Abc_Print( -2, "\t-p     : align polarity of SAT variables [default = %s]\n", fAlignPol? "yes": "no" );
-    Abc_Print( -2, "\t-s     : apply logic synthesis to each partition [default = %s]\n", fSynthesize? "yes": "no" );
-    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandProve( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkTemp;
-    Prove_Params_t Params, * pParams = &Params;
-    int c, RetValue;
-    abctime clk;
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    Prove_ParamsSetDefault( pParams );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "NCFGLIrfbvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pParams->nItersMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pParams->nItersMax < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pParams->nMiteringLimitStart = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pParams->nMiteringLimitStart < 0 )
-                goto usage;
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pParams->nFraigingLimitStart = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pParams->nFraigingLimitStart < 0 )
-                goto usage;
-            break;
-        case 'G':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-G\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pParams->nFraigingLimitMulti = (float)atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pParams->nFraigingLimitMulti < 0 )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pParams->nMiteringLimitLast = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pParams->nMiteringLimitLast < 0 )
-                goto usage;
-            break;
-        case 'I':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pParams->nTotalInspectLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pParams->nTotalInspectLimit < 0 )
-                goto usage;
-            break;
-        case 'r':
-            pParams->fUseRewriting ^= 1;
-            break;
-        case 'f':
-            pParams->fUseFraiging ^= 1;
-            break;
-        case 'b':
-            pParams->fUseBdds ^= 1;
-            break;
-        case 'v':
-            pParams->fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( Abc_NtkLatchNum(pNtk) > 0 )
-    {
-        Abc_Print( -1, "Currently can only solve the miter for combinational circuits.\n" );
-        return 0;
-    }
-    if ( Abc_NtkCoNum(pNtk) != 1 )
-    {
-        Abc_Print( -1, "Currently can only solve the miter with one output.\n" );
-        return 0;
-    }
-    clk = Abc_Clock();
-
-    if ( Abc_NtkIsStrash(pNtk) )
-        pNtkTemp = Abc_NtkDup( pNtk );
-    else
-        pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
-
-    RetValue = Abc_NtkMiterProve( &pNtkTemp, pParams );
-
-    // verify that the pattern is correct
-    if ( RetValue == 0 )
-    {
-        int * pSimInfo = Abc_NtkVerifySimulatePattern( pNtk, pNtkTemp->pModel );
-        if ( pSimInfo[0] != 1 )
-            Abc_Print( 1, "ERROR in Abc_NtkMiterProve(): Generated counter-example is invalid.\n" );
-        ABC_FREE( pSimInfo );
-    }
-    pAbc->Status = RetValue;
-    if ( RetValue == -1 )
-        Abc_Print( 1, "UNDECIDED      " );
-    else if ( RetValue == 0 )
-        Abc_Print( 1, "SATISFIABLE    " );
-    else
-        Abc_Print( 1, "UNSATISFIABLE  " );
-    //Abc_Print( -1, "\n" );
-
-    Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: prove [-NCFGLI num] [-rfbvh]\n" );
-    Abc_Print( -2, "\t         solves combinational miter by rewriting, FRAIGing, and SAT\n" );
-    Abc_Print( -2, "\t         replaces the current network by the cone modified by rewriting\n" );
-    Abc_Print( -2, "\t         (there is also newer CEC command \"iprove\")\n" );
-    Abc_Print( -2, "\t-N num : max number of iterations [default = %d]\n", pParams->nItersMax );
-    Abc_Print( -2, "\t-C num : max starting number of conflicts in mitering [default = %d]\n", pParams->nMiteringLimitStart );
-    Abc_Print( -2, "\t-F num : max starting number of conflicts in fraiging [default = %d]\n", pParams->nFraigingLimitStart );
-    Abc_Print( -2, "\t-G num : multiplicative coefficient for fraiging [default = %d]\n", (int)pParams->nFraigingLimitMulti );
-    Abc_Print( -2, "\t-L num : max last-gasp number of conflicts in mitering [default = %d]\n", pParams->nMiteringLimitLast );
-    Abc_Print( -2, "\t-I num : max number of clause inspections in all SAT calls [default = %d]\n", (int)pParams->nTotalInspectLimit );
-    Abc_Print( -2, "\t-r     : toggle the use of rewriting [default = %s]\n", pParams->fUseRewriting? "yes": "no" );
-    Abc_Print( -2, "\t-f     : toggle the use of FRAIGing [default = %s]\n", pParams->fUseFraiging? "yes": "no" );
-    Abc_Print( -2, "\t-b     : toggle the use of BDDs [default = %s]\n", pParams->fUseBdds? "yes": "no" );
-    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", pParams->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandDebug( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    extern void Abc_NtkAutoDebug( Abc_Ntk_t * pNtk, int (*pFuncError) (Abc_Ntk_t *) );
-    extern int Abc_NtkRetimeDebug( Abc_Ntk_t * pNtk );
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsLogic(pNtk) )
-    {
-        Abc_Print( -1, "This command is applicable to logic networks.\n" );
-        return 1;
-    }
-
-    Abc_NtkAutoDebug( pNtk, Abc_NtkRetimeDebug );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: debug [-h]\n" );
-    Abc_Print( -2, "\t        performs automated debugging of the given procedure\n" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandBmc( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int nFrames;
-    int nSizeMax;
-    int nBTLimit;
-    int nBTLimitAll;
-    int nNodeDelta;
-    int fRewrite;
-    int fNewAlgo;
-    int nCofFanLit;
-    int fVerbose;
-    int iFrames;
-    char * pLogFileName = NULL;
-
-    extern int Abc_NtkDarBmc( Abc_Ntk_t * pNtk, int nStart, int nFrames, int nSizeMax, int nNodeDelta, int nTimeOut, int nBTLimit, int nBTLimitAll, int fRewrite, int fNewAlgo, int fOrDecomp, int nCofFanLit, int fVerbose, int * piFrames );
-    // set defaults
-    nFrames     =       20;
-    nSizeMax    =   100000;
-    nBTLimit    =        0;
-    nBTLimitAll =        0;
-    nNodeDelta  =     1000;
-    fRewrite    =        0;
-    fNewAlgo    =        1;
-    nCofFanLit  =        0;
-    fVerbose    =        0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "FNCGDLrvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFrames = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFrames < 0 )
-                goto usage;
-            break;
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nSizeMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nSizeMax < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nBTLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nBTLimit < 0 )
-                goto usage;
-            break;
-        case 'G':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-G\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nBTLimitAll = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nBTLimitAll < 0 )
-                goto usage;
-            break;
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nNodeDelta = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nNodeDelta < 0 )
-                goto usage;
-            break;
-/*
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nCofFanLit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nCofFanLit < 0 )
-                goto usage;
-            break;
-*/
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by a file name.\n" );
-                goto usage;
-            }
-            pLogFileName = argv[globalUtilOptind];
-            globalUtilOptind++;
-            break;
-        case 'r':
-            fRewrite ^= 1;
-            break;
-        case 'a':
-            fNewAlgo ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
-        return 0;
-    }
-    if ( Abc_NtkLatchNum(pNtk) == 0 )
-    {
-        Abc_Print( -1, "Does not work for combinational networks.\n" );
-        return 0;
-    }
-    pAbc->Status = Abc_NtkDarBmc( pNtk, 0, nFrames, nSizeMax, nNodeDelta, 0, nBTLimit, nBTLimitAll, fRewrite, fNewAlgo, 0, nCofFanLit, fVerbose, &iFrames );
-    pAbc->nFrames = iFrames;
-    Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
-    if ( pLogFileName )
-        Abc_NtkWriteLogFile( pLogFileName, pAbc->pCex, pAbc->Status, pAbc->nFrames, "bmc" );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: bmc [-FNC num] [-L file] [-rcvh]\n" );
-    Abc_Print( -2, "\t         performs bounded model checking with static unrolling\n" );
-    Abc_Print( -2, "\t-F num : the number of time frames [default = %d]\n", nFrames );
-    Abc_Print( -2, "\t-N num : the max number of nodes in the frames [default = %d]\n", nSizeMax );
-    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", nBTLimit );
-//    Abc_Print( -2, "\t-L num : the limit on fanout count of resets/enables to cofactor [default = %d]\n", nCofFanLit );
-    Abc_Print( -2, "\t-L file: the log file name [default = %s]\n", pLogFileName ? pLogFileName : "no logging" );
-    Abc_Print( -2, "\t-r     : toggle the use of rewriting [default = %s]\n", fRewrite? "yes": "no" );
-//    Abc_Print( -2, "\t-a     : toggle SAT sweeping and SAT solving [default = %s]\n", fNewAlgo? "SAT solving": "SAT sweeping" );
-    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandBmc2( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    int nStart;
-    int nFrames;
-    int nSizeMax;
-    int nBTLimit;
-    int nBTLimitAll;
-    int nNodeDelta;
-    int nTimeOut;
-    int fRewrite;
-    int fNewAlgo;
-    int fOrDecomp;
-    int fVerbose;
-    int iFrames;
-    char * pLogFileName = NULL;
-
-    extern int Abc_NtkDarBmc( Abc_Ntk_t * pNtk, int nStart, int nFrames, int nSizeMax, int nNodeDelta, int nTimeOut, int nBTLimit, int nBTLimitAll, int fRewrite, int fNewAlgo, int fOrDecomp, int nCofFanLit, int fVerbose, int * piFrames );
-
-    // set defaults
-    nStart      =        0;
-    nFrames     =        0;
-    nSizeMax    =   200000;
-    nBTLimit    =        0;
-    nBTLimitAll =        0;
-    nNodeDelta  =     2000;
-    nTimeOut    =        0;
-    fRewrite    =        0;
-    fNewAlgo    =        0;
-    fOrDecomp   =        0;
-    fVerbose    =        0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "SFNTCGDLruvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nStart = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nStart < 0 )
-                goto usage;
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFrames = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFrames < 0 )
-                goto usage;
-            break;
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nSizeMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nSizeMax < 0 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nTimeOut = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nTimeOut < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nBTLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nBTLimit < 0 )
-                goto usage;
-            break;
-        case 'G':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-G\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nBTLimitAll = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nBTLimitAll < 0 )
-                goto usage;
-            break;
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nNodeDelta = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nNodeDelta < 0 )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by a file name.\n" );
-                goto usage;
-            }
-            pLogFileName = argv[globalUtilOptind];
-            globalUtilOptind++;
-            break;
-        case 'r':
-            fRewrite ^= 1;
-            break;
-        case 'a':
-            fNewAlgo ^= 1;
-            break;
-        case 'u':
-            fOrDecomp ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
-        return 0;
-    }
-    if ( Abc_NtkLatchNum(pNtk) == 0 )
-    {
-        Abc_Print( -1, "Does not work for combinational networks.\n" );
-        return 0;
-    }
-    pAbc->Status = Abc_NtkDarBmc( pNtk, nStart, nFrames, nSizeMax, nNodeDelta, nTimeOut, nBTLimit, nBTLimitAll, fRewrite, fNewAlgo, fOrDecomp, 0, fVerbose, &iFrames );
-    pAbc->nFrames = iFrames;
-    Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
-    if ( pLogFileName )
-        Abc_NtkWriteLogFile( pLogFileName, pAbc->pCex, pAbc->Status, pAbc->nFrames, "bmc2" );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: bmc2 [-SFTCGD num] [-L file] [-uvh]\n" );
-    Abc_Print( -2, "\t         performs bounded model checking with dynamic unrolling\n" );
-    Abc_Print( -2, "\t-S num : the starting time frame [default = %d]\n", nStart );
-    Abc_Print( -2, "\t-F num : the max number of time frames (0 = unused) [default = %d]\n", nFrames );
-    Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", nTimeOut );
-    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", nBTLimit );
-    Abc_Print( -2, "\t-G num : the max number of conflicts globally [default = %d]\n", nBTLimitAll );
-    Abc_Print( -2, "\t-D num : the delta in the number of nodes [default = %d]\n", nNodeDelta );
-    Abc_Print( -2, "\t-L file: the log file name [default = %s]\n", pLogFileName ? pLogFileName : "no logging" );
-    Abc_Print( -2, "\t-u     : toggle performing structural OR-decomposition [default = %s]\n", fOrDecomp? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandBmc3( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern int Abc_NtkDarBmc3( Abc_Ntk_t * pNtk, Saig_ParBmc_t * pPars, int fOrDecomp );
-    Saig_ParBmc_t Pars, * pPars = &Pars;
-    Abc_Ntk_t * pNtkRes, * pNtk = Abc_FrameReadNtk(pAbc);
-    Vec_Ptr_t * vSeqModelVec = NULL;
-    Vec_Int_t * vStatuses = NULL;
-    char * pLogFileName = NULL;
-    int fOrDecomp = 0;
-    int c;
-    Saig_ParBmcSetDefaultParams( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "SFTHGCDJIPQRLWaxdruvzh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nStart = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nStart < 0 )
-                goto usage;
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nFramesMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nFramesMax < 0 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nTimeOut = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nTimeOut < 0 )
-                goto usage;
-            break;
-        case 'H':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-H\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nTimeOutOne = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nTimeOutOne < 0 )
-                goto usage;
-            break;
-        case 'G':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-G\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nTimeOutGap = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nTimeOutGap < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nConfLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nConfLimit < 0 )
-                goto usage;
-            break;
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nConfLimitJump = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nConfLimitJump < 0 )
-                goto usage;
-            break;
-        case 'J':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-J\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nFramesJump = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nFramesJump < 0 )
-                goto usage;
-            break;
-        case 'I':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nPisAbstract = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nPisAbstract < 0 )
-                goto usage;
-            break;
-        case 'P':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nLearnedStart = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nLearnedStart < 0 )
-                goto usage;
-            break;
-        case 'Q':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-Q\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nLearnedDelta = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nLearnedDelta < 0 )
-                goto usage;
-            break;
-        case 'R':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nLearnedPerce = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nLearnedPerce < 0 )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by a file name.\n" );
-                goto usage;
-            }
-            pLogFileName = argv[globalUtilOptind];
-            globalUtilOptind++;
-            break;
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by a file name.\n" );
-                goto usage;
-            }
-            pPars->pLogFileName = argv[globalUtilOptind];
-            globalUtilOptind++;
-            break;
-        case 'a':
-            pPars->fSolveAll ^= 1;
-            break;
-        case 'x':
-            pPars->fStoreCex ^= 1;
-            break;
-        case 'd':
-            pPars->fDropSatOuts ^= 1;
-            break;
-        case 'u':
-            fOrDecomp ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'z':
-            pPars->fNotVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
-        return 0;
-    }
-    if ( Abc_NtkLatchNum(pNtk) == 0 )
-    {
-        Abc_Print( -1, "Does not work for combinational networks.\n" );
-        return 0;
-    }
-    if ( Abc_NtkConstrNum(pNtk) > 0 )
-    {
-        Abc_Print( -1, "Constraints have to be folded (use \"fold\").\n" );
-        return 0;
-    }
-    pPars->fUseBridge = pAbc->fBridgeMode;
-    pAbc->Status = Abc_NtkDarBmc3( pNtk, pPars, fOrDecomp );
-    pAbc->nFrames = pNtk->vSeqModelVec ? -1 : pPars->iFrame;
-    if ( pLogFileName )
-        Abc_NtkWriteLogFile( pLogFileName, pAbc->pCex, pAbc->Status, pAbc->nFrames, "bmc3" );
-    vSeqModelVec = pNtk->vSeqModelVec;  pNtk->vSeqModelVec = NULL;
-    if ( pPars->fSolveAll && pPars->fDropSatOuts )
-    {
-        if ( vSeqModelVec == NULL )
-            Abc_Print( 1,"The array of counter-examples is not available.\n" );
-        else if ( Vec_PtrSize(vSeqModelVec) != Abc_NtkPoNum(pNtk) )
-            Abc_Print( 1,"The array size does not match the number of outputs.\n" );
-        else
-        {
-            extern void Abc_NtkDropSatOutputs( Abc_Ntk_t * pNtk, Vec_Ptr_t * vCexes, int fVerbose );
-            Abc_NtkDropSatOutputs( pNtk, vSeqModelVec, pPars->fVerbose );
-            pNtkRes = Abc_NtkDarLatchSweep( pNtk, 1, 1, 1, 0, -1, -1, 0, 0 );
-            if ( pNtkRes == NULL )
-            {
-                Abc_Print( -1, "Removing SAT outputs has failed.\n" );
-                return 1;
-            }
-            Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-        }
-    }
-    vStatuses = Abc_FrameDeriveStatusArray( vSeqModelVec );
-    Abc_FrameReplacePoStatuses( pAbc, &vStatuses );        
-    if ( vSeqModelVec )
-        Abc_FrameReplaceCexVec( pAbc, &vSeqModelVec );
-    else
-        Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: bmc3 [-SFTHGCDJIPQR num] [-LW file] [-axduvzh]\n" );
-    Abc_Print( -2, "\t         performs bounded model checking with dynamic unrolling\n" );
-    Abc_Print( -2, "\t-S num : the starting time frame [default = %d]\n", pPars->nStart );
-    Abc_Print( -2, "\t-F num : the max number of time frames (0 = unused) [default = %d]\n",      pPars->nFramesMax );
-    Abc_Print( -2, "\t-T num : runtime limit, in seconds [default = %d]\n",                       pPars->nTimeOut );
-    Abc_Print( -2, "\t-H num : runtime limit per output, in miliseconds (with \"-a\") [default = %d]\n",    pPars->nTimeOutOne );
-    Abc_Print( -2, "\t-G num : runtime gap since the last CEX, in seconds [default = %d]\n",      pPars->nTimeOutGap );
-    Abc_Print( -2, "\t-C num : max conflicts at an output [default = %d]\n",                      pPars->nConfLimit );
-    Abc_Print( -2, "\t-D num : max conflicts after jumping (0 = infinity) [default = %d]\n",      pPars->nConfLimitJump );
-    Abc_Print( -2, "\t-J num : the number of timeframes to jump (0 = not used) [default = %d]\n", pPars->nFramesJump );
-    Abc_Print( -2, "\t-I num : the number of PIs to abstract [default = %d]\n",                   pPars->nPisAbstract );
-    Abc_Print( -2, "\t-P num : the max number of learned clauses to keep (0=unused) [default = %d]\n", pPars->nLearnedStart );
-    Abc_Print( -2, "\t-Q num : delta value for learned clause removal [default = %d]\n",          pPars->nLearnedDelta );
-    Abc_Print( -2, "\t-R num : percentage to keep for learned clause removal [default = %d]\n",   pPars->nLearnedPerce );
-    Abc_Print( -2, "\t-L file: the log file name [default = %s]\n",                               pLogFileName ? pLogFileName : "no logging" );
-    Abc_Print( -2, "\t-W file: the log file name with per-output details [default = %s]\n",       pPars->pLogFileName ? pPars->pLogFileName : "no logging" );
-    Abc_Print( -2, "\t-a     : solve all outputs (do not stop when one is SAT) [default = %s]\n", pPars->fSolveAll? "yes": "no" );
-    Abc_Print( -2, "\t-x     : toggle storing CEXes when solving all outputs [default = %s]\n",   pPars->fStoreCex? "yes": "no" );
-    Abc_Print( -2, "\t-d     : toggle dropping (replacing by 0) SAT outputs [default = %s]\n",    pPars->fDropSatOuts? "yes": "no" );
-    Abc_Print( -2, "\t-u     : toggle performing structural OR-decomposition [default = %s]\n",   fOrDecomp? "yes": "not" );
-    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n",                           pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-z     : toggle suppressing report about solved outputs [default = %s]\n",  pPars->fNotVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandBmcInter( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Inter_ManParams_t Pars, * pPars = &Pars;
-    Abc_Ntk_t * pNtkRes, * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    char * pLogFileName = NULL;
-
-    extern int Abc_NtkDarBmcInter( Abc_Ntk_t * pNtk, Inter_ManParams_t * pPars, Abc_Ntk_t ** ppNtkRes );
-    // set defaults
-    Inter_ManSetDefaultParams( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "CFTKLIrtpomcgbqkdivh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nBTLimit < 0 )
-                goto usage;
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nFramesMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nFramesMax < 0 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nSecLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nSecLimit < 0 )
-                goto usage;
-            break;
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nFramesK = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nFramesK < 0 )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by a file name.\n" );
-                goto usage;
-            }
-            pLogFileName = argv[globalUtilOptind];
-            globalUtilOptind++;
-            break;
-        case 'I':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-I\" should be followed by a file name.\n" );
-                goto usage;
-            }
-            pPars->pFileName = argv[globalUtilOptind];
-            globalUtilOptind++;
-            break;
-        case 'r':
-            pPars->fRewrite ^= 1;
-            break;
-        case 't':
-            pPars->fTransLoop ^= 1;
-            break;
-        case 'p':
-            pPars->fUsePudlak ^= 1;
-            break;
-        case 'o':
-            pPars->fUseOther ^= 1;
-            break;
-        case 'm':
-            pPars->fUseMiniSat ^= 1;
-            break;
-        case 'c':
-            pPars->fCheckKstep ^= 1;
-            break;
-        case 'g':
-            pPars->fUseBias ^= 1;
-            break;
-        case 'b':
-            pPars->fUseBackward ^= 1;
-            break;
-        case 'q':
-            pPars->fUseTwoFrames ^= 1;
-            break;
-        case 'k':
-            pPars->fUseSeparate ^= 1;
-            break;
-        case 'd':
-            pPars->fDropSatOuts ^= 1;
-            break;
-        case 'i':
-            pPars->fDropInvar ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
-        return 0;
-    }
-    if ( Abc_NtkLatchNum(pNtk) == 0 )
-    {
-        Abc_Print( -1, "Does not work for combinational networks.\n" );
-        return 0;
-    }
-    if ( Abc_NtkConstrNum(pNtk) > 0 )
-    {
-        Abc_Print( -1, "Cannot run interpolation with constraints. Use \"fold\".\n" );
-        return 0;
-    }
-    if ( Abc_NtkPoNum(pNtk)-Abc_NtkConstrNum(pNtk) != 1 )
-    {
-        if ( Abc_NtkConstrNum(pNtk) > 0 )
-        {
-            Abc_Print( 1,"Cannot solve multiple-output miter with constraints.\n" );
-            return 0;
-        }
-        if ( pPars->fUseSeparate )
-        {
-            Abc_Print( 0, "Each of %d outputs will be solved separately.\n", Abc_NtkPoNum(pNtk) );
-            pAbc->Status = Abc_NtkDarBmcInter( pNtk, pPars, &pNtkRes );
-            Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
-            if ( pNtkRes == NULL )
-            {
-                Abc_Print( -1, "Generating resulting network has failed.\n" );
-                return 0;
-            }
-            Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-        }
-        else
-        {
-            Abc_Ntk_t * pNtkNew = Abc_NtkDup( pNtk );
-            Abc_Print( 0, "All %d outputs will be ORed together.\n", Abc_NtkPoNum(pNtk) );
-            if ( !Abc_NtkCombinePos( pNtkNew, 0, 0 ) )
-            {
-                Abc_NtkDelete( pNtkNew );
-                Abc_Print( -1, "ORing outputs has failed.\n" );
-                return 0;
-            }
-            pAbc->Status = Abc_NtkDarBmcInter( pNtkNew, pPars, NULL );
-            if ( pAbc->Status == 0 )
-            {
-                Aig_Man_t * pMan = Abc_NtkToDar( pNtk, 0, 1 );
-                pNtkNew->pSeqModel->iPo = Saig_ManFindFailedPoCex( pMan, pNtkNew->pSeqModel );
-                Aig_ManStop( pMan );
-            }
-            Abc_FrameReplaceCex( pAbc, &pNtkNew->pSeqModel );
-            Abc_NtkDelete( pNtkNew );
-        }
-        pAbc->nFrames = -1;
-    }
-    else
-    {
-        pAbc->Status  = Abc_NtkDarBmcInter( pNtk, pPars, NULL );
-        pAbc->nFrames = pPars->iFrameMax;
-        Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
-    }
-    if ( pLogFileName )
-        Abc_NtkWriteLogFile( pLogFileName, pAbc->pCex, pAbc->Status, pAbc->nFrames, "int" );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: int [-CFTK num] [-LI file] [-irtpomcgbqkdvh]\n" );
-    Abc_Print( -2, "\t         uses interpolation to prove the property\n" );
-    Abc_Print( -2, "\t-C num : the limit on conflicts for one SAT run [default = %d]\n", pPars->nBTLimit );
-    Abc_Print( -2, "\t-F num : the limit on number of frames to unroll [default = %d]\n", pPars->nFramesMax );
-    Abc_Print( -2, "\t-T num : the limit on runtime per output in seconds [default = %d]\n", pPars->nSecLimit );
-    Abc_Print( -2, "\t-K num : the number of steps in inductive checking [default = %d]\n", pPars->nFramesK );
-    Abc_Print( -2, "\t         (K = 1 works in all cases; K > 1 works without -t and -b)\n" );
-    Abc_Print( -2, "\t-L file: the log file name [default = %s]\n", pLogFileName ? pLogFileName : "no logging" );
-    Abc_Print( -2, "\t-I file: the file name for dumping interpolant [default = \"%s\"]\n", pPars->pFileName ? pPars->pFileName : "invar.aig" );
-    Abc_Print( -2, "\t-i     : toggle dumping interpolant/invariant into a file [default = %s]\n", pPars->fDropInvar? "yes": "no" );
-    Abc_Print( -2, "\t-r     : toggle rewriting of the unrolled timeframes [default = %s]\n", pPars->fRewrite? "yes": "no" );
-    Abc_Print( -2, "\t-t     : toggle adding transition into the initial state [default = %s]\n", pPars->fTransLoop? "yes": "no" );
-    Abc_Print( -2, "\t-p     : toggle using original Pudlak's interpolation procedure [default = %s]\n", pPars->fUsePudlak? "yes": "no" );
-    Abc_Print( -2, "\t-o     : toggle using optimized Pudlak's interpolation procedure [default = %s]\n", pPars->fUseOther? "yes": "no" );
-    Abc_Print( -2, "\t-m     : toggle using MiniSat-1.14p (now, Windows-only) [default = %s]\n", pPars->fUseMiniSat? "yes": "no" );
-    Abc_Print( -2, "\t-c     : toggle using inductive containment check [default = %s]\n", pPars->fCheckKstep? "yes": "no" );
-    Abc_Print( -2, "\t-g     : toggle using bias for global variables using SAT [default = %s]\n", pPars->fUseBias? "yes": "no" );
-    Abc_Print( -2, "\t-b     : toggle using backward interpolation (works with -t) [default = %s]\n", pPars->fUseBackward? "yes": "no" );
-    Abc_Print( -2, "\t-q     : toggle using property in two last timeframes [default = %s]\n", pPars->fUseTwoFrames? "yes": "no" );
-    Abc_Print( -2, "\t-k     : toggle solving each output separately [default = %s]\n", pPars->fUseSeparate? "yes": "no" );
-    Abc_Print( -2, "\t-d     : toggle dropping (replacing by 0) SAT outputs (with -k is used) [default = %s]\n", pPars->fDropSatOuts? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandIndcut( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int nFrames;
-    int nPref;
-    int nClauses;
-    int nLutSize;
-    int nLevels;
-    int nCutsMax;
-    int nBatches;
-    int fStepUp;
-    int fBmc;
-    int fRegs;
-    int fTarget;
-    int fVerbose;
-    int fVeryVerbose;
-    int c;
-    extern int Abc_NtkDarClau( Abc_Ntk_t * pNtk, int nFrames, int nPref, int nClauses, int nLutSize, int nLevels, int nCutsMax, int nBatches, int fStepUp, int fBmc, int fRegs, int fTarget, int fVerbose, int fVeryVerbose );
-    // set defaults
-    nFrames      =    1;
-    nPref        =    0;
-    nClauses     = 5000;
-    nLutSize     =    4;
-    nLevels      =    8;
-    nCutsMax     =   16;
-    nBatches     =    1;
-    fStepUp      =    0;
-    fBmc         =    1;
-    fRegs        =    1;
-    fTarget      =    1;
-    fVerbose     =    0;
-    fVeryVerbose =    0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "FPCMLNBsbrtvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFrames = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFrames < 0 )
-                goto usage;
-            break;
-        case 'P':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nPref = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nPref < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nClauses = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nClauses < 0 )
-                goto usage;
-            break;
-        case 'M':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nLutSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nLutSize < 0 )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nLevels = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nLevels < 0 )
-                goto usage;
-            break;
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nCutsMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nCutsMax < 0 )
-                goto usage;
-            break;
-        case 'B':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nBatches = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nBatches < 0 )
-                goto usage;
-            break;
-        case 's':
-            fStepUp ^= 1;
-            break;
-        case 'b':
-            fBmc ^= 1;
-            break;
-        case 'r':
-            fRegs ^= 1;
-            break;
-        case 't':
-            fTarget ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'w':
-            fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( Abc_NtkIsComb(pNtk) )
-    {
-        Abc_Print( -1, "The network is combinational.\n" );
-        return 0;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
-        return 0;
-    }
-    if ( nLutSize > 12 )
-    {
-        Abc_Print( -1, "The cut size should be not exceed 12.\n" );
-        return 0;
-    }
-    Abc_NtkDarClau( pNtk, nFrames, nPref, nClauses, nLutSize, nLevels, nCutsMax, nBatches, fStepUp, fBmc, fRegs, fTarget, fVerbose, fVeryVerbose );
-    return 0;
-usage:
-    Abc_Print( -2, "usage: indcut [-FPCMLNB num] [-sbrtvh]\n" );
-    Abc_Print( -2, "\t         K-step induction strengthened with cut properties\n" );
-    Abc_Print( -2, "\t-F num : number of time frames for induction (1=simple) [default = %d]\n", nFrames );
-    Abc_Print( -2, "\t-P num : number of time frames in the prefix (0=no prefix) [default = %d]\n", nPref );
-    Abc_Print( -2, "\t-C num : the max number of clauses to use for strengthening [default = %d]\n", nClauses );
-    Abc_Print( -2, "\t-M num : the cut size (2 <= M <= 12) [default = %d]\n", nLutSize );
-    Abc_Print( -2, "\t-L num : the max number of levels for cut computation [default = %d]\n", nLevels );
-    Abc_Print( -2, "\t-N num : the max number of cuts to compute at a node [default = %d]\n", nCutsMax );
-    Abc_Print( -2, "\t-B num : the max number of invariant batches to try [default = %d]\n", nBatches );
-    Abc_Print( -2, "\t-s     : toggle increment cut size in each batch [default = %s]\n", fStepUp? "yes": "no" );
-    Abc_Print( -2, "\t-b     : toggle enabling BMC check [default = %s]\n", fBmc? "yes": "no" );
-    Abc_Print( -2, "\t-r     : toggle enabling register clauses [default = %s]\n", fRegs? "yes": "no" );
-    Abc_Print( -2, "\t-t     : toggle proving target / computing don't-cares [default = %s]\n", fTarget? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-//    Abc_Print( -2, "\t-w     : toggle printing very verbose information [default = %s]\n", fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandEnlarge( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int nFrames;
-    int fVerbose;
-    int c;
-    extern Abc_Ntk_t * Abc_NtkDarEnlarge( Abc_Ntk_t * pNtk, int nFrames, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    nFrames      = 5;
-    fVerbose     = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Fvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFrames = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFrames < 1 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( Abc_NtkIsComb(pNtk) )
-    {
-        Abc_Print( -1, "The network is combinational.\n" );
-        return 0;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
-        return 0;
-    }
-
-    // modify the current network
-    pNtkRes = Abc_NtkDarEnlarge( pNtk, nFrames, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Target enlargement has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-usage:
-    Abc_Print( -2, "usage: enlarge [-F <num>] [-vh]\n" );
-    Abc_Print( -2, "\t           performs structural K-step target enlargement\n" );
-    Abc_Print( -2, "\t-F <num> : the number of timeframes to unroll (<num> > 0) [default = %d]\n", nFrames );
-    Abc_Print( -2, "\t-v       : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandTempor( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Abc_Ntk_t * Abc_NtkDarTempor( Abc_Ntk_t * pNtk, int nFrames, int TimeOut, int nConfLimit, int fUseBmc, int fUseTransSigs, int fVerbose, int fVeryVerbose );
-    Abc_Ntk_t * pNtkRes, * pNtk = Abc_FrameReadNtk(pAbc);
-    int nFrames       =       0;
-    int TimeOut       =     300;
-    int nConfMax      =  100000;
-    int fUseBmc       =       1;
-    int fUseTransSigs =       0;
-    int fUpdateCex    =       0;
-    int fVerbose      =       0;
-    int fVeryVerbose  =       0;
-    int c;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "FTCbscvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFrames = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFrames < 0 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            TimeOut = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( TimeOut < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nConfMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nConfMax < 0 )
-                goto usage;
-            break;
-        case 'b':
-            fUseBmc ^= 1;
-            break;
-        case 's':
-            fUseTransSigs ^= 1;
-            break;
-        case 'c':
-            fUpdateCex ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'w':
-            fVeryVerbose ^= 1;
-            break;
-        case 'h':
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -2, "There is no current network.\n");
-        return 0;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -2, "The current network is not an AIG (run \"strash\").\n");
-        return 0;
-    }
-    if ( Abc_NtkLatchNum(pNtk) == 0 )
-    {
-        Abc_Print( -2, "The current network is combinational.\n");
-        return 0;
-    }
-    if ( fUpdateCex )
-    {
-        Abc_Cex_t * pCexNew;
-        if ( pAbc->pCex == NULL )
-        {
-            Abc_Print( -1, "Counter-example is not available.\n" );
-            return 1;
-        }
-        if ( pAbc->pCex->nPis % Abc_NtkPiNum(pNtk) != 0 )
-        {
-            Abc_Print( -1, "PI count of the CEX is not a multiple of PI count of the current AIG.\n" );
-            return 1;
-        }
-        pCexNew = Abc_CexTransformTempor( pAbc->pCex, Abc_NtkPiNum(pNtk), Abc_NtkPoNum(pNtk), Abc_NtkLatchNum(pNtk) );
-        Abc_FrameReplaceCex( pAbc, &pCexNew );
-        return 0;
-    }
-    // modify the current network
-    pNtkRes = Abc_NtkDarTempor( pNtk, nFrames, TimeOut, nConfMax, fUseBmc, fUseTransSigs, fVerbose, fVeryVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( -1, "Temporal decomposition has failed.\n" );
-        return 1;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: tempor [-FTC <num>] [-bscvwh]\n" );
-    Abc_Print( -2, "\t           performs temporal decomposition\n" );
-    Abc_Print( -2, "\t-F <num> : init logic timeframe count (0 = use leading length) [default = %d]\n", nFrames );
-    Abc_Print( -2, "\t-T <num> : runtime limit in seconds for BMC (0=unused) [default = %d]\n", TimeOut );
-    Abc_Print( -2, "\t-C <num> : max number of SAT conflicts in BMC (0=unused) [default = %d]\n", nConfMax );
-    Abc_Print( -2, "\t-b       : toggle running BMC2 on the init frames [default = %s]\n", fUseBmc? "yes": "no" );
-    Abc_Print( -2, "\t-s       : toggle using transient signals [default = %s]\n", fUseTransSigs? "yes": "no" );
-    Abc_Print( -2, "\t-c       : update the current CEX derived for a new AIG after \"tempor\"\n" );
-    Abc_Print( -2, "\t           to match the current AIG (the one before \"tempor\") [default = %s]\n", fUpdateCex? "yes": "no" );
-    Abc_Print( -2, "\t-v       : toggle printing verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w       : toggle printing ternary state space [default = %s]\n", fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandInduction( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int nTimeOut;
-    int nFramesMax;
-    int nConfMax;
-    int fUnique;
-    int fUniqueAll;
-    int fGetCex;
-    int fVerbose;
-    int fVeryVerbose;
-    int c;
-    extern int Abc_NtkDarInduction( Abc_Ntk_t * pNtk, int nTimeOut, int nFramesMax, int nConfMax, int fUnique, int fUniqueAll, int fGetCex, int fVerbose, int fVeryVerbose );
-    // set defaults
-    nTimeOut     =     0;
-    nFramesMax   =     0;
-    nConfMax     =     0;
-    fUnique      =     0;
-    fUniqueAll   =     0;
-    fGetCex      =     0;
-    fVerbose     =     0;
-    fVeryVerbose =     0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "FCTuaxvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFramesMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFramesMax < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nConfMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nConfMax < 0 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nTimeOut = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nTimeOut < 0 )
-                goto usage;
-            break;
-        case 'u':
-            fUnique ^= 1;
-            break;
-        case 'a':
-            fUniqueAll ^= 1;
-            break;
-        case 'x':
-            fGetCex ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'w':
-            fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( Abc_NtkIsComb(pNtk) )
-    {
-        Abc_Print( -1, "The network is combinational.\n" );
-        return 0;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
-        return 0;
-    }
-    if ( Abc_NtkPoNum(pNtk) != 1 )
-    {
-        Abc_Print( -1, "Currently this command works only for single-output miter.\n" );
-        return 0;
-    }
-    if ( fUnique && fUniqueAll )
-    {
-        Abc_Print( -1, "Only one of the options, \"-u\" or \"-a\", should be selected.\n" );
-        return 0;
-    }
-
-    // modify the current network
-    pAbc->Status = Abc_NtkDarInduction( pNtk, nTimeOut, nFramesMax, nConfMax, fUnique, fUniqueAll, fGetCex, fVerbose, fVeryVerbose );
-    if ( fGetCex )
-    {
-        Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
-        Abc_Print( 1,"The current CEX in ABC is set to be the CEX to induction.\n" );
-    }
-    return 0;
-usage:
-    Abc_Print( -2, "usage: ind [-FCT num] [-uaxvwh]\n" );
-    Abc_Print( -2, "\t         runs the inductive case of the K-step induction\n" );
-    Abc_Print( -2, "\t-F num : the max number of timeframes [default = %d]\n", nFramesMax );
-    Abc_Print( -2, "\t-C num : the max number of conflicts by SAT solver [default = %d]\n", nConfMax );
-    Abc_Print( -2, "\t-T num : the limit on runtime per output in seconds [default = %d]\n", nTimeOut );
-    Abc_Print( -2, "\t-u     : toggle adding uniqueness constraints on demand [default = %s]\n", fUnique? "yes": "no" );
-    Abc_Print( -2, "\t-a     : toggle adding uniqueness constraints always [default = %s]\n", fUniqueAll? "yes": "no" );
-    Abc_Print( -2, "\t-x     : toggle returning CEX to induction for the top frame [default = %s]\n", fGetCex? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w     : toggle printing additional verbose information [default = %s]\n", fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandConstr( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk;
-    int c;
-    int nFrames;
-    int nConfs;
-    int nProps;
-    int fRemove;
-    int fStruct;
-    int fInvert;
-    int fOldAlgo;
-    int fVerbose;
-    int nConstrs;
-    extern void Abc_NtkDarConstr( Abc_Ntk_t * pNtk, int nFrames, int nConfs, int nProps, int fStruct, int fOldAlgo, int fVerbose );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    nFrames   =      1;
-    nConfs    =   1000;
-    nProps    =   1000;
-    fRemove   =      0;
-    fStruct   =      0;
-    fInvert   =      0;
-    fOldAlgo  =      0;
-    fVerbose  =      0;
-    nConstrs  =     -1;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "FCPNrsiavh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFrames = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFrames < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nConfs = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nConfs < 0 )
-                goto usage;
-            break;
-        case 'P':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nProps = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nProps < 0 )
-                goto usage;
-            break;
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nConstrs = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nConstrs < 0 )
-                goto usage;
-            break;
-        case 'r':
-            fRemove ^= 1;
-            break;
-        case 's':
-            fStruct ^= 1;
-            break;
-        case 'i':
-            fInvert ^= 1;
-            break;
-        case 'a':
-            fOldAlgo ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
-        return 0;
-    }
-    if ( fRemove )
-    {
-        if ( Abc_NtkConstrNum(pNtk) == 0 )
-        {
-            Abc_Print( -1, "Constraints are not defined.\n" );
-            return 0;
-        }
-        Abc_Print( 1, "Constraints are converted to be primary outputs.\n" );
-        pNtk->nConstrs = 0;
-        return 0;
-    }
-    // consider the case of manual constraint definition
-    if ( nConstrs >= 0 )
-    {
-        if ( Abc_NtkIsComb(pNtk) )
-            Abc_Print( 0, "The network is combinational.\n" );
-        if ( Abc_NtkConstrNum(pNtk) > 0 )
-            Abc_Print( 0, "The network currently has %d constraints.\n", Abc_NtkConstrNum(pNtk) );
-        if ( nConstrs >= Abc_NtkPoNum(pNtk) )
-        {
-            Abc_Print( -1, "The number of constraints specified (%d) should be less than POs (%d).\n", nConstrs, Abc_NtkPoNum(pNtk) );
-            return 0;
-        }
-        Abc_Print( 1, "Setting the last %d POs as constraint outputs.\n", nConstrs );
-        pNtk->nConstrs = nConstrs;
-        return 0;
-    }
-    // consider the case of already defined constraints
-    if ( Abc_NtkConstrNum(pNtk) > 0 )
-    {
-        extern void Abc_NtkDarConstrProfile( Abc_Ntk_t * pNtk, int fVerbose );
-        if ( fInvert )
-        {
-            Abc_NtkInvertConstraints( pNtk );
-            if ( Abc_NtkConstrNum(pNtk) == 1 )
-                Abc_Print( 1, "The output of %d constraint is complemented.\n", Abc_NtkConstrNum(pNtk) );
-            else
-                Abc_Print( 1, "The outputs of %d constraints are complemented.\n", Abc_NtkConstrNum(pNtk) );
-        }
-        if ( fVerbose )
-            Abc_NtkDarConstrProfile( pNtk, fVerbose );
-        return 0;
-    }
-    if ( Abc_NtkIsComb(pNtk) )
-    {
-        Abc_Print( -1, "The network is combinational.\n" );
-        return 0;
-    }
-    // detect constraints using functional/structural methods
-    Abc_NtkDarConstr( pNtk, nFrames, nConfs, nProps, fStruct, fOldAlgo, fVerbose );
-    return 0;
-usage:
-    Abc_Print( -2, "usage: constr [-FCPN num] [-risavh]\n" );
-    Abc_Print( -2, "\t         a toolkit for constraint manipulation\n" );
-    Abc_Print( -2, "\t         if constraints are absent, detect them functionally\n" );
-    Abc_Print( -2, "\t         if constraints are present, profiles them using random simulation\n" );
-    Abc_Print( -2, "\t-F num : the max number of timeframes to consider [default = %d]\n", nFrames );
-    Abc_Print( -2, "\t-C num : the max number of conflicts in SAT solving [default = %d]\n", nConfs );
-    Abc_Print( -2, "\t-P num : the max number of propagations in SAT solving [default = %d]\n", nProps );
-    Abc_Print( -2, "\t-N num : manually set the last <num> POs to be constraints [default = %d]\n", nConstrs );
-    Abc_Print( -2, "\t-r     : manually remove the constraints [default = %s]\n", fRemove? "yes": "no" );
-    Abc_Print( -2, "\t-i     : toggle inverting already defined constraints [default = %s]\n", fInvert? "yes": "no" );
-    Abc_Print( -2, "\t-s     : toggle using structural detection methods [default = %s]\n", fStruct? "yes": "no" );
-    Abc_Print( -2, "\t-a     : toggle fast implication detection [default = %s]\n", !fOldAlgo? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandUnfold( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int nFrames;
-    int nConfs;
-    int nProps;
-    int fStruct;
-    int fOldAlgo;
-    int fVerbose;
-    int c;
-    extern Abc_Ntk_t * Abc_NtkDarUnfold( Abc_Ntk_t * pNtk, int nFrames, int nConfs, int nProps, int fStruct, int fOldAlgo, int fVerbose );
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    nFrames   =      1;
-    nConfs    =   1000;
-    nProps    =   1000;
-    fStruct   =      0;
-    fOldAlgo  =      0;
-    fVerbose  =      0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "FCPsavh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFrames = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFrames < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nConfs = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nConfs < 0 )
-                goto usage;
-            break;
-        case 'P':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nProps = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nProps < 0 )
-                goto usage;
-            break;
-        case 's':
-            fStruct ^= 1;
-            break;
-        case 'a':
-            fOldAlgo ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( Abc_NtkIsComb(pNtk) && Abc_NtkPoNum(pNtk) > 1 )
-    {
-        Abc_Print( -1, "Combinational miter has more than one PO.\n" );
-        return 0;
-    }
-    if ( Abc_NtkIsComb(pNtk) )
-    {
-        extern Gia_Man_t * Gia_ManDupWithConstr( Gia_Man_t * p );
-        Gia_Man_t * pNew;
-        Aig_Man_t * pAig = Abc_NtkToDar( pNtk, 0, 0 );
-        Gia_Man_t * pGia = Gia_ManFromAigSimple( pAig );
-        Aig_ManStop( pAig );
-        pNew = Gia_ManDupWithConstr( pGia );
-        if ( pNew == NULL )
-        {
-            Abc_Print( -1, "Cannot extract constrains from the miter.\n" );
-            return 0;
-        }
-        Gia_ManStop( pGia );
-        pAig = Gia_ManToAigSimple( pNew );
-        Gia_ManStop( pNew );
-        pNtkRes = Abc_NtkFromAigPhase( pAig );
-        Aig_ManStop( pAig );
-        ABC_FREE( pNtkRes->pName );
-        pNtkRes->pName = Extra_UtilStrsav( pNtk->pName );
-        // replace the current network
-        Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-        return 0;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
-        return 0;
-    }
-    if ( Abc_NtkConstrNum(pNtk) > 0 )
-    {
-        Abc_Print( -1, "Constraints are already extracted.\n" );
-        return 0;
-    }
-    if ( Abc_NtkPoNum(pNtk) > 1 && !fStruct )
-    {
-        Abc_Print( -1, "Functional constraint extraction works for single-output miters (use \"orpos\").\n" );
-        return 0;
-    }
-    // modify the current network
-    pNtkRes = Abc_NtkDarUnfold( pNtk, nFrames, nConfs, nProps, fStruct, fOldAlgo, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( 1,"Transformation has failed.\n" );
-        return 0;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-usage:
-    Abc_Print( -2, "usage: unfold [-FCP num] [-savh]\n" );
-    Abc_Print( -2, "\t         unfold hidden constraints as separate outputs\n" );
-    Abc_Print( -2, "\t-F num : the max number of timeframes to consider [default = %d]\n", nFrames );
-    Abc_Print( -2, "\t-C num : the max number of conflicts in SAT solving [default = %d]\n", nConfs );
-    Abc_Print( -2, "\t-P num : the max number of constraint propagations [default = %d]\n", nProps );
-    Abc_Print( -2, "\t-s     : toggle detecting structural constraints [default = %s]\n", fStruct? "yes": "no" );
-    Abc_Print( -2, "\t-a     : toggle fast implication detection [default = %s]\n", !fOldAlgo? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandFold( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkRes;
-    int fCompl;
-    int fVerbose;
-    int c;
-    extern Abc_Ntk_t * Abc_NtkDarFold( Abc_Ntk_t * pNtk, int fCompl, int fVerbose );
-    pNtk = Abc_FrameReadNtk(pAbc);
-    // set defaults
-    fCompl    =   0;
-    fVerbose  =   0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "cvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'c':
-            fCompl ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
-        return 0;
-    }
-    if ( Abc_NtkConstrNum(pNtk) == 0 )
-    {
-        Abc_Print( 0, "The network has no constraints.\n" );
-        return 0;
-    }
-    if ( Abc_NtkIsComb(pNtk) )
-        Abc_Print( 0, "The network is combinational.\n" );
-    // modify the current network
-    pNtkRes = Abc_NtkDarFold( pNtk, fCompl, fVerbose );
-    if ( pNtkRes == NULL )
-    {
-        Abc_Print( 1,"Transformation has failed.\n" );
-        return 0;
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
-    return 0;
-usage:
-    Abc_Print( -2, "usage: fold [-cvh]\n" );
-    Abc_Print( -2, "\t         folds constraints represented as separate outputs\n" );
-    Abc_Print( -2, "\t-c     : toggle complementing constraints while folding [default = %s]\n", fCompl? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandBm( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    FILE * pOut, * pErr;
-    Abc_Ntk_t *pNtk, *pNtk1, *pNtk2;
-    int fDelete1, fDelete2;
-    char ** pArgvNew;
-    int c, nArgcNew;
-    int p_equivalence = FALSE;
-    extern void bmGateWay( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int p_equivalence );
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    pOut = Abc_FrameReadOut(pAbc);
-    pErr = Abc_FrameReadErr(pAbc);
-
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Ph" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        case 'P':
-            p_equivalence = 1;
-            break;
-        default:
-            Abc_Print( -2, "Unknown switch.\n");
-            goto usage;
-        }
-    }
-
-    pArgvNew = argv + globalUtilOptind;
-    nArgcNew = argc - globalUtilOptind;
-    if ( !Abc_NtkPrepareTwoNtks( pErr, pNtk, pArgvNew, nArgcNew , &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
-        return 1;
-
-    if( (unsigned)Abc_NtkPiNum(pNtk1) != (unsigned)Abc_NtkPiNum(pNtk2) || (unsigned)Abc_NtkPoNum(pNtk1) != (unsigned)Abc_NtkPoNum(pNtk2) )
-    {
-        Abc_Print( -2, "Mismatch in the number of inputs or outputs\n");
-        if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
-        if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
-        return 1;
-    }
-
-    bmGateWay( pNtk1, pNtk2, p_equivalence );
-
-    if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
-    if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: bm [-P] <file1> <file2>\n" );
-    Abc_Print( -2, "\t        performs Boolean matching (P-equivalence & PP-equivalence)\n" );
-    Abc_Print( -2, "\t        for equivalent circuits, I/O matches are printed in IOmatch.txt\n" );
-    Abc_Print( -2, "\t-P    : performs P-equivalnce checking\n");
-    Abc_Print( -2, "\t        default is PP-equivalence checking (when -P is not provided)\n" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    Abc_Print( -2, "\tfile1 : the file with the first network\n");
-    Abc_Print( -2, "\tfile2 : the file with the second network\n");
-
-    Abc_Print( -2, "\t        \n" );
-    Abc_Print( -2, "\t        This command was contributed by Hadi Katebi from U Michigan.\n" );
-    Abc_Print( -2, "\t        The paper describing the method: H. Katebi and I. L. Markov.\n" );
-    Abc_Print( -2, "\t        \"Large-scale Boolean matching\". Proc. DATE 2010. \n" );
-    Abc_Print( -2, "\t        http://www.eecs.umich.edu/~imarkov/pubs/conf/date10-match.pdf\n" );
-//    Abc_Print( -2, "\t        \n" );
-
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-               
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandBm2( Abc_Frame_t * pAbc, int argc, char ** argv )
-{   
-    FILE * pOut, * pErr;
-    Abc_Ntk_t *pNtk, *pNtk1, *pNtk2;
-    int fDelete1, fDelete2; 
-    Abc_Obj_t * pObj;
-    char ** pArgvNew;
-    int c, nArgcNew, i; 
-
-    extern void saucyGateWay( Abc_Ntk_t * pNtk, Abc_Obj_t * pNodePo, FILE * gFile, int fBooleanMatching,
-                              int fLookForSwaps, int fFixOutputs, int fFixInputs, int fQuiet, int fPrintTree);
-
-    pNtk = Abc_FrameReadNtk(pAbc);
-    pOut = Abc_FrameReadOut(pAbc);
-    pErr = Abc_FrameReadErr(pAbc);  
-    
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;        
-        default:
-            Abc_Print( -2, "Unknown switch.\n");
-            goto usage;
-        }
-    }
-    
-    pArgvNew = argv + globalUtilOptind;
-    nArgcNew = argc - globalUtilOptind;
-    if ( !Abc_NtkPrepareTwoNtks( pErr, pNtk, pArgvNew, nArgcNew , &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
-        return 1;
-        
-    if( (unsigned)Abc_NtkPiNum(pNtk1) != (unsigned)Abc_NtkPiNum(pNtk2) || 
-        (unsigned)Abc_NtkPoNum(pNtk1) != (unsigned)Abc_NtkPoNum(pNtk2) )
-    {
-        Abc_Print( -2, "Mismatch in the number of inputs or outputs\n");
-        Abc_Print( -2, "*** Networks are NOT equivalent ***\n");
-        if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
-        if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
-        return 1;
-    }
-    
-    Abc_NtkPermute(pNtk2, 1, 1, 0, NULL );
-    Abc_NtkShortNames(pNtk2);
-
-    Abc_NtkForEachCi( pNtk1, pObj, i ) {
-        char * newName = Abc_ObjNamePrefix( pObj, "N1:" );
-        Nm_ManDeleteIdName( pNtk1->pManName, pObj->Id);
-        Abc_ObjAssignName( pObj, newName, NULL );
-    }
-    Abc_NtkForEachCo( pNtk1, pObj, i ) {
-        char * newName = Abc_ObjNamePrefix( pObj, "N1:" );
-        Nm_ManDeleteIdName( pNtk1->pManName, pObj->Id);
-        Abc_ObjAssignName( pObj, newName, NULL );
-    }
-
-    Abc_NtkForEachCi( pNtk2, pObj, i ) {
-        char * newName = Abc_ObjNamePrefix( pObj, "N2:" );
-        Nm_ManDeleteIdName( pNtk2->pManName, pObj->Id);
-        Abc_ObjAssignName( pObj, newName, NULL );
-    }
-    Abc_NtkForEachCo( pNtk2, pObj, i ) {
-        char * newName = Abc_ObjNamePrefix( pObj, "N2:" );
-        Nm_ManDeleteIdName( pNtk2->pManName, pObj->Id);
-        Abc_ObjAssignName( pObj, newName, NULL );
-    }
-
-    Abc_NtkAppend( pNtk1, pNtk2, 1 );
-    saucyGateWay( pNtk1, NULL, NULL, 1, 0, 0, 0, 0, 0);
-
-    if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
-    if ( fDelete2 ) Abc_NtkDelete( pNtk2 );     
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: bm2  <file1> <file2>\n" );
-    Abc_Print( -2, "\t        performs Boolean matching (PP-equivalence)\n" );
-    Abc_Print( -2, "\t        for equivalent circuits, permutation that maps one circuit\n" );
-    Abc_Print( -2, "\t        to another is printed to standard output (PIs and POs of the\n" );
-    Abc_Print( -2, "\t        first network have prefix \"N1:\", while PIs and POs of the\n" ); 
-    Abc_Print( -2, "\t        second network have prefix \"N2:\")\n" ); 
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    Abc_Print( -2, "\tfile1 : the file with the first network\n");
-    Abc_Print( -2, "\tfile2 : the file with the second network\n");
-
-    Abc_Print( -2, "\t        \n" );
-    Abc_Print( -2, "\t        This command was contributed by Hadi Katebi from U Michigan.\n" );
-    Abc_Print( -2, "\t        The paper describing the method: H. Katebi, K. Sakallah and\n");
-    Abc_Print( -2, "\t        I. L. Markov.\n" );
-    Abc_Print( -2, "\t        \"Generalized Boolean Symmetries Through Nested Partition\n");
-    Abc_Print( -2, "\t        Refinement\". Proc. ICCAD 2013. \n" );
-    //Abc_Print( -2, "\t        http://www.eecs.umich.edu/~imarkov/pubs/conf/date10-match.pdf\n" );
-//    Abc_Print( -2, "\t        \n" );
-
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-               
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandSaucy( Abc_Frame_t * pAbc, int argc, char ** argv )
-{   
-    Abc_Ntk_t *pNtk;
-    char * outputName = NULL;
-    FILE * gFile = NULL;
-    int fOutputsOneAtTime = 0;
-    int fFixOutputs = 0;
-    int fFixInputs = 0;
-    int fLookForSwaps = 0;
-    int fQuiet = 0;
-    int fPrintTree = 0;
-    int c;
-
-    extern void saucyGateWay( Abc_Ntk_t * pNtk, Abc_Obj_t * pNodePo, FILE * gFile, int fBooleanMatching,
-                              int fLookForSwaps, int fFixOutputs, int fFixInputs, int fQuiet, int fPrintTree);
-
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "OFiosqvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'O':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-O\" should be followed by an output name or the keyword all.\n" );
-                goto usage;
-            }
-            outputName = argv[globalUtilOptind];
-            if ( !strcmp(argv[globalUtilOptind], "all") )
-                fOutputsOneAtTime ^= 1;
-            globalUtilOptind++;         
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by a file name.\n" );
-                goto usage;
-            }           
-            if ( (gFile = fopen( argv[globalUtilOptind], "w" )) == NULL )
-            {
-                Abc_Print( -1, "Cannot create output file \"%s\". ", argv[globalUtilOptind] );              
-                return 1;
-            }
-            globalUtilOptind++;         
-            break;
-        case 'i':
-            fFixOutputs ^= 1;
-            break;
-        case 'o':
-            fFixInputs ^= 1;
-            break;
-        case 's':
-            fLookForSwaps ^= 1;
-            break;
-        case 'q':
-            fQuiet ^= 1;
-            break;
-        case 'v':
-            fPrintTree ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            Abc_Print( -2, "Unknown switch.\n");
-            goto usage;
-        }
-    }    
-    
-    pNtk = Abc_FrameReadNtk(pAbc);  
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command works only for AIGs (run \"strash\").\n" );
-        return 1;
-    }
-
-    pNtk = Abc_NtkDup( pNtk );
-    Abc_NtkOrderObjsByName( pNtk, 1 );
-
-    if (fOutputsOneAtTime) {
-        int i;
-        Abc_Obj_t * pNodePo;
-        FILE * hadi = fopen("hadi.txt", "w");
-        Abc_NtkForEachPo( pNtk, pNodePo, i ) {
-            printf("Ouput %s\n\n", Abc_ObjName(pNodePo));
-            saucyGateWay( pNtk, pNodePo, gFile, 0, fLookForSwaps, fFixOutputs, fFixInputs, fQuiet, fPrintTree );
-            printf("----------------------------------------\n");           
-        }
-        fclose(hadi);
-    } else if (outputName != NULL) {
-        int i;
-        Abc_Obj_t * pNodePo;        
-        Abc_NtkForEachPo( pNtk, pNodePo, i ) {
-            if (!strcmp(Abc_ObjName(pNodePo), outputName)) {
-                saucyGateWay( pNtk, pNodePo, gFile, 0, fLookForSwaps, fFixOutputs, fFixInputs, fQuiet, fPrintTree );
-                Abc_NtkDelete( pNtk );
-                return 0;
-            }   
-        }
-        Abc_Print( -1, "Output not found\n" );
-        return 1;       
-    } else
-        saucyGateWay( pNtk, NULL, gFile, 0, fLookForSwaps, fFixOutputs, fFixInputs, fQuiet, fPrintTree );
-
-    if (gFile != NULL) fclose(gFile);
-    Abc_NtkDelete( pNtk );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: saucy3 [-O <name>] [-F <file>] [-iosqvh]\n\n" );
-    Abc_Print( -2, "\t            computes functional symmetries of the netowrk\n" );
-    Abc_Print( -2, "\t            prints symmetry generators to the standard output\n" );   
-    Abc_Print( -2, "\t-O <name> : (optional) compute symmetries only for output given by name\n");
-    Abc_Print( -2, "\t            only inputs in the output cone are permuted\n");  
-    Abc_Print( -2, "\t            (special case) name=all, compute symmetries for each\n" );
-    Abc_Print( -2, "\t            output, but only one output at a time\n" );
-    Abc_Print( -2, "\t            [default = compute symmetries by permuting all I/Os]\n" );
-    Abc_Print( -2, "\t-F <file> : print symmetry generators to file [default = stdout]\n");
-    Abc_Print( -2, "\t-i        : permute just the inputs (fix the outputs) [default = no]\n");
-    Abc_Print( -2, "\t-o        : permute just the outputs (fix the inputs) [default = no]\n");
-    Abc_Print( -2, "\t-s        : only look for swaps of inputs [default = no]\n");
-    Abc_Print( -2, "\t-q        : quiet (do not print symmetry generators) [default = no]\n");
-    Abc_Print( -2, "\t-v        : verbose (print the search tree) [default = no]\n");   
-    Abc_Print( -2, "\t-h        : print the command usage\n"); 
-
-    Abc_Print( -2, "\t            \n" );
-    Abc_Print( -2, "\t            This command was contributed by Hadi Katebi from U Michigan.\n" );
-    Abc_Print( -2, "\t            The paper describing the method: H. Katebi, K. Sakallah and\n");
-    Abc_Print( -2, "\t            I. L. Markov.\n" );
-    Abc_Print( -2, "\t            \"Generalized Boolean Symmetries Through Nested Partition\n");
-    Abc_Print( -2, "\t            Refinement\". Proc. ICCAD 2013. \n" );
-    //Abc_Print( -2, "\t          http://www.eecs.umich.edu/~imarkov/pubs/conf/date10-match.pdf\n" );
-    Abc_Print( -2, "\t            Saucy webpage: http://vlsicad.eecs.umich.edu/BK/SAUCY/\n" );
-
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandTestCex( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk;
-    int c;
-    int nOutputs = 0;
-    int fCheckAnd = 1;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Oah" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'O':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-O\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nOutputs = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nOutputs < 0 )
-                goto usage;
-            break;
-        case 'a':
-            fCheckAnd ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            Abc_Print( -2, "Unknown switch.\n");
-            goto usage;
-        }
-    }
-
-    if ( pAbc->pCex == NULL )
-    {
-        Abc_Print( 1, "There is no current cex.\n");
-        return 0;
-    }
-
-    if ( !fCheckAnd )
-    {
-        // check the main AIG
-        pNtk = Abc_FrameReadNtk(pAbc);
-        if ( pNtk == NULL )
-            Abc_Print( 1, "Main AIG: There is no current network.\n");
-        else if ( !Abc_NtkIsStrash(pNtk) )
-            Abc_Print( 1, "Main AIG: The current network is not an AIG.\n");
-        else if ( Abc_NtkPiNum(pNtk) != pAbc->pCex->nPis )
-            Abc_Print( 1, "Main AIG: The number of PIs (%d) is different from cex (%d).\n", Abc_NtkPiNum(pNtk), pAbc->pCex->nPis );
-        else
-        {
-            extern int Abc_NtkVerifyCex( Abc_Ntk_t * pNtk, Abc_Cex_t * p );
-            int iPoOld = pAbc->pCex->iPo;
-            pAbc->pCex->iPo = Abc_NtkVerifyCex( pNtk, pAbc->pCex );
-            if ( pAbc->pCex->iPo == -1 )
-                Abc_Print( 1, "Main AIG: The cex does not fail any outputs.\n" );
-            else if ( iPoOld != pAbc->pCex->iPo )
-                Abc_Print( 1, "Main AIG: The cex refined PO %d instead of PO %d.\n", pAbc->pCex->iPo, iPoOld );
-            else
-                Abc_Print( 1, "Main AIG: The cex is correct.\n" );
-        }
-    }
-    else
-    {
-        // check the AND AIG
-        if ( pAbc->pGia == NULL )
-            Abc_Print( 1, "And  AIG: There is no current network.\n");
-        else if ( Gia_ManPiNum(pAbc->pGia) != pAbc->pCex->nPis )
-            Abc_Print( 1, "And  AIG: The number of PIs (%d) is different from cex (%d).\n", Gia_ManPiNum(pAbc->pGia), pAbc->pCex->nPis );
-        else
-        {
-            int iPoOld = pAbc->pCex->iPo;
-            pAbc->pCex->iPo = Gia_ManFindFailedPoCex( pAbc->pGia, pAbc->pCex, nOutputs );
-            if ( pAbc->pCex->iPo == -1 )
-                Abc_Print( 1, "And  AIG: The cex does not fail any outputs.\n" );
-            else if ( iPoOld != pAbc->pCex->iPo )
-                Abc_Print( 1, "And  AIG: The cex refined PO %d instead of PO %d.\n", pAbc->pCex->iPo, iPoOld );
-            else
-                Abc_Print( 1, "And  AIG: The cex is correct.\n" );
-        }
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: testcex [-O num] [-ah]\n" );
-    Abc_Print( -2, "\t         tests the current cex against the current AIG or the &-AIG\n" );
-    Abc_Print( -2, "\t-O num : the number of real POs in the PO list [default = %d]\n", nOutputs );
-    Abc_Print( -2, "\t-a     : toggle checking the current AIG or the &-AIG [default = %s]\n", fCheckAnd ? "&-AIG": "current AIG" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandPdr( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern int Abc_NtkDarPdr( Abc_Ntk_t * pNtk, Pdr_Par_t * pPars );
-    Pdr_Par_t Pars, * pPars = &Pars;
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    Pdr_ManSetDefaultParams( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "MFCRTHGaxrmsipdgvwzh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'M':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nRecycle = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nRecycle < 0 )
-                goto usage;
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nFrameMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nFrameMax < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nConfLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nConfLimit < 0 )
-                goto usage;
-            break;
-        case 'R':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nRestLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nRestLimit < 0 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nTimeOut = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nTimeOut < 0 )
-                goto usage;
-            break;
-        case 'H':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-H\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nTimeOutOne = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nTimeOutOne < 0 )
-                goto usage;
-            break;
-        case 'G':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-G\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nTimeOutGap = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nTimeOutGap < 0 )
-                goto usage;
-            break;
-        case 'a':
-            pPars->fSolveAll ^= 1;
-            break;
-        case 'x':
-            pPars->fStoreCex ^= 1;
-            break;
-        case 'r':
-            pPars->fTwoRounds ^= 1;
-            break;
-        case 'm':
-            pPars->fMonoCnf ^= 1;
-            break;
-        case 's':
-            pPars->fShortest ^= 1;
-            break;
-        case 'i':
-            pPars->fShiftStart ^= 1;
-            break;
-        case 'p':
-            pPars->fReuseProofOblig ^= 1;
-            break;
-        case 'd':
-            pPars->fDumpInv ^= 1;
-            break;
-        case 'g':
-            pPars->fSkipGeneral ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'w':
-            pPars->fVeryVerbose ^= 1;
-            break;
-        case 'z':
-            pPars->fNotVerbose ^= 1;
-            break;
-        case 'h':
-        default:
-            goto usage;
-        }
-    }
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -2, "There is no current network.\n");
-        return 0;
-    }
-    if ( Abc_NtkLatchNum(pNtk) == 0 )
-    {
-        Abc_Print( -2, "The current network is combinational.\n");
-        return 0;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -2, "The current network is not an AIG (run \"strash\").\n");
-        return 0;
-    }
-    // run the procedure
-    pPars->fUseBridge = pAbc->fBridgeMode;
-    pAbc->Status  = Abc_NtkDarPdr( pNtk, pPars );
-    pAbc->nFrames = pNtk->vSeqModelVec ? -1 : pPars->iFrame;
-    Abc_FrameReplacePoStatuses( pAbc, &pPars->vOutMap );
-    if ( pNtk->vSeqModelVec )
-        Abc_FrameReplaceCexVec( pAbc, &pNtk->vSeqModelVec );
-    else
-        Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: pdr [-MFCRTHG <num>] [-axrmsipdgvwzh]\n" );
-    Abc_Print( -2, "\t         model checking using property directed reachability (aka IC3)\n" );
-    Abc_Print( -2, "\t         pioneered by Aaron Bradley (http://ecee.colorado.edu/~bradleya/ic3/)\n" );
-    Abc_Print( -2, "\t         with improvements by Niklas Een (http://een.se/niklas/)\n" );
-    Abc_Print( -2, "\t-M num : limit on unused vars to trigger SAT solver recycling [default = %d]\n",       pPars->nRecycle );
-    Abc_Print( -2, "\t-F num : limit on timeframes explored to stop computation [default = %d]\n",           pPars->nFrameMax );
-    Abc_Print( -2, "\t-C num : limit on conflicts in one SAT call (0 = no limit) [default = %d]\n",          pPars->nConfLimit );
-    Abc_Print( -2, "\t-R num : limit on proof obligations before a restart (0 = no limit) [default = %d]\n", pPars->nRestLimit );
-    Abc_Print( -2, "\t-T num : runtime limit, in seconds (0 = no limit) [default = %d]\n",                   pPars->nTimeOut );
-    Abc_Print( -2, "\t-H num : runtime limit per output, in miliseconds (with \"-a\") [default = %d]\n",     pPars->nTimeOutOne );
-    Abc_Print( -2, "\t-G num : runtime gap since the last CEX (0 = no limit) [default = %d]\n",              pPars->nTimeOutGap );
-    Abc_Print( -2, "\t-a     : toggle solving all outputs even if one of them is SAT [default = %s]\n",      pPars->fSolveAll? "yes": "no" );
-    Abc_Print( -2, "\t-x     : toggle storing CEXes when solving all outputs [default = %s]\n",              pPars->fStoreCex? "yes": "no" );
-    Abc_Print( -2, "\t-r     : toggle using more effort in generalization [default = %s]\n",                 pPars->fTwoRounds? "yes": "no" );
-    Abc_Print( -2, "\t-m     : toggle using monolythic CNF computation [default = %s]\n",                    pPars->fMonoCnf? "yes": "no" );
-    Abc_Print( -2, "\t-s     : toggle creating only shortest counter-examples [default = %s]\n",             pPars->fShortest? "yes": "no" );
-    Abc_Print( -2, "\t-i     : toggle clause pushing from an intermediate timeframe [default = %s]\n",       pPars->fShiftStart? "yes": "no" );
-    Abc_Print( -2, "\t-p     : toggle reusing proof-obligations in the last timeframe [default = %s]\n",     pPars->fReuseProofOblig? "yes": "no" );
-    Abc_Print( -2, "\t-d     : toggle dumping invariant (valid if init state is all-0) [default = %s]\n",    pPars->fDumpInv? "yes": "no" );
-    Abc_Print( -2, "\t-g     : toggle skipping expensive generalization step [default = %s]\n",              pPars->fSkipGeneral? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing optimization summary [default = %s]\n",                       pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w     : toggle printing detailed stats default = %s]\n",                              pPars->fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-z     : toggle suppressing report about solved outputs [default = %s]\n",             pPars->fNotVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandReconcile( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Abc_Cex_t * Llb4_Nonlin4NormalizeCex( Aig_Man_t * pAigOrg, Aig_Man_t * pAigRpm, Abc_Cex_t * pCexRpm );
-    Abc_Cex_t * pCex;
-    Abc_Ntk_t * pNtk1 = NULL, * pNtk2 = NULL;
-    Aig_Man_t * pAig1 = NULL, * pAig2 = NULL;
-    int c;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            Abc_Print( -2, "Unknown switch.\n");
-            goto usage;
-        }
-    }
-
-    if ( argc != globalUtilOptind + 2 && argc != globalUtilOptind )
-    {
-        Abc_Print( 1,"Does not seen to have two files names as arguments.\n" );
-        return 1;
-    }
-    if ( pAbc->pCex == NULL )
-    {
-        Abc_Print( 1,"There is no current counter-example.\n" );
-        return 1;
-    }
-
-    if ( argc == globalUtilOptind + 2 )
-    {
-        // derive networks
-        pNtk1 = Io_Read( argv[globalUtilOptind], Io_ReadFileType(argv[globalUtilOptind]), 1, 0 );
-        if ( pNtk1 == NULL )
-            return 1;
-        pNtk2 = Io_Read( argv[globalUtilOptind+1], Io_ReadFileType(argv[globalUtilOptind+1]), 1, 0 );
-        if ( pNtk2 == NULL )
-        {
-            Abc_NtkDelete( pNtk1 );
-            return 1;
-        }
-        // create counter-examples
-        pAig1 = Abc_NtkToDar( pNtk1, 0, 0 );
-        pAig2 = Abc_NtkToDar( pNtk2, 0, 0 );
-    }
-    else if ( argc == globalUtilOptind )
-    {
-        if ( pAbc->pNtkCur == NULL )
-        {
-            Abc_Print( 1, "There is no AIG in the main-space.\n");
-            return 0;
-        }
-        if ( pAbc->pGia == NULL )
-        {
-            Abc_Print( 1, "There is no AIG in the &-space.\n");
-            return 0;
-        }
-        // create counter-examples
-        pAig1 = Abc_NtkToDar( pAbc->pNtkCur, 0, 0 );
-        pAig2 = Gia_ManToAigSimple( pAbc->pGia );
-    }
-    else assert( 0 );
-    pCex = Llb4_Nonlin4NormalizeCex( pAig1, pAig2, pAbc->pCex );
-    Aig_ManStop( pAig1 );
-    Aig_ManStop( pAig2 );
-    if ( pNtk2 )  Abc_NtkDelete( pNtk2 );
-    if ( pCex == NULL )
-    {
-        Abc_Print( 1,"Counter-example computation has failed.\n" );
-        if ( pNtk1 )  Abc_NtkDelete( pNtk1 );
-        return 1;
-    }
-
-    // replace the current network
-    if ( pNtk1 )
-        Abc_FrameReplaceCurrentNetwork( pAbc, pNtk1 );
-    // update the counter-example
-    pAbc->nFrames = pCex->iFrame;
-    Abc_FrameReplaceCex( pAbc, &pCex );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: reconcile [-h] <fileOrigin> <fileReparam>\n" );
-    Abc_Print( -2, "\t        reconciles current CEX with <fileOrigin>\n" );
-    Abc_Print( -2, "\t        More specifically:\n" );
-    Abc_Print( -2, "\t        (i) assumes that <fileReparam> is an AIG derived by input\n" );
-    Abc_Print( -2, "\t        reparametrization of <fileOrigin> without seq synthesis;\n" );
-    Abc_Print( -2, "\t        (ii) assumes that current CEX is valid for <fileReparam>;\n" );
-    Abc_Print( -2, "\t        (iii) derives new CEX for <fileOrigin> and sets this CEX\n" );
-    Abc_Print( -2, "\t        and <fileOrigin> to be current CEX and current network\n" );
-    Abc_Print( -2, "\t<fileOrigin>   : file name with the original AIG\n");
-    Abc_Print( -2, "\t<fileReparam>  : file name with the reparametrized AIG\n");
-    Abc_Print( -2, "\t        (if both file names are not given on the command line,\n");
-    Abc_Print( -2, "\t        original/reparam AIG has to be in the main-space/&-space)\n");
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandCexSave( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    int c;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pCex == NULL )
-    {
-        Abc_Print( -1, "Current CEX is not available..\n" );
-        return 1;
-    }
-    ABC_FREE( pAbc->pCex2 );
-    pAbc->pCex2 = Abc_CexDup( pAbc->pCex, -1 );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: cexsave [-h]\n" );
-    Abc_Print( -2, "\t        saves the current CEX into the internal storage\n" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandCexLoad( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    int c;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pCex2 == NULL )
-    {
-        Abc_Print( -1, "Saved CEX is not available.\n" );
-        return 1;
-    }
-    ABC_FREE( pAbc->pCex );
-    pAbc->pCex = Abc_CexDup( pAbc->pCex2, -1 );
-    // update status
-    pAbc->nFrames = pAbc->pCex2->iFrame;
-    pAbc->Status = 0;
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: cexload [-h]\n" );
-    Abc_Print( -2, "\t        loads the current CEX from the internal storage\n" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandCexCut( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtkNew;
-    int c, iFrStart = 0;
-    int iFrStop     = ABC_INFINITY;
-    int fCombOnly   = 0;
-    int fUseOne     = 0;
-    int fAllFrames  = 0;
-    int fVerbose    = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "FGcnmvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            iFrStart = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( iFrStart < 0 )
-                goto usage;
-            break;
-        case 'G':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-G\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            iFrStop = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( iFrStop < 0 )
-                goto usage;
-            break;
-        case 'c':
-            fCombOnly ^= 1;
-            break;
-        case 'n':
-            fUseOne ^= 1;
-            break;
-        case 'm':
-            fAllFrames ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            Abc_Print( -2, "Unknown switch.\n");
-            goto usage;
-        }
-    }
-
-    if ( pAbc->pCex == NULL )
-    {
-        Abc_Print( 1, "There is no current cex.\n");
-        return 0;
-    }
-    if ( pAbc->pNtkCur == NULL )
-    {
-        Abc_Print( 1, "There is no AIG in the &-space.\n");
-        return 0;
-    }
-    if ( !Abc_NtkIsStrash(pAbc->pNtkCur) )
-    {
-        Abc_Print( 1, "Current network is not an AIG.\n");
-        return 0;
-    }
-    if ( iFrStop == ABC_INFINITY )
-        iFrStop = pAbc->pCex->iFrame;
-
-    {
-        Aig_Man_t * pAig = Abc_NtkToDar( pAbc->pNtkCur, 0, 1 );
-        Aig_Man_t * pAigNew = Bmc_AigTargetStates( pAig, pAbc->pCex, iFrStart, iFrStop, fCombOnly, fUseOne, fAllFrames, fVerbose );
-        Aig_ManStop( pAig );
-        if ( pAigNew == NULL )
-        {
-            Abc_Print( 1, "Command has failed.\n");
-            return 0;
-        }
-        pNtkNew = Abc_NtkFromAigPhase( pAigNew );
-        pNtkNew->pName = Extra_UtilStrsav( pAbc->pNtkCur->pName );
-        Aig_ManStop( pAigNew );
-        // update the network
-        Abc_FrameReplaceCurrentNetwork( pAbc, pNtkNew );
-    }
-/*
-    pGiaNew = Bmc_GiaTargetStates( pAbc->pGia, pAbc->pCex, iFrStart, iFrStop, fCombOnly, fUseOne, fVerbose );
-    if ( pGiaNew == NULL )
-    {
-        Abc_Print( 1, "Command has failed.\n");
-        return 0;
-    }
-    Abc_FrameUpdateGia( pAbc, pGiaNew );
-*/
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: cexcut [-FG num] [-cnmvh]\n" );
-    Abc_Print( -2, "\t         creates logic for bad states using the current CEX\n" );
-    Abc_Print( -2, "\t-F num : 0-based number of the starting frame [default = %d]\n", iFrStart );
-    Abc_Print( -2, "\t-G num : 0-based number of the ending frame [default = %d]\n",   iFrStop );
-    Abc_Print( -2, "\t-c     : toggle outputting unate combinational circuit [default = %s]\n",  fCombOnly? "yes": "no" );
-    Abc_Print( -2, "\t-n     : toggle generating only one bad state [default = %s]\n", fUseOne? "yes": "no" );
-    Abc_Print( -2, "\t-m     : toggle generating bad states for all frames after G [default = %s]\n", fAllFrames? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n",  fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandCexMerge( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Cex_t * pCexNew;
-    int c;
-    int iFrStart = 0;
-    int iFrStop  = ABC_INFINITY;
-    int fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "FGvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            iFrStart = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( iFrStart < 0 )
-                goto usage;
-            break;
-        case 'G':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-G\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            iFrStop = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( iFrStop < 0 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            Abc_Print( -2, "Unknown switch.\n");
-            goto usage;
-        }
-    }
-
-    if ( pAbc->pCex == NULL )
-    {
-        Abc_Print( 1, "There is no current cex.\n");
-        return 0;
-    }
-    if ( pAbc->pCex2 == NULL )
-    {
-        Abc_Print( 1, "There is no saved cex.\n");
-        return 0;
-    }
-    if ( iFrStop - iFrStart + pAbc->pCex->iPo < pAbc->pCex->iFrame )
-    {
-        Abc_Print( 1, "Current CEX does not allow to shorten the saved CEX.\n");
-        return 0;
-    }
-    pCexNew = Abc_CexMerge( pAbc->pCex2, pAbc->pCex, iFrStart, iFrStop );
-    if ( pCexNew == NULL )
-    {
-        Abc_Print( 1, "Merging CEXes has failed.\n");
-        return 0;
-    }
-    // replace the saved CEX
-    ABC_FREE( pAbc->pCex2 );
-    pAbc->pCex2 = pCexNew;
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: cexmerge [-FG num] [-vh]\n" );
-    Abc_Print( -2, "\t         merges the current CEX into the saved one\n" );
-    Abc_Print( -2, "\t         and sets the resulting CEX as the saved one\n" );
-    Abc_Print( -2, "\t-F num : 0-based number of the starting frame [default = %d]\n", iFrStart );
-    Abc_Print( -2, "\t-G num : 0-based number of the ending frame [default = %d]\n",   iFrStop );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandCexMin( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk;
-    Abc_Cex_t * vCexNew = NULL;
-    int c;
-    int nConfLimit = 1000;
-    int nRounds    =    1;
-    int fVerbose   =    0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "CRvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nConfLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nConfLimit < 0 )
-                goto usage;
-            break;
-        case 'R':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nRounds = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nRounds < 0 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            Abc_Print( -2, "Unknown switch.\n");
-            goto usage;
-        }
-    }
-
-    if ( pAbc->pCex == NULL )
-    {
-        Abc_Print( 1, "There is no current cex.\n");
-        return 0;
-    }
-
-    // check the main AIG
-    pNtk = Abc_FrameReadNtk(pAbc);
-    if ( pNtk == NULL )
-        Abc_Print( 1, "Main AIG: There is no current network.\n");
-    else if ( !Abc_NtkIsStrash(pNtk) )
-        Abc_Print( 1, "Main AIG: The current network is not an AIG.\n");
-    else if ( Abc_NtkPiNum(pNtk) != pAbc->pCex->nPis )
-        Abc_Print( 1, "Main AIG: The number of PIs (%d) is different from cex (%d).\n", Abc_NtkPiNum(pNtk), pAbc->pCex->nPis );
-//      else if ( Abc_NtkLatchNum(pNtk) != pAbc->pCex->nRegs )
-//          Abc_Print( 1, "Main AIG: The number of registers (%d) is different from cex (%d).\n", Abc_NtkLatchNum(pNtk), pAbc->pCex->nRegs );
-//      else if ( Abc_NtkPoNum(pNtk) <= pAbc->pCex->iPo )
-//          Abc_Print( 1, "Main AIG: The number of POs (%d) is less than the PO index in cex (%d).\n", Abc_NtkPoNum(pNtk), pAbc->pCex->iPo );
-    else
-    {
-        Aig_Man_t * pAig = Abc_NtkToDar( pNtk, 0, 1 );
-        Gia_Man_t * pGia = Gia_ManFromAigSimple( pAig );
-//        if ( !Gia_ManVerifyCex( pGia, pAbc->pCex, 0 ) )
-        int iPoOld = pAbc->pCex->iPo;
-        pAbc->pCex->iPo = Gia_ManFindFailedPoCex( pGia, pAbc->pCex, 0 );
-        Gia_ManStop( pGia );
-        if ( pAbc->pCex->iPo == -1 )
-        {
-            pAbc->pCex->iPo = iPoOld;
-            Abc_Print( -1, "Main AIG: The cex does not fail any outputs.\n" );
-            return 0;
-        }
-        else if ( iPoOld != pAbc->pCex->iPo )
-            Abc_Print( 0, "Main AIG: The cex refined PO %d instead of PO %d.\n", pAbc->pCex->iPo, iPoOld );
-        // perform minimization
-        vCexNew = Saig_ManCexMinPerform( pAig, pAbc->pCex );
-        Aig_ManStop( pAig );
-        Abc_CexFree( vCexNew );
-//        Abc_FrameReplaceCex( pAbc, &vCexNew );
-
-//        Abc_Print( 1,"Implementation of this command is not finished.\n" );
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: cexmin [-CR num] [-vh]\n" );
-    Abc_Print( -2, "\t         reduces the length of the counter-example\n" );
-    Abc_Print( -2, "\t-C num : the maximum number of conflicts [default = %d]\n", nConfLimit );
-    Abc_Print( -2, "\t-R num : the number of minimization rounds [default = %d]\n", nRounds );
-    Abc_Print( -2, "\t-v     : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandDualRail( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Vec_Int_t * Abc_NtkFindDcLatches( Abc_Ntk_t * pNtk );
-    Abc_Ntk_t * pNtk, * pNtkNew = NULL;
-    Aig_Man_t * pAig, * pAigNew;
-    Vec_Int_t * vDcFlops = NULL;
-    int c;
-    int nDualPis   = 0;
-    int fDualFfs   = 0;
-    int fDualDcFfs = 0;
-    int fMiterFfs  = 0;
-    int fComplPo   = 0;
-    int fCheckZero = 0;
-    int fCheckOne  = 0;
-    int fVerbose   = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Itxfczovh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'I':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nDualPis = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nDualPis < 0 )
-                goto usage;
-            break;
-        case 't':
-            fDualFfs ^= 1;
-            break;
-        case 'x':
-            fDualDcFfs ^= 1;
-            break;
-        case 'f':
-            fMiterFfs ^= 1;
-            break;
-        case 'c':
-            fComplPo ^= 1;
-            break;
-        case 'z':
-            fCheckZero ^= 1;
-            break;
-        case 'o':
-            fCheckOne ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            Abc_Print( -2, "Unknown switch.\n");
-            goto usage;
-        }
-    }
-
-    // check the main AIG
-    pNtk = Abc_FrameReadNtk(pAbc);
-    if ( pNtk == NULL )
-    {
-        Abc_Print( 1, "Main AIG: There is no current network.\n");
-        return 0;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( 1, "Main AIG: The current network is not an AIG.\n");
-        return 0;
-    }
-
-    if ( fDualDcFfs )
-        vDcFlops = Abc_NtkFindDcLatches( pNtk );
-
-    // transform
-    pAig = Abc_NtkToDar( pNtk, 0, 1 );
-    pAigNew = Saig_ManDupDual( pAig, vDcFlops, nDualPis, fDualFfs, fMiterFfs, fComplPo, fCheckZero, fCheckOne );
-    Aig_ManStop( pAig );
-    pNtkNew = Abc_NtkFromAigPhase( pAigNew );
-    pNtkNew->pName = Extra_UtilStrsav(pNtk->pName);
-    Aig_ManStop( pAigNew );
-    Vec_IntFreeP( &vDcFlops );
-
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkNew );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: dualrail [-I num] [-txfczovh]\n" );
-    Abc_Print( -2, "\t         transforms the current AIG into a dual-rail miter\n" );
-    Abc_Print( -2, "\t         expressing the property \"at least one PO has ternary value\"\n" );
-    Abc_Print( -2, "\t         (to compute an initialization sequence, use switches \"-tfc\")\n" );
-    Abc_Print( -2, "\t-I num : the number of first PIs interpreted as ternary [default = %d]\n", nDualPis );
-    Abc_Print( -2, "\t-t     : toggle ternary flop init values for all flops [default = %s]\n", fDualFfs? "yes": "const0 init values" );
-    Abc_Print( -2, "\t-x     : toggle ternary flop init values for DC-valued flops [default = %s]\n", fDualDcFfs? "yes": "const0 init values" );
-    Abc_Print( -2, "\t-f     : toggle mitering flops instead of POs [default = %s]\n", fMiterFfs? "flops": "POs" );
-    Abc_Print( -2, "\t-c     : toggle complementing the miter output [default = %s]\n", fComplPo? "yes": "no" );
-    Abc_Print( -2, "\t-z     : toggle checking PO==0 instead of PO==X [default = %s]\n", fCheckZero? "yes": "no" );
-    Abc_Print( -2, "\t-o     : toggle checking PO==1 instead of PO==X [default = %s]\n", fCheckOne? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandBlockPo( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkNew = NULL;
-    Aig_Man_t * pAig;
-    int c;
-    int nCycles = 0;
-    int fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Fvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nCycles = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nCycles < 0 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            Abc_Print( -2, "Unknown switch.\n");
-            goto usage;
-        }
-    }
-
-    // check the main AIG
-    pNtk = Abc_FrameReadNtk(pAbc);
-    if ( pNtk == NULL )
-    {
-        Abc_Print( 1, "Main AIG: There is no current network.\n");
-        return 0;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( 1, "Main AIG: The current network is not an AIG.\n");
-        return 0;
-    }
-    if ( nCycles == 0 )
-    {
-        Abc_Print( 1, "The number of time frame is 0. The circuit is left unchanged.\n" );
-        return 0;
-    }
-
-    // transform
-    pAig = Abc_NtkToDar( pNtk, 0, 1 );
-    Saig_ManBlockPo( pAig, nCycles );
-    pNtkNew = Abc_NtkFromAigPhase( pAig );
-    Aig_ManStop( pAig );
-    // transfer the name
-    pNtkNew->pName = Extra_UtilStrsav(pNtk->pName);
-    pNtkNew->pSpec = Extra_UtilStrsav(pNtk->pSpec);
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkNew );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: blockpo [-F num] [-fvh]\n" );
-    Abc_Print( -2, "\t         forces the miter outputs to be \"true\" in the first F frames\n" );
-    Abc_Print( -2, "\t-F num : the number of time frames [default = %d]\n", nCycles );
-    Abc_Print( -2, "\t-v     : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandIso( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk, * pNtkNew = NULL;
-    Aig_Man_t * pAig, * pTemp;
-    Vec_Ptr_t * vPosEquivs = NULL;
-    int c, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            Abc_Print( -2, "Unknown switch.\n");
-            goto usage;
-        }
-    }
-
-    // check the main AIG
-    pNtk = Abc_FrameReadNtk(pAbc);
-    if ( pNtk == NULL )
-    {
-        Abc_Print( 1, "Main AIG: There is no current network.\n");
-        return 0;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( 1, "Main AIG: The current network is not an AIG.\n");
-        return 0;
-    }
-    if ( Abc_NtkPoNum(pNtk) == 1 )
-    {
-        Abc_Print( 1, "Current AIG has only one PO. Transformation is not performed.\n");
-        return 0;
-    }
-
-    // transform
-    pAig = Abc_NtkToDar( pNtk, 0, 1 );
-    pTemp = Saig_ManIsoReduce( pAig, &vPosEquivs, fVerbose );
-    pNtkNew = Abc_NtkFromAigPhase( pTemp );
-    Aig_ManStop( pTemp );
-    Aig_ManStop( pAig );
-
-    // update the internal storage of PO equivalences
-    Abc_FrameReplacePoEquivs( pAbc, &vPosEquivs );
-
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkNew );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: iso [-vh]\n" );
-    Abc_Print( -2, "\t         removes POs with isomorphic sequential COI\n" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandTraceStart( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command is applicable to AIGs.\n" );
-        return 1;
-    }
-/*
-    Abc_HManStart();
-    if ( !Abc_HManPopulate( pNtk ) )
-    {
-        Abc_Print( -1, "Failed to start the tracing database.\n" );
-        return 1;
-    }
-*/
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: trace_start [-h]\n" );
-    Abc_Print( -2, "\t        starts verification tracing\n" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandTraceCheck( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c;
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pNtk == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash(pNtk) )
-    {
-        Abc_Print( -1, "This command is applicable to AIGs.\n" );
-        return 1;
-    }
-/*
-    if ( !Abc_HManIsRunning(pNtk) )
-    {
-        Abc_Print( -1, "The tracing database is not available.\n" );
-        return 1;
-    }
-
-    if ( !Abc_HManVerify( 1, pNtk->Id ) )
-        Abc_Print( -1, "Verification failed.\n" );
-    Abc_HManStop();
-*/
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: trace_check [-h]\n" );
-    Abc_Print( -2, "\t        checks the current network using verification trace\n" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Read( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pAig;
-    FILE * pFile;
-    char ** pArgvNew;
-    char * FileName, * pTemp;
-    int c, nArgcNew;
-    int fUseMini = 0;
-    int fVerbose = 0;
-    int fSkipStrash = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "smvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 's':
-            fSkipStrash ^= 1;
-            break;
-        case 'm':
-            fUseMini ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        default:
-            goto usage;
-        }
-    }
-    pArgvNew = argv + globalUtilOptind;
-    nArgcNew = argc - globalUtilOptind;
-    if ( nArgcNew != 1 )
-    {
-        Abc_Print( -1, "There is no file name.\n" );
-        return 1;
-    }
-
-    // get the input file name
-    FileName = pArgvNew[0];
-    // fix the wrong symbol
-    for ( pTemp = FileName; *pTemp; pTemp++ )
-        if ( *pTemp == '>' )
-            *pTemp = '\\';
-    if ( (pFile = fopen( FileName, "r" )) == NULL )
-    {
-        Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
-        if ( (FileName = Extra_FileGetSimilarName( FileName, ".aig", ".blif", ".pla", ".eqn", ".bench" )) )
-            Abc_Print( 1, "Did you mean \"%s\"?", FileName );
-        Abc_Print( 1, "\n" );
-        return 1;
-    }
-    fclose( pFile );
-
-    if ( fUseMini )
-        pAig = Gia_ManReadMiniAig( FileName );
-    else
-        pAig = Gia_AigerRead( FileName, fSkipStrash, 0 );
-    Abc_FrameUpdateGia( pAbc, pAig );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &r [-smvh] <file>\n" );
-    Abc_Print( -2, "\t         reads the current AIG from the AIGER file\n" );
-    Abc_Print( -2, "\t-s     : toggles structural hashing while reading [default = %s]\n", !fSkipStrash? "yes": "no" );
-    Abc_Print( -2, "\t-m     : toggles reading MiniAIG rather than AIGER file [default = %s]\n", fUseMini? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggles additional verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\t<file> : the file name\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9ReadBlif( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Gia_Man_t * Abc_NtkHieCecTest( char * pFileName, int fVerbose );
-    Gia_Man_t * pAig;
-    FILE * pFile;
-    char ** pArgvNew;
-    char * FileName, * pTemp;
-    int nArgcNew;
-    int c, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        default:
-            goto usage;
-        }
-    }
-    pArgvNew = argv + globalUtilOptind;
-    nArgcNew = argc - globalUtilOptind;
-    if ( nArgcNew != 1 )
-    {
-        Abc_Print( -1, "There is no file name.\n" );
-        return 1;
-    }
-
-    // get the input file name
-    FileName = pArgvNew[0];
-    // fix the wrong symbol
-    for ( pTemp = FileName; *pTemp; pTemp++ )
-        if ( *pTemp == '>' )
-            *pTemp = '\\';
-    if ( (pFile = fopen( FileName, "r" )) == NULL )
-    {
-        Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
-        if ( (FileName = Extra_FileGetSimilarName( FileName, ".blif", NULL, NULL, NULL, NULL )) )
-            Abc_Print( 1, "Did you mean \"%s\"?", FileName );
-        Abc_Print( 1, "\n" );
-        return 1;
-    }
-    fclose( pFile );
-
-    pAig = Abc_NtkHieCecTest( FileName, fVerbose );
-    Abc_FrameUpdateGia( pAbc, pAig );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &read_blif [-vh] <file>\n" );
-    Abc_Print( -2, "\t         a specialized reader for hierarchical BLIF files\n" );
-    Abc_Print( -2, "\t         (for general-purpose BLIFs, please use \"read_blif\")\n" );
-    Abc_Print( -2, "\t-v     : toggles additional verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\t<file> : the file name\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9ReadCBlif( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Gia_Man_t * Abc_NtkHieCecTest2( char * pFileName, char * pModelName, int fVerbose );
-    Gia_Man_t * pAig;
-    FILE * pFile;
-    char ** pArgvNew;
-    char * FileName, * pTemp;
-    char * pModelName = NULL;
-    int nArgcNew;
-    int c, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Mvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'M':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-M\" should be followed by a file name.\n" );
-                goto usage;
-            }
-            pModelName = argv[globalUtilOptind];
-            globalUtilOptind++;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        default:
-            goto usage;
-        }
-    }
-    pArgvNew = argv + globalUtilOptind;
-    nArgcNew = argc - globalUtilOptind;
-    if ( nArgcNew != 1 )
-    {
-        Abc_Print( -1, "There is no file name.\n" );
-        return 1;
-    }
-
-    // get the input file name
-    FileName = pArgvNew[0];
-    // fix the wrong symbol
-    for ( pTemp = FileName; *pTemp; pTemp++ )
-        if ( *pTemp == '>' )
-            *pTemp = '\\';
-    if ( (pFile = fopen( FileName, "r" )) == NULL )
-    {
-        Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
-        if ( (FileName = Extra_FileGetSimilarName( FileName, ".cblif", NULL, NULL, NULL, NULL )) )
-            Abc_Print( 1, "Did you mean \"%s\"?", FileName );
-        Abc_Print( 1, "\n" );
-        return 1;
-    }
-    fclose( pFile );
-
-    pAig = Abc_NtkHieCecTest2( FileName, pModelName, fVerbose );
-    Abc_FrameUpdateGia( pAbc, pAig );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &read_cblif [-M name] [-vh] <file>\n" );
-    Abc_Print( -2, "\t         reads CBLIF file and collapse it into an AIG\n" );
-    Abc_Print( -2, "\t-M name: module name to collapse [default = <root_module>]\n" );
-    Abc_Print( -2, "\t-v     : toggles additional verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\t<file> : the file name\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9ReadStg( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pAig;
-    FILE * pFile;
-    char * FileName, ** pArgvNew;
-    int c, nArgcNew;
-    int kHot = 1;
-    int fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Kvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            kHot = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( kHot < 1 || kHot > 5 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        default:
-            goto usage;
-        }
-    }
-    pArgvNew = argv + globalUtilOptind;
-    nArgcNew = argc - globalUtilOptind;
-    if ( nArgcNew != 1 )
-    {
-        Abc_Print( -1, "There is no file name.\n" );
-        return 1;
-    }
-
-    // get the input file name
-    FileName = pArgvNew[0];
-    if ( (pFile = fopen( FileName, "r" )) == NULL )
-    {
-        Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
-        return 1;
-    }
-    fclose( pFile );
-
-    pAig = Gia_ManStgRead( FileName, kHot, fVerbose );
-    Abc_FrameUpdateGia( pAbc, pAig );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &read_stg [-K <num>] [-vh] <file>\n" );
-    Abc_Print( -2, "\t         reads STG file and generates K-hot-encoded AIG\n" );
-    Abc_Print( -2, "\t-K num : the K parameter for hotness of the encoding (1 <= K <= 5) [default = %d]\n", kHot );
-    Abc_Print( -2, "\t-v     : toggles printing state codes [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\t<file> : the file name\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Get( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Aig_Man_t * Abc_NtkToDarChoices( Abc_Ntk_t * pNtk );
-    extern Vec_Ptr_t * Abc_NtkCollectCiNames( Abc_Ntk_t * pNtk );
-    extern Vec_Ptr_t * Abc_NtkCollectCoNames( Abc_Ntk_t * pNtk );
-    Abc_Ntk_t * pStrash;
-    Aig_Man_t * pAig;
-    Gia_Man_t * pGia, * pTemp;
-    char * pInits;
-    int c, fMapped = 0, fNames = 0, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "mnvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'm':
-            fMapped ^= 1;
-            break;
-        case 'n':
-            fNames ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pNtkCur == NULL )
-    {
-        Abc_Print( -1, "There is no current network\n" );
-        return 1;
-    }
-    if ( !Abc_NtkIsStrash( pAbc->pNtkCur ) )
-    {
-        if ( fMapped )
-        {
-            assert( Abc_NtkIsLogic(pAbc->pNtkCur) );
-            Abc_NtkToAig( pAbc->pNtkCur );
-            pGia = Abc_NtkAigToGia( pAbc->pNtkCur );
-        }
-        else
-        {
-            // derive comb GIA
-            pStrash = Abc_NtkStrash( pAbc->pNtkCur, 0, 1, 0 );
-            pAig = Abc_NtkToDar( pStrash, 0, 0 );
-            Abc_NtkDelete( pStrash );
-            pGia = Gia_ManFromAig( pAig );
-            Aig_ManStop( pAig );
-            // perform undc/zero
-            pInits = Abc_NtkCollectLatchValuesStr( pAbc->pNtkCur );
-            pGia = Gia_ManDupZeroUndc( pTemp = pGia, pInits, fVerbose );
-            Gia_ManStop( pTemp );
-            ABC_FREE( pInits );
-        }
-    }
-    else
-    {
-        if ( Abc_NtkGetChoiceNum(pAbc->pNtkCur) )
-            pAig = Abc_NtkToDarChoices( pAbc->pNtkCur );
-        else
-            pAig = Abc_NtkToDar( pAbc->pNtkCur, 0, 1 );
-        pGia = Gia_ManFromAig( pAig );
-        Aig_ManStop( pAig );
-    }
-    // replace
-    if ( fNames )
-    {
-        pGia->vNamesIn  = Abc_NtkCollectCiNames( pAbc->pNtkCur );
-        pGia->vNamesOut = Abc_NtkCollectCoNames( pAbc->pNtkCur );
-    }
-    Abc_FrameUpdateGia( pAbc, pGia );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &get [-mnvh] <file>\n" );
-    Abc_Print( -2, "\t         converts the current network into GIA and moves it to the &-space\n" );
-    Abc_Print( -2, "\t         (if the network is a sequential logic network, normalizes the flops\n" );
-    Abc_Print( -2, "\t         to have const-0 initial values, equivalent to \"undc; st; zero\")\n" );
-    Abc_Print( -2, "\t-m     : toggles preserving the current mapping [default = %s]\n", fMapped? "yes": "no" );
-    Abc_Print( -2, "\t-n     : toggles saving CI/CO names of the AIG [default = %s]\n", fNames? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggles additional verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\t<file> : the file name\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Put( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Abc_Ntk_t * Abc_NtkFromDarChoices( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan );
-    Aig_Man_t * pMan;
-    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    int c, fVerbose = 0;
-    int fStatusClear = 1;
-
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "svh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 's':
-            fStatusClear ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( Gia_ManHasMapping(pAbc->pGia) )
-    {
-        extern Abc_Ntk_t * Abc_NtkFromMappedGia( Gia_Man_t * p );
-        pNtk = Abc_NtkFromMappedGia( pAbc->pGia );
-    }
-    else if ( Gia_ManHasCellMapping(pAbc->pGia) )
-    {
-        extern Abc_Ntk_t * Abc_NtkFromCellMappedGia( Gia_Man_t * p );
-        pNtk = Abc_NtkFromCellMappedGia( pAbc->pGia );
-    }
-    else if ( Gia_ManHasDangling(pAbc->pGia) == 0 )
-    {
-        pMan = Gia_ManToAig( pAbc->pGia, 0 );
-        pNtk = Abc_NtkFromAigPhase( pMan );
-        pNtk->pName = Extra_UtilStrsav(pMan->pName);
-        Aig_ManStop( pMan );
-    }
-    else
-    {
-        Abc_Ntk_t * pNtkNoCh;
-//        Abc_Print( -1, "Transforming AIG with %d choice nodes.\n", Gia_ManEquivCountClasses(pAbc->pGia) );
-        // create network without choices
-        pMan = Gia_ManToAig( pAbc->pGia, 0 );
-        pNtkNoCh = Abc_NtkFromAigPhase( pMan );
-        pNtkNoCh->pName = Extra_UtilStrsav(pMan->pName);
-        Aig_ManStop( pMan );
-        // derive network with choices
-        pMan = Gia_ManToAig( pAbc->pGia, 1 );
-        pNtk = Abc_NtkFromDarChoices( pNtkNoCh, pMan );
-        Abc_NtkDelete( pNtkNoCh );
-        Aig_ManStop( pMan );
-    }
-    // transfer PI names to pNtk
-    if ( pAbc->pGia->vNamesIn )
-    {
-        Abc_Obj_t * pObj;
-        int i;
-        Abc_NtkForEachCi( pNtk, pObj, i ) {
-            if (i < Vec_PtrSize(pAbc->pGia->vNamesIn)) {
-                Nm_ManDeleteIdName(pNtk->pManName, pObj->Id);
-                Abc_ObjAssignName( pObj, (char *)Vec_PtrEntry(pAbc->pGia->vNamesIn, i), NULL );
-            }
-        }
-    }
-    // transfer PO names to pNtk
-    if ( pAbc->pGia->vNamesOut )
-    {
-        Abc_Obj_t * pObj;
-        int i;
-        Abc_NtkForEachCo( pNtk, pObj, i ) {
-            if (i < Vec_PtrSize(pAbc->pGia->vNamesOut)) {
-                Nm_ManDeleteIdName(pNtk->pManName, pObj->Id);
-                Abc_ObjAssignName( pObj, (char *)Vec_PtrEntry(pAbc->pGia->vNamesOut, i), NULL );
-            }
-        }
-    }
-    // replace the current network
-    Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
-    if ( fStatusClear )
-        Abc_FrameClearVerifStatus( pAbc );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &put [-svh]\n" );
-    Abc_Print( -2, "\t         transfer the current network into the old ABC\n" );
-    Abc_Print( -2, "\t-s     : toggle clearning verification status [default = %s]\n", fStatusClear? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    [Compares to versions of the design and finds the best.]
-
-  Description []
-               
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-static inline int Gia_ManCompareWithBest( Gia_Man_t * pBest, Gia_Man_t * p, int * pnBestLuts, int * pnBestEdges, int * pnBestLevels )
-{
-    int nCurLuts, nCurEdges, nCurLevels;
-    Gia_ManLutParams( p, &nCurLuts, &nCurEdges, &nCurLevels );
-    if ( pBest == NULL ||
-         Gia_ManPiNum(pBest) != Gia_ManPiNum(p) || 
-         Gia_ManPoNum(pBest) != Gia_ManPoNum(p) || 
-         Gia_ManRegNum(pBest) != Gia_ManRegNum(p) ||
-         strcmp(Gia_ManName(pBest), Gia_ManName(p)) ||
-        (*pnBestLevels > nCurLevels) ||
-        (*pnBestLevels == nCurLevels && *pnBestLuts > nCurLuts) ||
-        (*pnBestLevels == nCurLevels && *pnBestLuts == nCurLuts && *pnBestEdges > nCurEdges) )
-    {
-        *pnBestLuts = nCurLuts;
-        *pnBestEdges = nCurEdges;
-        *pnBestLevels = nCurLevels;
-        return 1;
-    }
-    return 0;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-               
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Save( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    int c;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Empty network.\n" );
-        return 1;
-    }
-    if ( !Gia_ManHasMapping(pAbc->pGia) )
-    {
-        Abc_Print( -1, "GIA has no mapping.\n" );
-        return 1;
-    }
-    if ( !Gia_ManCompareWithBest( pAbc->pGiaBest, pAbc->pGia, &pAbc->nBestLuts, &pAbc->nBestEdges, &pAbc->nBestLevels ) )
-        return 0;
-    // save the design as best
-    Gia_ManStopP( &pAbc->pGiaBest );
-    pAbc->pGiaBest = Gia_ManDupWithAttributes( pAbc->pGia );
-    return 0; 
-
-usage:
-    Abc_Print( -2, "usage: &save [-h]\n" );
-    Abc_Print( -2, "\t        compares and possibly saves AIG with mapping\n" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-               
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Load( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    int c;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    // restore from best
-    if ( pAbc->pGiaBest == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Load(): There is no best design saved.\n" );
-        return 1;
-    }
-    Gia_ManStopP( &pAbc->pGia );
-    pAbc->pGia = Gia_ManDupWithAttributes( pAbc->pGiaBest );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &load [-h]\n" );
-    Abc_Print( -2, "\t        loads previously saved AIG with mapping" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Write( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    char * pFileName;
-    char ** pArgvNew;
-    int c, nArgcNew;
-    int fUnique = 0;
-    int fMiniAig = 0;
-    int fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "umvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'u':
-            fUnique ^= 1;
-            break;
-        case 'm':
-            fMiniAig ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    pArgvNew = argv + globalUtilOptind;
-    nArgcNew = argc - globalUtilOptind;
-    if ( nArgcNew != 1 )
-    {
-        Abc_Print( -1, "There is no file name.\n" );
-        return 1;
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Write(): There is no AIG to write.\n" );
-        return 1;
-    }
-    pFileName = argv[globalUtilOptind];
-    if ( fUnique )
-    {
-        Gia_Man_t * pGia = Gia_ManIsoCanonicize( pAbc->pGia, fVerbose );
-        Gia_AigerWriteSimple( pGia, pFileName );
-        Gia_ManStop( pGia );
-    }
-    else if ( fMiniAig )
-        Gia_ManWriteMiniAig( pAbc->pGia, pFileName );
-    else
-        Gia_AigerWrite( pAbc->pGia, pFileName, 0, 0 );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &w [-umvh] <file>\n" );
-    Abc_Print( -2, "\t         writes the current AIG into the AIGER file\n" );
-    Abc_Print( -2, "\t-u     : toggle writing canonical AIG structure [default = %s]\n", fUnique? "yes" : "no" );
-    Abc_Print( -2, "\t-m     : toggle writing MiniAIG rather than AIGER [default = %s]\n", fMiniAig? "yes" : "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\t<file> : the file name\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Ps( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gps_Par_t Pars, * pPars = &Pars;
-    int c, fBest = 0;
-    memset( pPars, 0, sizeof(Gps_Par_t) );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Dtpcnlmasbh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 't':
-            pPars->fTents ^= 1;
-            break;
-        case 'p':
-            pPars->fSwitch ^= 1;
-            break;
-        case 'c':
-            pPars->fCut ^= 1;
-            break;
-        case 'n':
-            pPars->fNpn ^= 1;
-            break;
-        case 'l':
-            pPars->fLutProf ^= 1;
-            break;
-        case 'm':
-            pPars->fMuxXor ^= 1;
-            break;
-        case 'a':
-            pPars->fMiter ^= 1;
-            break;
-        case 's':
-            pPars->fSkipMap ^= 1;
-            break;
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by a file name.\n" );
-                goto usage;
-            }
-            pPars->pDumpFile = argv[globalUtilOptind];
-            globalUtilOptind++;
-            break;
-        case 'b':
-            fBest ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( fBest )
-    {
-        if ( pAbc->pGiaBest == NULL )
-        {
-            Abc_Print( -1, "Abc_CommandAbc9Ps(): There is no AIG.\n" );
-            return 1;
-        }
-        Gia_ManPrintStats( pAbc->pGiaBest, pPars );
-    }
-    else
-    {
-        if ( pAbc->pGia == NULL )
-        {
-            Abc_Print( -1, "Abc_CommandAbc9Ps(): There is no AIG.\n" );
-            return 1;
-        }
-        Gia_ManPrintStats( pAbc->pGia, pPars );
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &ps [-tpcnlmasbh] [-D file]\n" );
-    Abc_Print( -2, "\t          prints stats of the current AIG\n" );
-    Abc_Print( -2, "\t-t      : toggle printing BMC tents [default = %s]\n",                pPars->fTents? "yes": "no" );
-    Abc_Print( -2, "\t-p      : toggle printing switching activity [default = %s]\n",       pPars->fSwitch? "yes": "no" );
-    Abc_Print( -2, "\t-c      : toggle printing the size of frontier cut [default = %s]\n", pPars->fCut? "yes": "no" );
-    Abc_Print( -2, "\t-n      : toggle printing NPN classes of functions [default = %s]\n", pPars->fNpn? "yes": "no" );
-    Abc_Print( -2, "\t-l      : toggle printing LUT size profile [default = %s]\n",         pPars->fLutProf? "yes": "no" );
-    Abc_Print( -2, "\t-m      : toggle printing MUX/XOR statistics [default = %s]\n",       pPars->fMuxXor? "yes": "no" );
-    Abc_Print( -2, "\t-a      : toggle printing miter statistics [default = %s]\n",         pPars->fMiter? "yes": "no" );
-    Abc_Print( -2, "\t-s      : skip mapping statistics even if mapped [default = %s]\n",   pPars->fSkipMap? "yes": "no" );
-    Abc_Print( -2, "\t-b      : toggle printing saved AIG statistics [default = %s]\n",     fBest? "yes": "no" );
-    Abc_Print( -2, "\t-D file : file name to dump statistics [default = none]\n" );
-    Abc_Print( -2, "\t-h      : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9PFan( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    int c;
-    int nNodes = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Nh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nNodes = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nNodes < 0 )
-                goto usage;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9PFan(): There is no AIG.\n" );
-        return 1;
-    }
-    Gia_ManPrintFanio( pAbc->pGia, nNodes );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &pfan [-N num] [-h]\n" );
-    Abc_Print( -2, "\t         prints fanin/fanout statistics\n" );
-    Abc_Print( -2, "\t-N num : the number of high-fanout nodes to explore [default = %d]\n", nNodes );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9PSig( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    int c;
-    int fSetReset = 1;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "rh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'r':
-            fSetReset ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9PSigs(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9PSigs(): Works only for sequential circuits.\n" );
-        return 1;
-    }
-    Gia_ManDetectSeqSignals( pAbc->pGia, fSetReset, 1 );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &psig [-rh]\n" );
-    Abc_Print( -2, "\t         prints enable/set/reset statistics\n" );
-    Abc_Print( -2, "\t-r     : toggle printing set/reset signals [default = %s]\n", fSetReset? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Status( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    int c;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Status(): There is no AIG.\n" );
-        return 1;
-    }
-    Gia_ManPrintMiterStatus( pAbc->pGia );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &status [-h]\n" );
-    Abc_Print( -2, "\t         prints status of the miter\n" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9MuxProfile( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern void Gia_ManMuxProfiling( Gia_Man_t * p );
-    int c;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9MuxProfile(): There is no AIG.\n" );
-        return 1;
-    }
-    Gia_ManMuxProfiling( pAbc->pGia );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &mux_profile [-h]\n" );
-    Abc_Print( -2, "\t         profile MUXes appearing in the design\n" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Show( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Aig_Man_t * pMan;
-    int c;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Show(): There is no AIG.\n" );
-        return 1;
-    }
-    pMan = Gia_ManToAigSimple( pAbc->pGia );
-    Aig_ManShow( pMan, 0, NULL );
-    Aig_ManStop( pMan );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &show [-h]\n" );
-    Abc_Print( -2, "\t        shows the current AIG using GSView\n" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Strash( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pTemp;
-    int c, Limit = 2;
-    int fAddStrash = 0;
-    int fCollapse = 0;
-    int fAddMuxes = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Lacmh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            Limit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( Limit < 0 )
-                goto usage;
-            break;
-        case 'a':
-            fAddStrash ^= 1;
-            break;
-        case 'c':
-            fCollapse ^= 1;
-            break;
-        case 'm':
-            fAddMuxes ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Strash(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( Gia_ManHasMapping(pAbc->pGia) )
-    {
-        pTemp = (Gia_Man_t *)Dsm_ManDeriveGia( pAbc->pGia, fAddMuxes );
-//        if ( !Abc_FrameReadFlag("silentmode") )
-//            printf( "Performed delay-oriented unmapping.\n" );
-    }
-    else if ( fAddMuxes )
-    {
-        if ( pAbc->pGia->pMuxes )
-        {
-            Abc_Print( -1, "Abc_CommandAbc9Strash(): The AIG already has MUXes.\n" );
-            return 1;
-        }
-        pTemp = Gia_ManDupMuxes( pAbc->pGia, Limit );
-        if ( !Abc_FrameReadFlag("silentmode") )
-            printf( "Generated AND/XOR/MUX graph.\n" );
-    }
-    else if ( fCollapse && pAbc->pGia->pAigExtra )
-    {
-        Gia_Man_t * pNew = Gia_ManDupUnnormalize( pAbc->pGia );
-        pNew->pManTime = pAbc->pGia->pManTime;
-        pTemp = Gia_ManDupCollapse( pNew, pAbc->pGia->pAigExtra, NULL );
-        pNew->pManTime = NULL;
-        Gia_ManStop( pNew );
-        if ( !Abc_FrameReadFlag("silentmode") )
-            printf( "Collapsed AIG with boxes with logic of the boxes.\n" );
-    }
-    else if ( pAbc->pGia->pMuxes )
-    {
-        pTemp = Gia_ManDupNoMuxes( pAbc->pGia );
-        if ( !Abc_FrameReadFlag("silentmode") )
-            printf( "Generated AIG from AND/XOR/MUX graph.\n" );
-    }
-    else
-    {
-        pTemp = Gia_ManRehash( pAbc->pGia, fAddStrash );
-        if ( !Abc_FrameReadFlag("silentmode") )
-            printf( "Rehashed the current AIG.\n" );
-    }
-    Gia_ManTransferTiming( pTemp, pAbc->pGia );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &st [-L num] [-acmh]\n" );
-    Abc_Print( -2, "\t         performs structural hashing\n" );
-    Abc_Print( -2, "\t-a     : toggle additional hashing [default = %s]\n", fAddStrash? "yes": "no" );
-    Abc_Print( -2, "\t-c     : toggle collapsing hierarchical AIG [default = %s]\n", fCollapse? "yes": "no" );
-    Abc_Print( -2, "\t-m     : toggle converting to larger gates [default = %s]\n", fAddMuxes? "yes": "no" );
-    Abc_Print( -2, "\t-L num : create MUX when sum of refs does not exceed this limit [default = %d]\n", Limit );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Topand( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pTemp;
-    int c, fVerbose = 1;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Topand(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( Gia_ManRegNum(pAbc->pGia) > 0 )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Topand(): Can only be applied to a combinational miter.\n" );
-        return 1;
-    }
-    pTemp = Gia_ManDupTopAnd( pAbc->pGia, fVerbose );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &topand [-vh]\n" );
-    Abc_Print( -2, "\t        performs AND decomposition for combinational miter\n" );
-    Abc_Print( -2, "\t-v    : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Add1Hot( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pTemp;
-    int c, fVerbose = 1;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Add1Hot(): There is no AIG.\n" );
-        return 1;
-    }
-    pTemp = Gia_ManDupOneHot( pAbc->pGia );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &add1hot [-vh]\n" );
-    Abc_Print( -2, "\t        adds 1-hotness constraints as additional primary outputs\n" );
-    Abc_Print( -2, "\t-v    : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Cof( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pTemp;
-    int c, fVerbose = 0;
-    int iVar = 0, nLimFan = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "VLvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'V':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-V\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            iVar = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( iVar < 0 )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nLimFan = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nLimFan < 0 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Cof(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( nLimFan )
-    {
-        Abc_Print( -1, "Cofactoring all variables whose fanout count is higher than %d.\n", nLimFan );
-        pTemp = Gia_ManDupCofAll( pAbc->pGia, nLimFan, fVerbose );
-        Abc_FrameUpdateGia( pAbc, pTemp );
-    }
-    else if ( iVar )
-    {
-        Abc_Print( -1, "Cofactoring one variable with object ID %d.\n", iVar );
-        pTemp = Gia_ManDupCof( pAbc->pGia, iVar );
-        Abc_FrameUpdateGia( pAbc, pTemp );
-    }
-    else
-    {
-        Abc_Print( -1, "One of the paramters, -V <num> or -L <num>, should be set on the command line.\n" );
-        goto usage;
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &cof [-VL num] [-vh]\n" );
-    Abc_Print( -2, "\t         performs cofactoring w.r.t. variable(s)\n" );
-    Abc_Print( -2, "\t-V num : the zero-based ID of one variable to cofactor [default = %d]\n", iVar );
-    Abc_Print( -2, "\t-L num : cofactor vars with fanout count higher than this [default = %d]\n", nLimFan );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Trim( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pTemp, * pTemp2;
-    int c;
-    int OutValue = -1;
-    int fTrimCis = 1;
-    int fTrimCos = 1;
-    int fDualOut = 0;
-    int fPoFedByPi = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Viocdh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'V':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-V\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            OutValue = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( OutValue < 0 )
-                goto usage;
-            break;
-        case 'i':
-            fTrimCis ^= 1;
-            break;
-        case 'o':
-            fTrimCos ^= 1;
-            break;
-        case 'c':
-            fPoFedByPi ^= 1;
-            break;
-        case 'd':
-            fDualOut ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Trim(): There is no AIG.\n" );
-        return 1;
-    }
-    pTemp = Gia_ManDupTrimmed( pAbc->pGia, fTrimCis, fTrimCos, fDualOut, OutValue );
-    if ( fPoFedByPi )
-    {
-        extern Gia_Man_t * Gia_ManDupTrimmed2( Gia_Man_t * p );
-        pTemp = Gia_ManDupTrimmed2( pTemp2 = pTemp );
-        Gia_ManStop( pTemp2 );
-    }
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &trim [-V num] [-iocdh]\n" );
-    Abc_Print( -2, "\t         removes PIs without fanout and PO driven by constants\n" );
-    Abc_Print( -2, "\t-V num : the value (0 or 1) of POs to remove [default = both]\n" );
-    Abc_Print( -2, "\t-i     : toggle removing PIs [default = %s]\n", fTrimCis? "yes": "no" );
-    Abc_Print( -2, "\t-o     : toggle removing POs [default = %s]\n", fTrimCos? "yes": "no" );
-    Abc_Print( -2, "\t-c     : toggle additionally removing POs fed by PIs [default = %s]\n", fPoFedByPi? "yes": "no" );
-    Abc_Print( -2, "\t-d     : toggle using dual-output miter [default = %s]\n", fDualOut? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Dfs( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pTemp;
-    int c;
-    int fNormal  = 0;
-    int fReverse = 0;
-    int fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "nrvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'n':
-            fNormal ^= 1;
-            break;
-        case 'r':
-            fReverse ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Dfs(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( fNormal )
-    {
-        pTemp = Gia_ManDupOrderAiger( pAbc->pGia );
-        if ( fVerbose )
-            Abc_Print( -1, "AIG objects are reordered as follows: CIs, ANDs, COs.\n" );
-    }
-    else if ( fReverse )
-    {
-        pTemp = Gia_ManDupOrderDfsReverse( pAbc->pGia );
-        if ( fVerbose )
-            Abc_Print( -1, "AIG objects are reordered in the reserve DFS order.\n" );
-    }
-    else
-    {
-        pTemp = Gia_ManDupOrderDfs( pAbc->pGia );
-        if ( fVerbose )
-            Abc_Print( -1, "AIG objects are reordered in the DFS order.\n" );
-    }
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &dfs [-nrvh]\n" );
-    Abc_Print( -2, "\t        orders objects in the DFS order\n" );
-    Abc_Print( -2, "\t-n    : toggle using normalized ordering [default = %s]\n", fNormal? "yes": "no" );
-    Abc_Print( -2, "\t-r    : toggle using reverse DFS ordering [default = %s]\n", fReverse? "yes": "no" );
-    Abc_Print( -2, "\t-v    : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Sim( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_ParSim_t Pars, * pPars = &Pars;
-    char * pFileName = NULL;
-    int c;
-    Gia_ManSimSetDefaultParams( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "FWNTImvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nIters = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nIters < 0 )
-                goto usage;
-            break;
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nWords = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nWords < 0 )
-                goto usage;
-            break;
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->RandSeed = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->RandSeed < 0 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->TimeLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->TimeLimit < 0 )
-                goto usage;
-            break;
-        case 'I':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pFileName = argv[globalUtilOptind];
-            globalUtilOptind++;
-            if ( pFileName == NULL )
-                goto usage;
-            break;
-        case 'm':
-            pPars->fCheckMiter ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Sim(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
-    {
-        Abc_Print( -1, "The network is combinational.\n" );
-        return 0;
-    }
-    if ( pFileName != NULL )
-    {
-        extern void Gia_ManSimSimulatePattern( Gia_Man_t * p, char * pFileIn, char * pFileOut );
-        char pFileNameOut[1000];
-        char * pNameGeneric = Extra_FileNameGeneric(pFileName);
-        assert( strlen(pNameGeneric) < 900 );
-        sprintf( pFileNameOut, "%s_out.%s", pNameGeneric, Extra_FileNameExtension(pFileName) );
-        ABC_FREE( pNameGeneric );
-        Gia_ManSimSimulatePattern( pAbc->pGia, pFileName, pFileNameOut );
-        return 1;
-    }
-
-    pAbc->nFrames = -1;
-    if ( Gia_ManSimSimulate( pAbc->pGia, pPars ) )
-        pAbc->Status =  0;
-    else
-        pAbc->Status = -1;
-    Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexSeq );
-//    if ( pLogFileName )
-//        Abc_NtkWriteLogFile( pLogFileName, pAbc->pCex, pAbc->Status, pAbc->nFrames, "&sim" );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &sim [-FWNT num] [-mvh] -I <file>\n" );
-    Abc_Print( -2, "\t         performs random simulation of the sequential miter\n" );
-    Abc_Print( -2, "\t         (if candidate equivalences are defined, performs refinement)\n" );
-    Abc_Print( -2, "\t-F num : the number of frames to simulate [default = %d]\n", pPars->nIters );
-    Abc_Print( -2, "\t-W num : the number of words to simulate [default = %d]\n", pPars->nWords );
-    Abc_Print( -2, "\t-N num : random number seed (1 <= num <= 1000) [default = %d]\n", pPars->RandSeed );
-    Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", pPars->TimeLimit );
-    Abc_Print( -2, "\t-m     : toggle miter vs. any circuit [default = %s]\n", pPars->fCheckMiter? "miter": "circuit" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\t-I file: (optional) file with input patterns (one line per frame, as many as PIs)\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Sim3( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern int Ssw_RarSimulateGia( Gia_Man_t * p, Ssw_RarPars_t * pPars );
-    Ssw_RarPars_t Pars, * pPars = &Pars;
-    int c;
-    Ssw_RarSetDefaultParams( pPars );
-    // parse command line
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "FWBRSNTGgvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nFrames = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nFrames < 0 )
-                goto usage;
-            break;
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nWords = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nWords < 0 )
-                goto usage;
-            break;
-        case 'B':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nBinSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nBinSize < 0 )
-                goto usage;
-            break;
-        case 'R':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nRounds = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nRounds < 0 )
-                goto usage;
-            break;
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nRestart = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nRestart < 0 )
-                goto usage;
-            break;
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nRandSeed = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nRandSeed < 0 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->TimeOut = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->TimeOut < 0 )
-                goto usage;
-            break;
-        case 'G':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-G\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->TimeOutGap = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->TimeOutGap < 0 )
-                goto usage;
-            break;
-        case 'g':
-            pPars->fUseFfGrouping ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Sim3(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Sim3(): This command works only for sequential AIGs.\n" );
-        return 0;
-    }
-    pAbc->Status = Ssw_RarSimulateGia( pAbc->pGia, pPars );
-    Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexSeq );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &sim3 [-FWBRNT num] [-gvh]\n" );
-    Abc_Print( -2, "\t         performs random simulation of the sequential miter\n" );
-    Abc_Print( -2, "\t-F num : the number of frames to simulate [default = %d]\n",       pPars->nFrames );
-    Abc_Print( -2, "\t-W num : the number of words to simulate [default = %d]\n",        pPars->nWords );
-    Abc_Print( -2, "\t-B num : the number of flops in one bin [default = %d]\n",         pPars->nBinSize );
-    Abc_Print( -2, "\t-R num : the number of simulation rounds [default = %d]\n",        pPars->nRounds );
-    Abc_Print( -2, "\t-S num : the number of rounds before a restart [default = %d]\n",  pPars->nRestart );
-    Abc_Print( -2, "\t-N num : random number seed (1 <= num <= 1000) [default = %d]\n",  pPars->nRandSeed );
-    Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n",   pPars->TimeOut );
-    Abc_Print( -2, "\t-g     : toggle heuristic flop grouping [default = %s]\n",    pPars->fUseFfGrouping? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n",    pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Resim( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Cec_ParSim_t Pars, * pPars = &Pars;
-    int c, RetValue;
-    Cec_ManSimSetDefaultParams( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Fmvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nFrames = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nFrames < 0 )
-                goto usage;
-            break;
-        case 'm':
-            pPars->fCheckMiter ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Resim(): There is no AIG.\n" );
-        return 1;
-    }
-    RetValue = Cec_ManSeqResimulateCounter( pAbc->pGia, pPars, pAbc->pCex );
-    pAbc->Status  = RetValue ? 0 : -1;
-    pAbc->nFrames = pAbc->pCex->iFrame;
-//    Abc_FrameReplaceCex( pAbc, &pAbc->pCex );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &resim [-F num] [-mvh]\n" );
-    Abc_Print( -2, "\t         resimulates equivalence classes using counter-example\n" );
-    Abc_Print( -2, "\t-F num : the number of additinal frames to simulate [default = %d]\n", pPars->nFrames );
-    Abc_Print( -2, "\t-m     : toggle miter vs. any circuit [default = %s]\n", pPars->fCheckMiter? "miter": "circuit" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9SpecI( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern int Gia_CommandSpecI( Gia_Man_t * pGia, int nFrames, int nBTLimit, int fUseStart, int fCheckMiter, int fVerbose );
-    int nFrames     =   100;
-    int nBTLimit    = 25000;
-    int fUseStart   =     1;
-    int fCheckMiter =     1;
-    int fVerbose    =     0;
-    int c;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "FCfmvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFrames = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFrames < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nBTLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nBTLimit < 0 )
-                goto usage;
-            break;
-        case 'f':
-            fUseStart ^= 1;
-            break;
-        case 'm':
-            fCheckMiter ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9SpecI(): There is no AIG.\n" );
-        return 1;
-    }
-    Gia_CommandSpecI( pAbc->pGia, nFrames, nBTLimit, fUseStart, fCheckMiter, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &speci [-FC num] [-fmvh]\n" );
-    Abc_Print( -2, "\t         refines equivalence classes using speculative reduction\n" );
-    Abc_Print( -2, "\t-F num : the max number of time frames [default = %d]\n", nFrames );
-    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", nBTLimit );
-    Abc_Print( -2, "\t-f     : toggle starting BMC from a later frame [default = %s]\n", fUseStart? "yes": "no" );
-    Abc_Print( -2, "\t-m     : toggle miter vs. any circuit [default = %s]\n", fCheckMiter? "miter": "circuit" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Equiv( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Cec_ParSim_t Pars, * pPars = &Pars;
-    int c;
-    Cec_ManSimSetDefaultParams( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "WFRSTsmdvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nWords = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nWords < 0 )
-                goto usage;
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nFrames = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nFrames < 0 )
-                goto usage;
-            break;
-        case 'R':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nRounds = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nRounds < 0 )
-                goto usage;
-            break;
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nNonRefines = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nNonRefines < 0 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->TimeLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->TimeLimit < 0 )
-                goto usage;
-            break;
-        case 's':
-            pPars->fSeqSimulate ^= 1;
-            break;
-        case 'm':
-            pPars->fCheckMiter ^= 1;
-            break;
-        case 'd':
-            pPars->fDualOut ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Equiv(): There is no AIG.\n" );
-        return 1;
-    }
-    Cec_ManSimulation( pAbc->pGia, pPars );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &equiv [-WFRST num] [-smdvh]\n" );
-    Abc_Print( -2, "\t         computes candidate equivalence classes\n" );
-    Abc_Print( -2, "\t-W num : the number of words to simulate [default = %d]\n", pPars->nWords );
-    Abc_Print( -2, "\t-F num : the number of frames to simulate [default = %d]\n", pPars->nFrames );
-    Abc_Print( -2, "\t-R num : the max number of simulation rounds [default = %d]\n", pPars->nRounds );
-    Abc_Print( -2, "\t-S num : the max number of rounds w/o refinement to stop [default = %d]\n", pPars->nNonRefines );
-    Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", pPars->TimeLimit );
-    Abc_Print( -2, "\t-s     : toggle seq vs. comb simulation [default = %s]\n", pPars->fSeqSimulate? "yes": "no" );
-    Abc_Print( -2, "\t-m     : toggle miter vs. any circuit [default = %s]\n", pPars->fCheckMiter? "miter": "circuit" );
-    Abc_Print( -2, "\t-d     : toggle using two POs intead of XOR [default = %s]\n", pPars->fDualOut? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Equiv2( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern void Ssw_SignalFilterGia( Gia_Man_t * p, int nFramesMax, int nConfMax, int nRounds, int TimeLimit, int TimeLimit2, Abc_Cex_t * pCex, int fLatchOnly, int fVerbose );
-    int nFramesMax =   20;
-    int nConfMax   =  500;
-    int nRounds    =   10;
-    int TimeLimit  =    0;
-    int TimeLimit2 =    0;
-    int fUseCex    =    0;
-    int fLatchOnly =    0;
-    int fVerbose   =    0;
-    int c;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "FCRTSxlvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFramesMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFramesMax < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nConfMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nConfMax < 0 )
-                goto usage;
-            break;
-        case 'R':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nRounds = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nRounds < 0 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            TimeLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( TimeLimit < 0 )
-                goto usage;
-            break;
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            TimeLimit2 = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( TimeLimit2 < 0 )
-                goto usage;
-            break;
-        case 'x':
-            fUseCex ^= 1;
-            break;
-        case 'l':
-            fLatchOnly ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Equiv2(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
-    {
-        Abc_Print( 0, "Abc_CommandAbc9Equiv2(): There is no flops. Nothing is done.\n" );
-        return 0;
-    }
-    if ( fUseCex )
-    {
-        if ( pAbc->pCex == NULL )
-        {
-            Abc_Print( 0, "Abc_CommandAbc9Equiv2(): Counter-example is not available.\n" );
-            return 0;
-        }
-        if ( pAbc->pCex->nPis != Gia_ManPiNum(pAbc->pGia) )
-        {
-            Abc_Print( -1, "Abc_CommandAbc9Equiv2(): The number of PIs differs in cex (%d) and in AIG (%d).\n",
-                pAbc->pCex->nPis, Gia_ManPiNum(pAbc->pGia) );
-            return 1;
-        }
-    }
-    Ssw_SignalFilterGia( pAbc->pGia, nFramesMax, nConfMax, nRounds, TimeLimit, TimeLimit2, fUseCex? pAbc->pCex: NULL, fLatchOnly, fVerbose );
-    pAbc->Status  = -1;
-//    pAbc->nFrames = pAbc->pCex->iFrame;
-//    Abc_FrameReplaceCex( pAbc, &pAbc->pCex );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &equiv2 [-FCRTS num] [-xlvh]\n" );
-    Abc_Print( -2, "\t         computes candidate equivalence classes\n" );
-    Abc_Print( -2, "\t-F num : the max number of frames for BMC [default = %d]\n", nFramesMax );
-    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", nConfMax );
-    Abc_Print( -2, "\t-R num : the max number of BMC rounds [default = %d]\n", nRounds );
-    Abc_Print( -2, "\t-T num : runtime limit in seconds for all rounds [default = %d]\n", TimeLimit );
-    Abc_Print( -2, "\t-S num : runtime limit in seconds for one round [default = %d]\n", TimeLimit2 );
-    Abc_Print( -2, "\t-x     : toggle using the current cex to perform refinement [default = %s]\n", fUseCex? "yes": "no" );
-    Abc_Print( -2, "\t-l     : toggle considering only latch output equivalences [default = %s]\n", fLatchOnly? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Equiv3( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern int Ssw_RarSignalFilterGia( Gia_Man_t * p, Ssw_RarPars_t * pPars );
-    Ssw_RarPars_t Pars, * pPars = &Pars;
-    int c;
-    Ssw_RarSetDefaultParams( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "FWBRSNTmxlvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nFrames = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nFrames < 0 )
-                goto usage;
-            break;
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nWords = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nWords < 0 )
-                goto usage;
-            break;
-        case 'B':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nBinSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nBinSize < 0 )
-                goto usage;
-            break;
-        case 'R':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nRounds = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nRounds < 0 )
-                goto usage;
-            break;
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nRestart = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nRestart < 0 )
-                goto usage;
-            break;
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nRandSeed = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nRandSeed < 0 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->TimeOut = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->TimeOut < 0 )
-                goto usage;
-            break;
-        case 'm':
-            pPars->fMiter ^= 1;
-            break;
-        case 'x':
-            pPars->fUseCex ^= 1;
-            break;
-        case 'l':
-            pPars->fLatchOnly ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Equiv3(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
-    {
-        Abc_Print( 0, "Abc_CommandAbc9Equiv3(): There is no flops. Nothing is done.\n" );
-        return 0;
-    }
-    if ( pPars->fUseCex )
-    {
-        if ( pPars->fMiter )
-        {
-            Abc_Print( 0, "Abc_CommandAbc9Equiv3(): Considering the miter as a circuit because the CEX is given.\n" );
-            pPars->fMiter = 0;
-        }
-        if ( pAbc->pCex == NULL )
-        {
-            Abc_Print( 0, "Abc_CommandAbc9Equiv3(): Counter-example is not available.\n" );
-            return 0;
-        }
-        if ( pAbc->pCex->nPis != Gia_ManPiNum(pAbc->pGia) )
-        {
-            Abc_Print( -1, "Abc_CommandAbc9Equiv3(): The number of PIs differs in cex (%d) and in AIG (%d).\n",
-                pAbc->pCex->nPis, Gia_ManPiNum(pAbc->pGia) );
-            return 1;
-        }
-        pPars->pCex = pAbc->pCex;
-    }
-    pAbc->Status = Ssw_RarSignalFilterGia( pAbc->pGia, pPars );
-//    pAbc->nFrames = pAbc->pGia->pCexSeq->iFrame;
-    Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexSeq );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &equiv3 [-FWRSNT num] [-mxlvh]\n" );
-    Abc_Print( -2, "\t         computes candidate equivalence classes\n" );
-    Abc_Print( -2, "\t-F num : the max number of frames for BMC [default = %d]\n",                   pPars->nFrames );
-    Abc_Print( -2, "\t-W num : the number of words to simulate [default = %d]\n",                    pPars->nWords );
-    Abc_Print( -2, "\t-R num : the max number of simulation rounds [default = %d]\n",                pPars->nRounds );
-    Abc_Print( -2, "\t-S num : the number of rounds before a restart [default = %d]\n",              pPars->nRestart );
-    Abc_Print( -2, "\t-N num : random number seed (1 <= num <= 1000) [default = %d]\n",              pPars->nRandSeed );
-    Abc_Print( -2, "\t-T num : runtime limit in seconds for all rounds [default = %d]\n",            pPars->TimeOut );
-    Abc_Print( -2, "\t-m     : toggle miter vs. any circuit [default = %s]\n",                       pPars->fMiter? "miter": "circuit" );
-    Abc_Print( -2, "\t-x     : toggle using the current CEX to perform refinement [default = %s]\n", pPars->fUseCex? "yes": "no" );
-    Abc_Print( -2, "\t-l     : toggle considering only latch output equivalences [default = %s]\n",  pPars->fLatchOnly? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n",                pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Semi( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Cec_ParSmf_t Pars, * pPars = &Pars;
-    int c;
-    Cec_ManSmfSetDefaultParams( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "WRFSMCTmdvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nWords = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nWords < 0 )
-                goto usage;
-            break;
-        case 'R':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nRounds = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nRounds < 0 )
-                goto usage;
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nFrames = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nFrames < 0 )
-                goto usage;
-            break;
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nNonRefines = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nNonRefines < 0 )
-                goto usage;
-            break;
-        case 'M':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nMinOutputs = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nMinOutputs < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nBTLimit < 0 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->TimeLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->TimeLimit < 0 )
-                goto usage;
-            break;
-        case 'm':
-            pPars->fCheckMiter ^= 1;
-            break;
-        case 'd':
-            pPars->fDualOut ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Resim(): There is no AIG.\n" );
-        return 1;
-    }
-    Cec_ManSeqSemiformal( pAbc->pGia, pPars );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &semi [-WRFSMCT num] [-mdvh]\n" );
-    Abc_Print( -2, "\t         performs semiformal refinement of equivalence classes\n" );
-    Abc_Print( -2, "\t-W num : the number of words to simulate [default = %d]\n", pPars->nWords );
-    Abc_Print( -2, "\t-R num : the max number of rounds to simulate [default = %d]\n", pPars->nRounds );
-    Abc_Print( -2, "\t-F num : the max number of frames to unroll [default = %d]\n", pPars->nFrames );
-    Abc_Print( -2, "\t-S num : the max number of rounds w/o refinement to stop [default = %d]\n", pPars->nNonRefines );
-    Abc_Print( -2, "\t-M num : the min number of outputs of bounded SRM [default = %d]\n", pPars->nMinOutputs );
-    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
-    Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", pPars->TimeLimit );
-    Abc_Print( -2, "\t-m     : toggle miter vs. any circuit [default = %s]\n", pPars->fCheckMiter? "miter": "circuit" );
-    Abc_Print( -2, "\t-d     : toggle using two POs intead of XOR [default = %s]\n", pPars->fDualOut? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Times( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pTemp;
-    int c, nTimes = 2, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Nvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nTimes = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nTimes < 0 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Times(): There is no AIG.\n" );
-        return 1;
-    }
-    pTemp = Gia_ManDupTimes( pAbc->pGia, nTimes );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &times [-N <num>] [-vh]\n" );
-    Abc_Print( -2, "\t         creates several \"parallel\" copies of the design\n" );
-    Abc_Print( -2, "\t-N num : number of copies to create [default = %d]\n", nTimes );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Frames( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Gia_Man_t * Gia_ManFrames2( Gia_Man_t * pAig, Gia_ParFra_t * pPars );
-
-    Gia_Man_t * pTemp;
-    Gia_ParFra_t Pars, * pPars = &Pars;
-    int c;
-    int nCofFanLit = 0;
-    int fNewAlgo = 0;
-    int fInitSpecial = 0;
-    Gia_ManFraSetDefaultParams( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "FLsoibavh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nFrames = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nFrames < 0 )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nCofFanLit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nCofFanLit < 0 )
-                goto usage;
-            break;
-        case 's':
-            pPars->fDisableSt ^= 1;
-            break;
-        case 'o':
-            pPars->fOrPos ^= 1;
-            break;
-        case 'i':
-            pPars->fInit ^= 1;
-            break;
-        case 'b':
-            fInitSpecial ^= 1;
-            break;
-        case 'a':
-            fNewAlgo ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Frames(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
-    {
-        Abc_Print( -1, "The network is combinational.\n" );
-        return 0;
-    }
-    if ( fInitSpecial )
-        pTemp = Gia_ManFramesInitSpecial( pAbc->pGia, pPars->nFrames, pPars->fVerbose );
-    else if ( nCofFanLit )
-        pTemp = Gia_ManUnrollAndCofactor( pAbc->pGia, pPars->nFrames, nCofFanLit, pPars->fVerbose );
-    else if ( fNewAlgo )
-        pTemp = Gia_ManFrames2( pAbc->pGia, pPars );
-    else
-        pTemp = Gia_ManFrames( pAbc->pGia, pPars );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &frames [-FL <num>] [-soibavh]\n" );
-    Abc_Print( -2, "\t         unrolls the design for several timeframes\n" );
-    Abc_Print( -2, "\t-F num : the number of frames to unroll [default = %d]\n", pPars->nFrames );
-    Abc_Print( -2, "\t-L num : the limit on fanout count of resets/enables to cofactor [default = %d]\n", nCofFanLit );
-    Abc_Print( -2, "\t-s     : toggle disabling structural hashing [default = %s]\n", pPars->fDisableSt? "yes": "no" );
-    Abc_Print( -2, "\t-o     : toggle ORing corresponding POs [default = %s]\n", pPars->fOrPos? "yes": "no" );
-    Abc_Print( -2, "\t-i     : toggle initializing registers [default = %s]\n", pPars->fInit? "yes": "no" );
-    Abc_Print( -2, "\t-b     : toggle computing special AIG for BMC [default = %s]\n", fInitSpecial? "yes": "no" );
-    Abc_Print( -2, "\t-a     : toggle using new algorithm [default = %s]\n", fNewAlgo? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Retime( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pTemp;
-    int c;
-    int nMaxIters = 100;
-    int fVerbose  =   0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Nvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nMaxIters = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nMaxIters < 0 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Retime(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
-    {
-        Abc_Print( -1, "The network is combinational.\n" );
-        return 0;
-    }
-    pTemp = Gia_ManRetimeForward( pAbc->pGia, nMaxIters, fVerbose );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &retime [-N <num>] [-vh]\n" );
-    Abc_Print( -2, "\t         performs most-forward retiming\n" );
-    Abc_Print( -2, "\t-N num : the number of incremental iterations [default = %d]\n", nMaxIters );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Enable( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pTemp;
-    int c;
-    int fRemove  = 0;
-    int fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "rvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'r':
-            fRemove ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Enable(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( fRemove )
-        pTemp = Gia_ManRemoveEnables( pAbc->pGia );
-    else
-        pTemp = Gia_ManDupSelf( pAbc->pGia );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &enable [-rvh]\n" );
-    Abc_Print( -2, "\t         adds or removes flop enable signals\n" );
-    Abc_Print( -2, "\t-r     : toggle adding vs. removing enables [default = %s]\n", fRemove? "remove": "add" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Dc2( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pTemp;
-    int c, fVerbose = 0;
-    int fUpdateLevel = 1;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "lvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'l':
-            fUpdateLevel ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Dc2(): There is no AIG.\n" );
-        return 1;
-    }
-    pTemp = Gia_ManCompress2( pAbc->pGia, fUpdateLevel, fVerbose );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &dc2 [-lvh]\n" );
-    Abc_Print( -2, "\t         performs heavy rewriting of the AIG\n" );
-    Abc_Print( -2, "\t-l     : toggle level update during rewriting [default = %s]\n", fUpdateLevel? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Dsd( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Gia_Man_t * Gia_ManCollapseTest( Gia_Man_t * p, int fVerbose );
-    Gia_Man_t * pTemp;
-    int c, fVerbose = 0;
-    int fUpdateLevel = 1;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "lvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'l':
-            fUpdateLevel ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Dsd(): There is no AIG.\n" );
-        return 1;
-    }
-    pTemp = Gia_ManCollapseTest( pAbc->pGia, fVerbose );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &dsd [-vh]\n" );
-    Abc_Print( -2, "\t         performs DSD-based collapsing\n" );
-//    Abc_Print( -2, "\t-l     : toggle level update during rewriting [default = %s]\n", fUpdateLevel? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Bidec( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pTemp;
-    int c, fVerbose = 0;
-    int fUpdateLevel = 1;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "lvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'l':
-            fUpdateLevel ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Bidec(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( !Gia_ManHasMapping(pAbc->pGia) )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Bidec(): Mapping of the AIG is not defined.\n" );
-        return 1;
-    }
-    pTemp = Gia_ManPerformBidec( pAbc->pGia, fVerbose );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &bidec [-vh]\n" );
-    Abc_Print( -2, "\t         performs heavy rewriting of the AIG\n" );
-//    Abc_Print( -2, "\t-l     : toggle level update during rewriting [default = %s]\n", fUpdateLevel? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Shrink( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pTemp = NULL;
-    int nLutSize;
-    int c,fVerbose = 0;
-    int fKeepLevel = 0;
-    int nFanoutMax = 50;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Nlvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by a char string.\n" );
-                goto usage;
-            }
-            nFanoutMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFanoutMax < 0 )
-                goto usage;
-            break;
-        case 'l':
-            fKeepLevel ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Shrink(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( !Gia_ManHasMapping(pAbc->pGia) )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Shrink(): Mapping of the AIG is not defined.\n" );
-        return 1;
-    }
-    nLutSize = Gia_ManLutSizeMax( pAbc->pGia );
-    if ( nLutSize <= 4 )
-        pTemp = Gia_ManMapShrink4( pAbc->pGia, fKeepLevel, fVerbose );
-    else if ( nLutSize <= 6 )
-        pTemp = Gia_ManMapShrink6( pAbc->pGia, nFanoutMax, fKeepLevel, fVerbose );
-    else
-        Abc_Print( -1, "Abc_CommandAbc9Shrink(): Works only for 4-LUTs and 6-LUTs.\n" );
-    if ( pTemp )
-        Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &shrink [-N num] [-lvh]\n" );
-    Abc_Print( -2, "\t         performs fast shrinking using current mapping\n" );
-    Abc_Print( -2, "\t-N num : the max fanout count to skip a divisor [default = %d]\n", nFanoutMax );
-    Abc_Print( -2, "\t-l     : toggle level update during shrinking [default = %s]\n", fKeepLevel? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Fx( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pTemp;
-    int nNewNodesMax = 1000000;
-    int LitCountMax  =       0;
-    int fReverse     =       0;
-    int c, fVerbose  =       0;
-    int fVeryVerbose =       0;
-    // set the defaults
-    Extra_UtilGetoptReset();
-    while ( (c = Extra_UtilGetopt(argc, argv, "NMrvwh")) != EOF )
-    {
-        switch (c)
-        {
-            case 'N':
-                if ( globalUtilOptind >= argc )
-                {
-                    Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                    goto usage;
-                }
-                nNewNodesMax = atoi(argv[globalUtilOptind]);
-                globalUtilOptind++;
-                if ( nNewNodesMax < 0 )
-                    goto usage;
-                break;
-            case 'M':
-                if ( globalUtilOptind >= argc )
-                {
-                    Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
-                    goto usage;
-                }
-                LitCountMax = atoi(argv[globalUtilOptind]);
-                globalUtilOptind++;
-                if ( LitCountMax < 0 )
-                    goto usage;
-                break;
-            case 'r':
-                fReverse ^= 1;
-                break;
-            case 'v':
-                fVerbose ^= 1;
-                break;
-            case 'w':
-                fVeryVerbose ^= 1;
-                break;
-            case 'h':
-                goto usage;
-                break;
-            default:
-                goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Shrink(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( !Gia_ManHasMapping(pAbc->pGia) )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Shrink(): Mapping of the AIG is not defined.\n" );
-        return 1;
-    }
-    pTemp = Gia_ManPerformFx( pAbc->pGia, nNewNodesMax, LitCountMax, fReverse, fVerbose, fVeryVerbose );
-    if ( pTemp != NULL )
-        Abc_FrameUpdateGia( pAbc, pTemp );
-    else
-        Abc_Print( -1, "Abc_CommandAbc9Fx(): Command has failed.\n" );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &fx [-NM <num>] [-vh]\n");
-    Abc_Print( -2, "\t           extract shared logic using the classical \"fast_extract\" algorithm\n");
-    Abc_Print( -2, "\t-N <num> : max number of divisors to extract during this run [default = %d]\n", nNewNodesMax );
-    Abc_Print( -2, "\t-M <num> : upper bound on literal count of divisors to extract [default = %d]\n", LitCountMax );
-    Abc_Print( -2, "\t-r       : reversing variable order during ISOP computation [default = %s]\n", fReverse? "yes": "no" );
-    Abc_Print( -2, "\t-v       : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w       : toggle printing additional information [default = %s]\n", fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Balance( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pTemp = NULL;
-    int nNewNodesMax = ABC_INFINITY;
-    int fDelayOnly   = 0;
-    int fSimpleAnd   = 0;
-    int fKeepLevel   = 0;
-    int c, fVerbose  = 0;
-    int fVeryVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Ndalvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by a char string.\n" );
-                goto usage;
-            }
-            nNewNodesMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nNewNodesMax < 0 )
-                goto usage;
-            break;
-        case 'd':
-            fDelayOnly ^= 1;
-            break;
-        case 'a':
-            fSimpleAnd ^= 1;
-            break;
-        case 'l':
-            fKeepLevel ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'w':
-            fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Balance(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( fDelayOnly )
-        pTemp = Gia_ManBalance( pAbc->pGia, fSimpleAnd, fVerbose );
-    else
-        pTemp = Gia_ManAreaBalance( pAbc->pGia, fSimpleAnd, nNewNodesMax, fVerbose, fVeryVerbose );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &b [-N num] [-davwh]\n" );
-    Abc_Print( -2, "\t         performs AIG balancing to reduce delay and area\n" );
-    Abc_Print( -2, "\t-N num : the max fanout count to skip a divisor [default = %d]\n", nNewNodesMax );
-    Abc_Print( -2, "\t-d     : toggle delay only balancing [default = %s]\n", fDelayOnly? "yes": "no" );
-    Abc_Print( -2, "\t-a     : toggle using AND instead of AND/XOR/MUX [default = %s]\n", fSimpleAnd? "yes": "no" );
-//    Abc_Print( -2, "\t-l     : toggle level update during shrinking [default = %s]\n", fKeepLevel? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w     : toggle printing additional information [default = %s]\n", fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9BalanceLut( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Gia_Man_t * Gia_ManBalanceLut( Gia_Man_t * p, int nLutSize, int nCutNum, int fVerbose );
-    extern Gia_Man_t * Gia_ManLutBalance( Gia_Man_t * p, int nLutSize, int fUseMuxes, int fRecursive, int fOptArea, int fVerbose );
-    Gia_Man_t * pTemp = NULL;
-    int fUseOld      = 0;
-    int nLutSize     = 6;
-    int nCutNum      = 8;
-    int fUseMuxes    = 1;
-    int fRecursive   = 1;
-    int fOptArea     = 1;
-    int c, fVerbose  = 0;
-    int fVeryVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "KCnmravwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-K\" should be followed by a char string.\n" );
-                goto usage;
-            }
-            nLutSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nLutSize < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by a char string.\n" );
-                goto usage;
-            }
-            nCutNum = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nCutNum < 0 )
-                goto usage;
-            break;
-        case 'n':
-            fUseOld ^= 1;
-            break;
-        case 'm':
-            fUseMuxes ^= 1;
-            break;
-        case 'r':
-            fRecursive ^= 1;
-            break;
-        case 'a':
-            fOptArea ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'w':
-            fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9BalanceLut(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( fUseOld )
-        pTemp = Gia_ManBalanceLut( pAbc->pGia, nLutSize, nCutNum, fVerbose );
-    else
-        pTemp = Gia_ManLutBalance( pAbc->pGia, nLutSize, fUseMuxes, fRecursive, fOptArea, fVerbose );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &blut [-KC num] [-mravh]\n" );
-    Abc_Print( -2, "\t           performs AIG balancing for the given LUT size\n" );
-    Abc_Print( -2, "\t-K num   : LUT size for the mapping (2 <= K <= %d) [default = %d]\n", 6, nLutSize );
-    Abc_Print( -2, "\t-C num   : the max number of priority cuts (1 <= C <= %d) [default = %d]\n", 8, nCutNum );
-    Abc_Print( -2, "\t-m       : toggle performing MUX restructuring [default = %s]\n", fUseMuxes? "yes": "no" );
-    Abc_Print( -2, "\t-r       : toggle performing recursive restructuring [default = %s]\n", fRecursive? "yes": "no" );
-    Abc_Print( -2, "\t-a       : toggle performing area-oriented restructuring [default = %s]\n", fOptArea? "yes": "no" );
-    Abc_Print( -2, "\t-v       : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-//    Abc_Print( -2, "\t-w       : toggle printing additional information [default = %s]\n", fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Syn2( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pTemp;
-    int c, fVerbose  =  0;
-    int fOldAlgo     =  0;
-    int fCoarsen     =  1;
-    int fCutMin      =  0;
-    int nRelaxRatio  = 20;
-    int fDelayMin    =  0;
-    int fVeryVerbose =  0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Rakmdvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-		case 'R':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( 1, "Command line switch \"-R\" should be followed by a floating point number.\n" );
-                return 0;
-            }
-			nRelaxRatio = atoi(argv[globalUtilOptind]);
-			globalUtilOptind++;
-			if ( nRelaxRatio < 0 ) 
-				goto usage;
-            break;
-        case 'a':
-            fOldAlgo ^= 1;
-            break;
-        case 'k':
-            fCoarsen ^= 1;
-            break;
-        case 'm':
-            fCutMin ^= 1;
-            break;
-        case 'd':
-            fDelayMin ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'w':
-            fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Syn2(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( fDelayMin )
-    {
-        If_DsdMan_t * p = (If_DsdMan_t *)Abc_FrameReadManDsd();
-        if ( p && If_DsdManVarNum(p) < 6 )
-        {
-            printf( "DSD manager has incompatible number of variables. Delay minimization is not performed.\n" );
-            fDelayMin = 0;
-        }
-    } 
-    pTemp = Gia_ManAigSyn2( pAbc->pGia, fOldAlgo, fCoarsen, fCutMin, nRelaxRatio, fDelayMin, fVerbose, fVeryVerbose );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &syn2 [-R num] [-akmdvh]\n" );
-    Abc_Print( -2, "\t           performs AIG optimization\n" );
-    Abc_Print( -2, "\t-R num   : the delay relaxation ratio (num >= 0) [default = %d]\n",   nRelaxRatio );
-    Abc_Print( -2, "\t-a       : toggles using the old algorithm [default = %s]\n",         fOldAlgo? "yes": "no" );
-    Abc_Print( -2, "\t-k       : toggles coarsening the subject graph [default = %s]\n",    fCoarsen? "yes": "no" );
-    Abc_Print( -2, "\t-m       : toggles cut minimization [default = %s]\n",                fCutMin? "yes": "no" );
-    Abc_Print( -2, "\t-d       : toggles additional delay optimization [default = %s]\n",   fDelayMin? "yes": "no" );
-    Abc_Print( -2, "\t-v       : toggles printing verbose information [default = %s]\n",    fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w       : toggles printing additional information [default = %s]\n", fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Synch2( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Gia_Man_t * Gia_ManAigSynch2( Gia_Man_t * p, int fVerbose );
-    Gia_Man_t * pTemp;
-    int c, fVerbose  =  0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Synch2(): There is no AIG.\n" );
-        return 1;
-    }
-    pTemp = Gia_ManAigSynch2( pAbc->pGia, fVerbose );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &synch2 [-vh]\n" );
-    Abc_Print( -2, "\t           performs synthesis and computes structural choices\n" );
-    Abc_Print( -2, "\t-v       : toggles printing additional information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Syn3( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pTemp;
-    int c, fVerbose = 0;
-    int fVeryVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "vwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'w':
-            fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Syn3(): There is no AIG.\n" );
-        return 1;
-    }
-    pTemp = Gia_ManAigSyn3( pAbc->pGia, fVerbose, fVeryVerbose );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &syn3 [-lvh]\n" );
-    Abc_Print( -2, "\t         performs AIG optimization\n" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w     : toggle printing additional information [default = %s]\n", fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Syn4( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pTemp;
-    int c, fVerbose = 0;
-    int fVeryVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "vwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'w':
-            fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Syn4(): There is no AIG.\n" );
-        return 1;
-    }
-    pTemp = Gia_ManAigSyn4( pAbc->pGia, fVerbose, fVeryVerbose );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &syn4 [-lvh]\n" );
-    Abc_Print( -2, "\t         performs AIG optimization\n" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w     : toggle printing additional information [default = %s]\n", fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9False( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Gia_Man_t * Gia_ManCheckFalse( Gia_Man_t * p, int nSlackMax, int nTimeOut, int fVerbose, int fVeryVerbose );
-    Gia_Man_t * pTemp;
-    int nSlackMax = 0;
-    int nTimeOut = 0;
-    int c, fVerbose = 0;
-    int fVeryVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "STvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by a char string.\n" );
-                goto usage;
-            }
-            nSlackMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nSlackMax < 0 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by a char string.\n" );
-                goto usage;
-            }
-            nTimeOut = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nTimeOut < 0 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'w':
-            fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9False(): There is no AIG.\n" );
-        return 1;
-    }
-    pTemp = Gia_ManCheckFalse( pAbc->pGia, nSlackMax, nTimeOut, fVerbose, fVeryVerbose );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &false [-ST num] [-vwh]\n" );
-    Abc_Print( -2, "\t         detecting and elimintation false paths\n" );
-    Abc_Print( -2, "\t-S num : maximum slack to identify false paths [default = %d]\n",  nSlackMax );
-    Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n",   nTimeOut );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n",    fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w     : toggle printing additional information [default = %s]\n", fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Miter( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    FILE * pFile;
-    Gia_Man_t * pAux;
-    Gia_Man_t * pSecond;
-    char * FileName, * pTemp;
-    char ** pArgvNew;
-    int nArgcNew;
-    int c;
-    int nInsDup  = 0;
-    int fDualOut = 0;
-    int fSeq     = 0;
-    int fTrans   = 0;
-    int fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Idstvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'I':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-I\" should be followed by a char string.\n" );
-                goto usage;
-            }
-            nInsDup = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nInsDup < 0 )
-                goto usage;
-            break;
-        case 'd':
-            fDualOut ^= 1;
-            break;
-        case 's':
-            fSeq ^= 1;
-            break;
-        case 't':
-            fTrans ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( fTrans )
-    {
-        if ( (Gia_ManPoNum(pAbc->pGia) & 1) == 1 )
-        {
-            Abc_Print( -1, "Abc_CommandAbc9Miter(): The number of outputs should be even.\n" );
-            return 0;
-        }
-        if ( pAbc->pGia == NULL )
-        {
-            Abc_Print( -1, "Abc_CommandAbc9Miter(): There is no AIG.\n" );
-            return 1;
-        }
-        pAux = Gia_ManTransformMiter( pAbc->pGia );
-        Abc_FrameUpdateGia( pAbc, pAux );
-        Abc_Print( 1, "The miter (current AIG) is transformed by XORing POs pair-wise.\n" );
-        return 0;
-    }
-
-    pArgvNew = argv + globalUtilOptind;
-    nArgcNew = argc - globalUtilOptind;
-    if ( nArgcNew != 1 )
-    {
-        Abc_Print( -1, "File name is not given on the command line.\n" );
-        return 1;
-    }
-
-    // get the input file name
-    FileName = pArgvNew[0];
-    // fix the wrong symbol
-    for ( pTemp = FileName; *pTemp; pTemp++ )
-        if ( *pTemp == '>' )
-            *pTemp = '\\';
-    if ( (pFile = fopen( FileName, "r" )) == NULL )
-    {
-        Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
-        if ( (FileName = Extra_FileGetSimilarName( FileName, ".aig", NULL, NULL, NULL, NULL )) )
-            Abc_Print( 1, "Did you mean \"%s\"?", FileName );
-        Abc_Print( 1, "\n" );
-        return 1;
-    }
-    fclose( pFile );
-    pSecond = Gia_AigerRead( FileName, 0, 0 );
-    if ( pSecond == NULL )
-    {
-        Abc_Print( -1, "Reading AIGER has failed.\n" );
-        return 0;
-    }
-    // compute the miter
-    pAux = Gia_ManMiter( pAbc->pGia, pSecond, nInsDup, fDualOut, fSeq, 0, fVerbose );
-    Gia_ManStop( pSecond );
-    Abc_FrameUpdateGia( pAbc, pAux );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &miter [-I num] [-dstvh] <file>\n" );
-    Abc_Print( -2, "\t         creates miter of two designs (current AIG vs. <file>)\n" );
-    Abc_Print( -2, "\t-I num : the number of last PIs to replicate [default = %d]\n", nInsDup );
-    Abc_Print( -2, "\t-d     : toggle creating dual-output miter [default = %s]\n", fDualOut? "yes": "no" );
-    Abc_Print( -2, "\t-s     : toggle creating sequential miter [default = %s]\n", fSeq? "yes": "no" );
-    Abc_Print( -2, "\t-t     : toggle XORing pair-wise POs of the miter [default = %s]\n", fTrans? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\t<file> : AIGER file with the design to miter\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Miter2( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    FILE * pFile;
-    Gia_Man_t * pAux;
-    char * FileName, * pTemp, * pInit;
-    char ** pArgvNew;
-    int nArgcNew;
-    int c, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    pArgvNew = argv + globalUtilOptind;
-    nArgcNew = argc - globalUtilOptind;
-    if ( nArgcNew != 1 )
-    {
-        Abc_Print( -1, "File name is not given on the command line.\n" );
-        return 1;
-    }
-    // get the input file name
-    FileName = pArgvNew[0];
-    // fix the wrong symbol
-    for ( pTemp = FileName; *pTemp; pTemp++ )
-        if ( *pTemp == '>' )
-            *pTemp = '\\';
-    if ( (pFile = fopen( FileName, "r" )) == NULL )
-    {
-        Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
-        if ( (FileName = Extra_FileGetSimilarName( FileName, ".aig", NULL, NULL, NULL, NULL )) )
-            Abc_Print( 1, "Did you mean \"%s\"?", FileName );
-        Abc_Print( 1, "\n" );
-        return 1;
-    }
-    fclose( pFile );
-    // extract string
-    pInit = Extra_FileReadContents( FileName );
-    Extra_StringClean( pInit, "01xX" );
-    if ( (int)strlen(pInit) != Gia_ManCiNum(pAbc->pGia) )
-    {
-        Abc_Print( -1, "Init string length (%d) differs from PI and flop count (%d).\n", strlen(pInit), Gia_ManCiNum(pAbc->pGia) );
-        ABC_FREE( pInit );
-        return 1;
-    }
-    // compute the miter
-    pAux = Gia_ManMiter2( pAbc->pGia, pInit, fVerbose );
-    ABC_FREE( pInit );
-    Abc_FrameUpdateGia( pAbc, pAux );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &miter2 [-vh] <file>\n" );
-    Abc_Print( -2, "\t         creates miter of two copies of the design\n" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\t<file> : file name with flop initial values (0/1/x/X) [default = required]\n" );
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Append( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    FILE * pFile;
-    Gia_Man_t * pSecond;
-    char * FileName, * pTemp;
-    char ** pArgvNew;
-    int nArgcNew;
-    int c;
-    int fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-
-    pArgvNew = argv + globalUtilOptind;
-    nArgcNew = argc - globalUtilOptind;
-    if ( nArgcNew != 1 )
-    {
-        Abc_Print( -1, "File name is not given on the command line.\n" );
-        return 1;
-    }
-
-    // get the input file name
-    FileName = pArgvNew[0];
-    // fix the wrong symbol
-    for ( pTemp = FileName; *pTemp; pTemp++ )
-        if ( *pTemp == '>' )
-            *pTemp = '\\';
-    if ( (pFile = fopen( FileName, "r" )) == NULL )
-    {
-        Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
-        if ( (FileName = Extra_FileGetSimilarName( FileName, ".aig", NULL, NULL, NULL, NULL )) )
-            Abc_Print( 1, "Did you mean \"%s\"?", FileName );
-        Abc_Print( 1, "\n" );
-        return 1;
-    }
-    fclose( pFile );
-    pSecond = Gia_AigerRead( FileName, 0, 0 );
-    if ( pSecond == NULL )
-    {
-        Abc_Print( -1, "Reading AIGER has failed.\n" );
-        return 0;
-    }
-    // compute the miter
-    Gia_ManDupAppend( pAbc->pGia, pSecond );
-    Gia_ManStop( pSecond );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &append [-vh] <file>\n" );
-    Abc_Print( -2, "\t         appends <file> to the current AIG using new PIs and POs\n" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\t<file> : AIGER file with the design to miter\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Scl( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pTemp;
-    int c;
-    int fConst = 1;
-    int fEquiv = 1;
-    int fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "cevh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'c':
-            fConst ^= 1;
-            break;
-        case 'e':
-            fEquiv ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Scl(): There is no AIG.\n" );
-        return 1;
-    }
-    pTemp = Gia_ManSeqStructSweep( pAbc->pGia, fConst, fEquiv, fVerbose );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &scl [-cevh]\n" );
-    Abc_Print( -2, "\t         performs structural sequential cleanup\n" );
-    Abc_Print( -2, "\t-c     : toggle removing stuck-at constant registers [default = %s]\n", fConst? "yes": "no" );
-    Abc_Print( -2, "\t-e     : toggle removing equivalent-driver registers [default = %s]\n", fEquiv? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Lcorr( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Cec_ParCor_t Pars, * pPars = &Pars;
-    Gia_Man_t * pTemp;
-    int c;
-    Cec_ManCorSetDefaultParams( pPars );
-    pPars->fLatchCorr = 1;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "FCPrcvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nFrames = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nFrames < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nBTLimit < 0 )
-                goto usage;
-            break;
-        case 'P':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nPrefix = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nPrefix < 0 )
-                goto usage;
-            break;
-        case 'r':
-            pPars->fUseRings ^= 1;
-            break;
-        case 'c':
-            pPars->fUseCSat ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Lcorr(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
-    {
-        Abc_Print( -1, "The network is combinational.\n" );
-        return 0;
-    }
-    pTemp = Cec_ManLSCorrespondence( pAbc->pGia, pPars );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &lcorr [-FCP num] [-rcvh]\n" );
-    Abc_Print( -2, "\t         performs latch correpondence computation\n" );
-    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
-    Abc_Print( -2, "\t-F num : the number of timeframes in inductive case [default = %d]\n", pPars->nFrames );
-    Abc_Print( -2, "\t-P num : the number of timeframes in the prefix [default = %d]\n", pPars->nPrefix );
-    Abc_Print( -2, "\t-r     : toggle using implication rings during refinement [default = %s]\n", pPars->fUseRings? "yes": "no" );
-    Abc_Print( -2, "\t-c     : toggle using circuit-based SAT solver [default = %s]\n", pPars->fUseCSat? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Scorr( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Cec_ParCor_t Pars, * pPars = &Pars;
-    Gia_Man_t * pTemp;
-    int c;
-    Cec_ManCorSetDefaultParams( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "FCPkrecqwvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nFrames = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nFrames < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nBTLimit < 0 )
-                goto usage;
-            break;
-        case 'P':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nPrefix = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nPrefix < 0 )
-                goto usage;
-            break;
-        case 'k':
-            pPars->fConstCorr ^= 1;
-            break;
-        case 'r':
-            pPars->fUseRings ^= 1;
-            break;
-        case 'e':
-            pPars->fMakeChoices ^= 1;
-            break;
-        case 'c':
-            pPars->fUseCSat ^= 1;
-            break;
-        case 'q':
-            pPars->fStopWhenGone ^= 1;
-            break;
-        case 'w':
-            pPars->fVerboseFlops ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Scorr(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
-    {
-        Abc_Print( -1, "The network is combinational.\n" );
-        return 0;
-    }
-    pTemp = Cec_ManLSCorrespondence( pAbc->pGia, pPars );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &scorr [-FCP num] [-krecqwvh]\n" );
-    Abc_Print( -2, "\t         performs signal correpondence computation\n" );
-    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
-    Abc_Print( -2, "\t-F num : the number of timeframes in inductive case [default = %d]\n", pPars->nFrames );
-    Abc_Print( -2, "\t-P num : the number of timeframes in the prefix [default = %d]\n", pPars->nPrefix );
-    Abc_Print( -2, "\t-k     : toggle using constant correspondence [default = %s]\n", pPars->fConstCorr? "yes": "no" );
-    Abc_Print( -2, "\t-r     : toggle using implication rings during refinement [default = %s]\n", pPars->fUseRings? "yes": "no" );
-    Abc_Print( -2, "\t-e     : toggle using equivalences as choices [default = %s]\n", pPars->fMakeChoices? "yes": "no" );
-    Abc_Print( -2, "\t-c     : toggle using circuit-based SAT solver [default = %s]\n", pPars->fUseCSat? "yes": "no" );
-    Abc_Print( -2, "\t-q     : toggle quitting when PO is not a constant candidate [default = %s]\n", pPars->fStopWhenGone? "yes": "no" );
-    Abc_Print( -2, "\t-w     : toggle printing verbose info about equivalent flops [default = %s]\n", pPars->fVerboseFlops? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Choice( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Cec_ParChc_t Pars, * pPars = &Pars;
-    Gia_Man_t * pTemp;
-    int c;
-    Cec_ManChcSetDefaultParams( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Ccvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nBTLimit < 0 )
-                goto usage;
-            break;
-        case 'c':
-            pPars->fUseCSat ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Choice(): There is no AIG.\n" );
-        return 1;
-    }
-    pTemp = Cec_ManChoiceComputation( pAbc->pGia, pPars );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &choice [-C num] [-cvh]\n" );
-    Abc_Print( -2, "\t         performs computation of structural choices\n" );
-    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
-    Abc_Print( -2, "\t-c     : toggle using circuit-based SAT solver [default = %s]\n", pPars->fUseCSat? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Sat( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Cec_ParSat_t ParsSat, * pPars = &ParsSat;
-    Gia_Man_t * pTemp;
-    int c;
-    int fCSat = 0;
-    Cec_ManSatSetDefaultParams( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "CSNnmtcvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nBTLimit < 0 )
-                goto usage;
-            break;
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nSatVarMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nSatVarMax < 0 )
-                goto usage;
-            break;
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nCallsRecycle = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nCallsRecycle < 0 )
-                goto usage;
-            break;
-        case 'n':
-            pPars->fNonChrono ^= 1;
-            break;
-        case 'm':
-            pPars->fCheckMiter ^= 1;
-            break;
-        case 't':
-            pPars->fLearnCls ^= 1;
-            break;
-        case 'c':
-            fCSat ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Sat(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( fCSat )
-    {
-        Vec_Int_t * vCounters;
-        Vec_Str_t * vStatus;
-        if ( pPars->fLearnCls )
-            vCounters = Tas_ManSolveMiterNc( pAbc->pGia, pPars->nBTLimit, &vStatus, pPars->fVerbose );
-        else if ( pPars->fNonChrono )
-            vCounters = Cbs_ManSolveMiterNc( pAbc->pGia, pPars->nBTLimit, &vStatus, pPars->fVerbose );
-        else
-            vCounters = Cbs_ManSolveMiter( pAbc->pGia, pPars->nBTLimit, &vStatus, pPars->fVerbose );
-        Vec_IntFree( vCounters );
-        Vec_StrFree( vStatus );
-    }
-    else
-    {
-        pTemp = Cec_ManSatSolving( pAbc->pGia, pPars );
-        Abc_FrameUpdateGia( pAbc, pTemp );
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &sat [-CSN <num>] [-nmctvh]\n" );
-    Abc_Print( -2, "\t         performs SAT solving for the combinational outputs\n" );
-    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
-    Abc_Print( -2, "\t-S num : the min number of variables to recycle the solver [default = %d]\n", pPars->nSatVarMax );
-    Abc_Print( -2, "\t-N num : the min number of calls to recycle the solver [default = %d]\n", pPars->nCallsRecycle );
-    Abc_Print( -2, "\t-n     : toggle using non-chronological backtracking [default = %s]\n", pPars->fNonChrono? "yes": "no" );
-    Abc_Print( -2, "\t-m     : toggle miter vs. any circuit [default = %s]\n", pPars->fCheckMiter? "miter": "circuit" );
-    Abc_Print( -2, "\t-c     : toggle using circuit-based SAT solver [default = %s]\n", fCSat? "yes": "no" );
-    Abc_Print( -2, "\t-t     : toggle using learning in curcuit-based solver [default = %s]\n", pPars->fLearnCls? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Fraig( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Cec_ParFra_t ParsFra, * pPars = &ParsFra;
-    Gia_Man_t * pTemp;
-    int c;
-    Cec_ManFraSetDefaultParams( pPars );
-    pPars->fSatSweeping = 1;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "WRILDCrmdcwvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nWords = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nWords < 0 )
-                goto usage;
-            break;
-        case 'R':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nRounds = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nRounds < 0 )
-                goto usage;
-            break;
-        case 'I':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nItersMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nItersMax < 0 )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nLevelMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nLevelMax < 0 )
-                goto usage;
-            break;
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nDepthMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nDepthMax < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nBTLimit < 0 )
-                goto usage;
-            break;
-        case 'r':
-            pPars->fRewriting ^= 1;
-            break;
-        case 'm':
-            pPars->fCheckMiter ^= 1;
-            break;
-        case 'd':
-            pPars->fDualOut ^= 1;
-            break;
-        case 'c':
-            pPars->fRunCSat ^= 1;
-            break;
-        case 'w':
-            pPars->fVeryVerbose ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Fraig(): There is no AIG.\n" );
-        return 1;
-    }
-    pTemp = Cec_ManSatSweeping( pAbc->pGia, pPars );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &fraig [-WRILDC <num>] [-rmdcwvh]\n" );
-    Abc_Print( -2, "\t         performs combinational SAT sweeping\n" );
-    Abc_Print( -2, "\t-W num : the number of simulation words [default = %d]\n", pPars->nWords );
-    Abc_Print( -2, "\t-R num : the number of simulation rounds [default = %d]\n", pPars->nRounds );
-    Abc_Print( -2, "\t-I num : the number of sweeping iterations [default = %d]\n", pPars->nItersMax );
-    Abc_Print( -2, "\t-L num : the max number of levels of nodes to consider [default = %d]\n", pPars->nLevelMax );
-    Abc_Print( -2, "\t-D num : the max number of steps of speculative reduction [default = %d]\n", pPars->nDepthMax );
-    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
-    Abc_Print( -2, "\t-r     : toggle the use of AIG rewriting [default = %s]\n", pPars->fRewriting? "yes": "no" );
-    Abc_Print( -2, "\t-m     : toggle miter vs. any circuit [default = %s]\n", pPars->fCheckMiter? "miter": "circuit" );
-    Abc_Print( -2, "\t-d     : toggle using double output miters [default = %s]\n", pPars->fDualOut? "yes": "no" );
-    Abc_Print( -2, "\t-c     : toggle using circuit-based solver [default = %s]\n", pPars->fRunCSat? "yes": "no" );
-    Abc_Print( -2, "\t-w     : toggle printing even more verbose information [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9CFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pTemp;
-    int c;
-    Ssc_Pars_t Pars, * pPars = &Pars;
-    Ssc_ManSetDefaultParams( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "WCacvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nWords = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nWords < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nBTLimit < 0 )
-                goto usage;
-            break;
-        case 'a':
-            pPars->fAppend ^= 1;
-            break;
-        case 'c':
-            pPars->fVerify ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9CFraig(): There is no AIG.\n" );
-        return 1;
-    }
-    pTemp = Ssc_PerformSweepingConstr( pAbc->pGia, pPars );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &cfraig [-WC <num>] [-acvh]\n" );
-    Abc_Print( -2, "\t         performs combinational SAT sweeping under constraints\n" );
-    Abc_Print( -2, "\t         which are present in the AIG or set manually using \"constr\"\n" );
-    Abc_Print( -2, "\t         (constraints are listed as last POs and true when they are 0)\n" );
-    Abc_Print( -2, "\t-W num : the number of simulation words [default = %d]\n", pPars->nWords );
-    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
-    Abc_Print( -2, "\t-a     : toggle appending constraints to the result [default = %s]\n", pPars->fAppend? "yes": "no" );
-    Abc_Print( -2, "\t-c     : toggle performing internal verification [default = %s]\n", pPars->fVerify? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Srm( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    char * pFileNameIn = NULL;
-    char pFileName[10] = "gsrm.aig", pFileName2[10] = "gsyn.aig";
-    Gia_Man_t * pTemp, * pAux;
-    int c, fVerbose = 0;
-    int fSynthesis = 0;
-    int fSpeculate = 1;
-    int fSkipSome = 0;
-    int fDualOut = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Adrsfvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'A':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-A\" should be followed by a file name.\n" );
-                goto usage;
-            }
-            pFileNameIn = argv[globalUtilOptind];
-            globalUtilOptind++;
-            break;
-        case 'd':
-            fDualOut ^= 1;
-            break;
-        case 'r':
-            fSynthesis ^= 1;
-            break;
-        case 's':
-            fSpeculate ^= 1;
-            break;
-        case 'f':
-            fSkipSome ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Srm(): There is no AIG.\n" );
-        return 1;
-    }
-    sprintf(pFileName,  "gsrm%s.aig", fSpeculate? "" : "s" );
-    sprintf(pFileName2, "gsyn%s.aig", fSpeculate? "" : "s" );
-    pTemp = Gia_ManSpecReduce( pAbc->pGia, fDualOut, fSynthesis, fSpeculate, fSkipSome, fVerbose );
-    if ( pTemp )
-    {
-        if ( fSpeculate )
-        {
-            pTemp = Gia_ManSeqStructSweep( pAux = pTemp, 1, 1, 0 );
-            Gia_ManStop( pAux );
-        }
-        Gia_AigerWrite( pTemp, pFileNameIn ? pFileNameIn : pFileName, 0, 0 );
-        Abc_Print( 1, "Speculatively reduced model was written into file \"%s\".\n", pFileName );
-        Gia_ManPrintStatsShort( pTemp );
-        Gia_ManStop( pTemp );
-    }
-    if ( fSynthesis )
-    {
-        pTemp = Gia_ManEquivReduce( pAbc->pGia, 1, fDualOut, 0, fVerbose );
-        if ( pTemp )
-        {
-            pTemp = Gia_ManSeqStructSweep( pAux = pTemp, 1, 1, 0 );
-            Gia_ManStop( pAux );
-
-            Gia_AigerWrite( pTemp, pFileName2, 0, 0 );
-            Abc_Print( 1, "Reduced original network was written into file \"%s\".\n", pFileName2 );
-            Gia_ManPrintStatsShort( pTemp );
-            Gia_ManStop( pTemp );
-        }
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &srm [-A file] [-drsfvh]\n" );
-    Abc_Print( -2, "\t          writes speculatively reduced model into file \"%s\"\n", pFileName );
-    Abc_Print( -2, "\t-A file : file name for dumping speculative-reduced model [default = \"gsrm.aig\"]\n" );
-    Abc_Print( -2, "\t-d      : toggle creating dual-output miter [default = %s]\n", fDualOut? "yes": "no" );
-    Abc_Print( -2, "\t-r      : toggle writing reduced network for synthesis [default = %s]\n", fSynthesis? "yes": "no" );
-    Abc_Print( -2, "\t-s      : toggle using speculation at the internal nodes [default = %s]\n", fSpeculate? "yes": "no" );
-    Abc_Print( -2, "\t-f      : toggle filtering to remove redundant equivalences [default = %s]\n", fSkipSome? "yes": "no" );
-    Abc_Print( -2, "\t-v      : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h      : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Srm2( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    char pFileName[10], * pFileName1, * pFileName2;
-    Gia_Man_t * pTemp, * pAux;
-    int fLatchA = 0, fLatchB = 0;
-    int c, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "abvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'a':
-            fLatchA ^= 1;
-            break;
-        case 'b':
-            fLatchB ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Srm2(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( pAbc->pGia->pReprs == NULL || pAbc->pGia->pNexts == NULL )
-    {
-        Abc_Print( -1, "Equivalences are not defined.\n" );
-        return 0;
-    }
-    if ( argc != globalUtilOptind + 2 )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Srm2(): Expecting two file names on the command line.\n" );
-        return 1;
-    }
-    // get the input file name
-    pFileName1 = argv[globalUtilOptind];
-    pFileName2 = argv[globalUtilOptind+1];
-    // create file name
-    sprintf(pFileName,  "gsrm.aig" );
-    pTemp = Gia_ManDup( pAbc->pGia );
-    // copy equivalences
-    pTemp->pReprs = ABC_ALLOC( Gia_Rpr_t, Gia_ManObjNum(pTemp) );
-    memcpy( pTemp->pReprs, pAbc->pGia->pReprs, sizeof(Gia_Rpr_t) * Gia_ManObjNum(pTemp) );
-    pTemp->pNexts = ABC_ALLOC( int, Gia_ManObjNum(pTemp) );
-    memcpy( pTemp->pNexts, pAbc->pGia->pNexts, sizeof(int) * Gia_ManObjNum(pTemp) );
-//Gia_ManPrintStats( pTemp, 0 );
-    // filter the classes
-    if ( !Gia_ManFilterEquivsForSpeculation( pTemp, pFileName1, pFileName2, fLatchA, fLatchB ) )
-    {
-        Gia_ManStop( pTemp );
-        Abc_Print( -1, "Filtering equivalences has failed.\n" );
-        return 1;
-    }
-//Gia_ManPrintStats( pTemp, 0 );
-    pTemp = Gia_ManSpecReduce( pAux = pTemp, 0, 0, 1, 0, 0 );
-    Gia_ManStop( pAux );
-    if ( pTemp )
-    {
-        pTemp = Gia_ManSeqStructSweep( pAux = pTemp, 1, 1, 0 );
-        Gia_ManStop( pAux );
-
-        Gia_AigerWrite( pTemp, pFileName, 0, 0 );
-        Abc_Print( 1, "Speculatively reduced model was written into file \"%s\".\n", pFileName );
-        Gia_ManPrintStatsShort( pTemp );
-        Gia_ManStop( pTemp );
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &srm2 [-abvh] <PartA_FileName> <PartB_FileName>\n" );
-    Abc_Print( -2, "\t         writes speculatively reduced model into file \"%s\"\n", pFileName );
-    Abc_Print( -2, "\t         only preserves equivalences across PartA and PartB\n" );
-    Abc_Print( -2, "\t-a     : toggle using latches only in PartA [default = %s]\n", fLatchA? "yes": "no" );
-    Abc_Print( -2, "\t-b     : toggle using latches only in PartB [default = %s]\n", fLatchB? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Filter( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    char * pFileName1 = NULL, * pFileName2 = NULL;
-    int fFlopsOnly = 0, fFlopsWith = 0;
-    int c, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "fgvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'f':
-            fFlopsOnly ^= 1;
-            break;
-        case 'g':
-            fFlopsWith ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Srm2(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( pAbc->pGia->pReprs == NULL || pAbc->pGia->pNexts == NULL )
-    {
-        Abc_Print( -1, "Equivalences are not defined.\n" );
-        return 0;
-    }
-    if ( argc != globalUtilOptind && argc != globalUtilOptind + 2 )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Srm2(): Expecting two file names on the command line.\n" );
-        return 1;
-    }
-    // filter using one of the choices
-    if ( fFlopsOnly ^ fFlopsWith )
-        Gia_ManFilterEquivsUsingLatches( pAbc->pGia, fFlopsOnly, fFlopsWith );
-    // get the input file name
-    if ( argc == globalUtilOptind + 2 )
-    {
-        pFileName1 = argv[globalUtilOptind];
-        pFileName2 = argv[globalUtilOptind+1];
-        if ( !Gia_ManFilterEquivsUsingParts( pAbc->pGia, pFileName1, pFileName2 ) )
-        {
-            Abc_Print( -1, "Filtering equivalences using PartA and PartB has failed.\n" );
-            return 1;
-        }
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &filter [-fgvh] <PartA_FileName> <PartB_FileName>\n" );
-    Abc_Print( -2, "\t         performs filtering of equivalence classes\n" );
-    Abc_Print( -2, "\t         (if Parts A/B are given, removes classes composed of one part)\n" );
-    Abc_Print( -2, "\t-f     : toggle removing all elements except flops [default = %s]\n", fFlopsOnly? "yes": "no" );
-    Abc_Print( -2, "\t-g     : toggle removing removing classes without flops [default = %s]\n", fFlopsWith? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Reduce( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pTemp, * pTemp2;
-    int c, fVerbose = 0;
-    int fUseAll = 0;
-    int fDualOut = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "advh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'a':
-            fUseAll ^= 1;
-            break;
-        case 'd':
-            fDualOut ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Reduce(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( fUseAll )
-    {
-        pTemp = Gia_ManEquivReduce( pAbc->pGia, fUseAll, fDualOut, 0, fVerbose );
-        pTemp = Gia_ManSeqStructSweep( pTemp2 = pTemp, 1, 1, 0 );
-        Gia_ManStop( pTemp2 );
-    }
-    else
-        pTemp = Gia_ManEquivReduceAndRemap( pAbc->pGia, 1, fDualOut );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &reduce [-advh]\n" );
-    Abc_Print( -2, "\t         reduces the circuit using equivalence classes\n" );
-    Abc_Print( -2, "\t-a     : toggle merging all equivalences [default = %s]\n", fUseAll? "yes": "no" );
-    Abc_Print( -2, "\t-d     : toggle using dual-output merging [default = %s]\n", fDualOut? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9EquivMark( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern void Gia_ManEquivMark( Gia_Man_t * p, char * pFileName, int fSkipSome, int fVerbose );
-    char * pFileName;
-    int c, fVerbose = 0;
-    int fSkipSome = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "fvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'f':
-            fSkipSome ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9EquivMark(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( argc != globalUtilOptind + 1 )
-        goto usage;
-    // get the input file name
-    pFileName = argv[globalUtilOptind];
-    // mark equivalences
-    Gia_ManEquivMark( pAbc->pGia, pFileName, fSkipSome, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &equiv_mark [-fvh] <miter.aig>\n" );
-    Abc_Print( -2, "\t              marks equivalences using an external miter\n" );
-    Abc_Print( -2, "\t-f          : toggle the use of filtered equivalences [default = %s]\n", fSkipSome? "yes": "no" );
-    Abc_Print( -2, "\t-v          : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h          : print the command usage\n");
-    Abc_Print( -2, "\t<miter.aig> : file with the external miter to read\n");
-    Abc_Print( -2, "\t              \n" );
-    Abc_Print( -2, "\t              The external miter should be generated by &srm -s\n" );
-    Abc_Print( -2, "\t              and (partially) solved by any verification engine(s).\n" );
-    Abc_Print( -2, "\t              The external miter should have as many POs as\n" );
-    Abc_Print( -2, "\t              the number of POs in the current AIG plus\n" );
-    Abc_Print( -2, "\t              the number of equivalences in the current AIG.\n" );
-    Abc_Print( -2, "\t              If some POs are proved, the corresponding equivs\n" );
-    Abc_Print( -2, "\t              are marked as proved, to be reduced by &reduce.\n" );
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9EquivFilter( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern void Gia_ManEquivFilter( Gia_Man_t * p, Vec_Int_t * vPoIds, int fVerbose );
-    int c, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9EquivFilter(): There is no AIG.\n" );
-        return 1;
-    }
-    Gia_ManEquivFilter( pAbc->pGia, pAbc->vAbcObjIds, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &equiv_filter [-vh]\n" );
-    Abc_Print( -2, "\t              filters equivalence candidates after disproving some SRM outputs\n" );
-    Abc_Print( -2, "\t              (the array of disproved outputs should be given as pAbc->vAbcObjIds)\n" );
-    Abc_Print( -2, "\t-v          : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h          : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Cec( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Cec_ParCec_t ParsCec, * pPars = &ParsCec;
-    FILE * pFile;
-    Gia_Man_t * pSecond, * pMiter;
-    char * FileName, * pTemp;
-    char ** pArgvNew;
-    int c, nArgcNew, fMiter = 0;
-    int fDumpMiter = 0;
-    Cec_ManCecSetDefaultParams( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "CTmdvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nBTLimit < 0 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->TimeLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->TimeLimit < 0 )
-                goto usage;
-            break;
-        case 'm':
-            fMiter ^= 1;
-            break;
-        case 'd':
-            fDumpMiter ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( fMiter )
-    {
-        if ( Gia_ManPoNum(pAbc->pGia) & 1 )
-        {
-            Abc_Print( -1, "The dual-output miter should have an even number of outputs.\n" );
-            return 1;
-        }
-        Abc_Print( 1, "Assuming the current network is a double-output miter. (Conflict limit = %d.)\n", pPars->nBTLimit );
-        pAbc->Status = Cec_ManVerify( pAbc->pGia, pPars );
-        Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexComb );
-        return 0;
-    }
-
-    pArgvNew = argv + globalUtilOptind;
-    nArgcNew = argc - globalUtilOptind;
-    if ( nArgcNew != 1 )
-    {
-        if ( pAbc->pGia->pSpec == NULL )
-        {
-            Abc_Print( -1, "File name is not given on the command line.\n" );
-            return 1;
-        }
-        FileName = pAbc->pGia->pSpec;
-    }
-    else
-        FileName = pArgvNew[0];
-    // fix the wrong symbol
-    for ( pTemp = FileName; *pTemp; pTemp++ )
-        if ( *pTemp == '>' )
-            *pTemp = '\\';
-    if ( (pFile = fopen( FileName, "r" )) == NULL )
-    {
-        Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
-        if ( (FileName = Extra_FileGetSimilarName( FileName, ".aig", NULL, NULL, NULL, NULL )) )
-            Abc_Print( 1, "Did you mean \"%s\"?", FileName );
-        Abc_Print( 1, "\n" );
-        return 1;
-    }
-    fclose( pFile );
-    pSecond = Gia_AigerRead( FileName, 0, 0 );
-    if ( pSecond == NULL )
-    {
-        Abc_Print( -1, "Reading AIGER has failed.\n" );
-        return 0;
-    }
-    // compute the miter
-    pMiter = Gia_ManMiter( pAbc->pGia, pSecond, 0, 1, 0, 0, pPars->fVerbose );
-    if ( pMiter )
-    {
-        if ( fDumpMiter )
-        {
-            Abc_Print( 0, "The verification miter is written into file \"%s\".\n", "cec_miter.aig" );
-            Gia_AigerWrite( pMiter, "cec_miter.aig", 0, 0 );
-        }
-        pAbc->Status = Cec_ManVerify( pMiter, pPars );
-        Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexComb );
-        Gia_ManStop( pMiter );
-    }
-    Gia_ManStop( pSecond );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &cec [-CT num] [-mdvh]\n" );
-    Abc_Print( -2, "\t         new combinational equivalence checker\n" );
-    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
-    Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", pPars->TimeLimit );
-    Abc_Print( -2, "\t-m     : toggle miter vs. two circuits [default = %s]\n", fMiter? "miter":"two circuits");
-    Abc_Print( -2, "\t-d     : toggle dumping dual-output miter [default = %s]\n", fDumpMiter? "yes":"no");
-    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes":"no");
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Verify( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Cec_ParCec_t ParsCec, * pPars = &ParsCec;
-    int c;
-    Cec_ManCecSetDefaultParams( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "CTvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nBTLimit < 0 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->TimeLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->TimeLimit < 0 )
-                goto usage;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    Gia_ManVerifyWithBoxes( pAbc->pGia, pPars );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &verify [-CT num] [-vh]\n" );
-    Abc_Print( -2, "\t         performs verification of combinational design\n" );
-    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
-    Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", pPars->TimeLimit );
-    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes":"no");
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Sweep( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pTemp;
-    Dch_Pars_t Pars, * pPars = &Pars;
-    int c;
-    // set defaults
-    Dch_ManSetDefaultParams( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "WCSsptfvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nWords = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nWords < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nBTLimit < 0 )
-                goto usage;
-            break;
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nSatVarMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nSatVarMax < 0 )
-                goto usage;
-            break;
-        case 's':
-            pPars->fSynthesis ^= 1;
-            break;
-        case 'p':
-            pPars->fPower ^= 1;
-            break;
-        case 't':
-            pPars->fSimulateTfo ^= 1;
-            break;
-        case 'f':
-            pPars->fLightSynth ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Sweep(): There is no AIG.\n" );
-        return 1;
-    }
-    pTemp = Gia_ManFraigSweep( pAbc->pGia, pPars );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &sweep [-WCS num] [-sptfvh]\n" );
-    Abc_Print( -2, "\t         computes structural choices using a new approach\n" );
-    Abc_Print( -2, "\t-W num : the max number of simulation words [default = %d]\n", pPars->nWords );
-    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
-    Abc_Print( -2, "\t-S num : the max number of SAT variables [default = %d]\n", pPars->nSatVarMax );
-    Abc_Print( -2, "\t-s     : toggle synthesizing three snapshots [default = %s]\n", pPars->fSynthesis? "yes": "no" );
-    Abc_Print( -2, "\t-p     : toggle power-aware rewriting [default = %s]\n", pPars->fPower? "yes": "no" );
-    Abc_Print( -2, "\t-t     : toggle simulation of the TFO classes [default = %s]\n", pPars->fSimulateTfo? "yes": "no" );
-    Abc_Print( -2, "\t-f     : toggle using lighter logic synthesis [default = %s]\n", pPars->fLightSynth? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Force( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    int nIters     = 20;
-    int fClustered =  1;
-    int fVerbose   =  1;
-    int c;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Icvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'I':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nIters = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nIters < 0 )
-                goto usage;
-            break;
-        case 'c':
-            fClustered ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Force(): There is no AIG.\n" );
-        return 1;
-    }
-    For_ManExperiment( pAbc->pGia, nIters, fClustered, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &force [-I <num>] [-cvh]\n" );
-    Abc_Print( -2, "\t         one-dimensional placement algorithm FORCE introduced by\n" );
-    Abc_Print( -2, "\t         F. A. Aloul, I. L. Markov, and K. A. Sakallah (GLSVLSI�03).\n" );
-    Abc_Print( -2, "\t-I num : the number of refinement iterations [default = %d]\n", nIters );
-    Abc_Print( -2, "\t-c     : toggle clustered representation [default = %s]\n", fClustered? "yes":"no");
-    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes":"no");
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Embed( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Emb_Par_t Pars, * pPars = &Pars;
-    int c;
-    pPars->nDims      = 30;
-    pPars->nIters     = 10;
-    pPars->nSols      =  2;
-    pPars->fRefine    =  0;
-    pPars->fCluster   =  0;
-    pPars->fDump      =  0;
-    pPars->fDumpLarge =  0;
-    pPars->fShowImage =  0;
-    pPars->fVerbose   =  0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "DIrcdlsvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nDims = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nDims < 0 )
-                goto usage;
-            break;
-        case 'I':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nIters = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nIters < 0 )
-                goto usage;
-            break;
-        case 'r':
-            pPars->fRefine ^= 1;
-            break;
-        case 'c':
-            pPars->fCluster ^= 1;
-            break;
-        case 'd':
-            pPars->fDump ^= 1;
-            break;
-        case 'l':
-            pPars->fDumpLarge ^= 1;
-            break;
-        case 's':
-            pPars->fShowImage ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Embed(): There is no AIG.\n" );
-        return 1;
-    }
-    Gia_ManSolveProblem( pAbc->pGia, pPars );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &embed [-DI <num>] [-rdlscvh]\n" );
-    Abc_Print( -2, "\t         fast placement based on high-dimensional embedding from\n" );
-    Abc_Print( -2, "\t         D. Harel and Y. Koren, \"Graph drawing by high-dimensional\n" );
-    Abc_Print( -2, "\t         embedding\", J. Graph Algs & Apps, 2004, Vol 8(2), pp. 195-217\n" );
-    Abc_Print( -2, "\t-D num : the number of dimensions for embedding [default = %d]\n", pPars->nDims );
-    Abc_Print( -2, "\t-I num : the number of refinement iterations [default = %d]\n", pPars->nIters );
-    Abc_Print( -2, "\t-r     : toggle the use of refinement [default = %s]\n", pPars->fRefine? "yes":"no");
-    Abc_Print( -2, "\t-c     : toggle clustered representation [default = %s]\n", pPars->fCluster? "yes":"no");
-    Abc_Print( -2, "\t-d     : toggle dumping placement into a Gnuplot file [default = %s]\n", pPars->fDump? "yes":"no");
-    Abc_Print( -2, "\t-l     : toggle dumping Gnuplot for large placement [default = %s]\n", pPars->fDumpLarge? "yes":"no");
-    Abc_Print( -2, "\t-s     : toggle showing image if Gnuplot is installed [default = %s]\n", pPars->fShowImage? "yes":"no");
-    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes":"no");
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Sopb( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pTemp;
-    int nLevelMax   = 0;
-    int nTimeWindow = 0;
-    int nCutNum     = 8;
-    int nRelaxRatio = 0;
-    int c, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "LWCRvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nLevelMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nLevelMax < 0 )
-                goto usage;
-            break;
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nTimeWindow = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nTimeWindow < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nCutNum = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nCutNum < 0 )
-                goto usage;
-            break;
-        case 'R':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nRelaxRatio = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nRelaxRatio < 0 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Sopb(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( nLevelMax || nTimeWindow )
-        pTemp = Gia_ManPerformSopBalanceWin( pAbc->pGia, nLevelMax, nTimeWindow, nCutNum, nRelaxRatio, fVerbose );
-    else
-        pTemp = Gia_ManPerformSopBalance( pAbc->pGia, nCutNum, nRelaxRatio, fVerbose );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &sopb [-LWCR num] [-vh]\n" );
-    Abc_Print( -2, "\t         performs SOP balancing\n" );
-    Abc_Print( -2, "\t-L num : optimize paths above this level [default = %d]\n", nLevelMax );
-    Abc_Print( -2, "\t-W num : optimize paths falling into this window [default = %d]\n", nTimeWindow );
-    Abc_Print( -2, "\t-C num : the number of cuts at a node [default = %d]\n", nCutNum );
-    Abc_Print( -2, "\t-R num : the delay relaxation ratio (num >= 0) [default = %d]\n", nRelaxRatio );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Dsdb( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pTemp;
-    int nLevelMax   = 0;
-    int nTimeWindow = 0;
-    int nLutSize    = 6;
-    int nCutNum     = 8;
-    int nRelaxRatio = 0;
-    int c, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "LWKCRvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nLevelMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nLevelMax < 0 )
-                goto usage;
-            break;
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nTimeWindow = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nTimeWindow < 0 )
-                goto usage;
-            break;
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nLutSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nLutSize < 0 )
-                goto usage;
-            break;
-         case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nCutNum = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nCutNum < 0 )
-                goto usage;
-            break;
-        case 'R':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nRelaxRatio = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nRelaxRatio < 0 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Dsdb(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( nLevelMax || nTimeWindow )
-        pTemp = Gia_ManPerformDsdBalanceWin( pAbc->pGia, nLevelMax, nTimeWindow, nLutSize, nCutNum, nRelaxRatio, fVerbose );
-    else
-        pTemp = Gia_ManPerformDsdBalance( pAbc->pGia, nLutSize, nCutNum, nRelaxRatio, fVerbose );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &dsdb [-LWKCR num] [-vh]\n" );
-    Abc_Print( -2, "\t         performs DSD balancing\n" );
-    Abc_Print( -2, "\t-L num : optimize paths above this level [default = %d]\n", nLevelMax );
-    Abc_Print( -2, "\t-W num : optimize paths falling into this window [default = %d]\n", nTimeWindow );
-    Abc_Print( -2, "\t-K num : the number of LUT inputs (LUT size) [default = %d]\n", nLutSize );
-    Abc_Print( -2, "\t-C num : the number of cuts at a node [default = %d]\n", nCutNum );
-    Abc_Print( -2, "\t-R num : the delay relaxation ratio (num >= 0) [default = %d]\n", nRelaxRatio );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Flow( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-	extern void Gia_ManPerformFlow( int fIsMapped, int nAnds, int nLevels, int nLutSize, int nCutNum, int nRelaxRatio, int fVerbose );
-//    Gia_Man_t * pTemp;
-    int nLutSize    = 4;
-    int nCutNum     = 8;
-    int nRelaxRatio = 0;
-    int c, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "KCRvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nLutSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nLutSize < 0 )
-                goto usage;
-            break;
-         case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nCutNum = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nCutNum < 0 )
-                goto usage;
-            break;
-        case 'R':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nRelaxRatio = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nRelaxRatio < 0 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Flow(): There is no AIG.\n" );
-        return 1;
-    }
-	Gia_ManPerformFlow( Gia_ManHasMapping(pAbc->pGia), Gia_ManAndNum(pAbc->pGia), Gia_ManLevelNum(pAbc->pGia), nLutSize, nCutNum, nRelaxRatio, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &flow [-KCR num] [-vh]\n" );
-    Abc_Print( -2, "\t         integration optimization and mapping flow\n" );
-    Abc_Print( -2, "\t-K num : the number of LUT inputs (LUT size) [default = %d]\n", nLutSize );
-    Abc_Print( -2, "\t-C num : the number of cuts at a node [default = %d]\n", nCutNum );
-    Abc_Print( -2, "\t-R num : the delay relaxation ratio (num >= 0) [default = %d]\n", nRelaxRatio );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9If( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    char Buffer[200];
-    char LutSize[200];
-    Gia_Man_t * pNew;
-    If_Par_t Pars, * pPars = &Pars;
-    int c;
-    // set defaults
-    Gia_ManSetIfParsDefault( pPars );
-    if ( pAbc->pLibLut == NULL )
-    {
-        Abc_Print( -1, "LUT library is not given. Using default LUT library.\n" );
-        pAbc->pLibLut = If_LibLutSetSimple( 6 );
-    }
-    pPars->pLutLib = (If_LibLut_t *)pAbc->pLibLut;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "KCFAGRDEWSTqalepmrsdbgxyojikfuztncvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nLutSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nLutSize < 0 )
-                goto usage;
-            // if the LUT size is specified, disable library
-            pPars->pLutLib = NULL;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nCutsMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nCutsMax < 0 )
-                goto usage;
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nFlowIters = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nFlowIters < 0 )
-                goto usage;
-            break;
-        case 'A':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-A\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nAreaIters = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nAreaIters < 0 )
-                goto usage;
-            break;
-        case 'G':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-G\" should be followed by a positive integer no less than 3.\n" );
-                goto usage;
-            }
-            pPars->nGateSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nGateSize < 2 )
-                goto usage;
-            break;
-		case 'R':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( 1, "Command line switch \"-R\" should be followed by a floating point number.\n" );
-                return 0;
-            }
-			pPars->nRelaxRatio = atoi(argv[globalUtilOptind]);
-			globalUtilOptind++;
-			if ( pPars->nRelaxRatio < 0 ) 
-				goto usage;
-            break;
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
-                goto usage;
-            }
-            pPars->DelayTarget = (float)atof(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->DelayTarget <= 0.0 )
-                goto usage;
-            break;
-        case 'E':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-E\" should be followed by a floating point number.\n" );
-                goto usage;
-            }
-            pPars->Epsilon = (float)atof(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->Epsilon < 0.0 || pPars->Epsilon > 1.0 )
-                goto usage;
-            break;
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by a floating point number.\n" );
-                goto usage;
-            }
-            pPars->WireDelay = (float)atof(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->WireDelay < 0.0 )
-                goto usage;
-            break;
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by string.\n" );
-                goto usage;
-            }
-            pPars->pLutStruct = argv[globalUtilOptind];
-            globalUtilOptind++;
-            if ( strlen(pPars->pLutStruct) != 2 && strlen(pPars->pLutStruct) != 3 )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by a 2- or 3-char string (e.g. \"44\" or \"555\").\n" );
-                goto usage;
-            }
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by a positive integer 0,1,or 2.\n" );
-                goto usage;
-            }
-            pPars->nStructType = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nStructType < 0 || pPars->nStructType > 2 )
-                goto usage;
-            break;
-        case 'q':
-            pPars->fPreprocess ^= 1;
-            break;
-        case 'a':
-            pPars->fArea ^= 1;
-            break;
-        case 'r':
-            pPars->fExpRed ^= 1;
-            break;
-        case 'l':
-            pPars->fLatchPaths ^= 1;
-            break;
-        case 'e':
-            pPars->fEdge ^= 1;
-            break;
-        case 'p':
-            pPars->fPower ^= 1;
-            break;
-        case 'm':
-            pPars->fCutMin ^= 1;
-            break;
-        case 's':
-            pPars->fDelayOptLut ^= 1;
-            break;
-        case 'd':
-            pPars->fBidec ^= 1;
-            break;
-        case 'b':
-            pPars->fUseBat ^= 1;
-            break;
-        case 'g':
-            pPars->fDelayOpt ^= 1;
-            break;
-        case 'x':
-            pPars->fDsdBalance ^= 1;
-            break;
-        case 'y':
-            pPars->fUserRecLib ^= 1;
-            break;
-        case 'o':
-            pPars->fUseBuffs ^= 1;
-            break;
-        case 'j':
-            pPars->fEnableCheck07 ^= 1;
-            break;
-        case 'i':
-            pPars->fEnableCheck08 ^= 1;
-            break;
-        case 'k':
-            pPars->fEnableCheck10 ^= 1;
-            break;
-        case 'f':
-            pPars->fEnableCheck75 ^= 1;
-            break;
-        case 'u':
-            pPars->fEnableCheck75u ^= 1;
-            break;
-        case 'z':
-            pPars->fDeriveLuts ^= 1;
-            break;
-        case 't':
-            pPars->fDoAverage ^= 1;
-            break;
-        case 'n':
-            pPars->fUseDsd ^= 1;
-            break;
-        case 'c':
-            pPars->fUseTtPerm ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'h':
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Empty GIA network.\n" );
-        return 1;
-    }
-    if ( Gia_ManHasMapping(pAbc->pGia) )
-    {
-        Abc_Print( -1, "Current AIG has mapping. Run \"&st\".\n" );
-        return 1;
-    }
-
-    if ( pPars->nLutSize == -1 )
-    {
-        if ( pPars->pLutLib == NULL )
-        {
-            Abc_Print( -1, "The LUT library is not given.\n" );
-            return 1;
-        }
-        // get LUT size from the library
-        pPars->nLutSize = pPars->pLutLib->LutMax;
-        // if variable pin delay, force truth table computation
-//        if ( pPars->pLutLib->fVarPinDelays )
-//            pPars->fTruth = 1;
-    }
-
-    if ( pPars->nLutSize < 2 || pPars->nLutSize > IF_MAX_LUTSIZE )
-    {
-        Abc_Print( -1, "Incorrect LUT size (%d).\n", pPars->nLutSize );
-        return 1;
-    }
-
-    if ( pPars->nCutsMax < 1 || pPars->nCutsMax >= (1<<12) )
-    {
-        Abc_Print( -1, "Incorrect number of cuts.\n" );
-        return 1;
-    }
-
-    // enable truth table computation if choices are selected
-    if ( Gia_ManHasChoices(pAbc->pGia) )
-    {
-//        if ( !Abc_FrameReadFlag("silentmode") )
-//            Abc_Print( 0, "Performing LUT mapping with choices.\n" );
-        pPars->fExpRed = 0;
-    }
-
-    if ( pPars->fUseBat )
-    {
-        if ( pPars->nLutSize < 4 || pPars->nLutSize > 6 )
-        {
-            Abc_Print( -1, "This feature only works for {4,5,6}-LUTs.\n" );
-            return 1;
-        }
-        pPars->fCutMin = 1;
-    }
-
-    if ( pPars->fEnableCheck07 + pPars->fEnableCheck08 + pPars->fEnableCheck10 + pPars->fEnableCheck75 + pPars->fEnableCheck75u + (pPars->pLutStruct != NULL) > 1 )
-    {
-        Abc_Print( -1, "Only one additional check can be performed at the same time.\n" );
-        return 1;
-    }
-    if ( pPars->fEnableCheck07 )
-    {
-        if ( pPars->nLutSize < 6 || pPars->nLutSize > 7 )
-        {
-            Abc_Print( -1, "This feature only works for {6,7}-LUTs.\n" );
-            return 1;
-        }
-        pPars->pFuncCell = If_CutPerformCheck07;
-        pPars->fCutMin = 1;
-    }
-    if ( pPars->fEnableCheck08 )
-    {
-        if ( pPars->nLutSize < 6 || pPars->nLutSize > 8 )
-        {
-            Abc_Print( -1, "This feature only works for {6,7,8}-LUTs.\n" );
-            return 1;
-        }
-        pPars->pFuncCell = If_CutPerformCheck08;
-        pPars->fCutMin = 1;
-    }
-    if ( pPars->fEnableCheck10 )
-    {
-        if ( pPars->nLutSize < 6 || pPars->nLutSize > 10 )
-        {
-            Abc_Print( -1, "This feature only works for {6,7,8,9,10}-LUTs.\n" );
-            return 1;
-        }
-        pPars->pFuncCell = If_CutPerformCheck10;
-        pPars->fCutMin = 1;
-    }
-    if ( pPars->fEnableCheck75 || pPars->fEnableCheck75u )
-    {
-        if ( pPars->fEnableCheck75 && pPars->fEnableCheck75u )
-        {
-            Abc_Print( -1, "Switches -f and -u are not compatible.\n" );
-            return 1;
-        }
-        if ( pPars->nLutSize < 5 || pPars->nLutSize > 8 )
-        {
-            Abc_Print( -1, "This feature only works for {6,7,8}-LUTs.\n" );
-            return 1;
-        }
-        pPars->pFuncCell = If_CutPerformCheck75;
-        pPars->fCutMin = 1;
-    }
-    if ( pPars->pLutStruct )
-    {
-        if ( pPars->fDsdBalance )
-        {
-            Abc_Print( -1, "Incompatible options (-S and -x).\n" );
-            return 1;
-        }
-        if ( pPars->nLutSize < 6 || pPars->nLutSize > 16 )
-        {
-            Abc_Print( -1, "This feature only works for [6;16]-LUTs.\n" );
-            return 1;
-        }
-        pPars->pFuncCell = pPars->fDelayOptLut ? NULL : If_CutPerformCheck16;
-        pPars->fCutMin = 1;
-    }
-
-    // enable truth table computation if cut minimization is selected
-    if ( pPars->fCutMin || pPars->fDeriveLuts )
-    {
-        pPars->fTruth = 1;
-        pPars->fExpRed = 0;
-        if ( pPars->pLutStruct == NULL )
-            pPars->fDeriveLuts = 1;
-    }
-    // modify the subgraph recording
-    if ( pPars->fUserRecLib )
-    {
-        pPars->fTruth      =  1;
-        pPars->fCutMin     =  1;
-        pPars->fExpRed     =  0;
-        pPars->fUsePerm    =  1;
-        pPars->pLutLib     =  NULL;
-    }
-    // modify for delay optimization
-    if ( pPars->fDelayOpt || pPars->fDsdBalance || pPars->fDelayOptLut )
-    {
-        pPars->fTruth      =  1;
-        pPars->fCutMin     =  1;
-        pPars->fExpRed     =  0;
-        pPars->fUseDsd     =  pPars->fDsdBalance || pPars->fDelayOptLut;
-        pPars->pLutLib     =  NULL;
-    }
-    // modify for delay optimization
-    if ( pPars->nGateSize > 0 )
-    {
-        pPars->fTruth      =  1;
-        pPars->fCutMin     =  1;
-        pPars->fExpRed     =  0;
-        pPars->fUsePerm    =  1;
-        pPars->pLutLib     =  NULL;
-        pPars->nLutSize    =  pPars->nGateSize;
-    }
-
-    if ( pPars->fUseDsd || pPars->fUseTtPerm )
-    {
-        pPars->fTruth      =  1;
-        pPars->fCutMin     =  1;
-        pPars->fExpRed     =  0;
-    }
-
-    if ( pPars->fUseDsd )
-    {
-        int LutSize = (pPars->pLutStruct && pPars->pLutStruct[2] == 0)? pPars->pLutStruct[0] - '0' : 0;
-        If_DsdMan_t * p = (If_DsdMan_t *)Abc_FrameReadManDsd();
-        if ( pPars->pLutStruct && pPars->pLutStruct[2] != 0 )
-        {
-            printf( "DSD only works for LUT structures XY.\n" );
-            return 0;
-        }
-        if ( p && pPars->nLutSize > If_DsdManVarNum(p) )
-        {
-            printf( "DSD manager has incompatible number of variables.\n" );
-            return 0;
-        }
-        if ( p && LutSize != If_DsdManLutSize(p) && !pPars->fDsdBalance )
-        {
-            printf( "DSD manager has different LUT size.\n" );
-            return 0;
-        }
-        if ( p == NULL )
-            Abc_FrameSetManDsd( If_DsdManAlloc(pPars->nLutSize, LutSize) );
-    }
-
-    if ( pPars->fUserRecLib )
-    {
-        if ( !Abc_NtkRecIsRunning3() )
-        {
-            printf( "LMS manager is not running (use \"rec_start3\").\n" );
-            return 0;
-        }
-        if ( Abc_NtkRecInputNum3() != pPars->nLutSize )
-        {
-            printf( "The number of library inputs (%d) different from the K parameters (%d).\n", Abc_NtkRecInputNum3(), pPars->nLutSize );
-            return 0;
-        }
-    }
-
-    // complain if truth tables are requested but the cut size is too large
-    if ( pPars->fTruth && pPars->nLutSize > IF_MAX_FUNC_LUTSIZE )
-    {
-        Abc_Print( -1, "Truth tables cannot be computed for LUT larger than %d inputs.\n", IF_MAX_FUNC_LUTSIZE );
-        return 1;
-    }
-    if ( pAbc->pGia->pManTime && pAbc->pLibBox == NULL )
-    {
-        Abc_Print( -1, "Design has boxes but box library is not entered.\n" );
-        return 1;
-    }
-
-    // perform mapping
-    pNew = Gia_ManPerformMapping( pAbc->pGia, pPars );
-    if ( pNew == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9If(): Mapping of GIA has failed.\n" );
-        return 1;
-    }
-    Abc_FrameUpdateGia( pAbc, pNew );
-    return 0;
-
-usage:
-    if ( pPars->DelayTarget == -1 )
-        sprintf(Buffer, "best possible" );
-    else
-        sprintf(Buffer, "%.2f", pPars->DelayTarget );
-    if ( pPars->nLutSize == -1 )
-        sprintf(LutSize, "library" );
-    else
-        sprintf(LutSize, "%d", pPars->nLutSize );
-    Abc_Print( -2, "usage: &if [-KCFAGRT num] [-DEW float] [-S str] [-qarlepmsdbgxyojikfuztncvh]\n" );
-    Abc_Print( -2, "\t           performs FPGA technology mapping of the network\n" );
-    Abc_Print( -2, "\t-K num   : the number of LUT inputs (2 < num < %d) [default = %s]\n", IF_MAX_LUTSIZE+1, LutSize );
-    Abc_Print( -2, "\t-C num   : the max number of priority cuts (0 < num < 2^12) [default = %d]\n", pPars->nCutsMax );
-    Abc_Print( -2, "\t-F num   : the number of area flow recovery iterations (num >= 0) [default = %d]\n", pPars->nFlowIters );
-    Abc_Print( -2, "\t-A num   : the number of exact area recovery iterations (num >= 0) [default = %d]\n", pPars->nAreaIters );
-    Abc_Print( -2, "\t-G num   : the max AND/OR gate size for mapping (0 = unused) [default = %d]\n", pPars->nGateSize );
-    Abc_Print( -2, "\t-R num   : the delay relaxation ratio (num >= 0) [default = %d]\n", pPars->nRelaxRatio );
-    Abc_Print( -2, "\t-D float : sets the delay constraint for the mapping [default = %s]\n", Buffer );
-    Abc_Print( -2, "\t-E float : sets epsilon used for tie-breaking [default = %f]\n", pPars->Epsilon );
-    Abc_Print( -2, "\t-W float : sets wire delay between adjects LUTs [default = %f]\n", pPars->WireDelay );
-    Abc_Print( -2, "\t-S str   : string representing the LUT structure [default = %s]\n", pPars->pLutStruct ? pPars->pLutStruct : "not used" );
-    Abc_Print( -2, "\t-T num   : the type of LUT structures [default = any]\n", pPars->nStructType );
-    Abc_Print( -2, "\t-q       : toggles preprocessing using several starting points [default = %s]\n", pPars->fPreprocess? "yes": "no" );
-    Abc_Print( -2, "\t-a       : toggles area-oriented mapping [default = %s]\n", pPars->fArea? "yes": "no" );
-    Abc_Print( -2, "\t-r       : enables expansion/reduction of the best cuts [default = %s]\n", pPars->fExpRed? "yes": "no" );
-    Abc_Print( -2, "\t-l       : optimizes latch paths for delay, other paths for area [default = %s]\n", pPars->fLatchPaths? "yes": "no" );
-    Abc_Print( -2, "\t-e       : uses edge-based cut selection heuristics [default = %s]\n", pPars->fEdge? "yes": "no" );
-    Abc_Print( -2, "\t-p       : uses power-aware cut selection heuristics [default = %s]\n", pPars->fPower? "yes": "no" );
-    Abc_Print( -2, "\t-m       : enables cut minimization by removing vacuous variables [default = %s]\n", pPars->fCutMin? "yes": "no" );
-    Abc_Print( -2, "\t-s       : toggles delay-oriented mapping used with -S <NN> [default = %s]\n", pPars->fDelayOptLut? "yes": "no" );
-    Abc_Print( -2, "\t-d       : toggles deriving local AIGs using bi-decomposition [default = %s]\n", pPars->fBidec? "yes": "no" );
-    Abc_Print( -2, "\t-b       : toggles the use of one special feature [default = %s]\n", pPars->fUseBat? "yes": "no" );
-    Abc_Print( -2, "\t-g       : toggles delay optimization by SOP balancing [default = %s]\n", pPars->fDelayOpt? "yes": "no" );
-    Abc_Print( -2, "\t-x       : toggles delay optimization by DSD balancing [default = %s]\n", pPars->fDsdBalance? "yes": "no" );
-    Abc_Print( -2, "\t-y       : toggles delay optimization with recorded library [default = %s]\n", pPars->fUserRecLib? "yes": "no" );
-    Abc_Print( -2, "\t-o       : toggles using buffers to decouple combinational outputs [default = %s]\n", pPars->fUseBuffs? "yes": "no" );
-    Abc_Print( -2, "\t-j       : toggles enabling additional check [default = %s]\n", pPars->fEnableCheck07? "yes": "no" );
-    Abc_Print( -2, "\t-i       : toggles enabling additional check [default = %s]\n", pPars->fEnableCheck08? "yes": "no" );
-    Abc_Print( -2, "\t-k       : toggles enabling additional check [default = %s]\n", pPars->fEnableCheck10? "yes": "no" );
-    Abc_Print( -2, "\t-f       : toggles enabling additional check [default = %s]\n", pPars->fEnableCheck75? "yes": "no" );
-    Abc_Print( -2, "\t-u       : toggles enabling additional check [default = %s]\n", pPars->fEnableCheck75u? "yes": "no" );
-    Abc_Print( -2, "\t-z       : toggles deriving LUTs when mapping into LUT structures [default = %s]\n", pPars->fDeriveLuts? "yes": "no" );
-    Abc_Print( -2, "\t-t       : toggles optimizing average rather than maximum level [default = %s]\n", pPars->fDoAverage? "yes": "no" );
-    Abc_Print( -2, "\t-n       : toggles computing DSDs of the cut functions [default = %s]\n", pPars->fUseDsd? "yes": "no" );
-    Abc_Print( -2, "\t-c       : toggles computing truth tables in a new way [default = %s]\n", pPars->fUseTtPerm? "yes": "no" );
-    Abc_Print( -2, "\t-v       : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : prints the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Iff( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern void Gia_ManIffTest( Gia_Man_t * pGia, If_LibLut_t * pLib, int fVerbose );
-    int c, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Iff(): There is no AIG to map.\n" );
-        return 1;
-    }
-    if ( !Gia_ManHasMapping(pAbc->pGia) )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Iff(): Mapping of the AIG is not defined.\n" );
-        return 1;
-    }
-    if ( pAbc->pLibLut == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Iff(): LUT library is not defined.\n" );
-        return 1;
-    }
-    Gia_ManIffTest( pAbc->pGia, (If_LibLut_t *)pAbc->pLibLut, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &iff [-vh]\n" );
-    Abc_Print( -2, "\t           performs structural mapping into LUT structures\n" );
-    Abc_Print( -2, "\t-v       : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9If2( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Abc_Ntk_t * Mpm_ManCellMapping( Gia_Man_t * p, Mpm_Par_t * pPars, void * pMio );
-    extern Gia_Man_t * Mpm_ManLutMapping( Gia_Man_t * p, Mpm_Par_t * pPars );
-    char Buffer[200];
-    Abc_Ntk_t * pTemp;
-    Gia_Man_t * pNew;
-    Mpm_Par_t Pars, * pPars = &Pars;
-    int c, nLutSize = 6;
-    // set defaults
-    Mpm_ManSetParsDefault( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "KCDtmzrcuxvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            nLutSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nLutSize < 2 || nLutSize > 16 )
-            {
-                Abc_Print( -1, "LUT size %d is not supported.\n", nLutSize );
-                goto usage;
-            }
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nNumCuts = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nNumCuts < 0 )
-                goto usage;
-            break;
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
-                goto usage;
-            }
-            pPars->DelayTarget = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->DelayTarget <= 0.0 )
-                goto usage;
-            break;
-        case 't':
-            pPars->fUseGates ^= 1;
-            break;
-        case 'm':
-            pPars->fCutMin ^= 1;
-            break;
-        case 'z':
-            pPars->fDeriveLuts ^= 1;
-            break;
-        case 'r':
-            pPars->fOneRound ^= 1;
-            break;
-        case 'c':
-            pPars->fMap4Cnf ^= 1;
-            break;
-        case 'u':
-            pPars->fMap4Aig ^= 1;
-            break;
-        case 'x':
-            pPars->fMap4Gates ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'w':
-            pPars->fVeryVerbose ^= 1;
-            break;
-        case 'h':
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Empty GIA network.\n" );
-        return 1;
-    }
-
-    if ( pPars->fMap4Cnf )
-        pPars->fUseDsd = 1;
-    if ( pPars->fCutMin )
-        pPars->fUseDsd = 1;
-//        pPars->fUseTruth = 1;
-    if ( pPars->fMap4Gates )
-    {
-        pPars->fUseDsd = 1;
-        if ( pAbc->pLibScl == NULL )
-        {
-            Abc_Print( -1, "There is no SCL library available.\n" );
-            return 1;
-        }
-        pPars->pScl = pAbc->pLibScl;
-    }
-    if ( pPars->fUseDsd || pPars->fUseTruth )
-        pPars->fDeriveLuts = 1;
-    if ( pPars->fUseDsd && nLutSize != 6 )
-    {
-        Abc_Print( -1, "Currently DSD can only be used with 6-input cuts.\n" );
-        return 1;
-    }
-    // perform mapping
-    assert( pPars->pLib == NULL );
-    if ( pPars->fMap4Gates )
-    {
-        if ( Abc_FrameReadLibGen() == NULL )
-        {
-            Abc_Print( -1, "There is no GENLIB library available.\n" );
-            return 1;
-        }
-        pPars->pLib = Mpm_LibLutSetSimple( nLutSize );
-        pTemp = Mpm_ManCellMapping( pAbc->pGia, pPars, Abc_FrameReadLibGen() );
-        Mpm_LibLutFree( pPars->pLib );
-        if ( pTemp == NULL )
-        {
-            Abc_Print( -1, "Abc_CommandAbc9If2(): Mapping into standard cells has failed.\n" );
-            return 1;
-        }
-        Abc_FrameReplaceCurrentNetwork( pAbc, pTemp );
-    }
-    else
-    {
-        pPars->pLib = Mpm_LibLutSetSimple( nLutSize );
-        pNew = Mpm_ManLutMapping( pAbc->pGia, pPars );
-        Mpm_LibLutFree( pPars->pLib );
-        if ( pNew == NULL )
-        {
-            Abc_Print( -1, "Abc_CommandAbc9If2(): Mapping into LUTs has failed.\n" );
-            return 1;
-        }
-        Abc_FrameUpdateGia( pAbc, pNew );
-    }
-    return 0;
-
-usage:
-    if ( pPars->DelayTarget == -1 )
-        sprintf(Buffer, "best possible" );
-    else
-        sprintf(Buffer, "%d", pPars->DelayTarget );
-    Abc_Print( -2, "usage: &if2 [-KCD num] [-tmzrcuxvwh]\n" );
-    Abc_Print( -2, "\t           performs technology mapping of the network\n" );
-    Abc_Print( -2, "\t-K num   : sets the LUT size for the mapping [default = %d]\n", nLutSize );
-    Abc_Print( -2, "\t-C num   : the max number of priority cuts (0 < num < 2^12) [default = %d]\n", pPars->nNumCuts );
-    Abc_Print( -2, "\t-D num   : sets the delay constraint for the mapping [default = %s]\n", Buffer );
-    Abc_Print( -2, "\t-t       : enables using AND/XOR/MUX nodes instead of simple AIG [default = %s]\n", pPars->fUseGates? "yes": "no" );
-    Abc_Print( -2, "\t-m       : enables cut minimization by removing vacuous variables [default = %s]\n", pPars->fCutMin? "yes": "no" );
-    Abc_Print( -2, "\t-z       : toggles deriving LUTs when mapping into LUT structures [default = %s]\n", pPars->fDeriveLuts? "yes": "no" );
-    Abc_Print( -2, "\t-r       : toggles using one round of mapping [default = %s]\n", pPars->fOneRound? "yes": "no" );
-    Abc_Print( -2, "\t-c       : toggles mapping for CNF computation [default = %s]\n", pPars->fMap4Cnf? "yes": "no" );
-    Abc_Print( -2, "\t-u       : toggles mapping for AIG computation [default = %s]\n", pPars->fMap4Aig? "yes": "no" );
-    Abc_Print( -2, "\t-x       : toggles mapping for standard cells [default = %s]\n", pPars->fMap4Gates? "yes": "no" );
-    Abc_Print( -2, "\t-v       : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w       : toggles very verbose output [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : prints the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Jf( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    char Buffer[200];
-    Jf_Par_t Pars, * pPars = &Pars;
-    Gia_Man_t * pNew; int c;
-    Jf_ManSetDefaultPars( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "KCDWaekmdcgvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nLutSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nLutSize < 2 || pPars->nLutSize > pPars->nLutSizeMax )
-            {
-                Abc_Print( -1, "LUT size %d is not supported.\n", pPars->nLutSize );
-                goto usage;
-            }
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nCutNum = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nCutNum < 1 || pPars->nCutNum > pPars->nCutNumMax )
-            {
-                Abc_Print( -1, "This number of cuts (%d) is not supported.\n", pPars->nCutNum );
-                goto usage;
-            }
-            break;
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
-                goto usage;
-            }
-            pPars->DelayTarget = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->DelayTarget <= 0.0 )
-                goto usage;
-            break;
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nVerbLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nVerbLimit < 0 )
-                goto usage;
-            break;
-        case 'a':
-            pPars->fAreaOnly ^= 1;
-            break;
-        case 'e':
-            pPars->fOptEdge ^= 1;
-            break;
-        case 'k':
-            pPars->fCoarsen ^= 1;
-            break;
-        case 'm':
-            pPars->fCutMin ^= 1;
-            break;
-        case 'd':
-            pPars->fFuncDsd ^= 1;
-            break;
-        case 'c':
-            pPars->fGenCnf ^= 1;
-            break;
-        case 'g':
-            pPars->fPureAig ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'w':
-            pPars->fVeryVerbose ^= 1;
-            break;
-        case 'h':
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Empty GIA network.\n" );
-        return 1;
-    }
-
-    if ( (pPars->fFuncDsd || pPars->fGenCnf) && pPars->nLutSize > 6 )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Jf(): DSD computation works for LUT6 or less.\n" );
-        return 1;
-    }
-
-    if ( (pPars->fFuncDsd || pPars->fGenCnf) && !Sdm_ManCanRead() )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Jf(): Cannot input DSD data from file.\n" );
-        return 1;
-    }
-
-    pNew = Jf_ManPerformMapping( pAbc->pGia, pPars );
-    if ( pNew == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Jf(): Mapping into LUTs has failed.\n" );
-        return 1;
-    }
-    Abc_FrameUpdateGia( pAbc, pNew );
-    return 0;
-
-usage:
-    if ( pPars->DelayTarget == -1 )
-        sprintf(Buffer, "best possible" );
-    else
-        sprintf(Buffer, "%d", pPars->DelayTarget );
-    Abc_Print( -2, "usage: &jf [-KCDW num] [-akmdcgvwh]\n" );
-    Abc_Print( -2, "\t           performs technology mapping of the network\n" );
-    Abc_Print( -2, "\t-K num   : LUT size for the mapping (2 <= K <= %d) [default = %d]\n", pPars->nLutSizeMax, pPars->nLutSize );
-    Abc_Print( -2, "\t-C num   : the max number of priority cuts (1 <= C <= %d) [default = %d]\n", pPars->nCutNumMax, pPars->nCutNum );
-    Abc_Print( -2, "\t-D num   : sets the delay constraint for the mapping [default = %s]\n", Buffer );
-    Abc_Print( -2, "\t-W num   : min frequency when printing functions with \"-w\" [default = %d]\n", pPars->nVerbLimit );
-    Abc_Print( -2, "\t-a       : toggles area-oriented mapping [default = %s]\n", pPars->fAreaOnly? "yes": "no" );
-    Abc_Print( -2, "\t-e       : toggles edge vs node minimization [default = %s]\n", pPars->fOptEdge? "yes": "no" );
-    Abc_Print( -2, "\t-k       : toggles coarsening the subject graph [default = %s]\n", pPars->fCoarsen? "yes": "no" );
-    Abc_Print( -2, "\t-m       : toggles cut minimization [default = %s]\n", pPars->fCutMin? "yes": "no" );
-    Abc_Print( -2, "\t-d       : toggles using DSD to represent cut functions [default = %s]\n", pPars->fFuncDsd? "yes": "no" );
-    Abc_Print( -2, "\t-c       : toggles mapping for CNF generation [default = %s]\n", pPars->fGenCnf? "yes": "no" );
-    Abc_Print( -2, "\t-g       : toggles generating AIG without mapping [default = %s]\n", pPars->fPureAig? "yes": "no" );
-    Abc_Print( -2, "\t-v       : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w       : toggles very verbose output [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : prints the command usage\n");
-    return 1;
-}
-
-#ifdef ABC_USE_PTHREADS
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Kf( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern void Kf_ManSetDefaultPars( Jf_Par_t * pPars );
-    extern Gia_Man_t * Kf_ManPerformMapping( Gia_Man_t * pGia, Jf_Par_t * pPars );
-    char Buffer[200];
-    Jf_Par_t Pars, * pPars = &Pars;
-    Gia_Man_t * pNew; int c;
-    Kf_ManSetDefaultPars( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "KCPDWaekmdcgtsvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nLutSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nLutSize < 2 || pPars->nLutSize > pPars->nLutSizeMax )
-            {
-                Abc_Print( -1, "LUT size %d is not supported.\n", pPars->nLutSize );
-                goto usage;
-            }
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nCutNum = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nCutNum < 1 || pPars->nCutNum > pPars->nCutNumMax )
-            {
-                Abc_Print( -1, "This number of cuts (%d) is not supported.\n", pPars->nCutNum );
-                goto usage;
-            }
-            break;
-        case 'P':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-P\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nProcNum = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nProcNum < 0 )
-                goto usage;
-            break;
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
-                goto usage;
-            }
-            pPars->DelayTarget = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->DelayTarget <= 0.0 )
-                goto usage;
-            break;
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nVerbLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nVerbLimit < 0 )
-                goto usage;
-            break;
-        case 'a':
-            pPars->fAreaOnly ^= 1;
-            break;
-        case 'e':
-            pPars->fOptEdge ^= 1;
-            break;
-        case 'k':
-            pPars->fCoarsen ^= 1;
-            break;
-        case 'm':
-            pPars->fCutMin ^= 1;
-            break;
-        case 'd':
-            pPars->fFuncDsd ^= 1;
-            break;
-        case 'c':
-            pPars->fGenCnf ^= 1;
-            break;
-        case 'g':
-            pPars->fPureAig ^= 1;
-            break;
-        case 't':
-            pPars->fCutHashing ^= 1;
-            break;
-        case 's':
-            pPars->fCutSimple ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'w':
-            pPars->fVeryVerbose ^= 1;
-            break;
-        case 'h':
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Empty GIA network.\n" );
-        return 1;
-    }
-
-    pNew = Kf_ManPerformMapping( pAbc->pGia, pPars );
-    if ( pNew == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Kf(): Mapping into LUTs has failed.\n" );
-        return 1;
-    }
-    Abc_FrameUpdateGia( pAbc, pNew );
-    return 0;
-
-usage:
-    if ( pPars->DelayTarget == -1 )
-        sprintf(Buffer, "best possible" );
-    else
-        sprintf(Buffer, "%d", pPars->DelayTarget );
-    Abc_Print( -2, "usage: &kf [-KCPDW num] [-akmdcgtsvwh]\n" );
-    Abc_Print( -2, "\t           performs technology mapping of the network\n" );
-    Abc_Print( -2, "\t-K num   : LUT size for the mapping (2 <= K <= %d) [default = %d]\n", pPars->nLutSizeMax, pPars->nLutSize );
-    Abc_Print( -2, "\t-C num   : the max number of priority cuts (1 <= C <= %d) [default = %d]\n", pPars->nCutNumMax, pPars->nCutNum );
-    Abc_Print( -2, "\t-P num   : the number of cut computation processes (0 <= P <= %d) [default = %d]\n", pPars->nProcNumMax, pPars->nProcNum );
-    Abc_Print( -2, "\t-D num   : sets the delay constraint for the mapping [default = %s]\n", Buffer );
-    Abc_Print( -2, "\t-W num   : min frequency when printing functions with \"-w\" [default = %d]\n", pPars->nVerbLimit );
-    Abc_Print( -2, "\t-a       : toggles area-oriented mapping [default = %s]\n", pPars->fAreaOnly? "yes": "no" );
-    Abc_Print( -2, "\t-e       : toggles edge vs node minimization [default = %s]\n", pPars->fOptEdge? "yes": "no" );
-    Abc_Print( -2, "\t-k       : toggles coarsening the subject graph [default = %s]\n", pPars->fCoarsen? "yes": "no" );
-    Abc_Print( -2, "\t-m       : toggles cut minimization [default = %s]\n", pPars->fCutMin? "yes": "no" );
-    Abc_Print( -2, "\t-d       : toggles using DSD to represent cut functions [default = %s]\n", pPars->fFuncDsd? "yes": "no" );
-    Abc_Print( -2, "\t-c       : toggles mapping for CNF generation [default = %s]\n", pPars->fGenCnf? "yes": "no" );
-    Abc_Print( -2, "\t-g       : toggles generating AIG without mapping [default = %s]\n", pPars->fPureAig? "yes": "no" );
-    Abc_Print( -2, "\t-t       : toggles cut computation using hash table [default = %s]\n", pPars->fCutHashing? "yes": "no" );
-    Abc_Print( -2, "\t-s       : toggles cut computation using a simple method [default = %s]\n", pPars->fCutSimple? "yes": "no" );
-    Abc_Print( -2, "\t-v       : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w       : toggles very verbose output [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : prints the command usage\n");
-    return 1;
-}
-#endif
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Lf( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    char Buffer[200];
-    Jf_Par_t Pars, * pPars = &Pars;
-    Gia_Man_t * pNew; int c;
-    Lf_ManSetDefaultPars( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "KCFARLEDWMaekmupgtvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nLutSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nLutSize < 2 || pPars->nLutSize > pPars->nLutSizeMax )
-            {
-                Abc_Print( -1, "LUT size %d is not supported.\n", pPars->nLutSize );
-                goto usage;
-            }
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nCutNum = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nCutNum < 1 || pPars->nCutNum > pPars->nCutNumMax )
-            {
-                Abc_Print( -1, "This number of cuts (%d) is not supported.\n", pPars->nCutNum );
-                goto usage;
-            }
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nRounds = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nRounds < 0 )
-                goto usage;
-            break;
-        case 'A':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-A\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nRoundsEla = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nRoundsEla < 0 )
-                goto usage;
-            break;
-		case 'R':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( 1, "Command line switch \"-R\" should be followed by a floating point number.\n" );
-                return 0;
-            }
-			pPars->nRelaxRatio = atoi(argv[globalUtilOptind]);
-			globalUtilOptind++;
-			if ( pPars->nRelaxRatio < 0 ) 
-				goto usage;
-            break;
-		case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( 1, "Command line switch \"-R\" should be followed by a floating point number.\n" );
-                return 0;
-            }
-			pPars->nCoarseLimit = atoi(argv[globalUtilOptind]);
-			globalUtilOptind++;
-			if ( pPars->nCoarseLimit < 0 ) 
-				goto usage;
-            break;
-		case 'E':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( 1, "Command line switch \"-E\" should be followed by a floating point number.\n" );
-                return 0;
-            }
-			pPars->nAreaTuner = atoi(argv[globalUtilOptind]);
-			globalUtilOptind++;
-			if ( pPars->nAreaTuner < 0 ) 
-				goto usage;
-            break;
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
-                goto usage;
-            }
-            pPars->DelayTarget = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->DelayTarget <= 0.0 )
-                goto usage;
-            break;
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nVerbLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nVerbLimit < 0 )
-                goto usage;
-            break;
-        case 'M':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-M\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nLutSizeMux = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nLutSizeMux < 2 || pPars->nLutSizeMux > pPars->nLutSizeMax )
-            {
-                Abc_Print( -1, "LUT size %d is not supported.\n", pPars->nLutSizeMux );
-                goto usage;
-            }
-            break;
-        case 'a':
-            pPars->fAreaOnly ^= 1;
-            break;
-        case 'e':
-            pPars->fOptEdge ^= 1;
-            break;
-        case 'k':
-            pPars->fCoarsen ^= 1;
-            break;
-        case 'm':
-            pPars->fCutMin ^= 1;
-            break;
-        case 'u':
-            pPars->fUseMux7 ^= 1;
-            break;
-        case 'p':
-            pPars->fPower ^= 1;
-            break;
-        case 'g':
-            pPars->fPureAig ^= 1;
-            break;
-        case 't':
-            pPars->fDoAverage ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'w':
-            pPars->fVeryVerbose ^= 1;
-            break;
-        case 'h':
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Empty GIA network.\n" );
-        return 1;
-    }
-    if ( Gia_ManHasMapping(pAbc->pGia) )
-    {
-        Abc_Print( -1, "Current AIG has mapping. Run \"&st\".\n" );
-        return 1;
-    }
-    if ( pPars->nLutSizeMux && pPars->fUseMux7 )
-    {
-        Abc_Print( -1, "Flags \"-M\" and \"-u\" are incompatible.\n" );
-        return 1;
-    }
-
-    pNew = Lf_ManPerformMapping( pAbc->pGia, pPars );
-    if ( pNew == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Lf(): Mapping into LUTs has failed.\n" );
-        return 1;
-    }
-    Abc_FrameUpdateGia( pAbc, pNew );
-    return 0;
-
-usage:
-    if ( pPars->DelayTarget == -1 )
-        sprintf(Buffer, "best possible" );
-    else
-        sprintf(Buffer, "%d", pPars->DelayTarget );
-    Abc_Print( -2, "usage: &lf [-KCFARLEDM num] [-kmupgtvwh]\n" );
-    Abc_Print( -2, "\t           performs technology mapping of the network\n" );
-    Abc_Print( -2, "\t-K num   : LUT size for the mapping (2 <= K <= %d) [default = %d]\n", pPars->nLutSizeMax, pPars->nLutSize );
-    Abc_Print( -2, "\t-C num   : the max number of priority cuts (1 <= C <= %d) [default = %d]\n", pPars->nCutNumMax, pPars->nCutNum );
-    Abc_Print( -2, "\t-F num   : the number of area flow rounds [default = %d]\n", pPars->nRounds );
-    Abc_Print( -2, "\t-A num   : the number of exact area rounds [default = %d]\n", pPars->nRoundsEla );
-    Abc_Print( -2, "\t-R num   : the delay relaxation ratio (num >= 0) [default = %d]\n", pPars->nRelaxRatio );
-    Abc_Print( -2, "\t-L num   : the fanout limit for coarsening XOR/MUX (num >= 2) [default = %d]\n", pPars->nCoarseLimit );
-    Abc_Print( -2, "\t-E num   : the area/edge tradeoff parameter (0 <= num <= 100) [default = %d]\n", pPars->nAreaTuner );
-    Abc_Print( -2, "\t-D num   : sets the delay constraint for the mapping [default = %s]\n", Buffer );
-    Abc_Print( -2, "\t-M num   : LUT size for the cofactoring (0 <= num <= 100) [default = %d]\n", pPars->nLutSizeMux );
-//    Abc_Print( -2, "\t-a       : toggles area-oriented mapping [default = %s]\n", pPars->fAreaOnly? "yes": "no" );
-    Abc_Print( -2, "\t-e       : toggles edge vs node minimization [default = %s]\n", pPars->fOptEdge? "yes": "no" );
-    Abc_Print( -2, "\t-k       : toggles coarsening the subject graph [default = %s]\n", pPars->fCoarsen? "yes": "no" );
-    Abc_Print( -2, "\t-m       : toggles cut minimization [default = %s]\n", pPars->fCutMin? "yes": "no" );
-    Abc_Print( -2, "\t-u       : toggles using additional MUXes [default = %s]\n", pPars->fUseMux7? "yes": "no" );
-    Abc_Print( -2, "\t-p       : toggles power-aware cut selection heuristics [default = %s]\n", pPars->fPower? "yes": "no" );
-    Abc_Print( -2, "\t-g       : toggles generating AIG without mapping [default = %s]\n", pPars->fPureAig? "yes": "no" );
-    Abc_Print( -2, "\t-t       : toggles optimizing average rather than maximum level [default = %s]\n", pPars->fDoAverage? "yes": "no" );
-    Abc_Print( -2, "\t-v       : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w       : toggles very verbose output [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : prints the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Mf( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    char Buffer[200];
-    Jf_Par_t Pars, * pPars = &Pars;
-    Gia_Man_t * pNew; int c;
-    Mf_ManSetDefaultPars( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "KCFARLEDWaekmcgvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nLutSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nLutSize < 2 || pPars->nLutSize > pPars->nLutSizeMax )
-            {
-                Abc_Print( -1, "LUT size %d is not supported.\n", pPars->nLutSize );
-                goto usage;
-            }
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nCutNum = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nCutNum < 1 || pPars->nCutNum > pPars->nCutNumMax )
-            {
-                Abc_Print( -1, "This number of cuts (%d) is not supported.\n", pPars->nCutNum );
-                goto usage;
-            }
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nRounds = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nRounds < 0 )
-                goto usage;
-            break;
-        case 'A':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-A\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nRoundsEla = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nRoundsEla < 0 )
-                goto usage;
-            break;
-		case 'R':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( 1, "Command line switch \"-R\" should be followed by a floating point number.\n" );
-                return 0;
-            }
-			pPars->nRelaxRatio = atoi(argv[globalUtilOptind]);
-			globalUtilOptind++;
-			if ( pPars->nRelaxRatio < 0 ) 
-				goto usage;
-            break;
-		case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( 1, "Command line switch \"-R\" should be followed by a floating point number.\n" );
-                return 0;
-            }
-			pPars->nCoarseLimit = atoi(argv[globalUtilOptind]);
-			globalUtilOptind++;
-			if ( pPars->nCoarseLimit < 0 ) 
-				goto usage;
-            break;
-		case 'E':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( 1, "Command line switch \"-E\" should be followed by a floating point number.\n" );
-                return 0;
-            }
-			pPars->nAreaTuner = atoi(argv[globalUtilOptind]);
-			globalUtilOptind++;
-			if ( pPars->nAreaTuner < 0 ) 
-				goto usage;
-            break;
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
-                goto usage;
-            }
-            pPars->DelayTarget = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->DelayTarget <= 0.0 )
-                goto usage;
-            break;
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nVerbLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nVerbLimit < 0 )
-                goto usage;
-            break;
-        case 'a':
-            pPars->fAreaOnly ^= 1;
-            break;
-        case 'e':
-            pPars->fOptEdge ^= 1;
-            break;
-        case 'k':
-            pPars->fCoarsen ^= 1;
-            break;
-        case 'm':
-            pPars->fCutMin ^= 1;
-            break;
-        case 'c':
-            pPars->fGenCnf ^= 1;
-            break;
-        case 'g':
-            pPars->fPureAig ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'w':
-            pPars->fVeryVerbose ^= 1;
-            break;
-        case 'h':
-        default:
-            goto usage;
-        }
-    }
-
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Empty GIA network.\n" );
-        return 1;
-    }
-
-    pNew = Mf_ManPerformMapping( pAbc->pGia, pPars );
-    if ( pNew == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Lf(): Mapping into LUTs has failed.\n" );
-        return 1;
-    }
-    if ( pPars->fGenCnf )
-        Cnf_DataFree( pAbc->pGia->pData ), pAbc->pGia->pData = NULL;
-    Abc_FrameUpdateGia( pAbc, pNew );
-    return 0;
-
-usage:
-    if ( pPars->DelayTarget == -1 )
-        sprintf(Buffer, "best possible" );
-    else
-        sprintf(Buffer, "%d", pPars->DelayTarget );
-    Abc_Print( -2, "usage: &mf [-KCFARLED num] [-akmcgvwh]\n" );
-    Abc_Print( -2, "\t           performs technology mapping of the network\n" );
-    Abc_Print( -2, "\t-K num   : LUT size for the mapping (2 <= K <= %d) [default = %d]\n", pPars->nLutSizeMax, pPars->nLutSize );
-    Abc_Print( -2, "\t-C num   : the max number of priority cuts (1 <= C <= %d) [default = %d]\n", pPars->nCutNumMax, pPars->nCutNum );
-    Abc_Print( -2, "\t-F num   : the number of area flow rounds [default = %d]\n", pPars->nRounds );
-    Abc_Print( -2, "\t-A num   : the number of exact area rounds [default = %d]\n", pPars->nRoundsEla );
-    Abc_Print( -2, "\t-R num   : the delay relaxation ratio (num >= 0) [default = %d]\n", pPars->nRelaxRatio );
-    Abc_Print( -2, "\t-L num   : the fanout limit for coarsening XOR/MUX (num >= 2) [default = %d]\n", pPars->nCoarseLimit );
-    Abc_Print( -2, "\t-E num   : the area/edge tradeoff parameter (0 <= num <= 100) [default = %d]\n", pPars->nAreaTuner );
-    Abc_Print( -2, "\t-D num   : sets the delay constraint for the mapping [default = %s]\n", Buffer );
-    Abc_Print( -2, "\t-a       : toggles area-oriented mapping [default = %s]\n", pPars->fAreaOnly? "yes": "no" );
-    Abc_Print( -2, "\t-e       : toggles edge vs node minimization [default = %s]\n", pPars->fOptEdge? "yes": "no" );
-    Abc_Print( -2, "\t-k       : toggles coarsening the subject graph [default = %s]\n", pPars->fCoarsen? "yes": "no" );
-    Abc_Print( -2, "\t-m       : toggles cut minimization [default = %s]\n", pPars->fCutMin? "yes": "no" );
-    Abc_Print( -2, "\t-c       : toggles mapping for CNF generation [default = %s]\n", pPars->fGenCnf? "yes": "no" );
-    Abc_Print( -2, "\t-g       : toggles generating AIG without mapping [default = %s]\n", pPars->fPureAig? "yes": "no" );
-    Abc_Print( -2, "\t-v       : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w       : toggles very verbose output [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : prints the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Nf( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern void Nf_ManSetDefaultPars( Jf_Par_t * pPars );
-    extern Gia_Man_t * Nf_ManPerformMapping( Gia_Man_t * pGia, Jf_Par_t * pPars );
-    char Buffer[200];
-    Jf_Par_t Pars, * pPars = &Pars;
-    Gia_Man_t * pNew; int c;
-    Nf_ManSetDefaultPars( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "KCFARLEDWakvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'K':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nLutSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nLutSize < 2 || pPars->nLutSize > pPars->nLutSizeMax )
-            {
-                Abc_Print( -1, "LUT size %d is not supported.\n", pPars->nLutSize );
-                goto usage;
-            }
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nCutNum = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nCutNum < 1 || pPars->nCutNum > pPars->nCutNumMax )
-            {
-                Abc_Print( -1, "This number of cuts (%d) is not supported.\n", pPars->nCutNum );
-                goto usage;
-            }
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nRounds = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nRounds < 0 )
-                goto usage;
-            break;
-        case 'A':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-A\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nRoundsEla = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nRoundsEla < 0 )
-                goto usage;
-            break;
-		case 'R':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( 1, "Command line switch \"-R\" should be followed by a floating point number.\n" );
-                return 0;
-            }
-			pPars->nRelaxRatio = atoi(argv[globalUtilOptind]);
-			globalUtilOptind++;
-			if ( pPars->nRelaxRatio < 0 ) 
-				goto usage;
-            break;
-		case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( 1, "Command line switch \"-R\" should be followed by a floating point number.\n" );
-                return 0;
-            }
-			pPars->nCoarseLimit = atoi(argv[globalUtilOptind]);
-			globalUtilOptind++;
-			if ( pPars->nCoarseLimit < 0 ) 
-				goto usage;
-            break;
-		case 'E':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( 1, "Command line switch \"-E\" should be followed by a floating point number.\n" );
-                return 0;
-            }
-			pPars->nAreaTuner = atoi(argv[globalUtilOptind]);
-			globalUtilOptind++;
-			if ( pPars->nAreaTuner < 0 ) 
-				goto usage;
-            break;
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
-                goto usage;
-            }
-            pPars->DelayTarget = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->DelayTarget <= 0.0 )
-                goto usage;
-            break;
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            pPars->nVerbLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nVerbLimit < 0 )
-                goto usage;
-            break;
-        case 'a':
-            pPars->fAreaOnly ^= 1;
-            break;
-        case 'k':
-            pPars->fCoarsen ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'w':
-            pPars->fVeryVerbose ^= 1;
-            break;
-        case 'h':
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Empty GIA network.\n" );
-        return 1;
-    }
-    if ( Abc_FrameReadLibGen() == NULL )
-    {
-        Abc_Print( -1, "Current library is not available.\n" );
-        return 1;
-    }
-    pNew = Nf_ManPerformMapping( pAbc->pGia, pPars );
-    if ( pNew == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Nf(): Mapping into LUTs has failed.\n" );
-        return 1;
-    }
-    Abc_FrameUpdateGia( pAbc, pNew );
-    return 0;
-
-usage:
-    if ( pPars->DelayTarget == -1 )
-        sprintf(Buffer, "best possible" );
-    else
-        sprintf(Buffer, "%d", pPars->DelayTarget );
-    Abc_Print( -2, "usage: &nf [-KCFARLED num] [-akvwh]\n" );
-    Abc_Print( -2, "\t           performs technology mapping of the network\n" );
-    Abc_Print( -2, "\t-K num   : LUT size for the mapping (2 <= K <= %d) [default = %d]\n", pPars->nLutSizeMax, pPars->nLutSize );
-    Abc_Print( -2, "\t-C num   : the max number of priority cuts (1 <= C <= %d) [default = %d]\n", pPars->nCutNumMax, pPars->nCutNum );
-    Abc_Print( -2, "\t-F num   : the number of area flow rounds [default = %d]\n", pPars->nRounds );
-    Abc_Print( -2, "\t-A num   : the number of exact area rounds [default = %d]\n", pPars->nRoundsEla );
-    Abc_Print( -2, "\t-R num   : the delay relaxation ratio (num >= 0) [default = %d]\n", pPars->nRelaxRatio );
-    Abc_Print( -2, "\t-L num   : the fanout limit for coarsening XOR/MUX (num >= 2) [default = %d]\n", pPars->nCoarseLimit );
-    Abc_Print( -2, "\t-E num   : the area/edge tradeoff parameter (0 <= num <= 100) [default = %d]\n", pPars->nAreaTuner );
-    Abc_Print( -2, "\t-D num   : sets the delay constraint for the mapping [default = %s]\n", Buffer );
-    Abc_Print( -2, "\t-a       : toggles area-oriented mapping [default = %s]\n", pPars->fAreaOnly? "yes": "no" );
-    Abc_Print( -2, "\t-k       : toggles coarsening the subject graph [default = %s]\n", pPars->fCoarsen? "yes": "no" );
-    Abc_Print( -2, "\t-v       : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w       : toggles very verbose output [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : prints the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Unmap( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern void Gia_ManTestStruct( Gia_Man_t * p );
-    int c, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Struct(): There is no AIG to map.\n" );
-        return 1;
-    }
-	Vec_IntFreeP( &pAbc->pGia->vMapping );
-	Vec_IntFreeP( &pAbc->pGia->vPacking );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &unmap [-vh]\n" );
-    Abc_Print( -2, "\t           removes mapping from the current network\n" );
-    Abc_Print( -2, "\t-v       : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Struct( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern void Gia_ManTestStruct( Gia_Man_t * p );
-    int c, fVerbose;
-    // set defaults
-    fVerbose   = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Struct(): There is no AIG to map.\n" );
-        return 1;
-    }
-    if ( !Gia_ManHasMapping(pAbc->pGia) )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Struct(): Mapping of the AIG is not defined.\n" );
-        return 1;
-    }
-    if ( Gia_ManLutSizeMax(pAbc->pGia) >= 8 )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Struct(): Can only handle nodes with less than 8 inputs.\n" );
-        return 1;
-    }
-    Gia_ManTestStruct( pAbc->pGia );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &struct [-vh]\n" );
-    Abc_Print( -2, "\t           checks decomposition structures of the current mapping\n" );
-    Abc_Print( -2, "\t-v       : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Trace( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    int c;
-    int fUseLutLib;
-    int fVerbose;
-    // set defaults
-    fUseLutLib = 0;
-    fVerbose   = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "lvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'l':
-            fUseLutLib ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Speedup(): There is no AIG to map.\n" );
-        return 1;
-    }
-    if ( !Gia_ManHasMapping(pAbc->pGia) )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Speedup(): Mapping of the AIG is not defined.\n" );
-        return 1;
-    }
-    pAbc->pGia->pLutLib = fUseLutLib ? pAbc->pLibLut : NULL;
-    Gia_ManDelayTraceLutPrint( pAbc->pGia, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &trace [-lvh]\n" );
-    Abc_Print( -2, "\t           performs delay trace of LUT-mapped network\n" );
-    Abc_Print( -2, "\t-l       : toggle using unit- or LUT-library-delay model [default = %s]\n", fUseLutLib? "lib": "unit" );
-    Abc_Print( -2, "\t-v       : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Speedup( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pTemp;
-    int fUseLutLib;
-    int Percentage;
-    int Degree;
-    int fVerbose;
-    int c, fVeryVerbose;
-
-    // set defaults
-    fUseLutLib   = 0;
-    Percentage   = 5;
-    Degree       = 2;
-    fVerbose     = 0;
-    fVeryVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "PNlvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'P':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            Percentage = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( Percentage < 1 || Percentage > 100 )
-                goto usage;
-            break;
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            Degree = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( Degree < 1 || Degree > 5 )
-                goto usage;
-            break;
-        case 'l':
-            fUseLutLib ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'w':
-            fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Speedup(): There is no AIG to map.\n" );
-        return 1;
-    }
-    if ( !Gia_ManHasMapping(pAbc->pGia) )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Speedup(): Mapping of the AIG is not defined.\n" );
-        return 1;
-    }
-    pAbc->pGia->pLutLib = fUseLutLib ? pAbc->pLibLut : NULL;
-    pTemp = Gia_ManSpeedup( pAbc->pGia, Percentage, Degree, fVerbose, fVeryVerbose );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &speedup [-P num] [-N num] [-lvwh]\n" );
-    Abc_Print( -2, "\t           transforms LUT-mapped network into an AIG with choices;\n" );
-    Abc_Print( -2, "\t           the choices are added to speedup the next round of mapping\n" );
-    Abc_Print( -2, "\t-P <num> : delay delta defining critical path for library model [default = %d%%]\n", Percentage );
-    Abc_Print( -2, "\t-N <num> : the max critical path degree for resynthesis (0 < num < 6) [default = %d]\n", Degree );
-    Abc_Print( -2, "\t-l       : toggle using unit- or LUT-library-delay model [default = %s]\n", fUseLutLib? "lib" : "unit" );
-    Abc_Print( -2, "\t-v       : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w       : toggle printing detailed stats for each node [default = %s]\n", fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h       : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Era( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-//    Gia_Man_t * pTemp = NULL;
-    int c, fVerbose = 0;
-    int fUseCubes = 1;
-    int fDumpFile = 0;
-    int fMiter = 0;
-    int nStatesMax = 1000000000;
-    extern int Gia_ManCollectReachable( Gia_Man_t * pAig, int nStatesMax, int fMiter, int fDumpFile, int fVerbose );
-    extern int Gia_ManArePerform( Gia_Man_t * pAig, int nStatesMax, int fMiter, int fVerbose );
-
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Smcdvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            nStatesMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nStatesMax < 0 )
-                goto usage;
-            break;
-        case 'm':
-            fMiter ^= 1;
-            break;
-        case 'c':
-            fUseCubes ^= 1;
-            break;
-        case 'd':
-            fDumpFile ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Era(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Era(): The network is combinational.\n" );
-        return 1;
-    }
-    if ( !fUseCubes && Gia_ManPiNum(pAbc->pGia) > 12 )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Era(): The number of PIs (%d) should be no more than 12 when cubes are not used.\n", Gia_ManPiNum(pAbc->pGia) );
-        return 1;
-    }
-    if ( fUseCubes && !fDumpFile )
-        pAbc->Status = Gia_ManArePerform( pAbc->pGia, nStatesMax, fMiter, fVerbose );
-    else
-        pAbc->Status = Gia_ManCollectReachable( pAbc->pGia, nStatesMax, fMiter, fDumpFile, fVerbose );
-    Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexSeq );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &era [-S num] [-mcdvh]\n" );
-    Abc_Print( -2, "\t          explicit reachability analysis for small sequential AIGs\n" );
-    Abc_Print( -2, "\t-S num  : the max number of states (num > 0) [default = %d]\n", nStatesMax );
-    Abc_Print( -2, "\t-m      : stop when the miter output is 1 [default = %s]\n", fMiter? "yes": "no" );
-    Abc_Print( -2, "\t-c      : use state cubes instead of state minterms [default = %s]\n", fUseCubes? "yes": "no" );
-    Abc_Print( -2, "\t-d      : toggle dumping STG into a file [default = %s]\n", fDumpFile? "yes": "no" );
-    Abc_Print( -2, "\t-v      : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h      : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Dch( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pTemp;
-    Dch_Pars_t Pars, * pPars = &Pars;
-    int c;
-    // set defaults
-    Dch_ManSetDefaultParams( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "WCSsptfvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nWords = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nWords < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nBTLimit < 0 )
-                goto usage;
-            break;
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nSatVarMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nSatVarMax < 0 )
-                goto usage;
-            break;
-        case 's':
-            pPars->fSynthesis ^= 1;
-            break;
-        case 'p':
-            pPars->fPower ^= 1;
-            break;
-        case 't':
-            pPars->fSimulateTfo ^= 1;
-            break;
-        case 'f':
-            pPars->fLightSynth ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Dch(): There is no AIG.\n" );
-        return 1;
-    }
-    pTemp = Gia_ManPerformDch( pAbc->pGia, pPars );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &dch [-WCS num] [-sptfvh]\n" );
-    Abc_Print( -2, "\t         computes structural choices using a new approach\n" );
-    Abc_Print( -2, "\t-W num : the max number of simulation words [default = %d]\n", pPars->nWords );
-    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
-    Abc_Print( -2, "\t-S num : the max number of SAT variables [default = %d]\n", pPars->nSatVarMax );
-    Abc_Print( -2, "\t-s     : toggle synthesizing three snapshots [default = %s]\n", pPars->fSynthesis? "yes": "no" );
-    Abc_Print( -2, "\t-p     : toggle power-aware rewriting [default = %s]\n", pPars->fPower? "yes": "no" );
-    Abc_Print( -2, "\t-t     : toggle simulation of the TFO classes [default = %s]\n", pPars->fSimulateTfo? "yes": "no" );
-    Abc_Print( -2, "\t-f     : toggle using lighter logic synthesis [default = %s]\n", pPars->fLightSynth? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Rpm( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pTemp;
-    int c, nCutMax   = 16;
-    int fUseOldAlgo  =  0;
-    int fVerbose     =  0;
-    int fVeryVerbose =  0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Cavwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nCutMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nCutMax < 0 )
-                goto usage;
-            break;
-        case 'a':
-            fUseOldAlgo ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'w':
-            fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Rpm(): There is no AIG.\n" );
-        return 0;
-    }
-    if ( fUseOldAlgo )
-        pTemp = Abs_RpmPerformOld( pAbc->pGia, fVerbose );
-    else
-        pTemp = Abs_RpmPerform( pAbc->pGia, nCutMax, fVerbose, fVeryVerbose );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &rpm [-C num] [-avwh]\n" );
-    Abc_Print( -2, "\t         performs structural reparametrization\n" );
-    Abc_Print( -2, "\t-C num : max cut size for testing range equivalence [default = %d]\n", nCutMax );
-    Abc_Print( -2, "\t-a     : toggle using old algorithm [default = %s]\n", fUseOldAlgo? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w     : toggle printing more verbose information [default = %s]\n", fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9BackReach( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Gia_Man_t * Gia_ManCofTest( Gia_Man_t * pGia, int nFrameMax, int nConfMax, int nTimeMax, int fVerbose );
-
-    Gia_Man_t * pTemp = NULL;
-    int c, fVerbose = 0;
-    int nFrameMax = 1000000;
-    int nConfMax  = 1000000;
-    int nTimeMax  =      10;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "FCTvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFrameMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFrameMax < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nConfMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nConfMax < 0 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nTimeMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nTimeMax < 0 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9BackReach(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( Gia_ManPoNum(pAbc->pGia) != 1 )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9BackReach(): The number of POs is different from 1.\n" );
-        return 1;
-    }
-    pTemp = Gia_ManCofTest( pAbc->pGia, nFrameMax, nConfMax, nTimeMax, fVerbose );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &back_reach [-FCT <num>] [-vh]\n" );
-    Abc_Print( -2, "\t         performs backward reachability by circuit cofactoring\n" );
-    Abc_Print( -2, "\t-F num : the limit on the depth of induction [default = %d]\n", nFrameMax );
-    Abc_Print( -2, "\t-C num : the conflict limit at a node during induction [default = %d]\n", nConfMax );
-    Abc_Print( -2, "\t-T num : the timeout for property directed reachability [default = %d]\n", nTimeMax );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Posplit( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Aig_Man_t * Aig_ManSplit( Aig_Man_t * p, int nVars, int fVerbose );
-    Aig_Man_t * pMan, * pAux;
-    Gia_Man_t * pTemp = NULL;
-    int c, nVars = 5, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Nvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nVars = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nVars < 0 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Posplit(): There is no AIG.\n" );
-        return 1;
-    }
-    pMan = Gia_ManToAigSimple( pAbc->pGia );
-    pMan = Aig_ManSplit( pAux = pMan, nVars, fVerbose );
-    Aig_ManStop( pAux );
-    if ( pMan != NULL )
-    {
-        pTemp = Gia_ManFromAigSimple( pMan );
-        Aig_ManStop( pMan );
-        Abc_FrameUpdateGia( pAbc, pTemp );
-    }
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &posplit [-N num] [-vh]\n" );
-    Abc_Print( -2, "\t         cofactors the property output w.r.t. a support subset\n" );
-    Abc_Print( -2, "\t         (the OR of new PO functions is equal to the original property)\n" );
-    Abc_Print( -2, "\t-N num : the number of random cofactoring variables [default = %d]\n", nVars );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9ReachM( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-//    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    Gia_ParLlb_t Pars, * pPars = &Pars;
-    char * pLogFileName = NULL;
-    int c;
-    extern int Llb_ManModelCheckGia( Gia_Man_t * pGia, Gia_ParLlb_t * pPars );
-
-    // set defaults
-    Llb_ManSetDefaultParams( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "TBFCHSLripcsyzvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->TimeLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->TimeLimit < 0 )
-                goto usage;
-            break;
-        case 'B':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nBddMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nBddMax < 0 )
-                goto usage;
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nIterMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nIterMax < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nClusterMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nClusterMax < 0 )
-                goto usage;
-            break;
-        case 'H':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-H\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nHintDepth = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nHintDepth < 0 )
-                goto usage;
-            break;
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->HintFirst = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->HintFirst < 0 )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by a file name.\n" );
-                goto usage;
-            }
-            pLogFileName = argv[globalUtilOptind];
-            globalUtilOptind++;
-            break;
-        case 'r':
-            pPars->fReorder ^= 1;
-            break;
-        case 'i':
-            pPars->fIndConstr ^= 1;
-            break;
-        case 'p':
-            pPars->fUsePivots ^= 1;
-            break;
-        case 'c':
-            pPars->fCluster ^= 1;
-            break;
-        case 's':
-            pPars->fSchedule ^= 1;
-            break;
-        case 'y':
-            pPars->fSkipOutCheck ^= 1;
-            break;
-        case 'z':
-            pPars->fSkipReach ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'w':
-            pPars->fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9ReachM(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9ReachM(): The current AIG has no latches.\n" );
-        return 0;
-    }
-    if ( Gia_ManObjNum(pAbc->pGia) >= (1<<16) )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9ReachM(): Currently cannot handle AIGs with more than %d objects.\n", (1<<16) );
-        return 0;
-    }
-    pAbc->Status  = Llb_ManModelCheckGia( pAbc->pGia, pPars );
-    pAbc->nFrames = pPars->iFrame;
-    Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexSeq );
-    if ( pLogFileName )
-        Abc_NtkWriteLogFile( pLogFileName, pAbc->pCex, pAbc->Status, pAbc->nFrames, "&reachm" );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &reachm [-TBFCHS num] [-L file] [-ripcsyzvwh]\n" );
-    Abc_Print( -2, "\t         model checking via BDD-based reachability (dependence-matrix-based)\n" );
-    Abc_Print( -2, "\t-T num : approximate time limit in seconds (0=infinite) [default = %d]\n", pPars->TimeLimit );
-    Abc_Print( -2, "\t-B num : max number of nodes in the intermediate BDDs [default = %d]\n", pPars->nBddMax );
-    Abc_Print( -2, "\t-F num : max number of reachability iterations [default = %d]\n", pPars->nIterMax );
-    Abc_Print( -2, "\t-C num : max number of variables in a cluster [default = %d]\n", pPars->nClusterMax );
-    Abc_Print( -2, "\t-H num : max number of hints to use [default = %d]\n", pPars->nHintDepth );
-    Abc_Print( -2, "\t-S num : the number of the starting hint [default = %d]\n", pPars->HintFirst );
-    Abc_Print( -2, "\t-L file: the log file name [default = %s]\n", pLogFileName ? pLogFileName : "no logging" );
-    Abc_Print( -2, "\t-r     : enable dynamic BDD variable reordering [default = %s]\n", pPars->fReorder? "yes": "no" );
-    Abc_Print( -2, "\t-i     : enable extraction of inductive constraints [default = %s]\n", pPars->fIndConstr? "yes": "no" );
-    Abc_Print( -2, "\t-p     : enable partitions for internal cut-points [default = %s]\n", pPars->fUsePivots? "yes": "no" );
-    Abc_Print( -2, "\t-c     : enable clustering of partitions [default = %s]\n", pPars->fCluster? "yes": "no" );
-    Abc_Print( -2, "\t-s     : enable scheduling of clusters [default = %s]\n", pPars->fSchedule? "yes": "no" );
-    Abc_Print( -2, "\t-y     : skip checking property outputs [default = %s]\n", pPars->fSkipOutCheck? "yes": "no" );
-    Abc_Print( -2, "\t-z     : skip reachability (run preparation phase only) [default = %s]\n", pPars->fSkipReach? "yes": "no" );
-    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w     : prints dependency matrix [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9ReachP( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-//    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    Gia_ParLlb_t Pars, * pPars = &Pars;
-    Aig_Man_t * pMan;
-    char * pLogFileName = NULL;
-    int c;
-    extern int Llb_ManReachMinCut( Aig_Man_t * pAig, Gia_ParLlb_t * pPars );
-
-    // set defaults
-    Llb_ManSetDefaultParams( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "NBFTLrbyzdvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'N':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nPartValue = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nPartValue < 0 )
-                goto usage;
-            break;
-        case 'B':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nBddMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nBddMax < 0 )
-                goto usage;
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nIterMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nIterMax < 0 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->TimeLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->TimeLimit < 0 )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by a file name.\n" );
-                goto usage;
-            }
-            pLogFileName = argv[globalUtilOptind];
-            globalUtilOptind++;
-            break;
-        case 'r':
-            pPars->fReorder ^= 1;
-            break;
-        case 'b':
-            pPars->fBackward ^= 1;
-            break;
-        case 'y':
-            pPars->fSkipOutCheck ^= 1;
-            break;
-        case 'z':
-            pPars->fSkipReach ^= 1;
-            break;
-        case 'd':
-            pPars->fDumpReached ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'w':
-            pPars->fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9ReachP(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9ReachP(): The current AIG has no latches.\n" );
-        return 0;
-    }
-    if ( Gia_ManObjNum(pAbc->pGia) >= (1<<16) )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9ReachP(): Currently cannot handle AIGs with more than %d objects.\n", (1<<16) );
-        return 0;
-    }
-    pMan          = Gia_ManToAigSimple( pAbc->pGia );
-    pAbc->Status  = Llb_ManReachMinCut( pMan, pPars );
-    pAbc->nFrames = pPars->iFrame;
-    Abc_FrameReplaceCex( pAbc, &pMan->pSeqModel );
-    if ( pLogFileName )
-        Abc_NtkWriteLogFile( pLogFileName, pAbc->pCex, pAbc->Status, pAbc->nFrames, "&reachp" );
-    Aig_ManStop( pMan );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &reachp [-NFT num] [-L file] [-rbyzdvwh]\n" );
-    Abc_Print( -2, "\t         model checking via BDD-based reachability (partitioning-based)\n" );
-    Abc_Print( -2, "\t-N num : partitioning value (MinVol=nANDs/N/2; MaxVol=nANDs/N) [default = %d]\n", pPars->nPartValue );
-//    Abc_Print( -2, "\t-B num : the BDD node increase when hints kick in [default = %d]\n", pPars->nBddMax );
-    Abc_Print( -2, "\t-F num : max number of reachability iterations [default = %d]\n", pPars->nIterMax );
-    Abc_Print( -2, "\t-T num : approximate time limit in seconds (0=infinite) [default = %d]\n", pPars->TimeLimit );
-    Abc_Print( -2, "\t-L file: the log file name [default = %s]\n", pLogFileName ? pLogFileName : "no logging" );
-    Abc_Print( -2, "\t-r     : enable additional BDD var reordering before image [default = %s]\n", pPars->fReorder? "yes": "no" );
-    Abc_Print( -2, "\t-b     : perform backward reachability analysis [default = %s]\n", pPars->fBackward? "yes": "no" );
-    Abc_Print( -2, "\t-y     : skip checking property outputs [default = %s]\n", pPars->fSkipOutCheck? "yes": "no" );
-    Abc_Print( -2, "\t-z     : skip reachability (run preparation phase only) [default = %s]\n", pPars->fSkipReach? "yes": "no" );
-    Abc_Print( -2, "\t-d     : dump BDD of reached states into file \"reached.blif\" [default = %s]\n", pPars->fDumpReached? "yes": "no" );
-    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w     : prints additional information [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9ReachN( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-//    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    Gia_ParLlb_t Pars, * pPars = &Pars;
-    Aig_Man_t * pMan;
-    char * pLogFileName = NULL;
-    int c;
-    extern int Llb_NonlinCoreReach( Aig_Man_t * pAig, Gia_ParLlb_t * pPars );
-
-    // set defaults
-    Llb_ManSetDefaultParams( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "BFTLryzvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'B':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nBddMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nBddMax < 0 )
-                goto usage;
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nIterMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nIterMax < 0 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->TimeLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->TimeLimit < 0 )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by a file name.\n" );
-                goto usage;
-            }
-            pLogFileName = argv[globalUtilOptind];
-            globalUtilOptind++;
-            break;
-        case 'r':
-            pPars->fReorder ^= 1;
-            break;
-        case 'y':
-            pPars->fSkipOutCheck ^= 1;
-            break;
-        case 'z':
-            pPars->fSkipReach ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'w':
-            pPars->fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9ReachN(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9ReachN(): The current AIG has no latches.\n" );
-        return 0;
-    }
-    if ( Gia_ManObjNum(pAbc->pGia) >= (1<<16) )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9ReachN(): Currently cannot handle AIGs with more than %d objects.\n", (1<<16) );
-        return 0;
-    }
-    pMan          = Gia_ManToAigSimple( pAbc->pGia );
-    pAbc->Status  = Llb_NonlinCoreReach( pMan, pPars );
-    pAbc->nFrames = pPars->iFrame;
-    Abc_FrameReplaceCex( pAbc, &pMan->pSeqModel );
-    if ( pLogFileName )
-        Abc_NtkWriteLogFile( pLogFileName, pAbc->pCex, pAbc->Status, pAbc->nFrames, "&reachn" );
-    Aig_ManStop( pMan );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &reachn [-BFT num] [-L file] [-ryzvh]\n" );
-    Abc_Print( -2, "\t         model checking via BDD-based reachability (non-linear-QS-based)\n" );
-    Abc_Print( -2, "\t-B num : the BDD node increase when hints kick in [default = %d]\n", pPars->nBddMax );
-    Abc_Print( -2, "\t-F num : max number of reachability iterations [default = %d]\n", pPars->nIterMax );
-    Abc_Print( -2, "\t-T num : approximate time limit in seconds (0=infinite) [default = %d]\n", pPars->TimeLimit );
-    Abc_Print( -2, "\t-L file: the log file name [default = %s]\n", pLogFileName ? pLogFileName : "no logging" );
-    Abc_Print( -2, "\t-r     : enable additional BDD var reordering before image [default = %s]\n", pPars->fReorder? "yes": "no" );
-    Abc_Print( -2, "\t-y     : skip checking property outputs [default = %s]\n", pPars->fSkipOutCheck? "yes": "no" );
-    Abc_Print( -2, "\t-z     : skip reachability (run preparation phase only) [default = %s]\n", pPars->fSkipReach? "yes": "no" );
-    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
-//    Abc_Print( -2, "\t-w     : prints additional information [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9ReachY( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-//    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
-    Gia_ParLlb_t Pars, * pPars = &Pars;
-    Aig_Man_t * pMan;
-    char * pLogFileName = NULL;
-    int c;
-
-    // set defaults
-    Llb_ManSetDefaultParams( pPars );
-    pPars->fCluster = 0;
-    pPars->fReorder = 0;
-    pPars->nBddMax     = 100;
-    pPars->nClusterMax = 500;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "BCFTLbcryzvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'B':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nBddMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nBddMax < 0 )
-                goto usage;
-            break;
-        case 'C':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nClusterMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nClusterMax < 0 )
-                goto usage;
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nIterMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nIterMax < 0 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->TimeLimit = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->TimeLimit < 0 )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by a file name.\n" );
-                goto usage;
-            }
-            pLogFileName = argv[globalUtilOptind];
-            globalUtilOptind++;
-            break;
-        case 'b':
-            pPars->fBackward ^= 1;
-            break;
-        case 'c':
-            pPars->fCluster ^= 1;
-            break;
-        case 'r':
-            pPars->fReorder ^= 1;
-            break;
-        case 'y':
-            pPars->fSkipOutCheck ^= 1;
-            break;
-        case 'z':
-            pPars->fSkipReach ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'w':
-            pPars->fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9ReachN(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9ReachN(): The current AIG has no latches.\n" );
-        return 0;
-    }
-/*
-    if ( Gia_ManObjNum(pAbc->pGia) >= (1<<16) )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9ReachN(): Currently cannot handle AIGs with more than %d objects.\n", (1<<16) );
-        return 0;
-    }
-*/
-    pMan          = Gia_ManToAigSimple( pAbc->pGia );
-    pAbc->Status  = Llb_Nonlin4CoreReach( pMan, pPars );
-    pAbc->nFrames = pPars->iFrame;
-    Abc_FrameReplaceCex( pAbc, &pMan->pSeqModel );
-    if ( pLogFileName )
-        Abc_NtkWriteLogFile( pLogFileName, pAbc->pCex, pAbc->Status, pAbc->nFrames, "&reachy" );
-    Aig_ManStop( pMan );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &reachy [-BCFT num] [-L file] [-bcryzvh]\n" );
-    Abc_Print( -2, "\t         model checking via BDD-based reachability (non-linear-QS-based)\n" );
-    Abc_Print( -2, "\t-B num : the max BDD size to introduce cut points [default = %d]\n", pPars->nBddMax );
-    Abc_Print( -2, "\t-C num : the max BDD size to reparameterize/cluster [default = %d]\n", pPars->nClusterMax );
-    Abc_Print( -2, "\t-F num : max number of reachability iterations [default = %d]\n", pPars->nIterMax );
-    Abc_Print( -2, "\t-T num : approximate time limit in seconds (0=infinite) [default = %d]\n", pPars->TimeLimit );
-    Abc_Print( -2, "\t-L file: the log file name [default = %s]\n", pLogFileName ? pLogFileName : "no logging" );
-    Abc_Print( -2, "\t-b     : enable using backward enumeration [default = %s]\n", pPars->fBackward? "yes": "no" );
-    Abc_Print( -2, "\t-c     : enable reparametrization clustering [default = %s]\n", pPars->fCluster? "yes": "no" );
-    Abc_Print( -2, "\t-r     : enable additional BDD var reordering before image [default = %s]\n", pPars->fReorder? "yes": "no" );
-    Abc_Print( -2, "\t-y     : skip checking property outputs [default = %s]\n", pPars->fSkipOutCheck? "yes": "no" );
-    Abc_Print( -2, "\t-z     : skip reachability (run preparation phase only) [default = %s]\n", pPars->fSkipReach? "yes": "no" );
-    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
-//    Abc_Print( -2, "\t-w     : prints additional information [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Undo( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    int c;
-    // set defaults
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Undo(): There is no design.\n" );
-        return 1;
-    }
-    if ( pAbc->pGia2 == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Undo(): There is no previously saved network.\n" );
-        return 1;
-    }
-    Gia_ManStop( pAbc->pGia );
-    pAbc->pGia = pAbc->pGia2;
-    pAbc->pGia2 = NULL;
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &undo [-h]\n" );
-    Abc_Print( -2, "\t        reverses the previous AIG transformation\n" );
-    Abc_Print( -2, "\t-h    : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Iso( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pAig;
-    Vec_Ptr_t * vPosEquivs;
-//    Vec_Ptr_t * vPiPerms;
-    int c, fNewAlgo = 1, fEstimate = 0, fBetterQual = 0, fDualOut = 0, fVerbose = 0, fVeryVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "neqdvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'n':
-            fNewAlgo ^= 1;
-            break;
-        case 'e':
-            fEstimate ^= 1;
-            break;
-        case 'q':
-            fBetterQual ^= 1;
-            break;
-        case 'd':
-            fDualOut ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'w':
-            fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Iso(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( Gia_ManPoNum(pAbc->pGia) == 1 )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Iso(): The AIG has only one PO. Isomorphism detection is not performed.\n" );
-        return 1;
-    }
-    if ( fNewAlgo )
-        pAig = Gia_ManIsoReduce2( pAbc->pGia, &vPosEquivs, NULL, fEstimate, fBetterQual, fDualOut, fVerbose, fVeryVerbose );
-    else
-        pAig = Gia_ManIsoReduce( pAbc->pGia, &vPosEquivs, NULL, fEstimate, fDualOut, fVerbose, fVeryVerbose );
-//    pAig = Gia_ManIsoReduce( pAbc->pGia, &vPosEquivs, &vPiPerms, 0, fDualOut, fVerbose, fVeryVerbose );
-//    Vec_VecFree( (Vec_Vec_t *)vPiPerms );
-    if ( pAig == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Iso(): Transformation has failed.\n" );
-        return 1;
-    }
-    // update the internal storage of PO equivalences
-    Abc_FrameReplacePoEquivs( pAbc, &vPosEquivs );
-    // update the AIG
-    Abc_FrameUpdateGia( pAbc, pAig );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &iso [-neqdvwh]\n" );
-    Abc_Print( -2, "\t         removes POs with isomorphic sequential COI\n" );
-    Abc_Print( -2, "\t-n     : toggle using new fast algorithm [default = %s]\n", fNewAlgo? "yes": "no" );
-    Abc_Print( -2, "\t-e     : toggle computing lower bound on equivalence classes [default = %s]\n", fEstimate? "yes": "no" );
-    Abc_Print( -2, "\t-q     : toggle improving quality at the expense of runtime [default = %s]\n", fBetterQual? "yes": "no" );
-    Abc_Print( -2, "\t-d     : toggle treating the current AIG as a dual-output miter [default = %s]\n", fDualOut? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w     : toggle printing very verbose information [default = %s]\n", fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9CexInfo( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern void Bmc_CexTest( Gia_Man_t * p, Abc_Cex_t * pCex, int fVerbose );
-    int c, fDualOut = 0, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "dvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'd':
-            fDualOut ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9CexInfo(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( pAbc->pCex == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9CexInfo(): There is no CEX.\n" );
-        return 1;
-    }
-    Bmc_CexTest( pAbc->pGia, pAbc->pCex, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &cexinfo [-vh]\n" );
-    Abc_Print( -2, "\t         prints information about the current counter-example\n" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Cycle( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pTemp;
-    int c, nFrames = 10, fUseCex = 0, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Fcvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFrames = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFrames < 0 )
-                goto usage;
-            break;
-        case 'c':
-            fUseCex ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Cycle(): There is no AIG.\n" );
-        return 1;
-    }
-    pTemp = Gia_ManDupCycled( pAbc->pGia, fUseCex ? pAbc->pCex : NULL, nFrames );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &cycle [-F num] [-cvh]\n" );
-    Abc_Print( -2, "\t         cycles sequential circuit for the given number of timeframes\n" );
-    Abc_Print( -2, "\t         to derive a new initial state (which may be on the envelope)\n" );
-    Abc_Print( -2, "\t-F num : the number of frames to simulate [default = %d]\n", nFrames );
-    Abc_Print( -2, "\t-c     : toggle using PI values from the current CEX [default = %s]\n", fUseCex? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Cone( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pTemp;
-    Vec_Int_t * vPos;
-    int c, iOutNum = -1, nOutRange = 1, iPartNum = -1, nLevelMax = 0, nTimeWindow = 0, fUseAllCis = 0, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "ORPLWavh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'O':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-O\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            iOutNum = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( iOutNum < 0 )
-                goto usage;
-            break;
-        case 'R':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nOutRange = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nOutRange < 0 )
-                goto usage;
-            break;
-        case 'P':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            iPartNum = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( iPartNum < 0 )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nLevelMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nLevelMax < 0 )
-                goto usage;
-            break;
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nTimeWindow = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nTimeWindow < 0 )
-                goto usage;
-            break;
-        case 'a':
-            fUseAllCis ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Cone(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( nLevelMax || nTimeWindow )
-    {
-        if ( nLevelMax && nTimeWindow )
-        {
-            Abc_Print( -1, "Abc_CommandAbc9Cone(): Parameters -L (max level) and -W (timing window) cannot be specified at the same time.\n" );
-            return 1;
-        }
-        else
-        {
-            pTemp = Gia_ManExtractWindow( pAbc->pGia, nLevelMax, nTimeWindow, fVerbose );
-            Abc_FrameUpdateGia( pAbc, pTemp );
-            return 0;
-        }
-    }
-    if ( iPartNum >= 0 )
-    {
-        Vec_Int_t * vClass;
-        Vec_Vec_t * vClasses = (Vec_Vec_t *)pAbc->vPoEquivs;
-        if ( vClasses == NULL )
-        {
-            Abc_Print( -1, "Abc_CommandAbc9Cone(): Partitions are not defined.\n" );
-            return 1;
-        }
-        if ( iPartNum >= Vec_VecSize(vClasses) )
-        {
-            Abc_Print( -1, "Abc_CommandAbc9Cone(): Partition index exceed the array size.\n" );
-            return 1;
-        }
-        vClass = Vec_VecEntryInt( vClasses, iPartNum );
-        pTemp = Gia_ManDupCones( pAbc->pGia, Vec_IntArray(vClass), Vec_IntSize(vClass), !fUseAllCis );
-        if ( pTemp )
-            Abc_FrameUpdateGia( pAbc, pTemp );
-        return 0;
-    }
-    if ( iOutNum < 0 || iOutNum + nOutRange >= Gia_ManPoNum(pAbc->pGia) )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Cone(): Range of outputs to extract is incorrect.\n" );
-        return 1;
-    }
-    vPos = Vec_IntStartRange( iOutNum, nOutRange );
-    pTemp = Gia_ManDupCones( pAbc->pGia, Vec_IntArray(vPos), nOutRange, !fUseAllCis );
-    Vec_IntFree( vPos );
-    if ( pTemp )
-        Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &cone [-ORPLW num] [-avh]\n" );
-    Abc_Print( -2, "\t         extracting multi-output sequential logic cones\n" );
-    Abc_Print( -2, "\t-O num : the index of first PO to extract [default = %d]\n", iOutNum );
-    Abc_Print( -2, "\t-R num : (optional) the number of outputs to extract [default = %d]\n", nOutRange );
-    Abc_Print( -2, "\t-P num : (optional) the partition number to extract [default = %d]\n", iPartNum );
-    Abc_Print( -2, "\t-L num : (optional) extract cones with higher level [default = %d]\n", nLevelMax );
-    Abc_Print( -2, "\t-W num : (optional) extract cones falling into this window [default = %d]\n", nTimeWindow );
-    Abc_Print( -2, "\t-a     : toggle keeping all CIs or structral support only [default = %s]\n", fUseAllCis? "all": "structural" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Slice( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    Gia_Man_t * pTemp;
-    int c, nSuppSize = 6, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Svh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nSuppSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nSuppSize < 0 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Slice(): There is no AIG.\n" );
-        return 1;
-    }
-    pTemp = Gia_ManDupSliced( pAbc->pGia, nSuppSize );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &slice [-S num] [-vh]\n" );
-    Abc_Print( -2, "\t         cuts the lower part of the AIG with nodes using their support\n" );
-    Abc_Print( -2, "\t-S num : the largest support size to keep in the slide [default = %d]\n", nSuppSize );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9PoPart( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Gia_Man_t * Gia_ManFindPoPartition( Gia_Man_t * p, int SelectShift, int fOnlyCis, int fSetLargest, int fVerbose, Vec_Ptr_t ** pvPosEquivs );
-    Gia_Man_t * pTemp;
-    Vec_Ptr_t * vPosEquivs = NULL;
-    int c, SelectShift = 0, fOnlyCis = 0, fSetLargest = 0, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Simvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            SelectShift = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( SelectShift < 0 )
-                goto usage;
-            break;
-        case 'i':
-            fOnlyCis ^= 1;
-            break;
-        case 'm':
-            fSetLargest ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9PoPart(): There is no AIG.\n" );
-        return 1;
-    }
-    pTemp = Gia_ManFindPoPartition( pAbc->pGia, SelectShift, fOnlyCis, fSetLargest, fVerbose, &vPosEquivs );
-    if ( pTemp )
-        Abc_FrameUpdateGia( pAbc, pTemp );
-    Abc_FrameReplacePoEquivs( pAbc, &vPosEquivs );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &popart [-S num] [-imvh]\n" );
-    Abc_Print( -2, "\t         partitioning of POs into equivalence classes\n" );
-    Abc_Print( -2, "\t-S num : random seed to select the set of pivot nodes [default = %d]\n", SelectShift );
-    Abc_Print( -2, "\t       : (if the seed is 0, the nodes with max fanout counts are used)\n" );
-    Abc_Print( -2, "\t-i     : toggle allowing only CIs to be the pivots [default = %s]\n", fOnlyCis? "yes": "no" );
-    Abc_Print( -2, "\t-m     : toggle using the largest part as the current network [default = %s]\n", fSetLargest? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9PoPart2( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Gia_Man_t * Gia_ManFindPoPartition2( Gia_Man_t * p, int iStartNum, int nDelta, int nOutsMin, int nOutsMax, int fSetLargest, int fVerbose, Vec_Ptr_t ** pvPosEquivs );
-    Gia_Man_t * pTemp = NULL;
-    Vec_Ptr_t * vPosEquivs = NULL;
-    int c, iStartNum = 0, nDelta = 10, nOutsMin = 100, nOutsMax = 1000, fSetLargest = 0, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "SDLUmvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            iStartNum = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( iStartNum < 0 )
-                goto usage;
-            break;
-        case 'D':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nDelta = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nDelta < 0 )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nOutsMin = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nOutsMin < 0 )
-                goto usage;
-            break;
-        case 'U':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-U\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nOutsMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nOutsMax < 0 )
-                goto usage;
-            break;
-        case 'm':
-            fSetLargest ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9PoPart(): There is no AIG.\n" );
-        return 1;
-    }
-    pTemp = Gia_ManFindPoPartition2( pAbc->pGia, iStartNum, nDelta, nOutsMin, nOutsMax, fSetLargest, fVerbose, &vPosEquivs );
-    if ( pTemp )
-        Abc_FrameUpdateGia( pAbc, pTemp );
-    Abc_FrameReplacePoEquivs( pAbc, &vPosEquivs );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &popart2 [-SDLU num] [-mvh]\n" );
-    Abc_Print( -2, "\t         extracting multi-output sequential logic cones\n" );
-    Abc_Print( -2, "\t-S num : the index of the PO to start the cluster [default = %d]\n", iStartNum );
-    Abc_Print( -2, "\t-D num : the max increase in flop count after adding one PO [default = %d]\n", nDelta );
-    Abc_Print( -2, "\t-L num : the minimum number of POs in a cluster [default = %d]\n", nOutsMin );
-    Abc_Print( -2, "\t-U num : the maximum number of POs in a cluster [default = %d]\n", nOutsMax );
-    Abc_Print( -2, "\t-m     : toggle selecting the largest cluster [default = %s]\n", fSetLargest? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9GroupProve( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Vec_Int_t * Gia_ManGroupProve( Gia_Man_t * p, char * pCommLine, int nGroupSize, int fVerbose );
-    Vec_Int_t * vStatus;
-    char * pCommLine = NULL;
-    int c, nGroupSize = 1, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "GSvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'G':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-G\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nGroupSize = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nGroupSize <= 0 )
-                goto usage;
-            break;
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by a file name.\n" );
-                goto usage;
-            }
-            pCommLine = argv[globalUtilOptind];
-            globalUtilOptind++;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9GroupProve(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( pCommLine == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9GroupProve(): Command line is not given.\n" );
-        return 1;
-    }
-    vStatus = Gia_ManGroupProve( pAbc->pGia, pCommLine, nGroupSize, fVerbose );
-    Vec_IntFree( vStatus );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &gprove [-GS num] [-vh]\n" );
-    Abc_Print( -2, "\t         proves multi-output testcase by splitting outputs into groups\n" );
-    Abc_Print( -2, "\t         (currently, group size more than one works only for \"bmc3\" and \"pdr\")\n" );
-    Abc_Print( -2, "\t-G num : the size of one group [default = %d]\n", nGroupSize );
-    Abc_Print( -2, "\t-S str : the command line to be executed for each group [default = %s]\n", pCommLine ? pCommLine : "none" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9MultiProve( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern int Gia_ManMultiProve( Gia_Man_t * p, Bmc_MulPar_t * pPars );
-    Vec_Int_t * vStatuses; int c;
-    Bmc_MulPar_t Pars, * pPars = &Pars;
-    memset( pPars, 0, sizeof(Bmc_MulPar_t) );
-    pPars->TimeOutGlo =  30;
-    pPars->TimeOutLoc =   2;
-    pPars->TimeOutInc = 100;
-    pPars->TimeOutGap =   0;
-    pPars->TimePerOut =   0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "TLMGHsdvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->TimeOutGlo = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->TimeOutGlo < 0 )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->TimeOutLoc = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->TimeOutLoc <= 0 )
-                goto usage;
-            break;
-        case 'M':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->TimeOutInc = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->TimeOutInc <= 0 )
-                goto usage;
-            break;
-        case 'G':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-G\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->TimeOutGap = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->TimeOutGap <= 0 )
-                goto usage;
-            break;
-        case 'H':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-H\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->TimePerOut = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->TimePerOut <= 0 )
-                goto usage;
-            break;
-        case 's':
-            pPars->fUseSyn ^= 1;
-            break;
-        case 'd':
-            pPars->fDumpFinal ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'w':
-            pPars->fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9MultiProve(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9MultiProve(): The problem is combinational.\n" );
-        return 1;
-    }
-    pAbc->Status = Gia_ManMultiProve( pAbc->pGia, pPars );
-    vStatuses = Abc_FrameDeriveStatusArray( pAbc->pGia->vSeqModelVec );
-    Abc_FrameReplacePoStatuses( pAbc, &vStatuses );        
-    Abc_FrameReplaceCexVec( pAbc, &pAbc->pGia->vSeqModelVec );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &mprove [-TLMGH num] [-sdvwh]\n" );
-    Abc_Print( -2, "\t         proves multi-output testcase by applying several engines\n" );
-    Abc_Print( -2, "\t-T num : approximate global runtime limit in seconds [default = %d]\n",     pPars->TimeOutGlo );
-    Abc_Print( -2, "\t-L num : approximate local runtime limit in seconds [default = %d]\n",      pPars->TimeOutLoc );
-    Abc_Print( -2, "\t-M num : percentage of local runtime limit increase [default = %d]\n",      pPars->TimeOutInc );
-    Abc_Print( -2, "\t-G num : approximate gap runtime limit in seconds [default = %d]\n",        pPars->TimeOutGap );
-    Abc_Print( -2, "\t-H num : timeout per output in miliseconds [default = %d]\n",               pPars->TimePerOut );
-    Abc_Print( -2, "\t-s     : toggle using combinational synthesis [default = %s]\n",            pPars->fUseSyn?      "yes": "no" );
-    Abc_Print( -2, "\t-d     : toggle dumping invariant into a file [default = %s]\n",            pPars->fDumpFinal?   "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n",             pPars->fVerbose?     "yes": "no" );
-    Abc_Print( -2, "\t-w     : toggle printing additional verbose information [default = %s]\n",  pPars->fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-#ifdef ABC_USE_PTHREADS
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9SplitProve( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern int Cec_GiaSplitTest( Gia_Man_t * p, int nProcs, int nTimeOut, int nIterMax, int LookAhead, int fVerbose, int fVeryVerbose );
-    int c, nProcs = 1, nTimeOut = 10, nIterMax = 0, LookAhead = 1, fVerbose = 0, fVeryVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "PTILvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'P':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-P\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            nProcs = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nProcs <= 0 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by a positive integer.\n" );
-                goto usage;
-            }
-            nTimeOut = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nTimeOut <= 0 )
-                goto usage;
-            break;
-        case 'I':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nIterMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nIterMax < 0 )
-                goto usage;
-            break;
-        case 'L':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            LookAhead = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( LookAhead <= 0 || LookAhead > 100 )
-            {
-                Abc_Print( -1, "Look-ahead value (\"-L <num>\") should be between 1 and 100.\n", LookAhead );
-                goto usage;
-            }
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'w':
-            fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9SplitProve(): There is no AIG.\n" );
-        return 1;
-    }
-    if ( Gia_ManRegNum(pAbc->pGia) > 0 )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9SplitProve(): The problem is sequential.\n" );
-        return 1;
-    }
-    pAbc->Status = Cec_GiaSplitTest( pAbc->pGia, nProcs, nTimeOut, nIterMax, LookAhead, fVerbose, fVeryVerbose );
-    pAbc->pCex = pAbc->pGia->pCexComb;  pAbc->pGia->pCexComb = NULL;
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &splitprove [-PTIL num] [-vwh]\n" );
-    Abc_Print( -2, "\t         proves CEC problem by case-splitting\n" );
-    Abc_Print( -2, "\t-P num : the number of concurrent processes [default = %d]\n",          nProcs );
-    Abc_Print( -2, "\t-T num : runtime limit in seconds per subproblem [default = %d]\n",     nTimeOut );
-    Abc_Print( -2, "\t-I num : the max number of iterations (0 = infinity) [default = %d]\n", nIterMax );
-    Abc_Print( -2, "\t-L num : maximum look-ahead during cofactoring [default = %d]\n",       LookAhead );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n",         fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-w     : toggle printing more verbose information [default = %s]\n",    fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-#endif
-
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Bmc( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    int c;
-    Bmc_AndPar_t Pars, * pPars = &Pars;
-    memset( pPars, 0, sizeof(Bmc_AndPar_t) );
-    pPars->nStart        =    0;  // starting timeframe
-    pPars->nFramesMax    =    0;  // maximum number of timeframes 
-    pPars->nFramesAdd    =   50;  // the number of additional frames
-    pPars->nConfLimit    =    0;  // maximum number of conflicts at a node
-    pPars->nTimeOut      =    0;  // timeout in seconds
-    pPars->fLoadCnf      =    0;  // dynamic CNF loading
-    pPars->fDumpFrames   =    0;  // dump unrolled timeframes
-    pPars->fUseSynth     =    0;  // use synthesis
-    pPars->fUseOldCnf    =    1;  // use old CNF construction
-    pPars->fVerbose      =    0;  // verbose 
-    pPars->fVeryVerbose  =    0;  // very verbose 
-    pPars->fNotVerbose   =    0;  // skip line-by-line print-out 
-    pPars->iFrame        =    0;  // explored up to this frame
-    pPars->nFailOuts     =    0;  // the number of failed outputs
-    pPars->nDropOuts     =    0;  // the number of dropped outputs
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "SFATdscvwh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nStart = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nStart < 0 )
-                goto usage;
-            break;
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nFramesMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nFramesMax < 0 )
-                goto usage;
-            break;
-        case 'A':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-A\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nFramesAdd = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nFramesAdd < 0 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nTimeOut = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nTimeOut < 0 )
-                goto usage;
-            break;
-        case 'd':
-            pPars->fDumpFrames ^= 1;
-            break;
-        case 's':
-            pPars->fUseSynth ^= 1;
-            break;
-        case 'c':
-            pPars->fUseOldCnf ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'w':
-            pPars->fVeryVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Bmc(): There is no AIG.\n" );
-        return 0;
-    }
-    if ( !pPars->fUseOldCnf && !Sdm_ManCanRead() )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Bmc(): Cannot input precomputed DSD information.\n" );
-        return 0;
-    }
-    pAbc->Status  = Gia_ManBmcPerform( pAbc->pGia, pPars );
-    pAbc->nFrames = pPars->iFrame;
-    Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexSeq );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &bmc [-SFAT num] [-dscvwh]\n" );
-    Abc_Print( -2, "\t         performs bounded model checking\n" );
-    Abc_Print( -2, "\t-S num : the starting timeframe [default = %d]\n",                      pPars->nStart );
-    Abc_Print( -2, "\t-F num : the maximum number of timeframes [default = %d]\n",            pPars->nFramesMax );
-    Abc_Print( -2, "\t-A num : the number of additional frames to unroll [default = %d]\n",   pPars->nFramesAdd );
-    Abc_Print( -2, "\t-T num : approximate timeout in seconds [default = %d]\n",              pPars->nTimeOut );
-    Abc_Print( -2, "\t-d     : toggle dumping unfolded timeframes [default = %s]\n",          pPars->fDumpFrames?  "yes": "no" );
-    Abc_Print( -2, "\t-s     : toggle synthesizing unrolled timeframes [default = %s]\n",     pPars->fUseSynth?    "yes": "no" );
-    Abc_Print( -2, "\t-c     : toggle using old CNF computation [default = %s]\n",            pPars->fUseOldCnf?   "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n",         pPars->fVerbose?     "yes": "no" );
-    Abc_Print( -2, "\t-w     : toggle printing information about unfolding [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9BCore( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    int c;
-    Bmc_BCorePar_t Pars, * pPars = &Pars;
-    memset( pPars, 0, sizeof(Bmc_BCorePar_t) );
-    pPars->iFrame        =   10;  // timeframe
-    pPars->iOutput       =    0;  // property output
-    pPars->nTimeOut      =    0;  // timeout in seconds
-    pPars->pFilePivots   = NULL;  // file name with AIG IDs of pivot objects
-    pPars->pFileProof    = NULL;  // file name to write the resulting proof
-    pPars->fVerbose      =    0;  // verbose output
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "FOTVvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->iFrame = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->iFrame < 0 )
-                goto usage;
-            break;
-        case 'O':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-O\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->iOutput = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->iOutput < 0 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nTimeOut = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nTimeOut < 0 )
-                goto usage;
-            break;
-        case 'V':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-V\" should be followed by a file name.\n" );
-                goto usage;
-            }
-            pPars->pFilePivots = argv[globalUtilOptind];
-            globalUtilOptind++;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9BCore(): There is no AIG.\n" );
-        return 0;
-    }
-    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9BCore(): AIG has no registers.\n" );
-        return 0;
-    }
-    // get the file name
-    if ( pPars->pFilePivots != NULL )
-    {
-        FILE * pFile;
-        pFile = fopen( pPars->pFilePivots, "r" );
-        if ( pFile == NULL )
-        {
-            Abc_Print( -1, "Abc_CommandAbc9BCore(): Cannot open file \"%s\" with pivot node IDs.\n", pPars->pFilePivots );
-            return 0;
-        }
-        fclose( pFile );
-    }
-    // get the file name
-    if ( argc == globalUtilOptind + 1 )
-    {
-        FILE * pFile;
-        pPars->pFileProof = argv[globalUtilOptind];
-        pFile = fopen( pPars->pFileProof, "wb" );
-        if ( pFile == NULL )
-        {
-            Abc_Print( -1, "Abc_CommandAbc9BCore(): Cannot open file \"%s\" for writing the proof.\n", pPars->pFileProof );
-            return 0;
-        }
-        fclose( pFile );
-    }
-    Bmc_ManBCorePerform( pAbc->pGia, pPars );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &bcore [-FOTV num] [-vh] <file>\n" );
-    Abc_Print( -2, "\t         records UNSAT core of the BMC instance\n" );
-    Abc_Print( -2, "\t-F num : the zero-based index of a timeframe [default = %d]\n",         pPars->iFrame );
-    Abc_Print( -2, "\t-O num : the zero-based index of a primary output [default = %d]\n",    pPars->iOutput );
-    Abc_Print( -2, "\t-T num : approximate timeout in seconds [default = %d]\n",              pPars->nTimeOut );
-    Abc_Print( -2, "\t-V file: file name with AIG IDs of pivot variables [default = no pivots]\n" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n",         pPars->fVerbose?     "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    Abc_Print( -2, "\t<file> : file name to write the resulting proof [default = stdout]\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9ICheck( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    int c, nFramesMax = 1, nTimeOut = 0, fEmpty = 0, fSearch = 1, fReverse = 0, fDump = 0, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "MTesrdvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'M':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFramesMax = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFramesMax <= 0 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nTimeOut = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nTimeOut < 0 )
-                goto usage;
-            break;
-        case 'e':
-            fEmpty ^= 1;
-            break;
-        case 's':
-            fSearch ^= 1;
-            break;
-        case 'r':
-            fReverse ^= 1;
-            break;
-        case 'd':
-            fDump ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9ICheck(): There is no AIG.\n" );
-        return 0;
-    }
-    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9ICheck(): The AIG is combinational.\n" );
-        return 0;
-    }
-    Vec_IntFreeP( &pAbc->vIndFlops );
-    if ( fSearch )
-        pAbc->vIndFlops = Bmc_PerformISearch( pAbc->pGia, nFramesMax, nTimeOut, fReverse, fDump, fVerbose );
-    else
-        Bmc_PerformICheck( pAbc->pGia, nFramesMax, nTimeOut, fEmpty, fVerbose );
-    pAbc->nIndFrames = pAbc->vIndFlops ? nFramesMax : 0;
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &icheck [-MT num] [-esrdvh]\n" );
-    Abc_Print( -2, "\t         performs specialized induction check\n" );
-    Abc_Print( -2, "\t-M num : the number of timeframes used for induction [default = %d]\n",    nFramesMax );
-    Abc_Print( -2, "\t-T num : approximate global runtime limit in seconds [default = %d]\n",    nTimeOut );
-    Abc_Print( -2, "\t-e     : toggle using empty set of next-state functions [default = %s]\n", fEmpty? "yes": "no" );
-    Abc_Print( -2, "\t-s     : toggle searching for a minimal subset [default = %s]\n",          fSearch? "yes": "no" );
-    Abc_Print( -2, "\t-r     : toggle searching in the reverse order [default = %s]\n",          fReverse? "yes": "no" );
-    Abc_Print( -2, "\t-d     : toggle printing out the resulting set [default = %s]\n",          fDump? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n",            fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9SatTest( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern void Bmc_LoadTest( Gia_Man_t * pGia, int fLoadCnf, int fVerbose );
-    int c, fLoadCnf = 0, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "cvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'c':
-            fLoadCnf ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9SatTest(): There is no AIG.\n" );
-        return 0;
-    }
-    Bmc_LoadTest( pAbc->pGia, fLoadCnf, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &sattest [-cvh]\n" );
-    Abc_Print( -2, "\t         performs testing of dynamic CNF loading\n" );
-    Abc_Print( -2, "\t-c     : toggle dynamic CNF loading [default = %s]\n",          fLoadCnf? "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9FFTest( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern void Gia_ParFfSetDefault( Bmc_ParFf_t * p );
-    extern void Gia_ManFaultTest( Gia_Man_t * p, Gia_Man_t * pG, Bmc_ParFf_t * pPars );
-    Bmc_ParFf_t Pars, * pPars = &Pars;
-    char * pFileName = NULL;
-    Gia_Man_t * pGold = NULL;
-    int c;
-    Gia_ParFfSetDefault( pPars );
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "ATSGsbduvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'A':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-A\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->Algo = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->Algo < 0 || pPars->Algo > 4 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            pPars->nTimeOut = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( pPars->nTimeOut < 0 )
-                goto usage;
-            break;
-        case 'S':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-S\" should be followed by string.\n" );
-                goto usage;
-            }
-            pPars->pFormStr = argv[globalUtilOptind];
-            globalUtilOptind++;
-            break;
-        case 'G':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-G\" should be followed by string.\n" );
-                goto usage;
-            }
-            pFileName = argv[globalUtilOptind];
-            globalUtilOptind++;
-            break;
-        case 's':
-            pPars->fStartPats ^= 1;
-            break;
-        case 'b':
-            pPars->fBasic ^= 1;
-            break;
-        case 'd':
-            pPars->fDump ^= 1;
-            break;
-        case 'u':
-            pPars->fDumpUntest ^= 1;
-            break;
-        case 'v':
-            pPars->fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pPars->Algo == 0 && pPars->pFormStr == NULL )
-    {
-        Abc_Print( -1, "Formula string (-S <str>) should be selected when algorithm is 0 (-A 0).\n" );
-        return 0;
-    }
-    if ( pPars->Algo != 0 && pPars->pFormStr != NULL )
-    {
-        Abc_Print( -1, "Algorithm should be 0 (-A 0) when formula string is selected (-S <str>).\n" );
-        return 0;
-    }
-    // get the file name
-    if ( argc == globalUtilOptind + 1 )
-    {
-        FILE * pFile;
-        pPars->pFileName = argv[globalUtilOptind];
-        pFile = fopen( pPars->pFileName, "r" );
-        if ( pFile == NULL )
-        {
-            Abc_Print( -1, "Cannot open file \"%s\" with the input test patterns.\n", pPars->pFileName );
-            return 0;
-        }
-        fclose( pFile );
-    }
-    // check other conditions
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9FFTest(): There is no AIG.\n" );
-        return 0;
-    }
-    if ( Gia_ManRegNum(pAbc->pGia) == 0 && pPars->Algo == 1 )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9FFTest(): For delay testing, AIG should be sequential.\n" );
-        return 0;
-    }
-    // check if the file is valid
-    if ( pFileName )
-    {
-        FILE * pFile = fopen( pFileName, "r" );
-        if ( pFile == NULL )
-        {
-            Abc_Print( -1, "Abc_CommandAbc9FFTest(): File name \"%s\" with golden model is invalid.\n", pFileName );
-            return 0;
-        }
-        fclose( pFile );
-        pGold = Gia_AigerRead( pFileName, 0, 0 );
-        if ( pGold == NULL )
-        {
-            Abc_Print( -1, "Abc_CommandAbc9FFTest(): Cannot read file \"%s\" with golden model.\n", pFileName );
-            return 0;
-        }
-        if ( Gia_ManPiNum(pAbc->pGia) != Gia_ManPiNum(pGold) )
-        {
-            Gia_ManStop( pGold );
-            Abc_Print( -1, "Abc_CommandAbc9FFTest(): Old model and gold model have different number of PIs.\n" );
-            return 0;
-        }
-        if ( Gia_ManPoNum(pAbc->pGia) != Gia_ManPoNum(pGold) )
-        {
-            Gia_ManStop( pGold );
-            Abc_Print( -1, "Abc_CommandAbc9FFTest(): Old model and gold model have different number of POs.\n" );
-            return 0;
-        }
-        printf( "Entered spec AIG from file \"%s\".\n", pFileName );
-    }
-    Gia_ManFaultTest( pAbc->pGia, pGold ? pGold : pAbc->pGia, pPars );
-    Gia_ManStopP( &pGold );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &fftest [-AT num] [-sbduvh] <file> [-G file] [-S str]\n" );
-    Abc_Print( -2, "\t          performs functional fault test generation\n" );
-    Abc_Print( -2, "\t-A num  : selects fault model for all gates [default = %d]\n", pPars->Algo );
-    Abc_Print( -2, "\t                0: fault model is not selected (use -S str)\n" );
-    Abc_Print( -2, "\t                1: delay fault testing for sequential circuits\n" );
-    Abc_Print( -2, "\t                2: traditional stuck-at fault: -S (((a&b)&~p)|q)\n" );
-    Abc_Print( -2, "\t                3: complement fault: -S ((a&b)^p)\n" );
-    Abc_Print( -2, "\t                4: functionally observable fault\n" );
-    Abc_Print( -2, "\t-T num  : specifies approximate runtime limit in seconds [default = %d]\n",        pPars->nTimeOut );
-    Abc_Print( -2, "\t-s      : toggles starting with the all-0 and all-1 patterns [default = %s]\n",    pPars->fStartPats?  "yes": "no" );
-    Abc_Print( -2, "\t-b      : toggles testing for single faults only [default = %s]\n",                pPars->fBasic?      "yes": "no" );
-    Abc_Print( -2, "\t-d      : toggles dumping test patterns into file \"tests.txt\" [default = %s]\n", pPars->fDump?       "yes": "no" );
-    Abc_Print( -2, "\t-u      : toggles dumping untestable faults into \"untest.txt\" [default = %s]\n", pPars->fDumpUntest? "yes": "no" );
-    Abc_Print( -2, "\t-v      : toggles printing verbose information [default = %s]\n",                  pPars->fVerbose?    "yes": "no" );
-    Abc_Print( -2, "\t-h      : print the command usage\n");
-    Abc_Print( -2, "\t<file>  : (optional) file name with input test patterns\n\n");
-    Abc_Print( -2, "\t-G file : (optional) file name with the golden model\n\n");
-    Abc_Print( -2, "\t-S str  : (optional) string representing the fault model\n");
-    Abc_Print( -2, "\t          The following notations are used:\n");
-    Abc_Print( -2, "\t            Functional variables: {a,b} (both a and b are always present)\n");
-    Abc_Print( -2, "\t            Parameter variables: {p,q,r,s,t,u,v,w} (any number from 1 to 8)\n");
-    Abc_Print( -2, "\t            Boolean operators: AND(&), OR(|), XOR(^), MUX(?:), NOT(~)\n");
-    Abc_Print( -2, "\t            Parantheses should be used around each operator. Spaces not allowed.\n");
-    Abc_Print( -2, "\t            Complement (~) is only allowed before variables (use DeMorgan law).\n");
-    Abc_Print( -2, "\t            Examples:\n");
-    Abc_Print( -2, "\t              (((a&b)&~p)|q)        stuck-at-0/1 at the output\n");
-    Abc_Print( -2, "\t              (((a&~p)|q)&b)        stuck-at-0/1 at input a\n");
-    Abc_Print( -2, "\t              (((a|p)&(b|q))&~r)    stuck-at-1 at the inputs and stuck-at-0 at the output\n");
-    Abc_Print( -2, "\t              (((a&~p)&(b&~q))|r)   stuck-at-0 at the inputs and stuck-at-1 at the output\n");
-    Abc_Print( -2, "\t              ((a&b)^p)             complement at the output\n");
-    Abc_Print( -2, "\t              (((a^p)&(b^q))^r)     complement at the inputs and at the output\n");
-    Abc_Print( -2, "\t              (a?(b?~s:r):(b?q:p))  functionally observable fault at the output\n");
-    Abc_Print( -2, "\t              (p?(a|b):(a&b))       replace AND by OR\n");    
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Inse( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Vec_Int_t * Gia_ManInseTest( Gia_Man_t * p, Vec_Int_t * vInit, int nFrames, int nWords, int nTimeOut, int fSim, int fVerbose );
-    int c, nFrames = 10, nWords = 1000, nTimeOut = 0, fSim = 0, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "FWTsvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFrames = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFrames < 0 )
-                goto usage;
-            break;
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nWords = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nWords < 0 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nTimeOut = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nTimeOut < 0 )
-                goto usage;
-            break;
-        case 's':
-            fSim ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Inse(): There is no AIG.\n" );
-        return 0;
-    }
-    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Inse(): AIG is combinational.\n" );
-        return 0;
-    }
-    if ( pAbc->pGia->vInitClasses != NULL )
-    {
-        Abc_Print( 1, "Abc_CommandAbc9Inse(): All-0 initial state is assumed.\n" );
-        Vec_IntFreeP( &pAbc->pGia->vInitClasses );
-    }
-    pAbc->pGia->vInitClasses = Gia_ManInseTest( pAbc->pGia, NULL, nFrames, nWords, nTimeOut, fSim, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &inse [-FWT num] [-svh]\n" );
-    Abc_Print( -2, "\t         experimental procedure\n" );
-    Abc_Print( -2, "\t-F num : the number of timeframes [default = %d]\n",                    nFrames );
-    Abc_Print( -2, "\t-W num : the number of machine words [default = %d]\n",                 nWords );
-    Abc_Print( -2, "\t-T num : approximate global runtime limit in seconds [default = %d]\n", nTimeOut );
-    Abc_Print( -2, "\t-s     : toggles using ternary simulation [default = %s]\n",            fSim?     "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggles printing verbose information [default = %s]\n",        fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Maxi( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Vec_Int_t * Gia_ManMaxiTest( Gia_Man_t * p, Vec_Int_t * vInit, int nFrames, int nWords, int nTimeOut, int fSim, int fVerbose );
-    Vec_Int_t * vTemp;
-    int c, nFrames = 5, nWords = 1000, nTimeOut = 0, fSim = 0, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "FWTsvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFrames = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFrames < 0 )
-                goto usage;
-            break;
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nWords = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nWords < 0 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nTimeOut = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nTimeOut < 0 )
-                goto usage;
-            break;
-        case 's':
-            fSim ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Maxi(): There is no AIG.\n" );
-        return 0;
-    }
-    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Maxi(): AIG is combinational.\n" );
-        return 0;
-    }
-    pAbc->pGia->vInitClasses = Gia_ManMaxiTest( pAbc->pGia, vTemp = pAbc->pGia->vInitClasses, nFrames, nWords, nTimeOut, fSim, fVerbose );
-    Vec_IntFreeP( &vTemp );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &maxi [-FWT num] [-svh]\n" );
-    Abc_Print( -2, "\t         experimental procedure\n" );
-    Abc_Print( -2, "\t-F num : the number of timeframes [default = %d]\n",                    nFrames );
-    Abc_Print( -2, "\t-W num : the number of machine words [default = %d]\n",                 nWords );
-    Abc_Print( -2, "\t-T num : approximate global runtime limit in seconds [default = %d]\n", nTimeOut );
-    Abc_Print( -2, "\t-s     : toggles using ternary simulation [default = %s]\n",            fSim?     "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggles printing verbose information [default = %s]\n",        fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Bmci( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern int Gia_ManBmciTest( Gia_Man_t * p, Vec_Int_t * vInit, int nFrames, int nWords, int nTimeOut, int fSim, int fVerbose );
-    int c, nFrames = 1000, nWords = 1000, nTimeOut = 0, fSim = 0, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "FWTsvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFrames = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFrames < 0 )
-                goto usage;
-            break;
-        case 'W':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nWords = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nWords < 0 )
-                goto usage;
-            break;
-        case 'T':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nTimeOut = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nTimeOut < 0 )
-                goto usage;
-            break;
-        case 's':
-            fSim ^= 1;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Bmci(): There is no AIG.\n" );
-        return 0;
-    }
-    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Bmci(): AIG is combinational.\n" );
-        return 0;
-    }
-    if ( pAbc->pGia->vInitClasses == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Bmci(): Init array is not given.\n" );
-        return 0;
-    }
-    Gia_ManBmciTest( pAbc->pGia, pAbc->pGia->vInitClasses, nFrames, nWords, nTimeOut, fSim, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &bmci [-FWT num] [-svh]\n" );
-    Abc_Print( -2, "\t         experimental procedure\n" );
-    Abc_Print( -2, "\t-F num : the number of timeframes [default = %d]\n",                    nFrames );
-    Abc_Print( -2, "\t-W num : the number of machine words [default = %d]\n",                 nWords );
-    Abc_Print( -2, "\t-T num : approximate global runtime limit in seconds [default = %d]\n", nTimeOut );
-    Abc_Print( -2, "\t-s     : toggles using ternary simulation [default = %s]\n",            fSim?     "yes": "no" );
-    Abc_Print( -2, "\t-v     : toggles printing verbose information [default = %s]\n",        fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9PoXsim( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Vec_Int_t * Gia_ManPoXSim( Gia_Man_t * p, int nFrames, int fVerbose );
-    int c, nFrames = 1000, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Fvh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'F':
-            if ( globalUtilOptind >= argc )
-            {
-                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
-                goto usage;
-            }
-            nFrames = atoi(argv[globalUtilOptind]);
-            globalUtilOptind++;
-            if ( nFrames < 0 )
-                goto usage;
-            break;
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Bmci(): There is no AIG.\n" );
-        return 0;
-    }
-    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Bmci(): AIG is combinational.\n" );
-        return 0;
-    }
-    Vec_IntFreeP( &pAbc->vAbcObjIds );
-    pAbc->vAbcObjIds = Gia_ManPoXSim( pAbc->pGia, nFrames, fVerbose );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &poxsim [-F num] [-vh]\n" );
-    Abc_Print( -2, "\t         X-valued simulation of the multi-output sequential miter\n" );
-    Abc_Print( -2, "\t-F num : the number of timeframes [default = %d]\n",                    nFrames );
-    Abc_Print( -2, "\t-v     : toggles printing verbose information [default = %s]\n",        fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    []
-
-  Description []
-
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_CommandAbc9Demiter( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
-    extern Gia_Man_t * Gia_ManDupDemiter( Gia_Man_t * p, int fVerbose );
-    Gia_Man_t * pTemp;
-    int c, fVerbose = 0;
-    Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
-    {
-        switch ( c )
-        {
-        case 'v':
-            fVerbose ^= 1;
-            break;
-        case 'h':
-            goto usage;
-        default:
-            goto usage;
-        }
-    }
-    if ( pAbc->pGia == NULL )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Demiter(): There is no AIG.\n" );
-        return 0;
-    }
-    if ( Gia_ManPoNum(pAbc->pGia) != 1 )
-    {
-        Abc_Print( -1, "Abc_CommandAbc9Demiter(): Miter should have one output.\n" );
-        return 0;
-    }
-    pTemp = Gia_ManDupDemiter( pAbc->pGia, fVerbose );
-    Abc_FrameUpdateGia( pAbc, pTemp );
-    if ( fVerbose )
-        Gia_ManPrintStatsMiter( pTemp, 0 );
-    return 0;
-
-usage:
-    Abc_Print( -2, "usage: &demiter [-vh]\n" );
-    Abc_Print( -2, "\t         decomposes a single-output miter\n" );
-    Abc_Print( -2, "\t-v     : toggles printing verbose information [default = %s]\n",  fVerbose? "yes": "no" );
-    Abc_Print( -2, "\t-h     : print the command usage\n");
+
+//#define USE_MINISAT22
+
+static int Abc_CommandPrintStats             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandPrintExdc              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandPrintIo                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandPrintLatch             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandPrintFanio             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandPrintMffc              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandPrintFactor            ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandPrintLevel             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandPrintSupport           ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandPrintSymms             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandPrintUnate             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandPrintAuto              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandPrintKMap              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandPrintGates             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandPrintSharing           ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandPrintXCut              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandPrintDsd               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandPrintCone              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandPrintMiter             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandPrintStatus            ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandPrintDelay             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+
+static int Abc_CommandShow                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandShowBdd                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandShowCut                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+
+static int Abc_CommandCollapse               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandStrash                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandBalance                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandMuxStruct              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandMulti                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandRenode                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandCleanup                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandSweep                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandFastExtract            ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandEliminate              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDisjoint               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandSparsify               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandLutpack                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandLutmin                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+//static int Abc_CommandImfs                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandMfs                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandMfs2                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandTrace                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandSpeedup                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandPowerdown              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAddBuffs               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+//static int Abc_CommandMerge                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandTestDec                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandTestNpn                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandTestRPO                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+
+static int Abc_CommandRewrite                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandRefactor               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandRestructure            ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandResubstitute           ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandRr                     ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandCascade                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandExtract                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandVarMin                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+
+static int Abc_CommandLogic                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandComb                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandMiter                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDemiter                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandOrPos                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAndPos                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandZeroPo                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandSwapPos                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandRemovePo               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDropSat                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAddPi                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAppend                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandPutOnTop               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandFrames                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDFrames                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandSop                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandBdd                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAig                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandReorder                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandBidec                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandOrder                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandMuxes                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandCubes                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandSplitSop               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandExtSeqDcs              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandReach                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandCone                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandNode                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandTopmost                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandTopAnd                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandTrim                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandShortNames             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandMoveNames              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandExdcFree               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandExdcGet                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandExdcSet                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandCareSet                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandCut                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandEspresso               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandGen                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandGenFsm                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandCover                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDouble                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandInter                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandBb2Wb                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandOutdec                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandNodeDup                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandTestColor              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandTest                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
+
+static int Abc_CommandQuaVar                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandQuaRel                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandQuaReach               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandSenseInput             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandNpnLoad                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandNpnSave                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+
+static int Abc_CommandSendAig                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandSendStatus             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+
+static int Abc_CommandBackup                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandRestore                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+
+static int Abc_CommandMinisat                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandMinisimp               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+
+static int Abc_CommandIStrash                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandICut                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandIRewrite               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDRewrite               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDRefactor              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDc2                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDChoice                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDch                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDrwsat                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandIRewriteSeq            ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandIResyn                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandISat                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandIFraig                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDFraig                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandCSweep                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDProve                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbSec                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandSimSec                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandMatch                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
+//static int Abc_CommandHaig                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandQbf                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
+
+static int Abc_CommandFraig                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandFraigTrust             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandFraigStore             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandFraigRestore           ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandFraigClean             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandFraigSweep             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandFraigDress             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+
+static int Abc_CommandRecStart3              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandRecStop3               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandRecPs3                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandRecAdd3                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandRecDump3               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandRecMerge3              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+
+static int Abc_CommandMap                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAmap                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandUnmap                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAttach                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandSuperChoice            ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandSuperChoiceLut         ( Abc_Frame_t * pAbc, int argc, char ** argv );
+
+//static int Abc_CommandFpga                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
+//static int Abc_CommandFpgaFast               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandIf                     ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandIfif                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
+
+static int Abc_CommandDsdSave                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDsdLoad                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDsdFree                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDsdPs                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDsdMatch               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDsdMerge               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDsdFilter              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+
+static int Abc_CommandScut                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandInit                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandZero                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandUndc                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandOneHot                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandPipe                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandSeq                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandUnseq                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandRetime                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDRetime                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandFlowRetime             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandCRetime                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandSeqFpga                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandSeqMap                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandSeqSweep               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandSeqSweep2              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandTestSeqSweep           ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandTestScorr              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandLcorr                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandSeqCleanup             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandCycle                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandXsim                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandSim                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandSim3                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDarPhase               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandSynch                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandClockGate              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandExtWin                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandInsWin                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandPermute                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandUnpermute              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandCubeEnum               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+
+static int Abc_CommandCec                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDCec                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDSec                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandSat                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDSat                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandPSat                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandProve                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandIProve                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDebug                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandBmc                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandBmc2                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandBmc3                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandBmcInter               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandIndcut                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandEnlarge                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandTempor                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandInduction              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandConstr                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandUnfold                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandFold                   ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandUnfold2                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandFold2                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandBm                     ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandBm2                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandSaucy                  ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandTestCex                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandPdr                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandReconcile              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandCexSave                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandCexLoad                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandCexCut                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandCexMerge               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+//static int Abc_CommandCexMin                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDualRail               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandBlockPo                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandIso                    ( Abc_Frame_t * pAbc, int argc, char ** argv );
+
+static int Abc_CommandTraceStart             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandTraceCheck             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+
+static int Abc_CommandAbc9Get                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Put                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Save               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Load               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Read               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9ReadBlif           ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9ReadCBlif          ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9ReadStg            ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9ReadVer            ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9WriteVer           ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Write              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Ps                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9PFan               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9PSig               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Status             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9MuxProfile         ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Show               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9SetRegNum          ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Strash             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Topand             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Add1Hot            ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Cof                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Trim               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Dfs                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Sim                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Sim3               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Resim              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9SpecI              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Equiv              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Equiv2             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Equiv3             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Semi               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Times              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Frames             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Retime             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Enable             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Dc2                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Dsd                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Bidec              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Shrink             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Fx                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Balance            ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9BalanceLut         ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Syn2               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Syn3               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Syn4               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Synch2             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9False              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Miter              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Miter2             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Append             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Scl                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Lcorr              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Scorr              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Choice             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Sat                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9SatEnum            ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Fraig              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9CFraig             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Srm                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Srm2               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Filter             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Reduce             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9EquivMark          ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9EquivFilter        ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Cec                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Verify             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Sweep              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Force              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Embed              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Sopb               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Dsdb               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Flow               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Flow2              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9If                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Iff                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9If2                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Jf                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Kf                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Lf                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Mf                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Nf                 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Unmap              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Struct             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Trace              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Speedup            ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Era                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Dch                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Rpm                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9BackReach          ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Posplit            ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9ReachM             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9ReachP             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9ReachN             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9ReachY             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Undo               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Iso                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9CexInfo            ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Cycle              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Cone               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Slice              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9PoPart             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9GroupProve         ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9MultiProve         ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9SplitProve         ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Bmc                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9ChainBmc           ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9BCore              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9ICheck             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9SatTest            ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9FFTest             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Qbf                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Inse               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Maxi               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Bmci               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9PoXsim             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Demiter            ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Fadds              ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Mfs                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+//static int Abc_CommandAbc9PoPart2            ( Abc_Frame_t * pAbc, int argc, char ** argv );
+//static int Abc_CommandAbc9CexCut             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+//static int Abc_CommandAbc9CexMerge           ( Abc_Frame_t * pAbc, int argc, char ** argv );
+//static int Abc_CommandAbc9CexMin             ( Abc_Frame_t * pAbc, int argc, char ** argv );
+
+static int Abc_CommandAbc9AbsDerive          ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9AbsRefine          ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9GlaDerive          ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9GlaRefine          ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9GlaShrink          ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Gla                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Vta                ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Vta2Gla            ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Gla2Vta            ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Fla2Gla            ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Gla2Fla            ( Abc_Frame_t * pAbc, int argc, char ** argv );
+
+static int Abc_CommandAbc9Test               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+
+extern int Abc_CommandAbcLivenessToSafety    ( Abc_Frame_t * pAbc, int argc, char ** argv );
+extern int Abc_CommandAbcLivenessToSafetySim ( Abc_Frame_t * pAbc, int argc, char ** argv );
+extern int Abc_CommandAbcLivenessToSafetyWithLTL( Abc_Frame_t * pAbc, int argc, char ** argv );
+extern int Abc_CommandCS_kLiveness           ( Abc_Frame_t * pAbc, int argc, char ** argv );
+extern int Abc_CommandNChooseK               ( Abc_Frame_t * pAbc, int argc, char ** argv );
+
+extern Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fExors, int fRegisters );
+extern Abc_Ntk_t * Abc_NtkFromAigPhase( Aig_Man_t * pMan );
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Abc_FrameReplaceCex( Abc_Frame_t * pAbc, Abc_Cex_t ** ppCex )
+{
+    // update CEX
+    ABC_FREE( pAbc->pCex );
+    pAbc->pCex = *ppCex;
+    *ppCex = NULL;
+    // remove CEX vector
+    if ( pAbc->vCexVec )
+    {
+        Vec_PtrFreeFree( pAbc->vCexVec );
+        pAbc->vCexVec = NULL;
+    }
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Abc_FrameReplaceCexVec( Abc_Frame_t * pAbc, Vec_Ptr_t ** pvCexVec )
+{
+    // update CEX vector
+    if ( pAbc->vCexVec )
+        Vec_PtrFreeFree( pAbc->vCexVec );
+    pAbc->vCexVec = *pvCexVec;
+    *pvCexVec = NULL;
+    // remove CEX
+    ABC_FREE( pAbc->pCex );
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Abc_FrameReplacePoEquivs( Abc_Frame_t * pAbc, Vec_Ptr_t ** pvPoEquivs )
+{
+    if ( pAbc->vPoEquivs )
+        Vec_VecFree( (Vec_Vec_t *)pAbc->vPoEquivs );
+    pAbc->vPoEquivs = *pvPoEquivs;
+    *pvPoEquivs = NULL;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Abc_FrameReplacePoStatuses( Abc_Frame_t * pAbc, Vec_Int_t ** pvStatuses )
+{
+    if ( pAbc->vStatuses )
+        Vec_IntFree( pAbc->vStatuses );
+    pAbc->vStatuses = *pvStatuses;
+    *pvStatuses = NULL;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Derives array of statuses from the array of CEXes.]
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Vec_Int_t * Abc_FrameDeriveStatusArray( Vec_Ptr_t * vCexes )
+{
+    Vec_Int_t * vStatuses;
+    Abc_Cex_t * pCex;
+    int i;
+    if ( vCexes == NULL )
+        return NULL;
+    vStatuses = Vec_IntAlloc( Vec_PtrSize(vCexes) );
+    Vec_IntFill( vStatuses, Vec_PtrSize(vCexes), -1 ); // assume UNDEC
+    Vec_PtrForEachEntry( Abc_Cex_t *, vCexes, pCex, i )
+        if ( pCex != NULL )
+            Vec_IntWriteEntry( vStatuses, i, 0 ); // set this output as SAT
+    return vStatuses;    
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Abc_FrameClearDesign()
+{
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Abc_FrameUpdateGia( Abc_Frame_t * pAbc, Gia_Man_t * pNew )
+{
+    if ( pNew == NULL )
+    {
+        Abc_Print( -1, "Abc_FrameUpdateGia(): Tranformation has failed.\n" );
+        return;
+    }
+    if ( Gia_ManPoNum(pNew) == 0 )
+        Abc_Print( 0, "The current GIA has no primary outputs. Some commands may not work correctly.\n" );
+    if ( pNew == pAbc->pGia )
+        return;
+    // transfer names
+    if (!pNew->vNamesIn && pAbc->pGia && pAbc->pGia->vNamesIn && Gia_ManCiNum(pNew) == Vec_PtrSize(pAbc->pGia->vNamesIn))
+    {
+        pNew->vNamesIn = pAbc->pGia->vNamesIn;
+        pAbc->pGia->vNamesIn = NULL;
+    }
+    if (!pNew->vNamesOut && pAbc->pGia && pAbc->pGia->vNamesOut && Gia_ManCoNum(pNew) == Vec_PtrSize(pAbc->pGia->vNamesOut))
+    {
+        pNew->vNamesOut = pAbc->pGia->vNamesOut;
+        pAbc->pGia->vNamesOut = NULL;
+    }
+    // update
+    if ( pAbc->pGia2 )
+        Gia_ManStop( pAbc->pGia2 );
+    pAbc->pGia2 = pAbc->pGia;
+    pAbc->pGia  = pNew;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Gia_Man_t * Abc_FrameGetGia( Abc_Frame_t * pAbc )
+{
+    Gia_Man_t * pGia;
+    if ( pAbc->pGia2 )
+        Gia_ManStop( pAbc->pGia2 );
+    pAbc->pGia2 = NULL;
+    pGia = pAbc->pGia;
+    pAbc->pGia = NULL;
+    return pGia;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Abc_Init( Abc_Frame_t * pAbc )
+{
+    Cmd_CommandAdd( pAbc, "Printing",     "print_stats",   Abc_CommandPrintStats,       0 );
+    Cmd_CommandAdd( pAbc, "Printing",     "print_exdc",    Abc_CommandPrintExdc,        0 );
+    Cmd_CommandAdd( pAbc, "Printing",     "print_io",      Abc_CommandPrintIo,          0 );
+    Cmd_CommandAdd( pAbc, "Printing",     "print_latch",   Abc_CommandPrintLatch,       0 );
+    Cmd_CommandAdd( pAbc, "Printing",     "print_fanio",   Abc_CommandPrintFanio,       0 );
+    Cmd_CommandAdd( pAbc, "Printing",     "print_mffc",    Abc_CommandPrintMffc,        0 );
+    Cmd_CommandAdd( pAbc, "Printing",     "print_factor",  Abc_CommandPrintFactor,      0 );
+    Cmd_CommandAdd( pAbc, "Printing",     "print_level",   Abc_CommandPrintLevel,       0 );
+    Cmd_CommandAdd( pAbc, "Printing",     "print_supp",    Abc_CommandPrintSupport,     0 );
+    Cmd_CommandAdd( pAbc, "Printing",     "print_symm",    Abc_CommandPrintSymms,       0 );
+    Cmd_CommandAdd( pAbc, "Printing",     "print_unate",   Abc_CommandPrintUnate,       0 );
+    Cmd_CommandAdd( pAbc, "Printing",     "print_auto",    Abc_CommandPrintAuto,        0 );
+    Cmd_CommandAdd( pAbc, "Printing",     "print_kmap",    Abc_CommandPrintKMap,        0 );
+    Cmd_CommandAdd( pAbc, "Printing",     "print_gates",   Abc_CommandPrintGates,       0 );
+    Cmd_CommandAdd( pAbc, "Printing",     "print_sharing", Abc_CommandPrintSharing,     0 );
+    Cmd_CommandAdd( pAbc, "Printing",     "print_xcut",    Abc_CommandPrintXCut,        0 );
+    Cmd_CommandAdd( pAbc, "Printing",     "print_dsd",     Abc_CommandPrintDsd,         0 );
+    Cmd_CommandAdd( pAbc, "Printing",     "print_cone",    Abc_CommandPrintCone,        0 );
+    Cmd_CommandAdd( pAbc, "Printing",     "print_miter",   Abc_CommandPrintMiter,       0 );
+    Cmd_CommandAdd( pAbc, "Printing",     "print_status",  Abc_CommandPrintStatus,      0 );
+    Cmd_CommandAdd( pAbc, "Printing",     "print_delay",   Abc_CommandPrintDelay,       0 );
+
+    Cmd_CommandAdd( pAbc, "Printing",     "show",          Abc_CommandShow,             0 );
+    Cmd_CommandAdd( pAbc, "Printing",     "show_bdd",      Abc_CommandShowBdd,          0 );
+    Cmd_CommandAdd( pAbc, "Printing",     "show_cut",      Abc_CommandShowCut,          0 );
+
+    Cmd_CommandAdd( pAbc, "Synthesis",    "collapse",      Abc_CommandCollapse,         1 );
+    Cmd_CommandAdd( pAbc, "Synthesis",    "strash",        Abc_CommandStrash,           1 );
+    Cmd_CommandAdd( pAbc, "Synthesis",    "balance",       Abc_CommandBalance,          1 );
+    Cmd_CommandAdd( pAbc, "Synthesis",    "mux_struct",    Abc_CommandMuxStruct,        1 );
+    Cmd_CommandAdd( pAbc, "Synthesis",    "multi",         Abc_CommandMulti,            1 );
+    Cmd_CommandAdd( pAbc, "Synthesis",    "renode",        Abc_CommandRenode,           1 );
+    Cmd_CommandAdd( pAbc, "Synthesis",    "cleanup",       Abc_CommandCleanup,          1 );
+    Cmd_CommandAdd( pAbc, "Synthesis",    "sweep",         Abc_CommandSweep,            1 );
+    Cmd_CommandAdd( pAbc, "Synthesis",    "fx",            Abc_CommandFastExtract,      1 );
+    Cmd_CommandAdd( pAbc, "Synthesis",    "eliminate",     Abc_CommandEliminate,        1 );
+    Cmd_CommandAdd( pAbc, "Synthesis",    "dsd",           Abc_CommandDisjoint,         1 );
+    Cmd_CommandAdd( pAbc, "Synthesis",    "sparsify",      Abc_CommandSparsify,         1 );
+    Cmd_CommandAdd( pAbc, "Synthesis",    "lutpack",       Abc_CommandLutpack,          1 );
+    Cmd_CommandAdd( pAbc, "Synthesis",    "lutmin",        Abc_CommandLutmin,           1 );
+//    Cmd_CommandAdd( pAbc, "Synthesis",    "imfs",          Abc_CommandImfs,             1 );
+    Cmd_CommandAdd( pAbc, "Synthesis",    "mfs",           Abc_CommandMfs,              1 );
+    Cmd_CommandAdd( pAbc, "Synthesis",    "mfs2",          Abc_CommandMfs2,             1 );
+    Cmd_CommandAdd( pAbc, "Synthesis",    "trace",         Abc_CommandTrace,            0 );
+    Cmd_CommandAdd( pAbc, "Synthesis",    "speedup",       Abc_CommandSpeedup,          1 );
+    Cmd_CommandAdd( pAbc, "Synthesis",    "powerdown",     Abc_CommandPowerdown,        1 );
+    Cmd_CommandAdd( pAbc, "Synthesis",    "addbuffs",      Abc_CommandAddBuffs,         1 );
+//    Cmd_CommandAdd( pAbc, "Synthesis",    "merge",         Abc_CommandMerge,            1 );
+    Cmd_CommandAdd( pAbc, "Synthesis",    "testdec",       Abc_CommandTestDec,          0 );
+    Cmd_CommandAdd( pAbc, "Synthesis",    "testnpn",       Abc_CommandTestNpn,          0 );
+    Cmd_CommandAdd( pAbc, "LogiCS",       "testrpo",       Abc_CommandTestRPO,          0 );
+
+    Cmd_CommandAdd( pAbc, "Synthesis",    "rewrite",       Abc_CommandRewrite,          1 );
+    Cmd_CommandAdd( pAbc, "Synthesis",    "refactor",      Abc_CommandRefactor,         1 );
+//    Cmd_CommandAdd( pAbc, "Synthesis",    "restructure",   Abc_CommandRestructure,      1 );
+    Cmd_CommandAdd( pAbc, "Synthesis",    "resub",         Abc_CommandResubstitute,     1 );
+//    Cmd_CommandAdd( pAbc, "Synthesis",    "rr",            Abc_CommandRr,               1 );
+    Cmd_CommandAdd( pAbc, "Synthesis",    "cascade",       Abc_CommandCascade,          1 );
+    Cmd_CommandAdd( pAbc, "Synthesis",    "extract",       Abc_CommandExtract,          1 );
+    Cmd_CommandAdd( pAbc, "Synthesis",    "varmin",        Abc_CommandVarMin,           0 );
+
+    Cmd_CommandAdd( pAbc, "Various",      "logic",         Abc_CommandLogic,            1 );
+    Cmd_CommandAdd( pAbc, "Various",      "comb",          Abc_CommandComb,             1 );
+    Cmd_CommandAdd( pAbc, "Various",      "miter",         Abc_CommandMiter,            1 );
+    Cmd_CommandAdd( pAbc, "Various",      "demiter",       Abc_CommandDemiter,          1 );
+    Cmd_CommandAdd( pAbc, "Various",      "orpos",         Abc_CommandOrPos,            1 );
+    Cmd_CommandAdd( pAbc, "Various",      "andpos",        Abc_CommandAndPos,           1 );
+    Cmd_CommandAdd( pAbc, "Various",      "zeropo",        Abc_CommandZeroPo,           1 );
+    Cmd_CommandAdd( pAbc, "Various",      "swappos",       Abc_CommandSwapPos,          1 );
+    Cmd_CommandAdd( pAbc, "Various",      "removepo",      Abc_CommandRemovePo,         1 );
+    Cmd_CommandAdd( pAbc, "Various",      "dropsat",       Abc_CommandDropSat,          1 );
+    Cmd_CommandAdd( pAbc, "Various",      "addpi",         Abc_CommandAddPi,            1 );
+    Cmd_CommandAdd( pAbc, "Various",      "append",        Abc_CommandAppend,           1 );
+    Cmd_CommandAdd( pAbc, "Various",      "putontop",      Abc_CommandPutOnTop,         1 );
+    Cmd_CommandAdd( pAbc, "Various",      "frames",        Abc_CommandFrames,           1 );
+    Cmd_CommandAdd( pAbc, "Various",      "dframes",       Abc_CommandDFrames,          1 );
+    Cmd_CommandAdd( pAbc, "Various",      "sop",           Abc_CommandSop,              0 );
+    Cmd_CommandAdd( pAbc, "Various",      "bdd",           Abc_CommandBdd,              0 );
+    Cmd_CommandAdd( pAbc, "Various",      "aig",           Abc_CommandAig,              0 );
+    Cmd_CommandAdd( pAbc, "Various",      "reorder",       Abc_CommandReorder,          0 );
+    Cmd_CommandAdd( pAbc, "Various",      "bidec",         Abc_CommandBidec,            1 );
+    Cmd_CommandAdd( pAbc, "Various",      "order",         Abc_CommandOrder,            0 );
+    Cmd_CommandAdd( pAbc, "Various",      "muxes",         Abc_CommandMuxes,            1 );
+    Cmd_CommandAdd( pAbc, "Various",      "cubes",         Abc_CommandCubes,            1 );
+    Cmd_CommandAdd( pAbc, "Various",      "splitsop",      Abc_CommandSplitSop,         1 );
+    Cmd_CommandAdd( pAbc, "Various",      "ext_seq_dcs",   Abc_CommandExtSeqDcs,        0 );
+    Cmd_CommandAdd( pAbc, "Various",      "reach",         Abc_CommandReach,            0 );
+    Cmd_CommandAdd( pAbc, "Various",      "cone",          Abc_CommandCone,             1 );
+    Cmd_CommandAdd( pAbc, "Various",      "node",          Abc_CommandNode,             1 );
+    Cmd_CommandAdd( pAbc, "Various",      "topmost",       Abc_CommandTopmost,          1 );
+    Cmd_CommandAdd( pAbc, "Various",      "topand",        Abc_CommandTopAnd,          1 );
+    Cmd_CommandAdd( pAbc, "Various",      "trim",          Abc_CommandTrim,             1 );
+    Cmd_CommandAdd( pAbc, "Various",      "short_names",   Abc_CommandShortNames,       0 );
+    Cmd_CommandAdd( pAbc, "Various",      "move_names",    Abc_CommandMoveNames,        0 );
+    Cmd_CommandAdd( pAbc, "Various",      "exdc_free",     Abc_CommandExdcFree,         1 );
+    Cmd_CommandAdd( pAbc, "Various",      "exdc_get",      Abc_CommandExdcGet,          1 );
+    Cmd_CommandAdd( pAbc, "Various",      "exdc_set",      Abc_CommandExdcSet,          1 );
+    Cmd_CommandAdd( pAbc, "Various",      "care_set",      Abc_CommandCareSet,          1 );
+    Cmd_CommandAdd( pAbc, "Various",      "cut",           Abc_CommandCut,              0 );
+    Cmd_CommandAdd( pAbc, "Various",      "espresso",      Abc_CommandEspresso,         1 );
+    Cmd_CommandAdd( pAbc, "Various",      "gen",           Abc_CommandGen,              0 );
+    Cmd_CommandAdd( pAbc, "Various",      "genfsm",        Abc_CommandGenFsm,           0 );
+    Cmd_CommandAdd( pAbc, "Various",      "cover",         Abc_CommandCover,            1 );
+    Cmd_CommandAdd( pAbc, "Various",      "double",        Abc_CommandDouble,           1 );
+    Cmd_CommandAdd( pAbc, "Various",      "inter",         Abc_CommandInter,            1 );
+    Cmd_CommandAdd( pAbc, "Various",      "bb2wb",         Abc_CommandBb2Wb,            0 );
+    Cmd_CommandAdd( pAbc, "Various",      "outdec",        Abc_CommandOutdec,           1 );
+    Cmd_CommandAdd( pAbc, "Various",      "nodedup",       Abc_CommandNodeDup,          1 );
+    Cmd_CommandAdd( pAbc, "Various",      "testcolor",     Abc_CommandTestColor,        0 );
+    Cmd_CommandAdd( pAbc, "Various",      "test",          Abc_CommandTest,             0 );
+//    Cmd_CommandAdd( pAbc, "Various",      "qbf_solve",     Abc_CommandTest,               0 );
+
+    Cmd_CommandAdd( pAbc, "Various",      "qvar",          Abc_CommandQuaVar,           1 );
+    Cmd_CommandAdd( pAbc, "Various",      "qrel",          Abc_CommandQuaRel,           1 );
+    Cmd_CommandAdd( pAbc, "Various",      "qreach",        Abc_CommandQuaReach,         1 );
+    Cmd_CommandAdd( pAbc, "Various",      "senseinput",    Abc_CommandSenseInput,       1 );
+    Cmd_CommandAdd( pAbc, "Various",      "npnload",       Abc_CommandNpnLoad,          0 );
+    Cmd_CommandAdd( pAbc, "Various",      "npnsave",       Abc_CommandNpnSave,          0 );
+
+    Cmd_CommandAdd( pAbc, "Various",      "send_aig",      Abc_CommandSendAig,          0 );
+    Cmd_CommandAdd( pAbc, "Various",      "send_status",   Abc_CommandSendStatus,       0 );
+
+    Cmd_CommandAdd( pAbc, "Various",      "backup",        Abc_CommandBackup,           0 );
+    Cmd_CommandAdd( pAbc, "Various",      "restore",       Abc_CommandRestore,          0 );
+
+    Cmd_CommandAdd( pAbc, "Various",      "minisat",       Abc_CommandMinisat,          0 );
+    Cmd_CommandAdd( pAbc, "Various",      "minisimp",      Abc_CommandMinisimp,         0 );
+
+    Cmd_CommandAdd( pAbc, "New AIG",      "istrash",       Abc_CommandIStrash,          1 );
+    Cmd_CommandAdd( pAbc, "New AIG",      "icut",          Abc_CommandICut,             0 );
+    Cmd_CommandAdd( pAbc, "New AIG",      "irw",           Abc_CommandIRewrite,         1 );
+    Cmd_CommandAdd( pAbc, "New AIG",      "drw",           Abc_CommandDRewrite,         1 );
+    Cmd_CommandAdd( pAbc, "New AIG",      "drf",           Abc_CommandDRefactor,        1 );
+    Cmd_CommandAdd( pAbc, "New AIG",      "dc2",           Abc_CommandDc2,              1 );
+    Cmd_CommandAdd( pAbc, "New AIG",      "dchoice",       Abc_CommandDChoice,          1 );
+    Cmd_CommandAdd( pAbc, "New AIG",      "dch",           Abc_CommandDch,              1 );
+    Cmd_CommandAdd( pAbc, "New AIG",      "drwsat",        Abc_CommandDrwsat,           1 );
+    Cmd_CommandAdd( pAbc, "New AIG",      "irws",          Abc_CommandIRewriteSeq,      1 );
+    Cmd_CommandAdd( pAbc, "New AIG",      "iresyn",        Abc_CommandIResyn,           1 );
+    Cmd_CommandAdd( pAbc, "New AIG",      "isat",          Abc_CommandISat,             1 );
+    Cmd_CommandAdd( pAbc, "New AIG",      "ifraig",        Abc_CommandIFraig,           1 );
+    Cmd_CommandAdd( pAbc, "New AIG",      "dfraig",        Abc_CommandDFraig,           1 );
+    Cmd_CommandAdd( pAbc, "New AIG",      "csweep",        Abc_CommandCSweep,           1 );
+//    Cmd_CommandAdd( pAbc, "New AIG",      "haig",          Abc_CommandHaig,             1 );
+    Cmd_CommandAdd( pAbc, "New AIG",      "qbf",           Abc_CommandQbf,              0 );
+
+    Cmd_CommandAdd( pAbc, "Fraiging",     "fraig",         Abc_CommandFraig,            1 );
+    Cmd_CommandAdd( pAbc, "Fraiging",     "fraig_trust",   Abc_CommandFraigTrust,       1 );
+    Cmd_CommandAdd( pAbc, "Fraiging",     "fraig_store",   Abc_CommandFraigStore,       0 );
+    Cmd_CommandAdd( pAbc, "Fraiging",     "fraig_restore", Abc_CommandFraigRestore,     1 );
+    Cmd_CommandAdd( pAbc, "Fraiging",     "fraig_clean",   Abc_CommandFraigClean,       0 );
+    Cmd_CommandAdd( pAbc, "Fraiging",     "fraig_sweep",   Abc_CommandFraigSweep,       1 );
+    Cmd_CommandAdd( pAbc, "Fraiging",     "dress",         Abc_CommandFraigDress,       1 );
+
+    Cmd_CommandAdd( pAbc, "Choicing",     "rec_start3",    Abc_CommandRecStart3,        0 );
+    Cmd_CommandAdd( pAbc, "Choicing",     "rec_stop3",     Abc_CommandRecStop3,         0 );
+    Cmd_CommandAdd( pAbc, "Choicing",     "rec_ps3",       Abc_CommandRecPs3,           0 );
+    Cmd_CommandAdd( pAbc, "Choicing",     "rec_add3",      Abc_CommandRecAdd3,          0 );
+    Cmd_CommandAdd( pAbc, "Choicing",     "rec_dump3",     Abc_CommandRecDump3,         0 );
+    Cmd_CommandAdd( pAbc, "Choicing",     "rec_merge3",    Abc_CommandRecMerge3,        0 );
+
+    Cmd_CommandAdd( pAbc, "SC mapping",   "map",           Abc_CommandMap,              1 );
+    Cmd_CommandAdd( pAbc, "SC mapping",   "amap",          Abc_CommandAmap,             1 );
+    Cmd_CommandAdd( pAbc, "SC mapping",   "unmap",         Abc_CommandUnmap,            1 );
+    Cmd_CommandAdd( pAbc, "SC mapping",   "attach",        Abc_CommandAttach,           1 );
+    Cmd_CommandAdd( pAbc, "SC mapping",   "superc",        Abc_CommandSuperChoice,      1 );
+    Cmd_CommandAdd( pAbc, "SC mapping",   "supercl",       Abc_CommandSuperChoiceLut,   1 );
+
+//    Cmd_CommandAdd( pAbc, "FPGA mapping", "fpga",          Abc_CommandFpga,             1 );
+//    Cmd_CommandAdd( pAbc, "FPGA mapping", "ffpga",         Abc_CommandFpgaFast,         1 );
+    Cmd_CommandAdd( pAbc, "FPGA mapping", "if",            Abc_CommandIf,               1 );
+    Cmd_CommandAdd( pAbc, "FPGA mapping", "ifif",          Abc_CommandIfif,             1 );
+
+    Cmd_CommandAdd( pAbc, "DSD manager",  "dsd_save",      Abc_CommandDsdSave,          0 );
+    Cmd_CommandAdd( pAbc, "DSD manager",  "dsd_load",      Abc_CommandDsdLoad,          0 );
+    Cmd_CommandAdd( pAbc, "DSD manager",  "dsd_free",      Abc_CommandDsdFree,          0 );
+    Cmd_CommandAdd( pAbc, "DSD manager",  "dsd_ps",        Abc_CommandDsdPs,            0 );
+    Cmd_CommandAdd( pAbc, "DSD manager",  "dsd_match",     Abc_CommandDsdMatch,         0 );
+    Cmd_CommandAdd( pAbc, "DSD manager",  "dsd_merge",     Abc_CommandDsdMerge,         0 );
+    Cmd_CommandAdd( pAbc, "DSD manager",  "dsd_filter",    Abc_CommandDsdFilter,        0 );
+
+//    Cmd_CommandAdd( pAbc, "Sequential",   "scut",          Abc_CommandScut,             0 );
+    Cmd_CommandAdd( pAbc, "Sequential",   "init",          Abc_CommandInit,             1 );
+    Cmd_CommandAdd( pAbc, "Sequential",   "zero",          Abc_CommandZero,             1 );
+    Cmd_CommandAdd( pAbc, "Sequential",   "undc",          Abc_CommandUndc,             1 );
+    Cmd_CommandAdd( pAbc, "Sequential",   "onehot",        Abc_CommandOneHot,           1 );
+//    Cmd_CommandAdd( pAbc, "Sequential",   "pipe",          Abc_CommandPipe,             1 );
+    Cmd_CommandAdd( pAbc, "Sequential",   "retime",        Abc_CommandRetime,           1 );
+    Cmd_CommandAdd( pAbc, "Sequential",   "dretime",       Abc_CommandDRetime,          1 );
+    Cmd_CommandAdd( pAbc, "Sequential",   "fretime",       Abc_CommandFlowRetime,       1 );
+    Cmd_CommandAdd( pAbc, "Sequential",   "cretime",       Abc_CommandCRetime,          1 );
+//    Cmd_CommandAdd( pAbc, "Sequential",   "sfpga",         Abc_CommandSeqFpga,          1 );
+//    Cmd_CommandAdd( pAbc, "Sequential",   "smap",          Abc_CommandSeqMap,           1 );
+    Cmd_CommandAdd( pAbc, "Sequential",   "ssweep",        Abc_CommandSeqSweep,         1 );
+    Cmd_CommandAdd( pAbc, "Sequential",   "scorr",         Abc_CommandSeqSweep2,        1 );
+    Cmd_CommandAdd( pAbc, "Sequential",   "testssw",       Abc_CommandTestSeqSweep,     0 );
+    Cmd_CommandAdd( pAbc, "Sequential",   "testscorr",     Abc_CommandTestScorr,        0 );
+    Cmd_CommandAdd( pAbc, "Sequential",   "lcorr",         Abc_CommandLcorr,            1 );
+    Cmd_CommandAdd( pAbc, "Sequential",   "scleanup",      Abc_CommandSeqCleanup,       1 );
+    Cmd_CommandAdd( pAbc, "Sequential",   "cycle",         Abc_CommandCycle,            1 );
+    Cmd_CommandAdd( pAbc, "Sequential",   "xsim",          Abc_CommandXsim,             0 );
+    Cmd_CommandAdd( pAbc, "Sequential",   "sim",           Abc_CommandSim,              0 );
+    Cmd_CommandAdd( pAbc, "Sequential",   "sim3",          Abc_CommandSim3,             0 );
+    Cmd_CommandAdd( pAbc, "Sequential",   "phase",         Abc_CommandDarPhase,         1 );
+    Cmd_CommandAdd( pAbc, "Sequential",   "synch",         Abc_CommandSynch,            1 );
+    Cmd_CommandAdd( pAbc, "Sequential",   "clockgate",     Abc_CommandClockGate,        1 );
+    Cmd_CommandAdd( pAbc, "Sequential",   "extwin",        Abc_CommandExtWin,           1 );
+    Cmd_CommandAdd( pAbc, "Sequential",   "inswin",        Abc_CommandInsWin,           1 );
+    Cmd_CommandAdd( pAbc, "Sequential",   "permute",       Abc_CommandPermute,          1 );
+    Cmd_CommandAdd( pAbc, "Sequential",   "unpermute",     Abc_CommandUnpermute,        1 );
+    Cmd_CommandAdd( pAbc, "Sequential",   "cubeenum",      Abc_CommandCubeEnum,         0 );
+
+    Cmd_CommandAdd( pAbc, "Verification", "cec",           Abc_CommandCec,              0 );
+    Cmd_CommandAdd( pAbc, "Verification", "dcec",          Abc_CommandDCec,             0 );
+    Cmd_CommandAdd( pAbc, "Verification", "dsec",          Abc_CommandDSec,             0 );
+    Cmd_CommandAdd( pAbc, "Verification", "dprove",        Abc_CommandDProve,           0 );
+    Cmd_CommandAdd( pAbc, "Verification", "absec",         Abc_CommandAbSec,            0 );
+    Cmd_CommandAdd( pAbc, "Verification", "simsec",        Abc_CommandSimSec,           0 );
+    Cmd_CommandAdd( pAbc, "Verification", "match",         Abc_CommandMatch,            0 );
+    Cmd_CommandAdd( pAbc, "Verification", "sat",           Abc_CommandSat,              0 );
+    Cmd_CommandAdd( pAbc, "Verification", "dsat",          Abc_CommandDSat,             0 );
+    Cmd_CommandAdd( pAbc, "Verification", "psat",          Abc_CommandPSat,             0 );
+    Cmd_CommandAdd( pAbc, "Verification", "prove",         Abc_CommandProve,            1 );
+    Cmd_CommandAdd( pAbc, "Verification", "iprove",        Abc_CommandIProve,           1 );
+    Cmd_CommandAdd( pAbc, "Verification", "debug",         Abc_CommandDebug,            0 );
+    Cmd_CommandAdd( pAbc, "Verification", "bmc",           Abc_CommandBmc,              0 );
+    Cmd_CommandAdd( pAbc, "Verification", "bmc2",          Abc_CommandBmc2,             0 );
+    Cmd_CommandAdd( pAbc, "Verification", "bmc3",          Abc_CommandBmc3,             1 );
+    Cmd_CommandAdd( pAbc, "Verification", "int",           Abc_CommandBmcInter,         1 );
+    Cmd_CommandAdd( pAbc, "Verification", "indcut",        Abc_CommandIndcut,           0 );
+    Cmd_CommandAdd( pAbc, "Verification", "enlarge",       Abc_CommandEnlarge,          1 );
+    Cmd_CommandAdd( pAbc, "Verification", "tempor",        Abc_CommandTempor,           1 );
+    Cmd_CommandAdd( pAbc, "Verification", "ind",           Abc_CommandInduction,        0 );
+    Cmd_CommandAdd( pAbc, "Verification", "constr",        Abc_CommandConstr,           0 );
+    Cmd_CommandAdd( pAbc, "Verification", "unfold",        Abc_CommandUnfold,           1 );
+    Cmd_CommandAdd( pAbc, "Verification", "fold",          Abc_CommandFold,             1 );
+    Cmd_CommandAdd( pAbc, "Verification", "unfold2",       Abc_CommandUnfold2,          1 );    // jlong 
+    Cmd_CommandAdd( pAbc, "Verification", "fold2",         Abc_CommandFold2,            1 );    // jlong 
+    Cmd_CommandAdd( pAbc, "Verification", "bm",            Abc_CommandBm,               1 );
+    Cmd_CommandAdd( pAbc, "Verification", "bm2",           Abc_CommandBm2,              1 );
+    Cmd_CommandAdd( pAbc, "Verification", "saucy3",        Abc_CommandSaucy,            1 );
+    Cmd_CommandAdd( pAbc, "Verification", "testcex",       Abc_CommandTestCex,          0 );
+    Cmd_CommandAdd( pAbc, "Verification", "pdr",           Abc_CommandPdr,              0 );
+    Cmd_CommandAdd( pAbc, "Verification", "reconcile",     Abc_CommandReconcile,        1 );
+    Cmd_CommandAdd( pAbc, "Verification", "cexsave",       Abc_CommandCexSave,          0 );
+    Cmd_CommandAdd( pAbc, "Verification", "cexload",       Abc_CommandCexLoad,          0 );
+    Cmd_CommandAdd( pAbc, "Verification", "cexcut",        Abc_CommandCexCut,           0 );
+    Cmd_CommandAdd( pAbc, "Verification", "cexmerge",      Abc_CommandCexMerge,         0 );
+//    Cmd_CommandAdd( pAbc, "Verification", "cexmin",        Abc_CommandCexMin,           0 );
+    Cmd_CommandAdd( pAbc, "Verification", "dualrail",      Abc_CommandDualRail,         1 );
+    Cmd_CommandAdd( pAbc, "Verification", "blockpo",       Abc_CommandBlockPo,          1 );
+    Cmd_CommandAdd( pAbc, "Verification", "iso",           Abc_CommandIso,              1 );
+
+    Cmd_CommandAdd( pAbc, "ABC9",         "&get",          Abc_CommandAbc9Get,          0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&put",          Abc_CommandAbc9Put,          0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&save",         Abc_CommandAbc9Save,         0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&load",         Abc_CommandAbc9Load,         0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&r",            Abc_CommandAbc9Read,         0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&read_blif",    Abc_CommandAbc9ReadBlif,     0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&read_cblif",   Abc_CommandAbc9ReadCBlif,    0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&read_stg",     Abc_CommandAbc9ReadStg,      0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&read_ver",     Abc_CommandAbc9ReadVer,      0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&write_ver",    Abc_CommandAbc9WriteVer,     0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&w",            Abc_CommandAbc9Write,        0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&ps",           Abc_CommandAbc9Ps,           0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&pfan",         Abc_CommandAbc9PFan,         0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&psig",         Abc_CommandAbc9PSig,         0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&status",       Abc_CommandAbc9Status,       0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&mux_profile",  Abc_CommandAbc9MuxProfile,   0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&show",         Abc_CommandAbc9Show,         0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&setregnum",    Abc_CommandAbc9SetRegNum,    0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&st",           Abc_CommandAbc9Strash,       0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&topand",       Abc_CommandAbc9Topand,       0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&add1hot",      Abc_CommandAbc9Add1Hot,      0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&cof",          Abc_CommandAbc9Cof,          0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&trim",         Abc_CommandAbc9Trim,         0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&dfs",          Abc_CommandAbc9Dfs,          0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&sim",          Abc_CommandAbc9Sim,          0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&sim3",         Abc_CommandAbc9Sim3,         0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&resim",        Abc_CommandAbc9Resim,        0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&speci",        Abc_CommandAbc9SpecI,        0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&equiv",        Abc_CommandAbc9Equiv,        0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&equiv2",       Abc_CommandAbc9Equiv2,       0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&equiv3",       Abc_CommandAbc9Equiv3,       0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&semi",         Abc_CommandAbc9Semi,         0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&times",        Abc_CommandAbc9Times,        0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&frames",       Abc_CommandAbc9Frames,       0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&retime",       Abc_CommandAbc9Retime,       0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&enable",       Abc_CommandAbc9Enable,       0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&dc2",          Abc_CommandAbc9Dc2,          0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&dsd",          Abc_CommandAbc9Dsd,          0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&bidec",        Abc_CommandAbc9Bidec,        0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&shrink",       Abc_CommandAbc9Shrink,       0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&fx",           Abc_CommandAbc9Fx,           0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&b",            Abc_CommandAbc9Balance,      0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&blut",         Abc_CommandAbc9BalanceLut,   0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&syn2",         Abc_CommandAbc9Syn2,         0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&syn3",         Abc_CommandAbc9Syn3,         0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&syn4",         Abc_CommandAbc9Syn4,         0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&synch2",       Abc_CommandAbc9Synch2,       0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&false",        Abc_CommandAbc9False,        0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&miter",        Abc_CommandAbc9Miter,        0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&miter2",       Abc_CommandAbc9Miter2,       0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&append",       Abc_CommandAbc9Append,       0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&scl",          Abc_CommandAbc9Scl,          0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&lcorr",        Abc_CommandAbc9Lcorr,        0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&scorr",        Abc_CommandAbc9Scorr,        0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&choice",       Abc_CommandAbc9Choice,       0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&sat",          Abc_CommandAbc9Sat,          0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&satenum",      Abc_CommandAbc9SatEnum,      0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&fraig",        Abc_CommandAbc9Fraig,        0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&cfraig",       Abc_CommandAbc9CFraig,       0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&srm",          Abc_CommandAbc9Srm,          0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&srm2",         Abc_CommandAbc9Srm2,         0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&filter",       Abc_CommandAbc9Filter,       0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&reduce",       Abc_CommandAbc9Reduce,       0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&equiv_mark",   Abc_CommandAbc9EquivMark,    0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&equiv_filter", Abc_CommandAbc9EquivFilter,  0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&cec",          Abc_CommandAbc9Cec,          0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&verify",       Abc_CommandAbc9Verify,       0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&sweep",        Abc_CommandAbc9Sweep,        0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&force",        Abc_CommandAbc9Force,        0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&embed",        Abc_CommandAbc9Embed,        0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&sopb",         Abc_CommandAbc9Sopb,         0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&dsdb",         Abc_CommandAbc9Dsdb,         0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&flow",         Abc_CommandAbc9Flow,         0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&flow2",        Abc_CommandAbc9Flow2,        0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&if",           Abc_CommandAbc9If,           0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&iff",          Abc_CommandAbc9Iff,          0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&if2",          Abc_CommandAbc9If2,          0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&jf",           Abc_CommandAbc9Jf,           0 );
+#ifdef ABC_USE_PTHREADS
+    Cmd_CommandAdd( pAbc, "ABC9",         "&kf",           Abc_CommandAbc9Kf,           0 );
+#endif
+    Cmd_CommandAdd( pAbc, "ABC9",         "&lf",           Abc_CommandAbc9Lf,           0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&mf",           Abc_CommandAbc9Mf,           0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&nf",           Abc_CommandAbc9Nf,           0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&unmap",        Abc_CommandAbc9Unmap,        0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&struct",       Abc_CommandAbc9Struct,       0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&trace",        Abc_CommandAbc9Trace,        0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&speedup",      Abc_CommandAbc9Speedup,      0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&era",          Abc_CommandAbc9Era,          0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&dch",          Abc_CommandAbc9Dch,          0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&rpm",          Abc_CommandAbc9Rpm,          0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&back_reach",   Abc_CommandAbc9BackReach,    0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&posplit",      Abc_CommandAbc9Posplit,      0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&reachm",       Abc_CommandAbc9ReachM,       0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&reachp",       Abc_CommandAbc9ReachP,       0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&reachn",       Abc_CommandAbc9ReachN,       0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&reachy",       Abc_CommandAbc9ReachY,       0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&undo",         Abc_CommandAbc9Undo,         0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&iso",          Abc_CommandAbc9Iso,          0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&cexinfo",      Abc_CommandAbc9CexInfo,      0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&cycle",        Abc_CommandAbc9Cycle,        0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&cone",         Abc_CommandAbc9Cone,         0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&slice",        Abc_CommandAbc9Slice,        0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&popart",       Abc_CommandAbc9PoPart,       0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&gprove",       Abc_CommandAbc9GroupProve,   0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&mprove",       Abc_CommandAbc9MultiProve,   0 );
+#ifdef ABC_USE_PTHREADS
+    Cmd_CommandAdd( pAbc, "ABC9",         "&splitprove",   Abc_CommandAbc9SplitProve,   0 );
+#endif
+    Cmd_CommandAdd( pAbc, "ABC9",         "&bmc",          Abc_CommandAbc9Bmc,          0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&chainbmc",     Abc_CommandAbc9ChainBmc,     0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&bcore",        Abc_CommandAbc9BCore,        0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&icheck",       Abc_CommandAbc9ICheck,       0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&sattest",      Abc_CommandAbc9SatTest,      0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&fftest",       Abc_CommandAbc9FFTest,       0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&qbf",          Abc_CommandAbc9Qbf,          0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&inse",         Abc_CommandAbc9Inse,         0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&maxi",         Abc_CommandAbc9Maxi,         0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&bmci",         Abc_CommandAbc9Bmci,         0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&poxsim",       Abc_CommandAbc9PoXsim,       0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&demiter",      Abc_CommandAbc9Demiter,      0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&fadds",        Abc_CommandAbc9Fadds,        0 );
+    Cmd_CommandAdd( pAbc, "ABC9",         "&mfs",          Abc_CommandAbc9Mfs,          0 );
+//    Cmd_CommandAdd( pAbc, "ABC9",         "&popart2",      Abc_CommandAbc9PoPart2,      0 );
+//    Cmd_CommandAdd( pAbc, "ABC9",         "&cexcut",       Abc_CommandAbc9CexCut,       0 );
+//    Cmd_CommandAdd( pAbc, "ABC9",         "&cexmerge",     Abc_CommandAbc9CexMerge,     0 );
+//    Cmd_CommandAdd( pAbc, "ABC9",         "&cexmin",       Abc_CommandAbc9CexMin,       0 );
+
+    Cmd_CommandAdd( pAbc, "Abstraction",  "&abs_derive",   Abc_CommandAbc9AbsDerive,    0 );
+    Cmd_CommandAdd( pAbc, "Abstraction",  "&abs_refine",   Abc_CommandAbc9AbsRefine,    0 );
+    Cmd_CommandAdd( pAbc, "Abstraction",  "&gla_derive",   Abc_CommandAbc9GlaDerive,    0 );
+    Cmd_CommandAdd( pAbc, "Abstraction",  "&gla_refine",   Abc_CommandAbc9GlaRefine,    0 );
+    Cmd_CommandAdd( pAbc, "Abstraction",  "&gla_shrink",   Abc_CommandAbc9GlaShrink,    0 );
+    Cmd_CommandAdd( pAbc, "Abstraction",  "&gla",          Abc_CommandAbc9Gla,          0 );
+    Cmd_CommandAdd( pAbc, "Abstraction",  "&vta",          Abc_CommandAbc9Vta,          0 );
+    Cmd_CommandAdd( pAbc, "Abstraction",  "&vta_gla",      Abc_CommandAbc9Vta2Gla,      0 );
+    Cmd_CommandAdd( pAbc, "Abstraction",  "&gla_vta",      Abc_CommandAbc9Gla2Vta,      0 );
+    Cmd_CommandAdd( pAbc, "Abstraction",  "&fla_gla",      Abc_CommandAbc9Fla2Gla,      0 );
+    Cmd_CommandAdd( pAbc, "Abstraction",  "&gla_fla",      Abc_CommandAbc9Gla2Fla,      0 );
+
+    Cmd_CommandAdd( pAbc, "Liveness",     "l2s",           Abc_CommandAbcLivenessToSafety,        0 );
+    Cmd_CommandAdd( pAbc, "Liveness",     "l2ssim",        Abc_CommandAbcLivenessToSafetySim,     0 );
+    Cmd_CommandAdd( pAbc, "Liveness",     "l3s",           Abc_CommandAbcLivenessToSafetyWithLTL, 0 );
+    Cmd_CommandAdd( pAbc, "Liveness",     "kcs",           Abc_CommandCS_kLiveness,               0 );
+    Cmd_CommandAdd( pAbc, "Liveness",     "nck",           Abc_CommandNChooseK,                   0 );
+
+    Cmd_CommandAdd( pAbc, "ABC9",         "&test",         Abc_CommandAbc9Test,         0 );
+    {
+//        extern Mf_ManTruthCount();
+//        Mf_ManTruthCount();
+    }
+
+    {
+        extern void Dar_LibStart();
+        Dar_LibStart();
+    }
+    {
+//        extern void Dau_DsdTest();
+//        Dau_DsdTest();
+//        extern void If_ManSatTest();
+//        If_ManSatTest();
+    }
+
+//    if ( Sdm_ManCanRead() )
+//        Sdm_ManRead();
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Abc_End( Abc_Frame_t * pAbc )
+{
+    extern Abc_Frame_t * Abc_FrameGetGlobalFrame();
+    Abc_FrameClearDesign();
+    Cnf_ManFree();
+    {
+        extern int Abc_NtkCompareAndSaveBest( Abc_Ntk_t * pNtk );
+        Abc_NtkCompareAndSaveBest( NULL );
+    }
+    {
+        extern void Dar_LibStop();
+        Dar_LibStop();
+    }
+    {
+        extern void Aig_RManQuit();
+        Aig_RManQuit();
+    }
+    {
+        extern void Npn_ManClean();
+        Npn_ManClean();
+    }
+    {
+        extern void Sdm_ManQuit();
+        Sdm_ManQuit();
+    }
+    Abc_NtkFraigStoreClean();
+    if ( Abc_FrameGetGlobalFrame()->pGia )
+        Gia_ManStop( Abc_FrameGetGlobalFrame()->pGia );
+    if ( Abc_FrameGetGlobalFrame()->pGia2 )
+        Gia_ManStop( Abc_FrameGetGlobalFrame()->pGia2 );
+    if ( Abc_FrameGetGlobalFrame()->pGiaBest )
+        Gia_ManStop( Abc_FrameGetGlobalFrame()->pGiaBest );
+    if ( Abc_NtkRecIsRunning3() )
+        Abc_NtkRecStop3();
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandPrintStats( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int fFactor;
+    int fSaveBest;
+    int fDumpResult;
+    int fUseLutLib;
+    int fPrintTime;
+    int fPrintMuxes;
+    int fPower;
+    int fGlitch;
+    int fSkipBuf;
+    int c;
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+
+    // set the defaults
+    fFactor   = 0;
+    fSaveBest = 0;
+    fDumpResult = 0;
+    fUseLutLib = 0;
+    fPrintTime = 0;
+    fPrintMuxes = 0;
+    fPower = 0;
+    fGlitch = 0;
+    fSkipBuf = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "fbdltmpgsh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'f':
+            fFactor ^= 1;
+            break;
+        case 'b':
+            fSaveBest ^= 1;
+            break;
+        case 'd':
+            fDumpResult ^= 1;
+            break;
+        case 'l':
+            fUseLutLib ^= 1;
+            break;
+        case 't':
+            fPrintTime ^= 1;
+            break;
+        case 'm':
+            fPrintMuxes ^= 1;
+            break;
+        case 'p':
+            fPower ^= 1;
+            break;
+        case 'g':
+            fGlitch ^= 1;
+            break;
+        case 's':
+            fSkipBuf ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsLogic(pNtk) && fUseLutLib )
+    {
+        Abc_Print( -1, "Cannot print LUT delay for a non-logic network.\n" );
+        return 1;
+    }
+    Abc_NtkPrintStats( pNtk, fFactor, fSaveBest, fDumpResult, fUseLutLib, fPrintMuxes, fPower, fGlitch, fSkipBuf );
+    if ( fPrintTime )
+    {
+        pAbc->TimeTotal += pAbc->TimeCommand;
+        Abc_Print( 1, "elapse: %3.2f seconds, total: %3.2f seconds\n", pAbc->TimeCommand, pAbc->TimeTotal );
+        pAbc->TimeCommand = 0.0;
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: print_stats [-fbdltmpgsh]\n" );
+    Abc_Print( -2, "\t        prints the network statistics\n" );
+    Abc_Print( -2, "\t-f    : toggles printing the literal count in the factored forms [default = %s]\n", fFactor? "yes": "no" );
+    Abc_Print( -2, "\t-b    : toggles saving the best logic network in \"best.blif\" [default = %s]\n", fSaveBest? "yes": "no" );
+    Abc_Print( -2, "\t-d    : toggles dumping statistics about the network into file [default = %s]\n", fDumpResult? "yes": "no" );
+    Abc_Print( -2, "\t-l    : toggles printing delay of LUT mapping using LUT library [default = %s]\n", fSaveBest? "yes": "no" );
+    Abc_Print( -2, "\t-t    : toggles printing runtime statistics [default = %s]\n", fPrintTime? "yes": "no" );
+    Abc_Print( -2, "\t-m    : toggles printing MUX statistics [default = %s]\n", fPrintMuxes? "yes": "no" );
+    Abc_Print( -2, "\t-p    : toggles printing power dissipation due to switching [default = %s]\n", fPower? "yes": "no" );
+    Abc_Print( -2, "\t-g    : toggles printing percentage of increased power due to glitching [default = %s]\n", fGlitch? "yes": "no" );
+    Abc_Print( -2, "\t-s    : toggles not counting single-output nodes as nodes [default = %s]\n", fSkipBuf? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandPrintExdc( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkTemp;
+    double Percentage;
+    int fShort;
+    int c;
+    int fPrintDc;
+    extern double Abc_NtkSpacePercentage( Abc_Obj_t * pNode );
+    pNtk = Abc_FrameReadNtk(pAbc);
+
+    // set the defaults
+    fShort  = 1;
+    fPrintDc = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "sdh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 's':
+            fShort ^= 1;
+            break;
+        case 'd':
+            fPrintDc ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( pNtk->pExdc == NULL )
+    {
+        Abc_Print( -1, "Network has no EXDC.\n" );
+        return 1;
+    }
+
+    if ( fPrintDc )
+    {
+        if ( !Abc_NtkIsStrash(pNtk->pExdc) )
+        {
+            pNtkTemp = Abc_NtkStrash(pNtk->pExdc, 0, 0, 0);
+            Percentage = Abc_NtkSpacePercentage( Abc_ObjChild0( Abc_NtkPo(pNtkTemp, 0) ) );
+            Abc_NtkDelete( pNtkTemp );
+        }
+        else
+            Percentage = Abc_NtkSpacePercentage( Abc_ObjChild0( Abc_NtkPo(pNtk->pExdc, 0) ) );
+
+        Abc_Print( 1, "EXDC network statistics: " );
+        Abc_Print( 1, "(" );
+        if ( Percentage > 0.05 && Percentage < 99.95 )
+            Abc_Print( 1, "%.2f", Percentage );
+        else if ( Percentage > 0.000005 && Percentage < 99.999995 )
+            Abc_Print( 1, "%.6f", Percentage );
+        else
+            Abc_Print( 1, "%f", Percentage );
+        Abc_Print( 1, " %% don't-cares)\n" );
+    }
+    else
+        Abc_Print( 1, "EXDC network statistics: \n" );
+    Abc_NtkPrintStats( pNtk->pExdc, 0, 0, 0, 0, 0, 0, 0, 0 );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: print_exdc [-dh]\n" );
+    Abc_Print( -2, "\t        prints the EXDC network statistics\n" );
+    Abc_Print( -2, "\t-d    : toggles printing don't-care percentage [default = %s]\n", fPrintDc? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandPrintIo( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    Abc_Obj_t * pNode;
+    int c, fPrintFlops = 1;
+
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "fh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'f':
+            fPrintFlops ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( argc > globalUtilOptind + 1 )
+    {
+        Abc_Print( -1, "Wrong number of auguments.\n" );
+        goto usage;
+    }
+
+    if ( argc == globalUtilOptind + 1 )
+    {
+        pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
+        if ( pNode == NULL )
+        {
+            Abc_Print( -1, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
+            return 1;
+        }
+        Abc_NodePrintFanio( stdout, pNode );
+        return 0;
+    }
+    // print the nodes
+    Abc_NtkPrintIo( stdout, pNtk, fPrintFlops );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: print_io [-fh] <node>\n" );
+    Abc_Print( -2, "\t        prints the PIs/POs/flops or fanins/fanouts of a node\n" );
+    Abc_Print( -2, "\t-f    : toggles printing flops [default = %s]\n", fPrintFlops? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    Abc_Print( -2, "\tnode  : the node to print fanins/fanouts\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandPrintLatch( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int fPrintSccs;
+    extern void Abc_NtkPrintSccs( Abc_Ntk_t * pNtk, int fVerbose );
+
+    // set defaults
+    fPrintSccs = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "sh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 's':
+            fPrintSccs ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    // print the nodes
+    Abc_NtkPrintLatch( stdout, pNtk );
+    if ( fPrintSccs )
+        Abc_NtkPrintSccs( pNtk, 0 );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: print_latch [-sh]\n" );
+    Abc_Print( -2, "\t        prints information about latches\n" );
+    Abc_Print( -2, "\t-s    : toggles printing SCCs of registers [default = %s]\n", fPrintSccs? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandPrintFanio( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int fUsePis   = 0;
+    int fMffc     = 0;
+    int fVerbose  = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "imvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'i':
+            fUsePis ^= 1;
+            break;
+        case 'm':
+            fMffc ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    // print the nodes
+    if ( fVerbose )
+        Abc_NtkPrintFanio( stdout, pNtk, fUsePis );
+    else
+        Abc_NtkPrintFanioNew( stdout, pNtk, fMffc );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: print_fanio [-imvh]\n" );
+    Abc_Print( -2, "\t        prints the statistics about fanins/fanouts of all nodes\n" );
+    Abc_Print( -2, "\t-i    : toggles considering fanouts of primary inputs only [default = %s]\n", fUsePis? "yes": "no" );
+    Abc_Print( -2, "\t-m    : toggles printing MFFC sizes instead of fanouts [default = %s]\n", fMffc? "yes": "no" );
+    Abc_Print( -2, "\t-v    : toggles verbose way of printing the stats [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandPrintMffc( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    extern void Abc_NtkPrintMffc( FILE * pFile, Abc_Ntk_t * pNtk );
+
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    // print the nodes
+    Abc_NtkPrintMffc( stdout, pNtk );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: print_mffc [-h]\n" );
+    Abc_Print( -2, "\t        prints the MFFC of each node in the network\n" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandPrintFactor( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    Abc_Obj_t * pNode;
+    int c;
+    int fUseRealNames;
+
+    // set defaults
+    fUseRealNames = 1;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "nh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'n':
+            fUseRealNames ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsSopLogic(pNtk) )
+    {
+        Abc_Print( -1, "Printing factored forms can be done for SOP networks.\n" );
+        return 1;
+    }
+
+    if ( argc > globalUtilOptind + 1 )
+    {
+        Abc_Print( -1, "Wrong number of auguments.\n" );
+        goto usage;
+    }
+
+    if ( argc == globalUtilOptind + 1 )
+    {
+        pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
+        if ( pNode == NULL )
+        {
+            Abc_Print( -1, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
+            return 1;
+        }
+        Abc_NodePrintFactor( stdout, pNode, fUseRealNames );
+        return 0;
+    }
+    // print the nodes
+    Abc_NtkPrintFactor( stdout, pNtk, fUseRealNames );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: print_factor [-nh] <node>\n" );
+    Abc_Print( -2, "\t        prints the factored forms of nodes\n" );
+    Abc_Print( -2, "\t-n    : toggles real/dummy fanin names [default = %s]\n", fUseRealNames? "real": "dummy" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    Abc_Print( -2, "\tnode  : (optional) one node to consider\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandPrintLevel( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    Abc_Obj_t * pNode;
+    int c;
+    int fListNodes;
+    int fProfile;
+    int fVerbose;
+
+    // set defaults
+    fListNodes = 0;
+    fProfile   = 1;
+    fVerbose   = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "npvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'n':
+            fListNodes ^= 1;
+            break;
+        case 'p':
+            fProfile ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( !fProfile && !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for AIGs (run \"strash\").\n" );
+        return 1;
+    }
+
+    if ( argc > globalUtilOptind + 1 )
+    {
+        Abc_Print( -1, "Wrong number of auguments.\n" );
+        goto usage;
+    }
+
+    if ( argc == globalUtilOptind + 1 )
+    {
+        pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
+        if ( pNode == NULL )
+        {
+            Abc_Print( -1, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
+            return 1;
+        }
+        Abc_NodePrintLevel( stdout, pNode );
+        return 0;
+    }
+    // process all COs
+    Abc_NtkPrintLevel( stdout, pNtk, fProfile, fListNodes, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: print_level [-npvh] <node>\n" );
+    Abc_Print( -2, "\t        prints information about node level and cone size\n" );
+    Abc_Print( -2, "\t-n    : toggles printing nodes by levels [default = %s]\n", fListNodes? "yes": "no" );
+    Abc_Print( -2, "\t-p    : toggles printing level profile [default = %s]\n", fProfile? "yes": "no" );
+    Abc_Print( -2, "\t-v    : enable verbose output [default = %s].\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    Abc_Print( -2, "\tnode  : (optional) one node to consider\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandPrintSupport( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Vec_Ptr_t * vSuppFun;
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int fStruct;
+    int fVerbose;
+    int fVeryVerbose;
+    extern Vec_Ptr_t * Sim_ComputeFunSupp( Abc_Ntk_t * pNtk, int fVerbose );
+    extern void Abc_NtkPrintStrSupports( Abc_Ntk_t * pNtk, int fMatrix );
+
+    // set defaults
+    fStruct = 1;
+    fVerbose = 0;
+    fVeryVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "svwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 's':
+            fStruct ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'w':
+            fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    // print support information
+    if ( fStruct )
+    {
+        Abc_NtkPrintStrSupports( pNtk, fVeryVerbose );
+        return 0;
+    }
+
+    if ( !Abc_NtkIsComb(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for combinational networks (run \"comb\").\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for AIGs (run \"strash\").\n" );
+        return 1;
+    }
+    vSuppFun = Sim_ComputeFunSupp( pNtk, fVerbose );
+    ABC_FREE( vSuppFun->pArray[0] );
+    Vec_PtrFree( vSuppFun );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: print_supp [-svwh]\n" );
+    Abc_Print( -2, "\t        prints the supports of the CO nodes\n" );
+    Abc_Print( -2, "\t-s    : toggle printing structural support only [default = %s].\n", fStruct? "yes": "no" );
+    Abc_Print( -2, "\t-v    : enable verbose output [default = %s].\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w    : enable printing CI/CO dependency matrix [default = %s].\n", fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandPrintSymms( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int fUseBdds;
+    int fNaive;
+    int fReorder;
+    int fVerbose;
+    extern void Abc_NtkSymmetries( Abc_Ntk_t * pNtk, int fUseBdds, int fNaive, int fReorder, int fVerbose );
+
+    // set defaults
+    fUseBdds = 0;
+    fNaive   = 0;
+    fReorder = 1;
+    fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "bnrvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'b':
+            fUseBdds ^= 1;
+            break;
+        case 'n':
+            fNaive ^= 1;
+            break;
+        case 'r':
+            fReorder ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsComb(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for combinational networks (run \"comb\").\n" );
+        return 1;
+    }
+    if ( Abc_NtkIsStrash(pNtk) )
+        Abc_NtkSymmetries( pNtk, fUseBdds, fNaive, fReorder, fVerbose );
+    else
+    {
+        pNtk = Abc_NtkStrash( pNtk, 0, 0, 0 );
+        Abc_NtkSymmetries( pNtk, fUseBdds, fNaive, fReorder, fVerbose );
+        Abc_NtkDelete( pNtk );
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: print_symm [-bnrvh]\n" );
+    Abc_Print( -2, "\t         computes symmetries of the PO functions\n" );
+    Abc_Print( -2, "\t-b     : toggle BDD-based or SAT-based computations [default = %s].\n", fUseBdds? "BDD": "SAT" );
+    Abc_Print( -2, "\t-n     : enable naive BDD-based computation [default = %s].\n", fNaive? "yes": "no" );
+    Abc_Print( -2, "\t-r     : enable dynamic BDD variable reordering [default = %s].\n", fReorder? "yes": "no" );
+    Abc_Print( -2, "\t-v     : enable verbose output [default = %s].\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandPrintUnate( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int fUseBdds;
+    int fUseNaive;
+    int fVerbose;
+    extern void Abc_NtkPrintUnate( Abc_Ntk_t * pNtk, int fUseBdds, int fUseNaive, int fVerbose );
+
+    // set defaults
+    fUseBdds  = 1;
+    fUseNaive = 0;
+    fVerbose  = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "bnvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'b':
+            fUseBdds ^= 1;
+            break;
+        case 'n':
+            fUseNaive ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for AIGs (run \"strash\").\n" );
+        return 1;
+    }
+    Abc_NtkPrintUnate( pNtk, fUseBdds, fUseNaive, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: print_unate [-bnvh]\n" );
+    Abc_Print( -2, "\t         computes unate variables of the PO functions\n" );
+    Abc_Print( -2, "\t-b     : toggle BDD-based or SAT-based computations [default = %s].\n", fUseBdds? "BDD": "SAT" );
+    Abc_Print( -2, "\t-n     : toggle naive BDD-based computation [default = %s].\n", fUseNaive? "yes": "no" );
+    Abc_Print( -2, "\t-v     : enable verbose output [default = %s].\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandPrintAuto( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int Output;
+    int fNaive;
+    int fVerbose;
+    extern void Abc_NtkAutoPrint( Abc_Ntk_t * pNtk, int Output, int fNaive, int fVerbose );
+
+    // set defaults
+    Output   = -1;
+    fNaive   = 0;
+    fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Onvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'O':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-O\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            Output = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( Output < 0 )
+                goto usage;
+            break;
+        case 'n':
+            fNaive ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for AIGs (run \"strash\").\n" );
+        return 1;
+    }
+
+
+    Abc_NtkAutoPrint( pNtk, Output, fNaive, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: print_auto [-O <num>] [-nvh]\n" );
+    Abc_Print( -2, "\t           computes autosymmetries of the PO functions\n" );
+    Abc_Print( -2, "\t-O <num> : (optional) the 0-based number of the output [default = all]\n");
+    Abc_Print( -2, "\t-n       : enable naive BDD-based computation [default = %s].\n", fNaive? "yes": "no" );
+    Abc_Print( -2, "\t-v       : enable verbose output [default = %s].\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandPrintKMap( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    Abc_Obj_t * pNode;
+    int c;
+    int fUseRealNames;
+
+    extern void Abc_NodePrintKMap( Abc_Obj_t * pNode, int fUseRealNames );
+
+    // set defaults
+    fUseRealNames = 1;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "nh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'n':
+            fUseRealNames ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( argc == globalUtilOptind + 2 )
+    {
+        Abc_NtkShow6VarFunc( argv[globalUtilOptind], argv[globalUtilOptind+1] );
+        return 0;
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsLogic(pNtk) )
+    {
+        Abc_Print( -1, "Visualization of Karnaugh maps works for logic networks.\n" );
+        return 1;
+    }
+    if ( argc > globalUtilOptind + 1 )
+    {
+        Abc_Print( -1, "Wrong number of auguments.\n" );
+        goto usage;
+    }
+    if ( argc == globalUtilOptind )
+    {
+        pNode = Abc_ObjFanin0( Abc_NtkPo(pNtk, 0) );
+        if ( !Abc_ObjIsNode(pNode) )
+        {
+            Abc_Print( -1, "The driver \"%s\" of the first PO is not an internal node.\n", Abc_ObjName(pNode) );
+            return 1;
+        }
+    }
+    else
+    {
+        pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
+        if ( pNode == NULL )
+        {
+            Abc_Print( -1, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
+            return 1;
+        }
+    }
+    Abc_NtkToBdd(pNtk);
+    Abc_NodePrintKMap( pNode, fUseRealNames );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: print_kmap [-nh] <node>\n" );
+    Abc_Print( -2, "\t        shows the truth table of the node\n" );
+    Abc_Print( -2, "\t-n    : toggles real/dummy fanin names [default = %s]\n", fUseRealNames? "real": "dummy" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    Abc_Print( -2, "\t<node>: the node to consider (default = the driver of the first PO)\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandPrintGates( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int fUseLibrary;
+
+    extern void Abc_NtkPrintGates( Abc_Ntk_t * pNtk, int fUseLibrary );
+
+    // set defaults
+    fUseLibrary = 1;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "lh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'l':
+            fUseLibrary ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( Abc_NtkHasAig(pNtk) )
+    {
+        Abc_Print( -1, "Printing gates does not work for AIGs and sequential AIGs.\n" );
+        return 1;
+    }
+
+    Abc_NtkPrintGates( pNtk, fUseLibrary );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: print_gates [-lh]\n" );
+    Abc_Print( -2, "\t        prints statistics about gates used in the network\n" );
+    Abc_Print( -2, "\t-l    : used library gate names (if mapped) [default = %s]\n", fUseLibrary? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandPrintSharing( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int fUseLibrary;
+
+    extern void Abc_NtkPrintSharing( Abc_Ntk_t * pNtk );
+
+    // set defaults
+    fUseLibrary = 1;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "lh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'l':
+            fUseLibrary ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    Abc_NtkPrintSharing( pNtk );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: print_sharing [-h]\n" );
+    Abc_Print( -2, "\t        prints the number of shared nodes in the TFI cones of the COs\n" );
+//    Abc_Print( -2, "\t-l    : used library gate names (if mapped) [default = %s]\n", fUseLibrary? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandPrintXCut( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int fUseLibrary;
+
+    extern int Abc_NtkCrossCut( Abc_Ntk_t * pNtk );
+
+    // set defaults
+    fUseLibrary = 1;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "lh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'l':
+            fUseLibrary ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    Abc_NtkCrossCut( pNtk );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: print_xcut [-h]\n" );
+    Abc_Print( -2, "\t        prints the size of the cross cut of the current network\n" );
+//    Abc_Print( -2, "\t-l    : used library gate names (if mapped) [default = %s]\n", fUseLibrary? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandPrintDsd( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int fCofactor;
+    int nCofLevel;
+    int fProfile;
+    int fPrintDec;
+
+    extern void Kit_DsdTest( unsigned * pTruth, int nVars );
+    extern void Kit_DsdPrintCofactors( unsigned * pTruth, int nVars, int nCofLevel, int fVerbose );
+    extern void Dau_DecTrySets( word * p, int nVars, int fVerbose );
+
+    // set defaults
+    nCofLevel = 1;
+    fCofactor = 0;
+    fProfile  = 0;
+    fPrintDec = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Npcdh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nCofLevel = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nCofLevel < 0 )
+                goto usage;
+            break;
+        case 'p':
+            fProfile ^= 1;
+            break;
+        case 'c':
+            fCofactor ^= 1;
+            break;
+        case 'd':
+            fPrintDec ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    // get the truth table of the first output
+    if ( !Abc_NtkIsLogic(pNtk) )
+    {
+        Abc_Print( -1, "Currently works only for logic networks.\n" );
+        return 1;
+    }
+    Abc_NtkToAig( pNtk );
+    // convert it to truth table
+    {
+        Abc_Obj_t * pObj = Abc_ObjFanin0( Abc_NtkPo(pNtk, 0) );
+        Vec_Int_t * vMemory;
+        unsigned * pTruth;
+        if ( !Abc_ObjIsNode(pObj) )
+        {
+            Abc_Print( -1, "The fanin of the first PO node does not have a logic function.\n" );
+            return 1;
+        }
+        if ( Abc_ObjFaninNum(pObj) > 16 )
+        {
+            Abc_Print( -1, "Currently works only for up to 16 inputs.\n" );
+            return 1;
+        }
+        vMemory = Vec_IntAlloc(0);
+        pTruth = Hop_ManConvertAigToTruth( (Hop_Man_t *)pNtk->pManFunc, Hop_Regular((Hop_Obj_t *)pObj->pData), Abc_ObjFaninNum(pObj), vMemory, 0 );
+        if ( Hop_IsComplement((Hop_Obj_t *)pObj->pData) )
+            Extra_TruthNot( pTruth, pTruth, Abc_ObjFaninNum(pObj) );
+//        Extra_PrintBinary( stdout, pTruth, 1 << Abc_ObjFaninNum(pObj) );
+//        Abc_Print( -1, "\n" );
+        if ( fPrintDec )//&&Abc_ObjFaninNum(pObj) <= 6 )
+        {
+            word * pTruthW = (word *)pTruth;
+            if ( Abc_ObjFaninNum(pObj) < 6 )
+                pTruthW[0] = Abc_Tt6Stretch( pTruthW[0], Abc_ObjFaninNum(pObj) );
+            Dau_DecTrySets( (word *)pTruth, Abc_ObjFaninNum(pObj), 1 );
+        }
+        if ( fProfile )
+            Kit_TruthPrintProfile( pTruth, Abc_ObjFaninNum(pObj) );
+        else if ( fCofactor )
+            Kit_DsdPrintCofactors( pTruth, Abc_ObjFaninNum(pObj), nCofLevel, 1 );
+        else
+            Kit_DsdTest( pTruth, Abc_ObjFaninNum(pObj) );
+        Vec_IntFree( vMemory );
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: print_dsd [-pcdh] [-N <num>]\n" );
+    Abc_Print( -2, "\t           print DSD formula for a single-output function with less than 16 variables\n" );
+    Abc_Print( -2, "\t-p       : toggle printing profile [default = %s]\n", fProfile? "yes": "no" );
+    Abc_Print( -2, "\t-c       : toggle recursive cofactoring [default = %s]\n", fCofactor? "yes": "no" );
+    Abc_Print( -2, "\t-d       : toggle printing decompositions [default = %s]\n", fPrintDec? "yes": "no" );
+    Abc_Print( -2, "\t-N <num> : the number of levels to cofactor [default = %d]\n", nCofLevel );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandPrintCone( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int fUseLibrary;
+
+    // set defaults
+    fUseLibrary = 1;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "lh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'l':
+            fUseLibrary ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( Abc_NtkLatchNum(pNtk) == 0 )
+    {
+        Abc_Print( -1, "The network is combinational.\n" );
+        return 1;
+    }
+    Abc_NtkDarPrintCone( pNtk );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: print_cone [-h]\n" );
+    Abc_Print( -2, "\t        prints cones of influence info for each primary output\n" );
+//    Abc_Print( -2, "\t-l    : used library gate names (if mapped) [default = %s]\n", fUseLibrary? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandPrintMiter( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int fUseLibrary;
+
+    extern void Abc_NtkPrintMiter( Abc_Ntk_t * pNtk );
+
+    // set defaults
+    fUseLibrary = 1;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "lh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'l':
+            fUseLibrary ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "The network is should be structurally hashed.\n" );
+        return 1;
+    }
+    Abc_NtkPrintMiter( pNtk );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: print_miter [-h]\n" );
+    Abc_Print( -2, "\t        prints the status of the miter\n" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandPrintStatus( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    int c, fShort = 1;
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "sh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 's':
+            fShort ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    Abc_Print( 1,"Status = %d  Frames = %d   ", pAbc->Status, pAbc->nFrames );
+    if ( pAbc->pCex == NULL && pAbc->vCexVec == NULL )
+        Abc_Print( 1,"Cex is not defined.\n" );
+    else
+    {
+        if ( pAbc->pCex )
+            Abc_CexPrintStats( pAbc->pCex );
+        if ( pAbc->vCexVec )
+        {
+            Abc_Cex_t * pTemp;
+            int nCexes = 0;
+            int Counter = 0;
+            printf( "\n" );
+            Vec_PtrForEachEntry( Abc_Cex_t *, pAbc->vCexVec, pTemp, c )
+            {
+                if ( pTemp == (void *)(ABC_PTRINT_T)1 )
+                {
+                    Counter++;
+                    continue;
+                }
+                if ( pTemp )
+                {
+                    printf( "%4d : ", ++nCexes );
+                    Abc_CexPrintStats( pTemp );
+                }
+            }
+            if ( Counter )
+                printf( "In total, %d (out of %d) outputs are \"sat\" but CEXes are not recorded.\n", Counter, Vec_PtrSize(pAbc->vCexVec) );
+        }
+    }
+    if ( pAbc->vStatuses )
+    {
+        if ( fShort )
+        {
+            printf( "Status array contains %d SAT, %d UNSAT, and %d UNDEC entries (out of %d).", 
+                Vec_IntCountEntry(pAbc->vStatuses, 0), Vec_IntCountEntry(pAbc->vStatuses, 1), 
+                Vec_IntCountEntry(pAbc->vStatuses, -1), Vec_IntSize(pAbc->vStatuses) );
+        }
+        else
+        {
+            int i, Entry;
+            Vec_IntForEachEntry( pAbc->vStatuses, Entry, i )
+                printf( "%d=%d  ", i, Entry );
+        }
+        printf( "\n" );
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: print_status [-sh]\n" );
+    Abc_Print( -2, "\t        prints verification status\n" );
+    Abc_Print( -2, "\t-s    : toggle using short print-out [default = %s]\n", fShort? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandPrintDelay( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    Abc_Obj_t * pObjIn = NULL, * pObjOut = NULL;
+    int c;
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsMappedLogic(pNtk) )
+    {
+        Abc_Print( -1, "Delay trace works only for network mapped into standard cells.\n" );
+        return 1;
+    }
+    if ( argc > globalUtilOptind + 2 )
+    {
+        Abc_Print( -1, "Wrong number of auguments.\n" );
+        goto usage;
+    }
+    // collect the first name (PO name)
+    if ( argc >= globalUtilOptind + 1 )
+    {
+        int Num = Nm_ManFindIdByName( pNtk->pManName, argv[globalUtilOptind], ABC_OBJ_PO );
+        if ( Num < 0 )
+            Num = Nm_ManFindIdByName( pNtk->pManName, argv[globalUtilOptind], ABC_OBJ_BI );
+        if ( Num >= 0 )
+            pObjOut = Abc_NtkObj( pNtk, Num );
+        if ( pObjOut == NULL )
+        {
+            Abc_Print( 1, "Cannot find combinational output \"%s\".\n", argv[globalUtilOptind] );
+            return 1;
+        }
+    }
+    // collect the second name (PI name)
+    if ( argc == globalUtilOptind + 2 )
+    {
+        int Num = Nm_ManFindIdByName( pNtk->pManName, argv[globalUtilOptind+1], ABC_OBJ_PI );
+        if ( Num < 0 )
+            Num = Nm_ManFindIdByName( pNtk->pManName, argv[globalUtilOptind+1], ABC_OBJ_BO );
+        if ( Num >= 0 )
+            pObjIn = Abc_NtkObj( pNtk, Num );
+        if ( pObjIn == NULL )
+        {
+            Abc_Print( 1, "Cannot find combinational input \"%s\".\n", argv[globalUtilOptind+1] );
+            return 1;
+        }
+    }
+    Abc_NtkDelayTrace( pNtk, pObjOut, pObjIn, 1 );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: print_delay [-h] <CO_name> <CI_name>\n" );
+    Abc_Print( -2, "\t            prints one critical path of the mapped network\n" );
+    Abc_Print( -2, "\t-h        : print the command usage\n");
+    Abc_Print( -2, "\t<CO_name> : (optional) the sink of the critical path (primary output or flop input)\n");
+    Abc_Print( -2, "\t<CI_name> : (optional) the source of the critical path (primary input or flop output)\n");
+    Abc_Print( -2, "\t            (if CO and/or CI are not given, uses the most critical ones)\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandShow( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int fSeq;
+    int fGateNames;
+    int fUseReverse;
+    int fFlopDep;
+    extern void Abc_NtkShow( Abc_Ntk_t * pNtk, int fGateNames, int fSeq, int fUseReverse );
+    extern void Abc_NtkShowFlopDependency( Abc_Ntk_t * pNtk );
+
+    // set defaults
+    fSeq        = 0;
+    fGateNames  = 0;
+    fUseReverse = 1;
+    fFlopDep    = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "rsgfh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'r':
+            fUseReverse ^= 1;
+            break;
+        case 's':
+            fSeq ^= 1;
+            break;
+        case 'g':
+            fGateNames ^= 1;
+            break;
+        case 'f':
+            fFlopDep ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( fFlopDep )
+        Abc_NtkShowFlopDependency( pNtk );
+    else
+        Abc_NtkShow( pNtk, fGateNames, fSeq, fUseReverse );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: show [-srgfh]\n" );
+    Abc_Print( -2, "       visualizes the network structure using DOT and GSVIEW\n" );
+#ifdef WIN32
+    Abc_Print( -2, "       \"dot.exe\" and \"gsview32.exe\" should be set in the paths\n" );
+    Abc_Print( -2, "       (\"gsview32.exe\" may be in \"C:\\Program Files\\Ghostgum\\gsview\\\")\n" );
+#endif
+    Abc_Print( -2, "\t-s    : toggles visualization of sequential networks [default = %s].\n", fSeq? "yes": "no" );
+    Abc_Print( -2, "\t-r    : toggles ordering nodes in reverse order [default = %s].\n", fUseReverse? "yes": "no" );
+    Abc_Print( -2, "\t-g    : toggles printing gate names for mapped network [default = %s].\n", fGateNames? "yes": "no" );
+    Abc_Print( -2, "\t-f    : toggles visualizing flop dependency graph [default = %s].\n", fFlopDep? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandShowBdd( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    Abc_Obj_t * pNode;
+    int c;
+    extern void Abc_NodeShowBdd( Abc_Obj_t * pNode );
+
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsBddLogic(pNtk) )
+    {
+        Abc_Print( -1, "Visualizing BDDs can only be done for logic BDD networks (run \"bdd\").\n" );
+        return 1;
+    }
+
+    if ( argc > globalUtilOptind + 1 )
+    {
+        Abc_Print( -1, "Wrong number of auguments.\n" );
+        goto usage;
+    }
+    if ( argc == globalUtilOptind )
+    {
+        pNode = Abc_ObjFanin0( Abc_NtkPo(pNtk, 0) );
+        if ( !Abc_ObjIsNode(pNode) )
+        {
+            Abc_Print( -1, "The driver \"%s\" of the first PO is not an internal node.\n", Abc_ObjName(pNode) );
+            return 1;
+        }
+    }
+    else
+    {
+        pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
+        if ( pNode == NULL )
+        {
+            Abc_Print( -1, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
+            return 1;
+        }
+    }
+    Abc_NodeShowBdd( pNode );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: show_bdd [-h] <node>\n" );
+    Abc_Print( -2, "       visualizes the BDD of a node using DOT and GSVIEW\n" );
+#ifdef WIN32
+    Abc_Print( -2, "       \"dot.exe\" and \"gsview32.exe\" should be set in the paths\n" );
+    Abc_Print( -2, "       (\"gsview32.exe\" may be in \"C:\\Program Files\\Ghostgum\\gsview\\\")\n" );
+#endif
+    Abc_Print( -2, "\t<node>: the node to consider [default = the driver of the first PO]\n");
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandShowCut( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    Abc_Obj_t * pNode;
+    int c;
+    int nNodeSizeMax;
+    int nConeSizeMax;
+    extern void Abc_NodeShowCut( Abc_Obj_t * pNode, int nNodeSizeMax, int nConeSizeMax );
+
+    // set defaults
+    nNodeSizeMax = 10;
+    nConeSizeMax = ABC_INFINITY;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "NCh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nNodeSizeMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nNodeSizeMax < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nConeSizeMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nConeSizeMax < 0 )
+                goto usage;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Visualizing cuts only works for AIGs (run \"strash\").\n" );
+        return 1;
+    }
+    if ( argc != globalUtilOptind + 1 )
+    {
+        Abc_Print( -1, "Wrong number of auguments.\n" );
+        goto usage;
+    }
+
+    pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
+    if ( pNode == NULL )
+    {
+        Abc_Print( -1, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
+        return 1;
+    }
+    Abc_NodeShowCut( pNode, nNodeSizeMax, nConeSizeMax );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: show_cut [-N <num>] [-C <num>] [-h] <node>\n" );
+    Abc_Print( -2, "             visualizes the cut of a node using DOT and GSVIEW\n" );
+#ifdef WIN32
+    Abc_Print( -2, "             \"dot.exe\" and \"gsview32.exe\" should be set in the paths\n" );
+    Abc_Print( -2, "             (\"gsview32.exe\" may be in \"C:\\Program Files\\Ghostgum\\gsview\\\")\n" );
+#endif
+    Abc_Print( -2, "\t-N <num> : the max size of the cut to be computed [default = %d]\n", nNodeSizeMax );
+    Abc_Print( -2, "\t-C <num> : the max support of the containing cone [default = %d]\n", nConeSizeMax );
+    Abc_Print( -2, "\t<node>   : the node to consider\n");
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandCollapse( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int fVerbose;
+    int fBddSizeMax;
+    int fDualRail;
+    int fReorder;
+    int c;
+    pNtk = Abc_FrameReadNtk(pAbc);
+
+    // set defaults
+    fVerbose = 0;
+    fReorder = 1;
+    fDualRail = 0;
+    fBddSizeMax = ABC_INFINITY;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Brdvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'B':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            fBddSizeMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( fBddSizeMax < 0 )
+                goto usage;
+            break;
+        case 'd':
+            fDualRail ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'r':
+            fReorder ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsLogic(pNtk) && !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Can only collapse a logic network or an AIG.\n" );
+        return 1;
+    }
+
+    // get the new network
+    if ( Abc_NtkIsStrash(pNtk) )
+        pNtkRes = Abc_NtkCollapse( pNtk, fBddSizeMax, fDualRail, fReorder, fVerbose );
+    else
+    {
+        pNtk = Abc_NtkStrash( pNtk, 0, 0, 0 );
+        pNtkRes = Abc_NtkCollapse( pNtk, fBddSizeMax, fDualRail, fReorder, fVerbose );
+        Abc_NtkDelete( pNtk );
+    }
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Collapsing has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: collapse [-B <num>] [-rdvh]\n" );
+    Abc_Print( -2, "\t          collapses the network by constructing global BDDs\n" );
+    Abc_Print( -2, "\t-B <num>: limit on live BDD nodes during collapsing [default = %d]\n", fBddSizeMax );
+    Abc_Print( -2, "\t-r      : toggles dynamic variable reordering [default = %s]\n", fReorder? "yes": "no" );
+    Abc_Print( -2, "\t-d      : toggles dual-rail collapsing mode [default = %s]\n", fDualRail? "yes": "no" );
+    Abc_Print( -2, "\t-v      : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h      : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandStrash( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    Abc_Obj_t * pObj;
+    int c;
+    int fAllNodes;
+    int fRecord;
+    int fCleanup;
+    int fComplOuts;
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    fAllNodes = 0;
+    fCleanup  = 1;
+    fRecord   = 0;
+    fComplOuts= 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "acrih" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'a':
+            fAllNodes ^= 1;
+            break;
+        case 'c':
+            fCleanup ^= 1;
+            break;
+        case 'r':
+            fRecord ^= 1;
+            break;
+        case 'i':
+            fComplOuts ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    // get the new network
+    pNtkRes = Abc_NtkStrash( pNtk, fAllNodes, fCleanup, fRecord );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Strashing has failed.\n" );
+        return 1;
+    }
+    if ( fComplOuts )
+    Abc_NtkForEachPo( pNtkRes, pObj, c )
+        Abc_ObjXorFaninC( pObj, 0 );
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: strash [-acrih]\n" );
+    Abc_Print( -2, "\t        transforms combinational logic into an AIG\n" );
+    Abc_Print( -2, "\t-a    : toggles between using all nodes and DFS nodes [default = %s]\n", fAllNodes? "all": "DFS" );
+    Abc_Print( -2, "\t-c    : toggles cleanup to remove the dagling AIG nodes [default = %s]\n", fCleanup? "all": "DFS" );
+    Abc_Print( -2, "\t-r    : toggles using the record of AIG subgraphs [default = %s]\n", fRecord? "yes": "no" );
+    Abc_Print( -2, "\t-i    : toggles complementing the POs of the AIG [default = %s]\n", fComplOuts? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandBalance( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes, * pNtkTemp;
+    int c;
+    int fDuplicate;
+    int fSelective;
+    int fUpdateLevel;
+    int fExor;
+    int fVerbose;
+    pNtk = Abc_FrameReadNtk(pAbc);
+
+    // set defaults
+    fDuplicate   = 0;
+    fSelective   = 0;
+    fUpdateLevel = 1;
+    fExor        = 0;
+    fVerbose     = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "ldsxvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'l':
+            fUpdateLevel ^= 1;
+            break;
+        case 'd':
+            fDuplicate ^= 1;
+            break;
+        case 's':
+            fSelective ^= 1;
+            break;
+        case 'x':
+            fExor ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    // get the new network
+    if ( Abc_NtkIsStrash(pNtk) )
+    {
+        if ( fExor )
+            pNtkRes = Abc_NtkBalanceExor( pNtk, fUpdateLevel, fVerbose );
+        else
+            pNtkRes = Abc_NtkBalance( pNtk, fDuplicate, fSelective, fUpdateLevel );
+    }
+    else
+    {
+        pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
+        if ( pNtkTemp == NULL )
+        {
+            Abc_Print( -1, "Strashing before balancing has failed.\n" );
+            return 1;
+        }
+        if ( fExor )
+            pNtkRes = Abc_NtkBalanceExor( pNtkTemp, fUpdateLevel, fVerbose );
+        else
+            pNtkRes = Abc_NtkBalance( pNtkTemp, fDuplicate, fSelective, fUpdateLevel );
+        Abc_NtkDelete( pNtkTemp );
+    }
+
+    // check if balancing worked
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Balancing has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: balance [-ldsxvh]\n" );
+    Abc_Print( -2, "\t        transforms the current network into a well-balanced AIG\n" );
+    Abc_Print( -2, "\t-l    : toggle minimizing the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
+    Abc_Print( -2, "\t-d    : toggle duplication of logic [default = %s]\n", fDuplicate? "yes": "no" );
+    Abc_Print( -2, "\t-s    : toggle duplication on the critical paths [default = %s]\n", fSelective? "yes": "no" );
+    Abc_Print( -2, "\t-x    : toggle balancing multi-input EXORs [default = %s]\n", fExor? "yes": "no" );
+    Abc_Print( -2, "\t-v    : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandMuxStruct( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c;
+    int fVerbose;
+
+    extern Abc_Ntk_t * Abc_NtkMuxRestructure( Abc_Ntk_t * pNtk, int fVerbose );
+    pNtk = Abc_FrameReadNtk(pAbc);
+
+    // set defaults
+    fVerbose     = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    // get the new network
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Does not work for a logic network.\n" );
+        return 1;
+    }
+    // check if balancing worked
+//    pNtkRes = Abc_NtkMuxRestructure( pNtk, fVerbose );
+    pNtkRes = NULL;
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "MUX restructuring has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: mux_struct [-vh]\n" );
+    Abc_Print( -2, "\t        performs MUX restructuring of the current network\n" );
+    Abc_Print( -2, "\t-v    : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandMulti( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int nThresh, nFaninMax, c;
+    int fCnf;
+    int fMulti;
+    int fSimple;
+    int fFactor;
+    extern Abc_Ntk_t * Abc_NtkMulti( Abc_Ntk_t * pNtk, int nThresh, int nFaninMax, int fCnf, int fMulti, int fSimple, int fFactor );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+
+    // set defaults
+    nThresh   =  1;
+    nFaninMax = 20;
+    fCnf      =  0;
+    fMulti    =  1;
+    fSimple   =  0;
+    fFactor   =  0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "TFmcsfh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nThresh = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nThresh < 0 )
+                goto usage;
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFaninMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFaninMax < 0 )
+                goto usage;
+            break;
+        case 'c':
+            fCnf ^= 1;
+            break;
+        case 'm':
+            fMulti ^= 1;
+            break;
+        case 's':
+            fSimple ^= 1;
+            break;
+        case 'f':
+            fFactor ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Cannot renode a network that is not an AIG (run \"strash\").\n" );
+        return 1;
+    }
+
+    // get the new network
+    pNtkRes = Abc_NtkMulti( pNtk, nThresh, nFaninMax, fCnf, fMulti, fSimple, fFactor );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Renoding has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: multi [-TF <num>] [-msfch]\n" );
+    Abc_Print( -2, "\t          transforms an AIG into a logic network by creating larger nodes\n" );
+    Abc_Print( -2, "\t-F <num>: the maximum fanin size after renoding [default = %d]\n", nFaninMax );
+    Abc_Print( -2, "\t-T <num>: the threshold for AIG node duplication [default = %d]\n", nThresh );
+    Abc_Print( -2, "\t          (an AIG node is the root of a new node after renoding\n" );
+    Abc_Print( -2, "\t          if this leads to duplication of no more than %d AIG nodes,\n", nThresh );
+    Abc_Print( -2, "\t          that is, if [(numFanouts(Node)-1) * size(MFFC(Node))] <= %d)\n", nThresh );
+    Abc_Print( -2, "\t-m      : creates multi-input AND graph [default = %s]\n", fMulti? "yes": "no" );
+    Abc_Print( -2, "\t-s      : creates a simple AIG (no renoding) [default = %s]\n", fSimple? "yes": "no" );
+    Abc_Print( -2, "\t-f      : creates a factor-cut network [default = %s]\n", fFactor? "yes": "no" );
+    Abc_Print( -2, "\t-c      : performs renoding to derive the CNF [default = %s]\n", fCnf? "yes": "no" );
+    Abc_Print( -2, "\t-h      : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandRenode( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int nLutSize, nCutsMax, c;
+    int nFlowIters, nAreaIters;
+    int fArea;
+    int fUseBdds;
+    int fUseSops;
+    int fUseCnfs;
+    int fUseMv;
+    int fVerbose;
+    extern Abc_Ntk_t * Abc_NtkRenode( Abc_Ntk_t * pNtk, int nLutSize, int nCutsMax, int nFlowIters, int nAreaIters, int fArea, int fUseBdds, int fUseSops, int fUseCnfs, int fUseMv, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+
+    // set defaults
+    nLutSize   =  8;
+    nCutsMax   =  4;
+    nFlowIters =  1;
+    nAreaIters =  1;
+    fArea      =  0;
+    fUseBdds   =  0;
+    fUseSops   =  0;
+    fUseCnfs   =  0;
+    fUseMv     =  0;
+    fVerbose   =  0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "KCFAabscivh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nLutSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLutSize < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nCutsMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nCutsMax < 0 )
+                goto usage;
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            nFlowIters = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFlowIters < 0 )
+                goto usage;
+            break;
+        case 'A':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-A\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            nAreaIters = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nAreaIters < 0 )
+                goto usage;
+            break;
+        case 'a':
+            fArea ^= 1;
+            break;
+        case 'b':
+            fUseBdds ^= 1;
+            break;
+        case 's':
+            fUseSops ^= 1;
+            break;
+        case 'c':
+            fUseCnfs ^= 1;
+            break;
+        case 'i':
+            fUseMv ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( fUseBdds + fUseSops + fUseCnfs + fUseMv > 1 )
+    {
+        Abc_Print( -1, "Cannot optimize two parameters at the same time.\n" );
+        return 1;
+    }
+
+    if ( nLutSize < 2 || nLutSize > IF_MAX_FUNC_LUTSIZE )
+    {
+        Abc_Print( -1, "Incorrect LUT size (%d).\n", nLutSize );
+        return 1;
+    }
+
+    if ( nCutsMax < 1 || nCutsMax >= (1<<12) )
+    {
+        Abc_Print( -1, "Incorrect number of cuts.\n" );
+        return 1;
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Cannot renode a network that is not an AIG (run \"strash\").\n" );
+        return 1;
+    }
+
+    // get the new network
+    pNtkRes = Abc_NtkRenode( pNtk, nLutSize, nCutsMax, nFlowIters, nAreaIters, fArea, fUseBdds, fUseSops, fUseCnfs, fUseMv, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Renoding has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: renode [-KCFA <num>] [-sbciav]\n" );
+    Abc_Print( -2, "\t          transforms the AIG into a logic network with larger nodes\n" );
+    Abc_Print( -2, "\t          while minimizing the number of FF literals of the node SOPs\n" );
+    Abc_Print( -2, "\t-K <num>: the max cut size for renoding (2 < num < %d) [default = %d]\n", IF_MAX_FUNC_LUTSIZE+1, nLutSize );
+    Abc_Print( -2, "\t-C <num>: the max number of cuts used at a node (0 < num < 2^12) [default = %d]\n", nCutsMax );
+    Abc_Print( -2, "\t-F <num>: the number of area flow recovery iterations (num >= 0) [default = %d]\n", nFlowIters );
+    Abc_Print( -2, "\t-A <num>: the number of exact area recovery iterations (num >= 0) [default = %d]\n", nAreaIters );
+    Abc_Print( -2, "\t-s      : toggles minimizing SOP cubes instead of FF lits [default = %s]\n", fUseSops? "yes": "no" );
+    Abc_Print( -2, "\t-b      : toggles minimizing BDD nodes instead of FF lits [default = %s]\n", fUseBdds? "yes": "no" );
+    Abc_Print( -2, "\t-c      : toggles minimizing CNF clauses instead of FF lits [default = %s]\n", fUseCnfs? "yes": "no" );
+    Abc_Print( -2, "\t-i      : toggles minimizing MV-SOP instead of FF lits [default = %s]\n", fUseMv? "yes": "no" );
+    Abc_Print( -2, "\t-a      : toggles area-oriented mapping [default = %s]\n", fArea? "yes": "no" );
+    Abc_Print( -2, "\t-v      : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h      : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandCleanup( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c;
+    int fCleanupPis;
+    int fCleanupPos;
+    int fVerbose;
+
+    extern Abc_Ntk_t * Abc_NtkDarCleanupAig( Abc_Ntk_t * pNtk, int fCleanupPis, int fCleanupPos, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+
+    // set defaults
+    fCleanupPis = 1;
+    fCleanupPos = 1;
+    fVerbose    = 1;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "iovh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'i':
+            fCleanupPis ^= 1;
+            break;
+        case 'o':
+            fCleanupPos ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( Abc_NtkIsStrash(pNtk) )
+    {
+        if ( !fCleanupPos && !fCleanupPos )
+        {
+            Abc_Print( -1, "Cleanup for PIs and POs is not enabled.\n" );
+            pNtkRes = Abc_NtkDup( pNtk );
+        }
+        else
+            pNtkRes = Abc_NtkDarCleanupAig( pNtk, fCleanupPis, fCleanupPos, fVerbose );
+    }
+    else
+    {
+        Abc_NtkCleanup( pNtk, fVerbose );
+        pNtkRes = Abc_NtkDup( pNtk );
+    }
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Cleanup has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: cleanup [-iovh]\n" );
+    Abc_Print( -2, "\t        for logic networks, removes dangling combinatinal logic\n" );
+    Abc_Print( -2, "\t        for AIGs, removes PIs w/o fanout and POs driven by const-0\n" );
+    Abc_Print( -2, "\t-i    : toggles removing PIs without fanout [default = %s]\n", fCleanupPis? "yes": "no" );
+    Abc_Print( -2, "\t-o    : toggles removing POs with const-0 drivers [default = %s]\n", fCleanupPos? "yes": "no" );
+    Abc_Print( -2, "\t-v    : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int fSingle = 0;
+    int fVerbose = 0;
+
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "svh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 's':
+            fSingle ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsLogic(pNtk) )
+    {
+        Abc_Print( -1, "The classical (SIS-like) sweep can only be performed on a logic network.\n" );
+        return 1;
+    }
+    // modify the current network
+    if ( fSingle )
+        Abc_NtkSweepBufsInvs( pNtk, fVerbose );
+    else
+        Abc_NtkSweep( pNtk, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: sweep [-svh]\n" );
+    Abc_Print( -2, "\t        removes dangling nodes; propagates constant, buffers, inverters\n" );
+    Abc_Print( -2, "\t-s    : toggle sweeping buffers/inverters only [default = %s]\n", fSingle? "yes": "no" );
+    Abc_Print( -2, "\t-v    : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandFastExtract( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern int Abc_NtkFxPerform( Abc_Ntk_t * pNtk, int nNewNodesMax, int nLitCountMax, int fVerbose, int fVeryVerbose );
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    Fxu_Data_t Params, * p = &Params;
+    int c, fNewAlgo = 1;
+    int nPairsLimit = 1000000000;
+    // set the defaults
+    Abc_NtkSetDefaultFxParams( p );
+    Extra_UtilGetoptReset();
+    while ( (c = Extra_UtilGetopt(argc, argv, "SDNWMPsdzcnvwh")) != EOF )
+    {
+        switch (c)
+        {
+            case 'S':
+                if ( globalUtilOptind >= argc )
+                {
+                    Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+                    goto usage;
+                }
+                p->nSingleMax = atoi(argv[globalUtilOptind]);
+                globalUtilOptind++;
+                if ( p->nSingleMax < 0 )
+                    goto usage;
+                break;
+            case 'D':
+                if ( globalUtilOptind >= argc )
+                {
+                    Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
+                    goto usage;
+                }
+                p->nPairsMax = atoi(argv[globalUtilOptind]);
+                globalUtilOptind++;
+                if ( p->nPairsMax < 0 )
+                    goto usage;
+                break;
+            case 'N':
+                if ( globalUtilOptind >= argc )
+                {
+                    Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                    goto usage;
+                }
+                p->nNodesExt = atoi(argv[globalUtilOptind]);
+                globalUtilOptind++;
+                if ( p->nNodesExt < 0 )
+                    goto usage;
+                break;
+            case 'W':
+                if ( globalUtilOptind >= argc )
+                {
+                    Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
+                    goto usage;
+                }
+                p->WeightMin = atoi(argv[globalUtilOptind]);
+                globalUtilOptind++;
+                if ( p->WeightMin < 0 )
+                    goto usage;
+                break;
+            case 'M':
+                if ( globalUtilOptind >= argc )
+                {
+                    Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
+                    goto usage;
+                }
+                p->LitCountMax = atoi(argv[globalUtilOptind]);
+                globalUtilOptind++;
+                if ( p->LitCountMax < 0 )
+                    goto usage;
+                break;
+            case 'P':
+                if ( globalUtilOptind >= argc )
+                {
+                    Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
+                    goto usage;
+                }
+                nPairsLimit = atoi(argv[globalUtilOptind]);
+                globalUtilOptind++;
+                if ( nPairsLimit < 0 )
+                    goto usage;
+                break;
+            case 's':
+                p->fOnlyS ^= 1;
+                break;
+            case 'd':
+                p->fOnlyD ^= 1;
+                break;
+            case 'z':
+                p->fUse0 ^= 1;
+                break;
+            case 'c':
+                p->fUseCompl ^= 1;
+                break;
+            case 'n':
+                fNewAlgo ^= 1;
+                break;
+            case 'v':
+                p->fVerbose ^= 1;
+                break;
+            case 'w':
+                p->fVeryVerbose ^= 1;
+                break;
+            case 'h':
+                goto usage;
+                break;
+            default:
+                goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( Abc_NtkNodeNum(pNtk) == 0 )
+    {
+        Abc_Print( -1, "The network does not have internal nodes.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsLogic(pNtk) )
+    {
+        Abc_Print( -1, "Fast extract can only be applied to a logic network (run \"renode\" or \"if\").\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsSopLogic(pNtk) )
+    {
+        Abc_Print( -1, "Fast extract can only be applied to a logic network with SOP local functions (run \"bdd; sop\").\n" );
+        return 1;
+    }
+    if ( Abc_NtkGetCubePairNum(pNtk) > nPairsLimit )
+    {
+        Abc_Print( -1, "Cannot perform \"fx\" because the number cube pairs exceeds the limit (%d).\n", nPairsLimit );
+        return 1;
+    }
+
+    // the nodes to be merged are linked into the special linked list
+    if ( fNewAlgo )
+        Abc_NtkFxPerform( pNtk, p->nNodesExt, p->LitCountMax, p->fVerbose, p->fVeryVerbose );
+    else
+        Abc_NtkFastExtract( pNtk, p );
+    Abc_NtkFxuFreeInfo( p );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: fx [-SDNWMP <num>] [-sdzcnvwh]\n");
+    Abc_Print( -2, "\t           performs unate fast extract on the current network\n");
+    Abc_Print( -2, "\t-S <num> : max number of single-cube divisors to consider [default = %d]\n", p->nSingleMax );
+    Abc_Print( -2, "\t-D <num> : max number of double-cube divisors to consider [default = %d]\n", p->nPairsMax );
+    Abc_Print( -2, "\t-N <num> : max number of divisors to extract during this run [default = %d]\n", p->nNodesExt );
+    Abc_Print( -2, "\t-W <num> : lower bound on the weight of divisors to extract [default = %d]\n", p->WeightMin );
+    Abc_Print( -2, "\t-M <num> : upper bound on literal count of divisors to extract [default = %d]\n", p->LitCountMax );
+    Abc_Print( -2, "\t-P <num> : skip \"fx\" if cube pair count exceeds this limit [default = %d]\n", nPairsLimit );
+    Abc_Print( -2, "\t-s       : use only single-cube divisors [default = %s]\n", p->fOnlyS? "yes": "no" );
+    Abc_Print( -2, "\t-d       : use only double-cube divisors [default = %s]\n", p->fOnlyD? "yes": "no" );
+    Abc_Print( -2, "\t-z       : use zero-weight divisors [default = %s]\n", p->fUse0? "yes": "no" );
+    Abc_Print( -2, "\t-c       : use complement in the binary case [default = %s]\n", p->fUseCompl? "yes": "no" );
+    Abc_Print( -2, "\t-n       : use new implementation of fast extract [default = %s]\n", fNewAlgo? "yes": "no" );
+    Abc_Print( -2, "\t-v       : print verbose information [default = %s]\n", p->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w       : print additional information [default = %s]\n", p->fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandEliminate( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int ElimValue;
+    int nMaxSize;
+    int nIterMax;
+    int fGreedy;
+    int fReverse;
+    int fSpecial;
+    int fVerbose;
+    int c;
+    extern int Abc_NtkEliminate( Abc_Ntk_t * pNtk, int nMaxSize, int fReverse, int fVerbose );
+    extern int Abc_NtkEliminate1( Abc_Ntk_t * pNtk, int ElimValue, int nMaxSize, int nIterMax, int fReverse, int fVerbose );
+    extern int Abc_NtkEliminateSpecial( Abc_Ntk_t * pNtk, int nMaxSize, int fVerbose );
+
+    // set the defaults
+    ElimValue = -1;
+    nMaxSize  = 12;
+    nIterMax  =  1;
+    fGreedy   =  0;
+    fReverse  =  0;
+    fSpecial  =  0;
+    fVerbose  =  0;
+    Extra_UtilGetoptReset();
+    while ( (c = Extra_UtilGetopt(argc, argv, "VNIgrsvh")) != EOF )
+    {
+        switch (c)
+        {
+            case 'V':
+                if ( globalUtilOptind >= argc )
+                {
+                    Abc_Print( -1, "Command line switch \"-V\" should be followed by an integer that is -1 or larger.\n" );
+                    goto usage;
+                }
+                ElimValue = atoi(argv[globalUtilOptind]);
+                globalUtilOptind++;
+                if ( ElimValue < -1 )
+                    goto usage;
+                break;
+            case 'N':
+                if ( globalUtilOptind >= argc )
+                {
+                    Abc_Print( -1, "Command line switch \"-N\" should be followed by a positive integer.\n" );
+                    goto usage;
+                }
+                nMaxSize = atoi(argv[globalUtilOptind]);
+                globalUtilOptind++;
+                if ( nMaxSize <= 0 )
+                    goto usage;
+                break;
+            case 'I':
+                if ( globalUtilOptind >= argc )
+                {
+                    Abc_Print( -1, "Command line switch \"-I\" should be followed by a positive integer.\n" );
+                    goto usage;
+                }
+                nIterMax = atoi(argv[globalUtilOptind]);
+                globalUtilOptind++;
+                if ( nIterMax <= 0 )
+                    goto usage;
+                break;
+            case 'g':
+                fGreedy ^= 1;
+                break;
+            case 'r':
+                fReverse ^= 1;
+                break;
+            case 's':
+                fSpecial ^= 1;
+                break;
+            case 'v':
+                fVerbose ^= 1;
+                break;
+            case 'h':
+                goto usage;
+                break;
+            default:
+                goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( Abc_NtkNodeNum(pNtk) == 0 )
+    {
+        Abc_Print( -1, "The network does not have internal nodes.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsLogic(pNtk) )
+    {
+        Abc_Print( -1, "This command can only be applied to a logic network (run \"renode\" or \"if\").\n" );
+        return 1;
+    }
+
+    if ( fSpecial )
+        Abc_NtkEliminateSpecial( pNtk, 1000, fVerbose );
+    else if ( fGreedy )
+        Abc_NtkEliminate( pNtk, nMaxSize, fReverse, fVerbose );
+    else
+        Abc_NtkEliminate1( pNtk, ElimValue, nMaxSize, nIterMax, fReverse, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: eliminate [-VNI <num>] [-grsvh]\n");
+    Abc_Print( -2, "\t           traditional \"eliminate -1\", which collapses the node into its fanout\n");
+    Abc_Print( -2, "\t           if the node's variable appears in the fanout's factored form only once\n");
+    Abc_Print( -2, "\t-V <num> : the \"value\" parameter used by \"eliminate\" in SIS [default = %d]\n", ElimValue );
+    Abc_Print( -2, "\t-N <num> : the maximum node support after collapsing [default = %d]\n", nMaxSize );
+    Abc_Print( -2, "\t-I <num> : the maximum number of iterations [default = %d]\n", nIterMax );
+    Abc_Print( -2, "\t-g       : toggle using greedy eliminate (without \"value\") [default = %s]\n", fGreedy? "yes": "no" );
+    Abc_Print( -2, "\t-r       : use the reverse topological order [default = %s]\n", fReverse? "yes": "no" );
+    Abc_Print( -2, "\t-s       : toggle eliminating similar nodes [default = %s]\n", fSpecial? "yes": "no" );
+    Abc_Print( -2, "\t-v       : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandDisjoint( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes, * pNtkNew;
+    int fGlobal, fRecursive, fVerbose, fPrint, fShort, c;
+
+    extern Abc_Ntk_t * Abc_NtkDsdGlobal( Abc_Ntk_t * pNtk, int fVerbose, int fPrint, int fShort );
+    extern int         Abc_NtkDsdLocal( Abc_Ntk_t * pNtk, int fVerbose, int fRecursive );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    fGlobal    = 1;
+    fRecursive = 0;
+    fVerbose   = 0;
+    fPrint     = 0;
+    fShort     = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "grvpsh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+            case 'g':
+                fGlobal ^= 1;
+                break;
+            case 'r':
+                fRecursive ^= 1;
+                break;
+            case 'v':
+                fVerbose ^= 1;
+                break;
+            case 'p':
+                fPrint ^= 1;
+                break;
+            case 's':
+                fShort ^= 1;
+                break;
+            case 'h':
+                goto usage;
+                break;
+            default:
+                goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( fGlobal )
+    {
+//        Abc_Print( 0, "Performing DSD of global functions of the network.\n" );
+        // get the new network
+        if ( !Abc_NtkIsStrash(pNtk) )
+        {
+            pNtkNew = Abc_NtkStrash( pNtk, 0, 0, 0 );
+            pNtkRes = Abc_NtkDsdGlobal( pNtkNew, fVerbose, fPrint, fShort );
+            Abc_NtkDelete( pNtkNew );
+        }
+        else
+        {
+            pNtkRes = Abc_NtkDsdGlobal( pNtk, fVerbose, fPrint, fShort );
+        }
+        if ( pNtkRes == NULL )
+        {
+            Abc_Print( -1, "Global DSD has failed.\n" );
+            return 1;
+        }
+        // replace the current network
+        Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    }
+    else if ( fRecursive )
+    {
+        if ( !Abc_NtkIsBddLogic( pNtk ) )
+        {
+            Abc_Print( -1, "This command is only applicable to logic BDD networks.\n" );
+            return 1;
+        }
+        if ( fVerbose )
+            Abc_Print( 1, "Performing recursive DSD and MUX decomposition of local functions.\n" );
+        if ( !Abc_NtkDsdLocal( pNtk, fVerbose, fRecursive ) )
+            Abc_Print( -1, "Recursive DSD has failed.\n" );
+    }
+    else
+    {
+        if ( !Abc_NtkIsBddLogic( pNtk ) )
+        {
+            Abc_Print( -1, "This command is only applicable to logic BDD networks (run \"bdd\").\n" );
+            return 1;
+        }
+        if ( fVerbose )
+            Abc_Print( 1, "Performing simple non-recursive DSD of local functions.\n" );
+        if ( !Abc_NtkDsdLocal( pNtk, fVerbose, fRecursive ) )
+            Abc_Print( -1, "Simple DSD of local functions has failed.\n" );
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: dsd [-grvpsh]\n" );
+    Abc_Print( -2, "\t     decomposes the network using disjoint-support decomposition\n" );
+    Abc_Print( -2, "\t-g     : toggle DSD of global and local functions [default = %s]\n", fGlobal? "global": "local" );
+    Abc_Print( -2, "\t-r     : toggle recursive DSD/MUX and simple DSD [default = %s]\n", fRecursive? "recursive DSD/MUX": "simple DSD" );
+    Abc_Print( -2, "\t-v     : prints DSD statistics and runtime [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-p     : prints DSD structure to the standard output [default = %s]\n", fPrint? "yes": "no" );
+    Abc_Print( -2, "\t-s     : use short PI names when printing DSD structure [default = %s]\n", fShort? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandSparsify( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Abc_Ntk_t * Abc_NtkSparsify( Abc_Ntk_t * pNtk, int nPerc, int fVerbose );
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc), * pNtkNew;
+    int nPerc, fVerbose, c;
+    // set defaults
+    nPerc      = 10;
+    fVerbose   =  0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Nvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+            case 'N':
+                if ( globalUtilOptind >= argc )
+                {
+                    Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                    goto usage;
+                }
+                nPerc = atoi(argv[globalUtilOptind]);
+                globalUtilOptind++;
+                if ( nPerc < 1 || nPerc > 100 )
+                    goto usage;
+                break;
+            case 'v':
+                fVerbose ^= 1;
+                break;
+            case 'h':
+                goto usage;
+                break;
+            default:
+                goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsBddLogic( pNtk ) )
+    {
+        Abc_Print( -1, "This command is only applicable to logic BDD networks (run \"bdd\").\n" );
+        return 1;
+    }
+    if ( Abc_NtkCiNum(pNtk) > 16 )
+    {
+        Abc_Print( -1, "The number of primary inputs is more than 16.\n" );
+        return 1;
+    }
+    pNtkNew = Abc_NtkSparsify( pNtk, nPerc, fVerbose );
+    if ( pNtkNew == NULL )
+    {
+        Abc_Print( -1, "Command has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkNew );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: sparsify [-N num] [-vh]\n" );
+    Abc_Print( -2, "\t           creates incompletely-specified function\n" );
+    Abc_Print( -2, "\t-N <num> : the percentage of on-set and off-set minterms (1 <= num <= 100) [default = %d]\n", nPerc );
+    Abc_Print( -2, "\t-v       : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandLutpack( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    Lpk_Par_t Pars, * pPars = &Pars;
+    int c;
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    memset( pPars, 0, sizeof(Lpk_Par_t) );
+    pPars->nLutsMax     =  4; // (N) the maximum number of LUTs in the structure
+    pPars->nLutsOver    =  3; // (Q) the maximum number of LUTs not in the MFFC
+    pPars->nVarsShared  =  0; // (S) the maximum number of shared variables (crossbars)
+    pPars->nGrowthLevel =  0; // (L) the maximum number of increased levels
+    pPars->fSatur       =  1;
+    pPars->fZeroCost    =  0;
+    pPars->fFirst       =  0;
+    pPars->fOldAlgo     =  0;
+    pPars->fVerbose     =  0;
+    pPars->fVeryVerbose =  0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "NQSLszfovwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nLutsMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nLutsMax < 2 || pPars->nLutsMax > 8 )
+                goto usage;
+            break;
+        case 'Q':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-Q\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nLutsOver = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nLutsOver < 0 || pPars->nLutsOver > 8 )
+                goto usage;
+            break;
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nVarsShared = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nVarsShared < 0 || pPars->nVarsShared > 4 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nGrowthLevel = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nGrowthLevel < 0 || pPars->nGrowthLevel > ABC_INFINITY )
+                goto usage;
+            break;
+        case 's':
+            pPars->fSatur ^= 1;
+            break;
+        case 'z':
+            pPars->fZeroCost ^= 1;
+            break;
+        case 'f':
+            pPars->fFirst ^= 1;
+            break;
+        case 'o':
+            pPars->fOldAlgo ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'w':
+            pPars->fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsLogic(pNtk) )
+    {
+        Abc_Print( -1, "This command can only be applied to a logic network.\n" );
+        return 1;
+    }
+    if ( pPars->nVarsShared < 0 || pPars->nVarsShared > 3 )
+    {
+        Abc_Print( -1, "The number of shared variables (%d) is not in the range 0 <= S <= 3.\n", pPars->nVarsShared );
+        return 1;
+    }
+
+    // modify the current network
+    if ( !Lpk_Resynthesize( pNtk, pPars ) )
+    {
+        Abc_Print( -1, "Resynthesis has failed.\n" );
+        return 1;
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: lutpack [-NQSL <num>] [-szfovwh]\n" );
+    Abc_Print( -2, "\t           performs \"rewriting\" for LUT network;\n" );
+    Abc_Print( -2, "\t           determines LUT size as the max fanin count of a node;\n" );
+    Abc_Print( -2, "\t           if the network is not LUT-mapped, packs it into 6-LUTs\n" );
+    Abc_Print( -2, "\t           (there is another command for resynthesis after LUT mapping, \"imfs\")\n" );
+    Abc_Print( -2, "\t-N <num> : the max number of LUTs in the structure (2 <= num) [default = %d]\n", pPars->nLutsMax );
+    Abc_Print( -2, "\t-Q <num> : the max number of LUTs not in MFFC (0 <= num) [default = %d]\n", pPars->nLutsOver );
+    Abc_Print( -2, "\t-S <num> : the max number of LUT inputs shared (0 <= num <= 3) [default = %d]\n", pPars->nVarsShared );
+    Abc_Print( -2, "\t-L <num> : max level increase after resynthesis (0 <= num) [default = %d]\n", pPars->nGrowthLevel );
+    Abc_Print( -2, "\t-s       : toggle iteration till saturation [default = %s]\n", pPars->fSatur? "yes": "no" );
+    Abc_Print( -2, "\t-z       : toggle zero-cost replacements [default = %s]\n", pPars->fZeroCost? "yes": "no" );
+    Abc_Print( -2, "\t-f       : toggle using only first node and first cut [default = %s]\n", pPars->fFirst? "yes": "no" );
+    Abc_Print( -2, "\t-o       : toggle using old implementation [default = %s]\n", pPars->fOldAlgo? "yes": "no" );
+    Abc_Print( -2, "\t-v       : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w       : toggle detailed printout of decomposed functions [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandLutmin( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c;
+    int nLutSize;
+    int fVerbose;
+    extern Abc_Ntk_t * Abc_NtkLutmin( Abc_Ntk_t * pNtk, int nLutSize, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    nLutSize = 4;
+    fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Kvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nLutSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    // modify the current network
+    pNtkRes = Abc_NtkLutmin( pNtk, nLutSize, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "The command has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: lutmin [-K <num>] [-vh]\n" );
+    Abc_Print( -2, "\t           perform FPGA mapping while minimizing the LUT count\n" );
+    Abc_Print( -2, "\t           as described in the paper T. Sasao and A. Mishchenko:\n" );
+    Abc_Print( -2, "\t           \"On the number of LUTs to implement logic functions\".\n" );
+    Abc_Print( -2, "\t-K <num> : the LUT size to use for the mapping (2 <= num) [default = %d]\n", nLutSize );
+    Abc_Print( -2, "\t-v       : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+#if 0
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandImfs( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    Res_Par_t Pars, * pPars = &Pars;
+    int c;
+
+    // set defaults
+    pPars->nWindow      = 62;
+    pPars->nCands       =  5;
+    pPars->nSimWords    =  4;
+    pPars->nGrowthLevel =  0;
+    pPars->fArea        =  0;
+    pPars->fVerbose     =  0;
+    pPars->fVeryVerbose =  0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "WSCLavwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nWindow = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nWindow < 1 || pPars->nWindow > 99 )
+                goto usage;
+            break;
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nSimWords = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nSimWords < 1 || pPars->nSimWords > 256 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nCands = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nCands < 0 || pPars->nCands > ABC_INFINITY )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nGrowthLevel = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nGrowthLevel < 0 || pPars->nGrowthLevel > ABC_INFINITY )
+                goto usage;
+            break;
+        case 'a':
+            pPars->fArea ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'w':
+            pPars->fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsLogic(pNtk) )
+    {
+        Abc_Print( -1, "This command can only be applied to a logic network.\n" );
+        return 1;
+    }
+
+    // modify the current network
+    if ( !Abc_NtkResynthesize( pNtk, pPars ) )
+    {
+        Abc_Print( -1, "Resynthesis has failed.\n" );
+        return 1;
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: imfs [-W <NM>] [-LCS <num>] [-avwh]\n" );
+    Abc_Print( -2, "\t           performs resubstitution-based resynthesis with interpolation\n" );
+    Abc_Print( -2, "\t           (there is another command for resynthesis after LUT mapping, \"lutpack\")\n" );
+    Abc_Print( -2, "\t-W <NM>  : fanin/fanout levels (NxM) of the window (00 <= NM <= 99) [default = %d%d]\n", pPars->nWindow/10, pPars->nWindow%10 );
+    Abc_Print( -2, "\t-C <num> : the max number of resub candidates (1 <= n) [default = %d]\n", pPars->nCands );
+    Abc_Print( -2, "\t-S <num> : the number of simulation words (1 <= n <= 256) [default = %d]\n", pPars->nSimWords );
+    Abc_Print( -2, "\t-L <num> : the max increase in node level after resynthesis (0 <= num) [default = %d]\n", pPars->nGrowthLevel );
+    Abc_Print( -2, "\t-a       : toggle optimization for area only [default = %s]\n", pPars->fArea? "yes": "no" );
+    Abc_Print( -2, "\t-v       : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w       : toggle printout subgraph statistics [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+#endif
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandMfs( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    Mfs_Par_t Pars, * pPars = &Pars;
+    int c;
+    // set defaults
+    Abc_NtkMfsParsDefault( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "WFDMLCdraestpgvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nWinTfoLevs = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nWinTfoLevs < 0 )
+                goto usage;
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nFanoutsMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nFanoutsMax < 0 )
+                goto usage;
+            break;
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nDepthMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nDepthMax < 0 )
+                goto usage;
+            break;
+        case 'M':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nWinMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nWinMax < 0 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nGrowthLevel = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nGrowthLevel < 0 || pPars->nGrowthLevel > ABC_INFINITY )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nBTLimit < 0 )
+                goto usage;
+            break;
+        case 'd':
+            pPars->fRrOnly ^= 1;
+            break;
+        case 'r':
+            pPars->fResub ^= 1;
+            break;
+        case 'a':
+            pPars->fArea ^= 1;
+            break;
+        case 'e':
+            pPars->fMoreEffort ^= 1;
+            break;
+        case 's':
+            pPars->fSwapEdge ^= 1;
+            break;
+        case 't':
+            pPars->fOneHotness ^= 1;
+            break;
+        case 'p':
+            pPars->fPower ^= 1;
+            break;
+        case 'g':
+            pPars->fGiaSat ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'w':
+            pPars->fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsLogic(pNtk) )
+    {
+        Abc_Print( -1, "This command can only be applied to a logic network.\n" );
+        return 1;
+    }
+
+    // modify the current network
+    if ( !Abc_NtkMfs( pNtk, pPars ) )
+    {
+        Abc_Print( -1, "Resynthesis has failed.\n" );
+        return 1;
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: mfs [-WFDMLC <num>] [-draestpgvh]\n" );
+    Abc_Print( -2, "\t           performs don't-care-based optimization of logic networks\n" );
+    Abc_Print( -2, "\t-W <num> : the number of levels in the TFO cone (0 <= num) [default = %d]\n", pPars->nWinTfoLevs );
+    Abc_Print( -2, "\t-F <num> : the max number of fanouts to skip (1 <= num) [default = %d]\n", pPars->nFanoutsMax );
+    Abc_Print( -2, "\t-D <num> : the max depth nodes to try (0 = no limit) [default = %d]\n", pPars->nDepthMax );
+    Abc_Print( -2, "\t-M <num> : the max node count of windows to consider (0 = no limit) [default = %d]\n", pPars->nWinMax );
+    Abc_Print( -2, "\t-L <num> : the max increase in node level after resynthesis (0 <= num) [default = %d]\n", pPars->nGrowthLevel );
+    Abc_Print( -2, "\t-C <num> : the max number of conflicts in one SAT run (0 = no limit) [default = %d]\n", pPars->nBTLimit );
+    Abc_Print( -2, "\t-d       : toggle performing redundancy removal [default = %s]\n", pPars->fRrOnly? "yes": "no" );
+    Abc_Print( -2, "\t-r       : toggle resubstitution and dc-minimization [default = %s]\n", pPars->fResub? "resub": "dc-min" );
+    Abc_Print( -2, "\t-a       : toggle minimizing area or area+edges [default = %s]\n", pPars->fArea? "area": "area+edges" );
+    Abc_Print( -2, "\t-e       : toggle high-effort resubstitution [default = %s]\n", pPars->fMoreEffort? "yes": "no" );
+    Abc_Print( -2, "\t-s       : toggle evaluation of edge swapping [default = %s]\n", pPars->fSwapEdge? "yes": "no" );
+    Abc_Print( -2, "\t-t       : toggle using artificial one-hotness conditions [default = %s]\n", pPars->fOneHotness? "yes": "no" );
+    Abc_Print( -2, "\t-p       : toggle power-aware optimization [default = %s]\n", pPars->fPower? "yes": "no" );
+    Abc_Print( -2, "\t-g       : toggle using new SAT solver [default = %s]\n", pPars->fGiaSat? "yes": "no" );
+    Abc_Print( -2, "\t-v       : toggle printing optimization summary [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w       : toggle printing detailed stats for each node [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandMfs2( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern int Abc_NtkPerformMfs( Abc_Ntk_t * pNtk, Sfm_Par_t * pPars );
+    extern int Abc_NtkMfsAfterICheck( Abc_Ntk_t * p, int nFrames, int nFramesAdd, Vec_Int_t * vFlops, Sfm_Par_t * pPars );
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    Sfm_Par_t Pars, * pPars = &Pars;
+    int c, fIndDCs = 0, fUseAllFfs = 0, nFramesAdd = 0;
+    // set defaults
+    Sfm_ParSetDefault( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "WFDMLCZNIdaeijvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nTfoLevMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nTfoLevMax < 0 )
+                goto usage;
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nFanoutMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nFanoutMax < 0 )
+                goto usage;
+            break;
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nDepthMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nDepthMax < 0 )
+                goto usage;
+            break;
+        case 'M':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nWinSizeMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nWinSizeMax < 0 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nGrowthLevel = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nGrowthLevel < -ABC_INFINITY || pPars->nGrowthLevel > ABC_INFINITY )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nBTLimit < 0 )
+                goto usage;
+            break;
+        case 'Z':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-Z\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nFirstFixed = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nFirstFixed < 0 )
+                goto usage;
+            break;
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nNodesMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nNodesMax < 0 )
+                goto usage;
+            break;
+        case 'I':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFramesAdd = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFramesAdd < 0 )
+                goto usage;
+            break;
+        case 'd':
+            pPars->fRrOnly ^= 1;
+            break;
+        case 'a':
+            pPars->fArea ^= 1;
+            break;
+        case 'e':
+            pPars->fMoreEffort ^= 1;
+            break;
+        case 'i':
+            fIndDCs ^= 1;
+            break;
+        case 'j':
+            fUseAllFfs ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'w':
+            pPars->fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsLogic(pNtk) )
+    {
+        Abc_Print( -1, "This command can only be applied to a logic network.\n" );
+        return 1;
+    }
+    if ( fIndDCs )
+    {
+        if ( fUseAllFfs )
+        {
+            pAbc->nIndFrames = 1;
+            Vec_IntFreeP( &pAbc->vIndFlops );
+            pAbc->vIndFlops = Vec_IntAlloc( Abc_NtkLatchNum(pNtk) );
+            Vec_IntFill( pAbc->vIndFlops, Abc_NtkLatchNum(pNtk), 1 );
+        }
+        if ( pAbc->nIndFrames <= 0 )
+        {
+            Abc_Print( -1, "The number of k-inductive frames is not specified.\n" );
+            return 0;
+        }
+        if ( pAbc->vIndFlops == NULL )
+        {
+            Abc_Print( -1, "The set of k-inductive flops is not specified.\n" );
+            return 0;
+        }
+        if ( Vec_IntSize(pAbc->vIndFlops) != Abc_NtkLatchNum(pNtk) )
+        {
+            Abc_Print( -1, "The saved flop count (%d) does not match that of the current network (%d).\n", 
+                Vec_IntSize(pAbc->vIndFlops), Abc_NtkLatchNum(pNtk) );
+            return 0;
+        }
+        // modify the current network
+        if ( !Abc_NtkMfsAfterICheck( pNtk, pAbc->nIndFrames, nFramesAdd, pAbc->vIndFlops, pPars ) )
+        {
+            Abc_Print( -1, "Resynthesis has failed.\n" );
+            return 1;
+        }
+        if ( fUseAllFfs )
+        {
+            pAbc->nIndFrames = 0;
+            Vec_IntFreeP( &pAbc->vIndFlops );
+        }
+    }
+    else
+    {
+        // modify the current network
+        if ( !Abc_NtkPerformMfs( pNtk, pPars ) )
+        {
+            Abc_Print( -1, "Resynthesis has failed.\n" );
+            return 1;
+        }
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: mfs2 [-WFDMLCZNI <num>] [-daeijvwh]\n" );
+    Abc_Print( -2, "\t           performs don't-care-based optimization of logic networks\n" );
+    Abc_Print( -2, "\t-W <num> : the number of levels in the TFO cone (0 <= num) [default = %d]\n",             pPars->nTfoLevMax );
+    Abc_Print( -2, "\t-F <num> : the max number of fanouts to skip (1 <= num) [default = %d]\n",                pPars->nFanoutMax );
+    Abc_Print( -2, "\t-D <num> : the max depth nodes to try (0 = no limit) [default = %d]\n",                   pPars->nDepthMax );
+    Abc_Print( -2, "\t-M <num> : the max node count of windows to consider (0 = no limit) [default = %d]\n",    pPars->nWinSizeMax );
+    Abc_Print( -2, "\t-L <num> : the max increase in node level after resynthesis (0 <= num) [default = %d]\n", pPars->nGrowthLevel );
+    Abc_Print( -2, "\t-C <num> : the max number of conflicts in one SAT run (0 = no limit) [default = %d]\n",   pPars->nBTLimit );
+    Abc_Print( -2, "\t-Z <num> : treat the first <num> logic nodes as fixed (0 = none) [default = %d]\n",       pPars->nFirstFixed );
+    Abc_Print( -2, "\t-N <num> : the max number of nodes to try (0 = all) [default = %d]\n",                    pPars->nNodesMax );
+    Abc_Print( -2, "\t-d       : toggle performing redundancy removal [default = %s]\n",                        pPars->fRrOnly? "yes": "no" );
+    Abc_Print( -2, "\t-a       : toggle minimizing area or area+edges [default = %s]\n",                        pPars->fArea? "area": "area+edges" );
+    Abc_Print( -2, "\t-e       : toggle high-effort resubstitution [default = %s]\n",                           pPars->fMoreEffort? "yes": "no" );
+    Abc_Print( -2, "\t-i       : toggle using inductive don't-cares [default = %s]\n",                          fIndDCs? "yes": "no" );
+    Abc_Print( -2, "\t-j       : toggle using all flops when \"-i\" is enabled [default = %s]\n",               fUseAllFfs? "yes": "no" );
+    Abc_Print( -2, "\t-I       : the number of additional frames inserted [default = %d]\n",                    nFramesAdd );
+    Abc_Print( -2, "\t-v       : toggle printing optimization summary [default = %s]\n",                        pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w       : toggle printing detailed stats for each node [default = %s]\n",                pPars->fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandTrace( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int fUseLutLib;
+    int fVerbose;
+    extern void Abc_NtkDelayTracePrint( Abc_Ntk_t * pNtk, int fUseLutLib, int fVerbose );
+
+    // set defaults
+    fUseLutLib = 0;
+    fVerbose   = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "lvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'l':
+            fUseLutLib ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsLogic(pNtk) )
+    {
+        Abc_Print( -1, "This command can only be applied to a logic network.\n" );
+        return 1;
+    }
+
+    // modify the current network
+    Abc_NtkDelayTracePrint( pNtk, fUseLutLib, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: trace [-lvh]\n" );
+    Abc_Print( -2, "\t           performs delay trace of LUT-mapped network\n" );
+    Abc_Print( -2, "\t-l       : toggle using unit- or LUT-library-delay model [default = %s]\n", fUseLutLib? "lib": "unit" );
+    Abc_Print( -2, "\t-v       : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandSpeedup( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c;
+    int fUseLutLib;
+    int Percentage;
+    int Degree;
+    int fVerbose;
+    int fVeryVerbose;
+    extern Abc_Ntk_t * Abc_NtkSpeedup( Abc_Ntk_t * pNtk, int fUseLutLib, int Percentage, int Degree, int fVerbose, int fVeryVerbose );
+    pNtk = Abc_FrameReadNtk(pAbc);
+
+    // set defaults
+    fUseLutLib = 0;
+    Percentage = 5;
+    Degree     = 2;
+    fVerbose   = 0;
+    fVeryVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "PNlvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'P':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            Percentage = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( Percentage < 1 || Percentage > 100 )
+                goto usage;
+            break;
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            Degree = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( Degree < 1 || Degree > 5 )
+                goto usage;
+            break;
+        case 'l':
+            fUseLutLib ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'w':
+            fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsLogic(pNtk) )
+    {
+        Abc_Print( -1, "This command can only be applied to a logic network.\n" );
+        return 1;
+    }
+
+    // modify the current network
+    pNtkRes = Abc_NtkSpeedup( pNtk, fUseLutLib, Percentage, Degree, fVerbose, fVeryVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "The command has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: speedup [-PN <num>] [-lvwh]\n" );
+    Abc_Print( -2, "\t           transforms LUT-mapped network into an AIG with choices;\n" );
+    Abc_Print( -2, "\t           the choices are added to speedup the next round of mapping\n" );
+    Abc_Print( -2, "\t-P <num> : delay delta defining critical path for library model [default = %d%%]\n", Percentage );
+    Abc_Print( -2, "\t-N <num> : the max critical path degree for resynthesis (0 < num < 6) [default = %d]\n", Degree );
+    Abc_Print( -2, "\t-l       : toggle using unit- or LUT-library-delay model [default = %s]\n", fUseLutLib? "lib" : "unit" );
+    Abc_Print( -2, "\t-v       : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w       : toggle printing detailed stats for each node [default = %s]\n", fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandPowerdown( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c;
+    int fUseLutLib;
+    int Percentage;
+    int Degree;
+    int fVerbose;
+    int fVeryVerbose;
+    extern Abc_Ntk_t * Abc_NtkPowerdown( Abc_Ntk_t * pNtk, int fUseLutLib, int Percentage, int Degree, int fVerbose, int fVeryVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    fUseLutLib = 0;
+    Percentage =10;
+    Degree     = 2;
+    fVerbose   = 0;
+    fVeryVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "PNlvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'P':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            Percentage = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( Percentage < 1 || Percentage > 100 )
+                goto usage;
+            break;
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            Degree = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( Degree < 1 || Degree > 5 )
+                goto usage;
+            break;
+        case 'l':
+            fUseLutLib ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'w':
+            fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsLogic(pNtk) )
+    {
+        Abc_Print( -1, "This command can only be applied to a logic network.\n" );
+        return 1;
+    }
+
+    // modify the current network
+    pNtkRes = Abc_NtkPowerdown( pNtk, fUseLutLib, Percentage, Degree, fVerbose, fVeryVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "The command has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: powerdown [-PN <num>] [-vwh]\n" );
+    Abc_Print( -2, "\t           transforms LUT-mapped network into an AIG with choices;\n" );
+    Abc_Print( -2, "\t           the choices are added to power down the next round of mapping\n" );
+    Abc_Print( -2, "\t-P <num> : switching propability delta defining power critical edges [default = %d%%]\n", Percentage );
+    Abc_Print( -2, "\t           (e.g. 5% means hot wires switch with probability: 0.45 <= p <= 0.50 (max)\n" );
+    Abc_Print( -2, "\t-N <num> : the max critical path degree for resynthesis (0 < num < 6) [default = %d]\n", Degree );
+//    Abc_Print( -2, "\t-l       : toggle using unit- or LUT-library-delay model [default = %s]\n", fUseLutLib? "lib" : "unit" );
+    Abc_Print( -2, "\t-v       : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w       : toggle printing detailed stats for each node [default = %s]\n", fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAddBuffs( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Abc_Ntk_t * Abc_NtkAddBuffs( Abc_Ntk_t * pNtk, int fDirect, int fReverse, int nImprove, int fVerbose );
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    Abc_Ntk_t * pNtkRes;
+    int fDirect;
+    int fReverse;
+    int nImprove;
+    int c, fVerbose;
+
+    fDirect  = 0;
+    fReverse = 0;
+    nImprove = 1000;
+    fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Idrvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'I':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-I\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            nImprove = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nImprove < 0 )
+                goto usage;
+            break;
+        case 'd':
+            fDirect ^= 1;
+            break;
+        case 'r':
+            fReverse ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsLogic(pNtk) )
+    {
+        Abc_Print( -1, "This command can only be applied to a logic network.\n" );
+        return 1;
+    }
+
+    // modify the current network
+    pNtkRes = Abc_NtkAddBuffs( pNtk, fDirect, fReverse, nImprove, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "The command has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: addbuffs [-I num] [-drvh]\n" );
+    Abc_Print( -2, "\t           adds buffers to create balanced CI/CO paths\n" );
+    Abc_Print( -2, "\t-I <num> : the number of refinement iterations [default = %d]\n", nImprove );
+    Abc_Print( -2, "\t-d       : toggle using only CI-to-CO levelized order [default = %s]\n", fDirect? "yes": "no" );
+    Abc_Print( -2, "\t-r       : toggle using only CO-to-C1 levelized order [default = %s]\n", fReverse? "yes": "no" );
+    Abc_Print( -2, "\t-v       : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+#if 0
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandMerge( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    Nwk_LMPars_t Pars, * pPars = &Pars;
+    Vec_Int_t * vResult;
+    int c;
+    extern Vec_Int_t * Abc_NtkLutMerge( Abc_Ntk_t * pNtk, Nwk_LMPars_t * pPars );
+    // set defaults
+    memset( pPars, 0, sizeof(Nwk_LMPars_t) );
+    pPars->nMaxLutSize    = 5;   // the max LUT size for merging (N=5)
+    pPars->nMaxSuppSize   = 5;   // the max total support size after merging (S=5)
+    pPars->nMaxDistance   = 3;   // the max number of nodes separating LUTs
+    pPars->nMaxLevelDiff  = 2;   // the max difference in levels
+    pPars->nMaxFanout     = 100; // the max number of fanouts to traverse
+    pPars->fUseDiffSupp   = 0;   // enables the use of nodes with different support
+    pPars->fUseTfiTfo     = 0;   // enables the use of TFO/TFO nodes as candidates
+    pPars->fVeryVerbose   = 0;   // enables additional verbose output
+    pPars->fVerbose       = 1;   // enables verbose output
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "NSDLFscvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nMaxLutSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nMaxLutSize < 2 )
+                goto usage;
+            break;
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nMaxSuppSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nMaxSuppSize < 2 )
+                goto usage;
+            break;
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nMaxDistance = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nMaxDistance < 2 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nMaxLevelDiff = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nMaxLevelDiff < 2 )
+                goto usage;
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nMaxFanout = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nMaxFanout < 2 )
+                goto usage;
+            break;
+        case 's':
+            pPars->fUseDiffSupp ^= 1;
+            break;
+        case 'c':
+            pPars->fUseTfiTfo ^= 1;
+            break;
+        case 'w':
+            pPars->fVeryVerbose ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL || !Abc_NtkIsLogic(pNtk) )
+    {
+        Abc_Print( -1, "Abc_CommandMerge(): There is no mapped network to merge LUTs.\n" );
+        return 1;
+    }
+
+    vResult = Abc_NtkLutMerge( pNtk, pPars );
+    Vec_IntFree( vResult );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: merge [-NSDLF <num>] [-scwvh]\n" );
+    Abc_Print( -2, "\t           creates pairs of topologically-related LUTs\n" );
+    Abc_Print( -2, "\t-N <num> : the max LUT size for merging (1 < num) [default = %d]\n", pPars->nMaxLutSize );
+    Abc_Print( -2, "\t-S <num> : the max total support size after merging (1 < num) [default = %d]\n", pPars->nMaxSuppSize );
+    Abc_Print( -2, "\t-D <num> : the max distance in terms of LUTs (0 < num) [default = %d]\n", pPars->nMaxDistance );
+    Abc_Print( -2, "\t-L <num> : the max difference in levels (0 <= num) [default = %d]\n", pPars->nMaxLevelDiff );
+    Abc_Print( -2, "\t-F <num> : the max number of fanouts to stop traversal (0 < num) [default = %d]\n", pPars->nMaxFanout );
+    Abc_Print( -2, "\t-s       : toggle the use of nodes without support overlap [default = %s]\n", pPars->fUseDiffSupp? "yes" : "no" );
+    Abc_Print( -2, "\t-c       : toggle the use of TFI/TFO nodes as candidates [default = %s]\n", pPars->fUseTfiTfo? "yes" : "no" );
+    Abc_Print( -2, "\t-w       : toggle printing detailed stats for each node [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-v       : toggle printing optimization summary [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+#endif
+
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandTestDec( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern int Abc_DecTest( char * pFileName, int DecType, int nVarNum, int fVerbose );
+    char * pFileName;
+    int c;
+    int fVerbose = 0;
+    int DecType = 0;
+    int nVarNum = -1;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "ANvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'A':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-A\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            DecType = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( DecType < 0 )
+                goto usage;
+            break;
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nVarNum = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nVarNum < 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( argc != globalUtilOptind + 1 )
+    {
+        Abc_Print( 1,"Input file is not given.\n" );
+        return 0;
+    }
+    if ( nVarNum >= 0 && nVarNum < 6 )
+    {
+        Abc_Print( 1,"The number of variables cannot be less than 6.\n" );
+        return 0;
+    }
+    // get the output file name
+    pFileName = argv[globalUtilOptind];
+    // call the testbench
+    Abc_DecTest( pFileName, DecType, nVarNum, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: testdec [-AN <num>] [-vh] <file>\n" );
+    Abc_Print( -2, "\t           testbench for Boolean decomposition algorithms\n" );
+    Abc_Print( -2, "\t-A <num> : decomposition algorithm [default = %d]\n", DecType );
+    Abc_Print( -2, "\t               0: none (reading and writing the file)\n" );
+    Abc_Print( -2, "\t               1: algebraic factoring applied to ISOP\n" );
+    Abc_Print( -2, "\t               2: bi-decomposition with cofactoring\n" );
+    Abc_Print( -2, "\t               3: disjoint-support decomposition with cofactoring\n" );
+    Abc_Print( -2, "\t               4: updated disjoint-support decomposition with cofactoring\n" );
+    Abc_Print( -2, "\t               5: enumerating decomposable variable sets\n" );
+    Abc_Print( -2, "\t-N <num> : the number of support variables (binary files only) [default = unused]\n" );
+    Abc_Print( -2, "\t-v       : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    Abc_Print( -2, "\t<file>   : a text file with truth tables in hexadecimal, listed one per line,\n");
+    Abc_Print( -2, "\t           or a binary file with an array of truth tables (in this case,\n");
+    Abc_Print( -2, "\t           -N <num> is required to determine how many functions are stored)\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandTestNpn( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern int Abc_NpnTest( char * pFileName, int NpnType, int nVarNum, int fDumpRes, int fBinary, int fVerbose );
+    char * pFileName;
+    int c;
+    int fVerbose = 0;
+    int NpnType = 0;
+    int nVarNum = -1;
+    int fDumpRes = 0;
+    int fBinary = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "ANdbvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'A':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-A\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            NpnType = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( NpnType < 0 )
+                goto usage;
+            break;
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nVarNum = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nVarNum < 0 )
+                goto usage;
+            break;
+        case 'd':
+            fDumpRes ^= 1;
+            break;
+        case 'b':
+            fBinary ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( argc != globalUtilOptind + 1 )
+    {
+        Abc_Print( 1,"Input file is not given.\n" );
+        return 0;
+    }
+    if ( nVarNum >= 0 && nVarNum < 6 )
+    {
+        Abc_Print( 1,"The number of variables cannot be less than 6.\n" );
+        return 0;
+    }
+    // get the output file name
+    pFileName = argv[globalUtilOptind];
+    // call the testbench
+    Abc_NpnTest( pFileName, NpnType, nVarNum, fDumpRes, fBinary, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: testnpn [-AN <num>] [-dbvh] <file>\n" );
+    Abc_Print( -2, "\t           testbench for computing (semi-)canonical forms\n" );
+    Abc_Print( -2, "\t           of completely-specified Boolean functions up to 16 varibles\n" );
+    Abc_Print( -2, "\t-A <num> : semi-caninical form computation algorithm [default = %d]\n", NpnType );
+    Abc_Print( -2, "\t               0: uniqifying truth tables\n" );
+    Abc_Print( -2, "\t               1: exact NPN canonical form by brute-force enumeration\n" );
+    Abc_Print( -2, "\t               2: semi-canonical form by counting 1s in cofactors\n" );
+    Abc_Print( -2, "\t               3: Jake's hybrid semi-canonical form (fast)\n" );
+    Abc_Print( -2, "\t               4: Jake's hybrid semi-canonical form (high-effort)\n" );
+    Abc_Print( -2, "\t               5: new fast hybrid semi-canonical form\n" );
+    Abc_Print( -2, "\t               6: new phase canonical form\n" );
+    Abc_Print( -2, "\t-N <num> : the number of support variables (binary files only) [default = unused]\n" );
+    Abc_Print( -2, "\t-d       : toggle dumping resulting functions into a file [default = %s]\n", fDumpRes? "yes": "no" );
+    Abc_Print( -2, "\t-b       : toggle dumping in binary format [default = %s]\n", fBinary? "yes": "no" );
+    Abc_Print( -2, "\t-v       : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    Abc_Print( -2, "\t<file>   : a text file with truth tables in hexadecimal, listed one per line,\n");
+    Abc_Print( -2, "\t           or a binary file with an array of truth tables (in this case,\n");
+    Abc_Print( -2, "\t           -N <num> is required to determine how many functions are stored)\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandTestRPO(Abc_Frame_t * pAbc, int argc, char ** argv) {
+    extern int Abc_RpoTest(char * pFileName, int nVarNum, int nThreshold, int fVerbose);
+    char * pFileName;
+    int c;
+    int nVarNum = -1;
+    int fVerbose = 0;
+    int nThreshold = -1;
+    Extra_UtilGetoptReset();
+    while ((c = Extra_UtilGetopt(argc, argv, "TNvh")) != EOF) {
+        switch (c) {
+            case 'N':
+                if (globalUtilOptind >= argc) {
+                    Abc_Print(-1, "Command line switch \"-N\" should be followed by an integer.\n");
+                    goto usage;
+                }
+                nVarNum = atoi(argv[globalUtilOptind]);
+                globalUtilOptind++;
+                if (nVarNum < 0)
+                    goto usage;
+                break;
+            case 'T':
+                if (globalUtilOptind >= argc) {
+                    Abc_Print(-1, "Command line switch \"-T\" should be followed by an integer.\n");
+                    goto usage;
+                }
+                nThreshold = atoi(argv[globalUtilOptind]);
+                globalUtilOptind++;
+                if (nThreshold < 0)
+                    goto usage;
+                break;
+            case 'v':
+                fVerbose ^= 1;
+                break;
+            case 'h':
+                goto usage;
+            default:
+                goto usage;
+        }
+    }
+    if (argc != globalUtilOptind + 1) 
+    {
+        Abc_Print(1, "Input file is not given.\n");
+        goto usage;
+    }
+    // get the output file name
+    pFileName = argv[globalUtilOptind];
+    // call the testbench
+    Abc_RpoTest( pFileName, nVarNum, nThreshold, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print(-2, "usage: testrpo [-NT <num>] [-vh] <file>\n");
+    Abc_Print(-2, "\t           RPO algorithm developed and implemented by Mayler G. A. Martins,\n");
+    Abc_Print(-2, "\t           Vinicius Callegaro, Renato P. Ribas and Andre' I. Reis\n");
+    Abc_Print(-2, "\t           at Federal University of Rio Grande do Sul, Porto Alegre, Brazil\n");
+    Abc_Print(-2, "\t-N <num> : the number of support variables (binary files only) [default = unused]\n");
+    Abc_Print(-2, "\t-T <num> : the number of recursions accepted before abort [default = INFINITE]\n");
+    Abc_Print(-2, "\t-v       : toggle verbose printout [default = %s]\n", fVerbose ? "yes" : "no");
+    Abc_Print(-2, "\t-h       : print the command usage\n");
+    Abc_Print(-2, "\t<file>   : a text file with truth tables in hexadecimal, listed one per line,\n");
+    Abc_Print(-2, "\t           or a binary file with an array of truth tables (in this case,\n");
+    Abc_Print(-2, "\t           -N <num> is required to determine how many functions are stored)\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandRewrite( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int fUpdateLevel;
+    int fPrecompute;
+    int fUseZeros;
+    int fVerbose;
+    int fVeryVerbose;
+    int fPlaceEnable;
+    // external functions
+    extern void Rwr_Precompute();
+
+    // set defaults
+    fUpdateLevel = 1;
+    fPrecompute  = 0;
+    fUseZeros    = 0;
+    fVerbose     = 0;
+    fVeryVerbose = 0;
+    fPlaceEnable = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "lxzvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'l':
+            fUpdateLevel ^= 1;
+            break;
+        case 'x':
+            fPrecompute ^= 1;
+            break;
+        case 'z':
+            fUseZeros ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'w':
+            fVeryVerbose ^= 1;
+            break;
+        case 'p':
+            fPlaceEnable ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( fPrecompute )
+    {
+        Rwr_Precompute();
+        return 0;
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command can only be applied to an AIG (run \"strash\").\n" );
+        return 1;
+    }
+    if ( Abc_NtkGetChoiceNum(pNtk) )
+    {
+        Abc_Print( -1, "AIG resynthesis cannot be applied to AIGs with choice nodes.\n" );
+        return 1;
+    }
+
+    // modify the current network
+    if ( !Abc_NtkRewrite( pNtk, fUpdateLevel, fUseZeros, fVerbose, fVeryVerbose, fPlaceEnable ) )
+    {
+        Abc_Print( -1, "Rewriting has failed.\n" );
+        return 1;
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: rewrite [-lzvwh]\n" );
+    Abc_Print( -2, "\t         performs technology-independent rewriting of the AIG\n" );
+    Abc_Print( -2, "\t-l     : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
+    Abc_Print( -2, "\t-z     : toggle using zero-cost replacements [default = %s]\n", fUseZeros? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w     : toggle printout subgraph statistics [default = %s]\n", fVeryVerbose? "yes": "no" );
+//    Abc_Print( -2, "\t-p     : toggle placement-aware rewriting [default = %s]\n", fPlaceEnable? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandRefactor( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int nNodeSizeMax;
+    int nConeSizeMax;
+    int fUpdateLevel;
+    int fUseZeros;
+    int fUseDcs;
+    int fVerbose;
+    extern int Abc_NtkRefactor( Abc_Ntk_t * pNtk, int nNodeSizeMax, int nConeSizeMax, int fUpdateLevel, int fUseZeros, int fUseDcs, int fVerbose );
+
+    // set defaults
+    nNodeSizeMax = 10;
+    nConeSizeMax = 16;
+    fUpdateLevel =  1;
+    fUseZeros    =  0;
+    fUseDcs      =  0;
+    fVerbose     =  0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "NClzdvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nNodeSizeMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nNodeSizeMax < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nConeSizeMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nConeSizeMax < 0 )
+                goto usage;
+            break;
+        case 'l':
+            fUpdateLevel ^= 1;
+            break;
+        case 'z':
+            fUseZeros ^= 1;
+            break;
+        case 'd':
+            fUseDcs ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command can only be applied to an AIG (run \"strash\").\n" );
+        return 1;
+    }
+    if ( Abc_NtkGetChoiceNum(pNtk) )
+    {
+        Abc_Print( -1, "AIG resynthesis cannot be applied to AIGs with choice nodes.\n" );
+        return 1;
+    }
+
+    if ( fUseDcs && nNodeSizeMax >= nConeSizeMax )
+    {
+        Abc_Print( -1, "For don't-care to work, containing cone should be larger than collapsed node.\n" );
+        return 1;
+    }
+
+    // modify the current network
+    if ( !Abc_NtkRefactor( pNtk, nNodeSizeMax, nConeSizeMax, fUpdateLevel, fUseZeros, fUseDcs, fVerbose ) )
+    {
+        Abc_Print( -1, "Refactoring has failed.\n" );
+        return 1;
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: refactor [-NC <num>] [-lzdvh]\n" );
+    Abc_Print( -2, "\t           performs technology-independent refactoring of the AIG\n" );
+    Abc_Print( -2, "\t-N <num> : the max support of the collapsed node [default = %d]\n", nNodeSizeMax );
+    Abc_Print( -2, "\t-C <num> : the max support of the containing cone [default = %d]\n", nConeSizeMax );
+    Abc_Print( -2, "\t-l       : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
+    Abc_Print( -2, "\t-z       : toggle using zero-cost replacements [default = %s]\n", fUseZeros? "yes": "no" );
+    Abc_Print( -2, "\t-d       : toggle using don't-cares [default = %s]\n", fUseDcs? "yes": "no" );
+    Abc_Print( -2, "\t-v       : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandRestructure( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int nCutsMax;
+    int fUpdateLevel;
+    int fUseZeros;
+    int fVerbose;
+    extern int Abc_NtkRestructure( Abc_Ntk_t * pNtk, int nCutsMax, int fUpdateLevel, int fUseZeros, int fVerbose );
+
+    // set defaults
+    nCutsMax      =  5;
+    fUpdateLevel =  0;
+    fUseZeros    =  0;
+    fVerbose     =  0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Klzvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nCutsMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nCutsMax < 0 )
+                goto usage;
+            break;
+        case 'l':
+            fUpdateLevel ^= 1;
+            break;
+        case 'z':
+            fUseZeros ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( nCutsMax < 4 || nCutsMax > CUT_SIZE_MAX )
+    {
+        Abc_Print( -1, "Can only compute the cuts for %d <= K <= %d.\n", 4, CUT_SIZE_MAX );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command can only be applied to an AIG (run \"strash\").\n" );
+        return 1;
+    }
+    if ( Abc_NtkGetChoiceNum(pNtk) )
+    {
+        Abc_Print( -1, "AIG resynthesis cannot be applied to AIGs with choice nodes.\n" );
+        return 1;
+    }
+
+    // modify the current network
+    if ( !Abc_NtkRestructure( pNtk, nCutsMax, fUpdateLevel, fUseZeros, fVerbose ) )
+    {
+        Abc_Print( -1, "Refactoring has failed.\n" );
+        return 1;
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: restructure [-K <num>] [-lzvh]\n" );
+    Abc_Print( -2, "\t           performs technology-independent restructuring of the AIG\n" );
+    Abc_Print( -2, "\t-K <num> : the max cut size (%d <= num <= %d) [default = %d]\n",   CUT_SIZE_MIN, CUT_SIZE_MAX, nCutsMax );
+    Abc_Print( -2, "\t-l       : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
+    Abc_Print( -2, "\t-z       : toggle using zero-cost replacements [default = %s]\n", fUseZeros? "yes": "no" );
+    Abc_Print( -2, "\t-v       : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandResubstitute( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int RS_CUT_MIN =  4;
+    int RS_CUT_MAX = 16;
+    int c;
+    int nCutsMax;
+    int nNodesMax;
+    int nLevelsOdc;
+    int fUpdateLevel;
+    int fUseZeros;
+    int fVerbose;
+    int fVeryVerbose;
+    extern int Abc_NtkResubstitute( Abc_Ntk_t * pNtk, int nCutsMax, int nNodesMax, int nLevelsOdc, int fUpdateLevel, int fVerbose, int fVeryVerbose );
+
+    // set defaults
+    nCutsMax     =  8;
+    nNodesMax    =  1;
+    nLevelsOdc   =  0;
+    fUpdateLevel =  1;
+    fUseZeros    =  0;
+    fVerbose     =  0;
+    fVeryVerbose =  0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "KNFlzvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nCutsMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nCutsMax < 0 )
+                goto usage;
+            break;
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nNodesMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nNodesMax < 0 )
+                goto usage;
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nLevelsOdc = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLevelsOdc < 0 )
+                goto usage;
+            break;
+        case 'l':
+            fUpdateLevel ^= 1;
+            break;
+        case 'z':
+            fUseZeros ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'w':
+            fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( nCutsMax < RS_CUT_MIN || nCutsMax > RS_CUT_MAX )
+    {
+        Abc_Print( -1, "Can only compute cuts for %d <= K <= %d.\n", RS_CUT_MIN, RS_CUT_MAX );
+        return 1;
+    }
+    if ( nNodesMax < 0 || nNodesMax > 3 )
+    {
+        Abc_Print( -1, "Can only resubstitute at most 3 nodes.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command can only be applied to an AIG (run \"strash\").\n" );
+        return 1;
+    }
+    if ( Abc_NtkGetChoiceNum(pNtk) )
+    {
+        Abc_Print( -1, "AIG resynthesis cannot be applied to AIGs with choice nodes.\n" );
+        return 1;
+    }
+
+    // modify the current network
+    if ( !Abc_NtkResubstitute( pNtk, nCutsMax, nNodesMax, nLevelsOdc, fUpdateLevel, fVerbose, fVeryVerbose ) )
+    {
+        Abc_Print( -1, "Refactoring has failed.\n" );
+        return 1;
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: resub [-KN <num>] [-lzvwh]\n" );
+    Abc_Print( -2, "\t           performs technology-independent restructuring of the AIG\n" );
+    Abc_Print( -2, "\t-K <num> : the max cut size (%d <= num <= %d) [default = %d]\n", RS_CUT_MIN, RS_CUT_MAX, nCutsMax );
+    Abc_Print( -2, "\t-N <num> : the max number of nodes to add (0 <= num <= 3) [default = %d]\n", nNodesMax );
+    Abc_Print( -2, "\t-F <num> : the number of fanout levels for ODC computation [default = %d]\n", nLevelsOdc );
+    Abc_Print( -2, "\t-l       : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
+    Abc_Print( -2, "\t-z       : toggle using zero-cost replacements [default = %s]\n", fUseZeros? "yes": "no" );
+    Abc_Print( -2, "\t-v       : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w       : toggle verbose printout of ODC computation [default = %s]\n", fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandRr( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c, Window;
+    int nFaninLevels;
+    int nFanoutLevels;
+    int fUseFanouts;
+    int fVerbose;
+    extern int Abc_NtkRR( Abc_Ntk_t * pNtk, int nFaninLevels, int nFanoutLevels, int fUseFanouts, int fVerbose );
+
+    // set defaults
+    nFaninLevels  = 3;
+    nFanoutLevels = 3;
+    fUseFanouts   = 0;
+    fVerbose      = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Wfvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            Window = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( Window < 0 )
+                goto usage;
+            nFaninLevels  = Window / 10;
+            nFanoutLevels = Window % 10;
+            break;
+        case 'f':
+            fUseFanouts ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command can only be applied to an AIG (run \"strash\").\n" );
+        return 1;
+    }
+    if ( Abc_NtkGetChoiceNum(pNtk) )
+    {
+        Abc_Print( -1, "AIG resynthesis cannot be applied to AIGs with choice nodes.\n" );
+        return 1;
+    }
+
+    // modify the current network
+    if ( !Abc_NtkRR( pNtk, nFaninLevels, nFanoutLevels, fUseFanouts, fVerbose ) )
+    {
+        Abc_Print( -1, "Redundancy removal has failed.\n" );
+        return 1;
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: rr [-W NM] [-fvh]\n" );
+    Abc_Print( -2, "\t         removes combinational redundancies in the current network\n" );
+    Abc_Print( -2, "\t-W NM  : window size: TFI (N) and TFO (M) logic levels [default = %d%d]\n", nFaninLevels, nFanoutLevels );
+    Abc_Print( -2, "\t-f     : toggle RR w.r.t. fanouts [default = %s]\n", fUseFanouts? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandCascade( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c, nLutSize;
+    int fCheck;
+    int fVerbose;
+    extern Abc_Ntk_t * Abc_NtkCascade( Abc_Ntk_t * pNtk, int nLutSize, int fCheck, int fVerbose );
+    pNtk = Abc_FrameReadNtk(pAbc);
+
+    // set defaults
+    nLutSize = 12;
+    fCheck   = 0;
+    fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Kcvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nLutSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLutSize < 0 )
+                goto usage;
+            break;
+        case 'c':
+            fCheck ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsLogic(pNtk) && !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Can only collapse a logic network or an AIG.\n" );
+        return 1;
+    }
+
+    // get the new network
+    if ( Abc_NtkIsStrash(pNtk) )
+        pNtkRes = Abc_NtkCascade( pNtk, nLutSize, fCheck, fVerbose );
+    else
+    {
+        pNtk = Abc_NtkStrash( pNtk, 0, 0, 0 );
+        pNtkRes = Abc_NtkCascade( pNtk, nLutSize, fCheck, fVerbose );
+        Abc_NtkDelete( pNtk );
+    }
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Cascade synthesis has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: cascade [-K <num>] [-cvh]\n" );
+    Abc_Print( -2, "\t           performs LUT cascade synthesis for the current network\n" );
+    Abc_Print( -2, "\t-K <num> : the number of LUT inputs [default = %d]\n", nLutSize );
+    Abc_Print( -2, "\t-c       : check equivalence after synthesis [default = %s]\n", fCheck? "yes": "no" );
+    Abc_Print( -2, "\t-v       : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    Abc_Print( -2, "\t           \n");
+    Abc_Print( -2, "  A lookup-table cascade is a programmable architecture developed by\n");
+    Abc_Print( -2, "  Professor Tsutomu Sasao (sasao@cse.kyutech.ac.jp) at Kyushu Institute\n");
+    Abc_Print( -2, "  of Technology. This work received Takeda Techno-Entrepreneurship Award:\n");
+    Abc_Print( -2, "  http://www.lsi-cad.com/sasao/photo/takeda.html\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandExtract( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Abc_Ntk_t * Abc_NtkShareXor( Abc_Ntk_t * pNtk, int nMultiSize, int fAnd, int fVerbose );
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c, nMultiSize, fAnd, fVerbose;
+    pNtk = Abc_FrameReadNtk(pAbc);
+
+    // set defaults
+    nMultiSize = 3;
+    fAnd       = 0;
+    fVerbose   = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Kavh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nMultiSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nMultiSize < 0 )
+                goto usage;
+            break;
+        case 'a':
+            fAnd ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Can only collapse a logic network or an AIG.\n" );
+        return 1;
+    }
+    // get the new network
+    pNtkRes = Abc_NtkShareXor( pNtk, nMultiSize, fAnd, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Cascade synthesis has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: extract [-K <num>] [-avh]\n" );
+    Abc_Print( -2, "\t           extracts shared logic from multi-input gates\n" );
+    Abc_Print( -2, "\t-K <num> : the minimum gate size to consider for extraction [default = %d]\n", nMultiSize );
+    Abc_Print( -2, "\t-a       : toggle multi-input XOR vs multi-input AND [default = %s]\n", fAnd? "AND": "XOR" );
+    Abc_Print( -2, "\t-v       : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandVarMin( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern void Abc_SuppTest( int nOnes, int nVars, int fUseSimple, int fCheck, int fVerbose );
+    extern void Abc_SuppReadMinTest( char * pFileName );
+    int nOnes      =  4;
+    int nVars      = 20;
+    int fUseSimple =  0;
+    int fCheck     =  0;
+    int fVerbose   =  0;
+    int c;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "MNocvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'M':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nOnes = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nOnes < 0 )
+                goto usage;
+            break;
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nVars = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nVars < 0 )
+                goto usage;
+            break;
+        case 'o':
+            fUseSimple ^= 1;
+            break;
+        case 'c':
+            fCheck ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    // get the file name
+    if ( argc == globalUtilOptind + 1 )
+    {
+        Abc_SuppReadMinTest( argv[globalUtilOptind] );
+        return 0;
+    }
+    Abc_SuppTest( nOnes, nVars, fUseSimple, fCheck, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: varmin [-MN <num>] [-ocvh]\n" );
+    Abc_Print( -2, "\t           performs support minimization\n" );
+    Abc_Print( -2, "\t-M <num> : the number of ones in the combination [default = %d]\n", nOnes );
+    Abc_Print( -2, "\t-N <num> : the number of variables in the problem [default = %d]\n", nVars );
+    Abc_Print( -2, "\t-o       : toggle computing reduced difference matrix [default = %s]\n", fUseSimple? "yes": "no" );
+    Abc_Print( -2, "\t-c       : toggle verifying the final result [default = %s]\n", fCheck? "yes": "no" );
+    Abc_Print( -2, "\t-v       : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandLogic( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c;
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsStrash( pNtk ) )
+    {
+        Abc_Print( -1, "This command is only applicable to strashed networks.\n" );
+        return 1;
+    }
+
+    // get the new network
+    pNtkRes = Abc_NtkToLogic( pNtk );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Converting to a logic network has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: logic [-h]\n" );
+    Abc_Print( -2, "\t        transforms an AIG into a logic network with SOPs\n" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandComb( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c;
+    int fRemoveLatches;
+    int nLatchesToAdd;
+    extern void Abc_NtkMakeSeq( Abc_Ntk_t * pNtk, int nLatchesToAdd );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    fRemoveLatches = 0;
+    nLatchesToAdd = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Llh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nLatchesToAdd = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLatchesToAdd < 0 )
+                goto usage;
+            break;
+        case 'l':
+            fRemoveLatches ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( Abc_NtkIsComb(pNtk) && nLatchesToAdd == 0 )
+    {
+        Abc_Print( -1, "The network is already combinational.\n" );
+        return 0;
+    }
+    if ( !Abc_NtkIsComb(pNtk) && nLatchesToAdd != 0 )
+    {
+        Abc_Print( -1, "The network is already combinational.\n" );
+        return 0;
+    }
+
+    // get the new network
+    pNtkRes = Abc_NtkDup( pNtk );
+    if ( nLatchesToAdd )
+        Abc_NtkMakeSeq( pNtkRes, nLatchesToAdd );
+    else
+        Abc_NtkMakeComb( pNtkRes, fRemoveLatches );
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: comb [-L <num>] [-lh]\n" );
+    Abc_Print( -2, "\t           converts comb network into seq, and vice versa\n" );
+    Abc_Print( -2, "\t-L <num> : number of latches to add to comb network (0 = do not add) [default = %d]\n", nLatchesToAdd );
+    Abc_Print( -2, "\t-l       : toggle converting latches to PIs/POs or removing them [default = %s]\n", fRemoveLatches? "remove": "convert" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandMiter( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    char Buffer[32];
+    Abc_Ntk_t * pNtk, * pNtk1, * pNtk2, * pNtkRes;
+    int fDelete1, fDelete2;
+    char ** pArgvNew;
+    int nArgcNew;
+    int c;
+    int fCheck;
+    int fComb;
+    int fImplic;
+    int fMulti;
+    int nPartSize;
+    int fTrans;
+    int fIgnoreNames;
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+
+    // set defaults
+    fComb  = 0;
+    fCheck = 1;
+    fImplic = 0;
+    fMulti = 0;
+    nPartSize = 0;
+    fTrans = 0;
+    fIgnoreNames = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Pcmitnh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'P':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nPartSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nPartSize < 0 )
+                goto usage;
+            break;
+        case 'c':
+            fComb ^= 1;
+            break;
+        case 'm':
+            fMulti ^= 1;
+            break;
+        case 'i':
+            fImplic ^= 1;
+            break;
+        case 't':
+            fTrans ^= 1;
+            break;
+        case 'n':
+            fIgnoreNames ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( fTrans )
+    {
+        if ( (Abc_NtkPoNum(pNtk) & 1) == 1 )
+        {
+            Abc_Print( -1, "Abc_CommandMiter(): The number of outputs should be even.\n" );
+            return 0;
+        }
+        // replace the current network
+        pNtkRes = Abc_NtkDupTransformMiter( pNtk );
+        Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+        Abc_Print( 1, "The miter (current network) is transformed by XORing POs pair-wise.\n" );
+        return 0;
+    }
+
+    pArgvNew = argv + globalUtilOptind;
+    nArgcNew = argc - globalUtilOptind;
+    if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
+        return 1;
+
+    if ( fIgnoreNames )
+    {
+        if ( !fDelete1 )
+        {
+            pNtk1 = Abc_NtkStrash( pNtk1, 0, 1, 0 );
+            fDelete1 = 1;
+        }
+        if ( !fDelete2 )
+        {
+            pNtk2 = Abc_NtkStrash( pNtk2, 0, 1, 0 );
+            fDelete2 = 1;
+        }
+        Abc_NtkShortNames( pNtk1 );
+        Abc_NtkShortNames( pNtk2 );
+    }
+    // compute the miter
+    pNtkRes = Abc_NtkMiter( pNtk1, pNtk2, fComb, nPartSize, fImplic, fMulti );
+    if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
+    if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
+
+    // get the new network
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Miter computation has failed.\n" );
+        return 0;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    if ( nPartSize == 0 )
+        strcpy( Buffer, "unused" );
+    else
+        sprintf(Buffer, "%d", nPartSize );
+    Abc_Print( -2, "usage: miter [-P <num>] [-cimtnh] <file1> <file2>\n" );
+    Abc_Print( -2, "\t           computes the miter of the two circuits\n" );
+    Abc_Print( -2, "\t-P <num> : output partition size [default = %s]\n", Buffer );
+    Abc_Print( -2, "\t-c       : toggles deriving combinational miter (latches as POs) [default = %s]\n", fComb? "yes": "no" );
+    Abc_Print( -2, "\t-i       : toggles deriving implication miter (file1 => file2) [default = %s]\n", fImplic? "yes": "no" );
+    Abc_Print( -2, "\t-m       : toggles creating multi-output miter [default = %s]\n", fMulti? "yes": "no" );
+    Abc_Print( -2, "\t-t       : toggle XORing pair-wise POs of the miter [default = %s]\n", fTrans? "yes": "no" );
+    Abc_Print( -2, "\t-n       : toggle ignoring names when matching CIs/COs [default = %s]\n", fIgnoreNames? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    Abc_Print( -2, "\tfile1    : (optional) the file with the first network\n");
+    Abc_Print( -2, "\tfile2    : (optional) the file with the second network\n");
+    Abc_Print( -2, "\t           if no files are given, uses the current network and its spec\n");
+    Abc_Print( -2, "\t           if one file is given, uses the current network and the file\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandDemiter( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c, fDual, fVerbose;
+    extern int Abc_NtkDarDemiter( Abc_Ntk_t * pNtk );
+    extern int Abc_NtkDarDemiterDual( Abc_Ntk_t * pNtk, int fVerbose );
+    // set defaults
+    fDual = 0;
+    fVerbose = 1;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "dvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'd':
+            fDual ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "The network is not strashed.\n" );
+        return 1;
+    }
+
+    if ( fDual )
+    {
+        if ( (Abc_NtkPoNum(pNtk) & 1) )
+        {
+            Abc_Print( -1, "The number of POs should be even.\n" );
+            return 0;
+        }
+        if ( !Abc_NtkDarDemiterDual( pNtk, fVerbose ) )
+        {
+            Abc_Print( -1, "Demitering has failed.\n" );
+            return 1;
+        }
+        return 0;
+    }
+/*
+    if ( Abc_NtkPoNum(pNtk) != 1 )
+    {
+        Abc_Print( -1, "The network is not a single-output miter.\n" );
+        return 1;
+    }
+    if ( !Abc_NodeIsExorType(Abc_ObjFanin0(Abc_NtkPo(pNtk,0))) )
+    {
+        Abc_Print( -1, "The miter's PO is not an EXOR.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkDemiter( pNtk ) )
+    {
+        Abc_Print( -1, "Demitering has failed.\n" );
+        return 1;
+    }
+*/
+    // get the new network
+    if ( !Abc_NtkDarDemiter( pNtk ) )
+    {
+        Abc_Print( -1, "Demitering has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+//    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: demiter [-dvh]\n" );
+    Abc_Print( -2, "\t        splits sequential miter into two circuits\n" );
+    Abc_Print( -2, "\t-d    : expects a dual-output miter (without XORs) [default = %s]\n", fDual? "yes": "no" );
+    Abc_Print( -2, "\t-v    : toggles outputting verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandOrPos( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);//, * pNtkRes;
+    int fReverse = 0;
+    int fComb = 0;
+    int fXor = 0;
+    int c;
+    extern int Abc_NtkCombinePos( Abc_Ntk_t * pNtk, int fAnd, int fXor );
+
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "rxh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'r':
+            fReverse ^= 1;
+            break;
+        case 'x':
+            fXor ^= 1;
+            break;
+        case 'c':
+            fComb ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "The network is not strashed.\n" );
+        return 1;
+    }
+    // get the new network
+    if ( fReverse )
+    {
+        extern Aig_Man_t * Abc_NtkToDarBmc( Abc_Ntk_t * pNtk, Vec_Int_t ** pvMap );
+        Aig_Man_t * pMan = Abc_NtkToDarBmc( pNtk, NULL );
+        Abc_Ntk_t * pNtkRes = Abc_NtkFromAigPhase( pMan );
+        Aig_ManStop( pMan );
+        // perform expansion
+        if ( Abc_NtkPoNum(pNtk) != Abc_NtkPoNum(pNtkRes) )
+            Abc_Print( 1,"Expanded %d outputs into %d outputs using OR decomposition.\n", Abc_NtkPoNum(pNtk), Abc_NtkPoNum(pNtkRes) );
+        else
+            Abc_Print( 1,"The output(s) cannot be structurally decomposed.\n" );
+        // clear counter-example
+        if ( pAbc->pCex )
+            ABC_FREE( pAbc->pCex );
+        // replace the current network
+        ABC_FREE( pNtkRes->pName );
+        pNtkRes->pName = Extra_UtilStrsav(pNtk->pName);
+        Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    }
+    else
+    {
+        if ( !Abc_NtkCombinePos( pNtk, 0, fXor ) )
+        {
+            Abc_Print( -1, "ORing the POs has failed.\n" );
+            return 1;
+        }
+        // update counter-example
+        if ( pAbc->pCex )
+            pAbc->pCex->iPo = 0;
+        // replace the current network
+    //    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: orpos [-rxh]\n" );
+    Abc_Print( -2, "\t        creates single-output miter by ORing the POs of the current network\n" );
+    Abc_Print( -2, "\t-r    : performs the reverse transform (OR decomposition) [default = %s]\n", fReverse? "yes": "no" );
+    Abc_Print( -2, "\t-x    : toggles combining the PO using XOR [default = %s]\n", fXor? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAndPos( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);//, * pNtkRes;
+    int fComb = 0;
+    int c;
+
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'c':
+            fComb ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "The network is not strashed.\n" );
+        return 1;
+    }
+
+    if ( Abc_NtkPoNum(pNtk) == 1 )
+    {
+        Abc_Print( -1, "The network already has one PO.\n" );
+        return 1;
+    }
+
+    if ( Abc_NtkLatchNum(pNtk) )
+    {
+        Abc_Print( -1, "The miter has latches. ORing is not performed.\n" );
+        return 1;
+    }
+
+    // get the new network
+    if ( !Abc_NtkCombinePos( pNtk, 1, 0 ) )
+    {
+        Abc_Print( -1, "ANDing the POs has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+//    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: andpos [-h]\n" );
+    Abc_Print( -2, "\t        creates single-output miter by ANDing the POs of the current network\n" );
+//    Abc_Print( -2, "\t-c    : computes combinational miter (latches as POs) [default = %s]\n", fComb? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandZeroPo( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);//, * pNtkRes = NULL;
+    int c, iOutput = -1;
+    int fSkipSweep = 0;
+    int fUseConst1 = 0;
+    extern void Abc_NtkDropOneOutput( Abc_Ntk_t * pNtk, int iOutput, int fSkipSweep, int fUseConst1 );
+
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Nsoh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            iOutput = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( iOutput < 0 )
+                goto usage;
+            break;
+        case 's':
+            fSkipSweep ^= 1;
+            break;
+        case 'o':
+            fUseConst1 ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "The network is not strashed.\n" );
+        return 1;
+    }
+    if ( iOutput < 0 )
+    {
+        Abc_Print( -1, "The output index is not specified.\n" );
+        return 1;
+    }
+    if ( iOutput >= Abc_NtkPoNum(pNtk) )
+    {
+        Abc_Print( -1, "The output index is larger than the allowed POs.\n" );
+        return 1;
+    }
+
+    // get the new network
+//    pNtkRes = Abc_NtkDup( pNtk );
+//    Abc_NtkDropOneOutput( pNtkRes, iOutput );
+//    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    Abc_NtkDropOneOutput( pNtk, iOutput, fSkipSweep, fUseConst1 );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: zeropo [-N <num>] [-soh]\n" );
+    Abc_Print( -2, "\t           replaces the PO driver by constant 0\n" );
+    Abc_Print( -2, "\t-N <num> : the zero-based index of the PO to replace [default = %d]\n", iOutput );
+    Abc_Print( -2, "\t-s       : performs comb sweep after removimg a PO [default = %s]\n", !fSkipSweep? "yes": "no" );
+    Abc_Print( -2, "\t-o       : toggles using const 1 instead of const 0 [default = %s]\n", fUseConst1? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandSwapPos( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc), * pNtkRes;
+    int c, iOutput = -1;
+    extern void Abc_NtkSwapOneOutput( Abc_Ntk_t * pNtk, int iOutput );
+
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Nh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            iOutput = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( iOutput < 0 )
+                goto usage;
+            break;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "The network is not strashed.\n" );
+        return 1;
+    }
+    if ( iOutput < 0 )
+    {
+        Abc_Print( -1, "The output index is not specified.\n" );
+        return 1;
+    }
+    if ( iOutput >= Abc_NtkPoNum(pNtk) )
+    {
+        Abc_Print( -1, "The output index is larger than the allowed POs.\n" );
+        return 1;
+    }
+
+    // get the new network
+    pNtkRes = Abc_NtkDup( pNtk );
+    Abc_NtkSwapOneOutput( pNtkRes, iOutput );
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: swappos [-N <num>] [-h]\n" );
+    Abc_Print( -2, "\t           swap the 0-th PO with the <num>-th PO\n" );
+    Abc_Print( -2, "\t-N <num> : the zero-based index of the PO to swap [default = %d]\n", iOutput );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandRemovePo( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);//, * pNtkRes = NULL;
+    int c, iOutput = -1;
+    int fRemoveConst0 = 1;
+    extern void Abc_NtkRemovePo( Abc_Ntk_t * pNtk, int iOutput, int fRemoveConst0 );
+
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Nzh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            iOutput = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( iOutput < 0 )
+                goto usage;
+            break;
+        case 'z':
+            fRemoveConst0 ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "The network is not strashed.\n" );
+        return 1;
+    }
+    if ( iOutput < 0 )
+    {
+        Abc_Print( -1, "The output index is not specified.\n" );
+        return 1;
+    }
+    if ( iOutput >= Abc_NtkPoNum(pNtk) )
+    {
+        Abc_Print( -1, "The output index is larger than the allowed POs.\n" );
+        return 1;
+    }
+
+    // get the new network
+//    pNtkRes = Abc_NtkDup( pNtk );
+//    Abc_NtkRemovePo( pNtkRes, iOutput );
+//    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    Abc_NtkRemovePo( pNtk, iOutput, fRemoveConst0 );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: removepo [-N <num>] [-zh]\n" );
+    Abc_Print( -2, "\t           remove PO with number <num> if it is const0\n" );
+    Abc_Print( -2, "\t-N <num> : the zero-based index of the PO to remove [default = %d]\n", iOutput );
+    Abc_Print( -2, "\t-z       : toggle removing const1 instead of const0 [default = %s]\n", fRemoveConst0? "const0": "const1" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandDropSat( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern void Abc_NtkDropSatOutputs( Abc_Ntk_t * pNtk, Vec_Ptr_t * vCexes, int fVerbose );
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc), * pNtkRes = NULL;
+    int fNoSweep = 0;
+    int c, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "svh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 's':
+            fNoSweep ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for AIGs (run \"strash\").\n" );
+        return 1;
+    }
+    if ( pAbc->vCexVec == NULL )
+    {
+        Abc_Print( -1, "CEX array is not defined. Run \"bmc3 -az\", \"sim3 -az\", or \"pdr -az\".\n" );
+        return 1;
+    }
+    if ( Vec_PtrSize(pAbc->vCexVec) != Abc_NtkPoNum(pNtk) )
+    {
+        Abc_Print( -1, "CEX array size (%d) does not match the number of outputs (%d).\n", Vec_PtrSize(pAbc->vCexVec), Abc_NtkPoNum(pNtk) );
+        return 1;
+    }
+    Abc_NtkDropSatOutputs( pNtk, pAbc->vCexVec, fVerbose );
+    if ( !fNoSweep )
+    {
+        pNtkRes = Abc_NtkDarLatchSweep( pNtk, 1, 1, 1, 0, -1, -1, 0, 0 );
+        if ( pNtkRes == NULL )
+        {
+            Abc_Print( -1, "Removing SAT outputs has failed.\n" );
+            return 1;
+        }
+        Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: dropsat [-sh]\n" );
+    Abc_Print( -2, "\t         replaces satisfiable POs by constant 0 and cleans up the AIG\n" );
+    Abc_Print( -2, "\t-s     : toggles skipping sequential sweep [default = %s]\n", fNoSweep? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAddPi( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc), * pNtkRes;
+    int c;
+
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    // get the new network
+    pNtkRes = Abc_NtkDup( pNtk );
+    if ( Abc_NtkPiNum(pNtkRes) == 0 )
+    {
+        Abc_Obj_t * pObj = Abc_NtkCreatePi( pNtkRes );
+        Abc_ObjAssignName( pObj, "dummy_pi", NULL );
+        Abc_NtkOrderCisCos( pNtkRes );
+    }
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: addpi [-h]\n" );
+    Abc_Print( -2, "\t         if the network has no PIs, add one dummy PI\n" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAppend( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtk2;
+    char * FileName;
+    int fComb = 0;
+    int c;
+    pNtk = Abc_FrameReadNtk(pAbc);
+
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'c':
+            fComb ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+
+    // get the second network
+    if ( argc != globalUtilOptind + 1 )
+    {
+        Abc_Print( -1, "The network to append is not given.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "The base network should be strashed for the appending to work.\n" );
+        return 1;
+    }
+
+    // read the second network
+    FileName = argv[globalUtilOptind];
+    pNtk2 = Io_Read( FileName, Io_ReadFileType(FileName), 1, 0 );
+    if ( pNtk2 == NULL )
+        return 1;
+
+    // check if the second network is combinational
+    if ( Abc_NtkLatchNum(pNtk2) )
+    {
+        Abc_NtkDelete( pNtk2 );
+        Abc_Print( -1, "The second network has latches. Appending does not work for such networks.\n" );
+        return 0;
+    }
+
+    // get the new network
+    if ( !Abc_NtkAppend( pNtk, pNtk2, 1 ) )
+    {
+        Abc_NtkDelete( pNtk2 );
+        Abc_Print( -1, "Appending the networks failed.\n" );
+        return 1;
+    }
+    Abc_NtkDelete( pNtk2 );
+    // sweep dangling logic
+    Abc_AigCleanup( (Abc_Aig_t *)pNtk->pManFunc );
+    // replace the current network
+//    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: append [-h] <file>\n" );
+    Abc_Print( -2, "\t         appends a combinational network on top of the current network\n" );
+//    Abc_Print( -2, "\t-c     : computes combinational miter (latches as POs) [default = %s]\n", fComb? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\t<file> : file name with the second network\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandPutOnTop( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Abc_Ntk_t * Abc_NtkPutOnTop( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtk2 );
+
+    Abc_Ntk_t * pNtk, * pNtk2, * pNtkRes;
+    char * FileName;
+    int fComb = 0;
+    int c;
+    pNtk = Abc_FrameReadNtk(pAbc);
+
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'c':
+            fComb ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+
+    // get the second network
+    if ( argc != globalUtilOptind + 1 )
+    {
+        Abc_Print( -1, "The network to append is not given.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsLogic(pNtk) )
+    {
+        Abc_Print( -1, "The base network should be in the logic form.\n" );
+        return 1;
+    }
+
+    // check if the second network is combinational
+    if ( Abc_NtkLatchNum(pNtk) )
+    {
+        Abc_Print( -1, "The current network has latches. This command does not work for such networks.\n" );
+        return 0;
+    }
+
+    // read the second network
+    FileName = argv[globalUtilOptind];
+    pNtk2 = Io_Read( FileName, Io_ReadFileType(FileName), 1, 0 );
+    if ( pNtk2 == NULL )
+        return 1;
+
+    // check if the second network is combinational
+    if ( Abc_NtkLatchNum(pNtk2) )
+    {
+        Abc_NtkDelete( pNtk2 );
+        Abc_Print( -1, "The second network has latches. This command does not work for such networks.\n" );
+        return 0;
+    }
+    // compare inputs/outputs
+    if ( Abc_NtkPoNum(pNtk) != Abc_NtkPiNum(pNtk2) )
+    {
+        Abc_NtkDelete( pNtk2 );
+        Abc_Print( -1, "The PO count (%d) of the first network is not equal to PI count (%d) of the second network.\n", Abc_NtkPoNum(pNtk), Abc_NtkPiNum(pNtk2) );
+        return 0;
+    }
+
+    // get the new network
+    pNtkRes = Abc_NtkPutOnTop( pNtk, pNtk2 );
+    Abc_NtkDelete( pNtk2 );
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: putontop [-h] <file>\n" );
+    Abc_Print( -2, "\t         connects PIs of network in <file> to POs of current network\n" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\t<file> : file name with the second network\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandFrames( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkTemp, * pNtkRes;
+    int nFrames;
+    int fInitial;
+    int fVerbose;
+    int c;
+    pNtk = Abc_FrameReadNtk(pAbc);
+
+    // set defaults
+    nFrames  = 5;
+    fInitial = 0;
+    fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Fivh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFrames = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFrames <= 0 )
+                goto usage;
+            break;
+        case 'i':
+            fInitial ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    // get the new network
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
+        pNtkRes  = Abc_NtkFrames( pNtkTemp, nFrames, fInitial, fVerbose );
+        Abc_NtkDelete( pNtkTemp );
+    }
+    else
+        pNtkRes  = Abc_NtkFrames( pNtk, nFrames, fInitial, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Unrolling the network has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: frames [-F <num>] [-ivh]\n" );
+    Abc_Print( -2, "\t           unrolls the network for a number of time frames\n" );
+    Abc_Print( -2, "\t-F <num> : the number of frames to unroll [default = %d]\n", nFrames );
+    Abc_Print( -2, "\t-i       : toggles initializing the first frame [default = %s]\n", fInitial? "yes": "no" );
+    Abc_Print( -2, "\t-v       : toggles outputting verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandDFrames( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkTemp, * pNtkRes;
+    int nPrefix;
+    int nFrames;
+    int fInitial;
+    int fVerbose;
+    int c;
+
+    extern Abc_Ntk_t * Abc_NtkDarFrames( Abc_Ntk_t * pNtk, int nPrefix, int nFrames, int fInitial, int fVerbose );
+    pNtk = Abc_FrameReadNtk(pAbc);
+
+    // set defaults
+    nPrefix  = 5;
+    nFrames  = 5;
+    fInitial = 0;
+    fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "NFivh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nPrefix = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nPrefix <= 0 )
+                goto usage;
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFrames = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFrames <= 0 )
+                goto usage;
+            break;
+        case 'i':
+            fInitial ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( nPrefix > nFrames )
+    {
+        Abc_Print( -1, "Prefix (%d) cannot be more than the number of frames (%d).\n", nPrefix, nFrames );
+        return 1;
+    }
+
+    // get the new network
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
+        pNtkRes  = Abc_NtkDarFrames( pNtkTemp, nPrefix, nFrames, fInitial, fVerbose );
+        Abc_NtkDelete( pNtkTemp );
+    }
+    else
+        pNtkRes  = Abc_NtkDarFrames( pNtk, nPrefix, nFrames, fInitial, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Unrolling the network has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: dframes [-NF <num>] [-ivh]\n" );
+    Abc_Print( -2, "\t         unrolls the network with simplification\n" );
+    Abc_Print( -2, "\t-N num : the number of frames to use as prefix [default = %d]\n", nPrefix );
+    Abc_Print( -2, "\t-F num : the number of frames to unroll [default = %d]\n", nFrames );
+    Abc_Print( -2, "\t-i     : toggles initializing the first frame [default = %s]\n", fInitial? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggles outputting verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandSop( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int fDirect;
+    int c;
+
+    // set defaults
+    fDirect = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'd':
+            fDirect ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsLogic(pNtk) )
+    {
+        Abc_Print( -1, "Converting to SOP is possible only for logic networks.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkToSop(pNtk, fDirect) )
+    {
+        Abc_Print( -1, "Converting to SOP has failed.\n" );
+        return 1;
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: sop [-dh]\n" );
+    Abc_Print( -2, "\t         converts node functions to SOP\n" );
+    Abc_Print( -2, "\t-d     : toggles using both phases or only positive [default = %s]\n", fDirect? "direct": "both" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandBdd( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int fReorder = 1;
+    int c;
+
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "rh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'r':
+            fReorder ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsLogic(pNtk) )
+    {
+        Abc_Print( -1, "Converting to BDD is possible only for logic networks.\n" );
+        return 1;
+    }
+    if ( Abc_NtkIsBddLogic(pNtk) )
+    {
+        Abc_Print( -1, "The logic network is already in the BDD form.\n" );
+        return 0;
+    }
+    if ( !Abc_NtkToBdd(pNtk) )
+    {
+        Abc_Print( -1, "Converting to BDD has failed.\n" );
+        return 1;
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: bdd [-rh]\n" );
+    Abc_Print( -2, "\t         converts node functions to BDD\n" );
+    Abc_Print( -2, "\t-r     : toggles enabling dynamic variable reordering [default = %s]\n", fReorder? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAig( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsLogic(pNtk) )
+    {
+        Abc_Print( -1, "Converting to AIG is possible only for logic networks.\n" );
+        return 1;
+    }
+    if ( Abc_NtkIsAigLogic(pNtk) )
+    {
+        Abc_Print( -1, "The logic network is already in the AIG form.\n" );
+        return 0;
+    }
+    if ( !Abc_NtkToAig(pNtk) )
+    {
+        Abc_Print( -1, "Converting to AIG has failed.\n" );
+        return 1;
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: aig [-h]\n" );
+    Abc_Print( -2, "\t         converts node functions to AIG\n" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandReorder( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int fVerbose;
+    extern void Abc_NtkBddReorder( Abc_Ntk_t * pNtk, int fVerbose );
+
+    // set defaults
+    fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    // get the new network
+    if ( !Abc_NtkIsBddLogic(pNtk) )
+    {
+        Abc_Print( -1, "Variable reordering is possible when node functions are BDDs (run \"bdd\").\n" );
+        return 1;
+    }
+    Abc_NtkBddReorder( pNtk, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: reorder [-vh]\n" );
+    Abc_Print( -2, "\t         reorders local functions of the nodes using sifting\n" );
+    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandBidec( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int fVerbose;
+    extern void Abc_NtkBidecResyn( Abc_Ntk_t * pNtk, int fVerbose );
+
+    // set defaults
+    fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    // get the new network
+    if ( !Abc_NtkIsAigLogic(pNtk) )
+    {
+        Abc_Print( -1, "Bi-decomposition only works when node functions are AIGs (run \"aig\").\n" );
+        return 1;
+    }
+    Abc_NtkBidecResyn( pNtk, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: bidec [-vh]\n" );
+    Abc_Print( -2, "\t         applies bi-decomposition to local functions of the nodes\n" );
+    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandOrder( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    FILE * pFile;
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    char * pFileName;
+    int c;
+    int fReverse;
+    int fVerbose;
+    extern void Abc_NtkImplementCiOrder( Abc_Ntk_t * pNtk, char * pFileName, int fReverse, int fVerbose );
+    extern void Abc_NtkFindCiOrder( Abc_Ntk_t * pNtk, int fReverse, int fVerbose );
+
+    // set defaults
+    fReverse = 0;
+    fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "rvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'r':
+            fReverse ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+//    if ( Abc_NtkLatchNum(pNtk) > 0 )
+//    {
+//        Abc_Print( -1, "Currently this procedure does not work for sequential networks.\n" );
+//        return 1;
+//    }
+
+    // if the var order file is given, implement this order
+    pFileName = NULL;
+    if ( argc == globalUtilOptind + 1 )
+    {
+        pFileName = argv[globalUtilOptind];
+        pFile = fopen( pFileName, "r" );
+        if ( pFile == NULL )
+        {
+            Abc_Print( -1, "Cannot open file \"%s\" with the BDD variable order.\n", pFileName );
+            return 1;
+        }
+        fclose( pFile );
+    }
+    if ( pFileName )
+        Abc_NtkImplementCiOrder( pNtk, pFileName, fReverse, fVerbose );
+    else
+        Abc_NtkFindCiOrder( pNtk, fReverse, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: order [-rvh] <file>\n" );
+    Abc_Print( -2, "\t         computes a good static CI variable order\n" );
+    Abc_Print( -2, "\t-r     : toggle reverse ordering [default = %s]\n", fReverse? "yes": "no" );
+    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\t<file> : (optional) file with the given variable order\n" );
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandMuxes( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c;
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsBddLogic(pNtk) )
+    {
+        Abc_Print( -1, "Only a BDD logic network can be converted to MUXes.\n" );
+        return 1;
+    }
+
+    // get the new network
+    pNtkRes = Abc_NtkBddToMuxes( pNtk );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Converting to MUXes has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: muxes [-h]\n" );
+    Abc_Print( -2, "\t        converts the current network into a network derived by\n" );
+    Abc_Print( -2, "\t        replacing all nodes by DAGs isomorphic to the local BDDs\n" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandCubes( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Abc_Ntk_t * Abc_NtkSopToCubes( Abc_Ntk_t * pNtk );
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c;
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsSopLogic(pNtk) )
+    {
+        Abc_Print( -1, "Only a SOP logic network can be transformed into cubes.\n" );
+        return 1;
+    }
+
+    // get the new network
+    pNtkRes = Abc_NtkSopToCubes( pNtk );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Converting to cubes has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: cubes [-h]\n" );
+    Abc_Print( -2, "\t        converts the current network into a network derived by creating\n" );
+    Abc_Print( -2, "\t        a separate node for each product and sum in the local SOPs\n" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandSplitSop( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Abc_Ntk_t * Abc_NtkSplitSop( Abc_Ntk_t * pNtk, int nCubesMax, int fVerbose );
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c, fVerbose = 0, nCubesMax = 100;
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Nvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nCubesMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nCubesMax < 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsSopLogic(pNtk) )
+    {
+        Abc_Print( -1, "Only a SOP logic network can be transformed into cubes.\n" );
+        return 1;
+    }
+
+    // get the new network
+    pNtkRes = Abc_NtkSplitSop( pNtk, nCubesMax, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Converting to cubes has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: splitsop [-N num] [-vh]\n" );
+    Abc_Print( -2, "\t         splits nodes whose SOP size is larger than the given one\n" );
+    Abc_Print( -2, "\t-N num : the maximum number of cubes after splitting [default = %d]\n", nCubesMax );
+    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandExtSeqDcs( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int fVerbose;
+    extern int Abc_NtkExtractSequentialDcs( Abc_Ntk_t * pNet, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( Abc_NtkLatchNum(pNtk) == 0 )
+    {
+        Abc_Print( -1, "The current network has no latches.\n" );
+        return 0;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Extracting sequential don't-cares works only for AIGs (run \"strash\").\n" );
+        return 0;
+    }
+    if ( !Abc_NtkExtractSequentialDcs( pNtk, fVerbose ) )
+    {
+        Abc_Print( -1, "Extracting sequential don't-cares has failed.\n" );
+        return 1;
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: ext_seq_dcs [-vh]\n" );
+    Abc_Print( -2, "\t         create EXDC network using unreachable states\n" );
+    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandReach( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Saig_ParBbr_t Pars, * pPars = &Pars;
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    char * pLogFileName = NULL;
+
+    extern int Abc_NtkDarReach( Abc_Ntk_t * pNtk, Saig_ParBbr_t * pPars );
+
+    // set defaults
+    Bbr_ManSetDefaultParams( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "TBFLproyvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->TimeLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->TimeLimit < 0 )
+                goto usage;
+            break;
+        case 'B':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nBddMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nBddMax < 0 )
+                goto usage;
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nIterMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nIterMax < 0 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by a file name.\n" );
+                goto usage;
+            }
+            pLogFileName = argv[globalUtilOptind];
+            globalUtilOptind++;
+            break;
+        case 'p':
+            pPars->fPartition ^= 1;
+            break;
+        case 'r':
+            pPars->fReorder ^= 1;
+            break;
+        case 'o':
+            pPars->fReorderImage ^= 1;
+            break;
+        case 'y':
+            pPars->fSkipOutCheck ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( Abc_NtkLatchNum(pNtk) == 0 )
+    {
+        Abc_Print( -1, "The current network has no latches.\n" );
+        return 0;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Reachability analysis works only for AIGs (run \"strash\").\n" );
+        return 1;
+    }
+    pAbc->Status  = Abc_NtkDarReach( pNtk, pPars );
+    pAbc->nFrames = pPars->iFrame;
+    Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
+    if ( pLogFileName )
+        Abc_NtkWriteLogFile( pLogFileName, pAbc->pCex, pAbc->Status, pAbc->nFrames, "reach" );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: reach [-TBF num] [-L file] [-proyvh]\n" );
+    Abc_Print( -2, "\t         verifies sequential miter using BDD-based reachability\n" );
+    Abc_Print( -2, "\t-T num : approximate time limit in seconds (0=infinite) [default = %d]\n", pPars->TimeLimit );
+    Abc_Print( -2, "\t-B num : max number of nodes in the intermediate BDDs [default = %d]\n", pPars->nBddMax );
+    Abc_Print( -2, "\t-F num : max number of reachability iterations [default = %d]\n", pPars->nIterMax );
+    Abc_Print( -2, "\t-L file: the log file name [default = %s]\n", pLogFileName ? pLogFileName : "no logging" );
+    Abc_Print( -2, "\t-p     : enable partitioned image computation [default = %s]\n", pPars->fPartition? "yes": "no" );
+    Abc_Print( -2, "\t-r     : enable dynamic BDD variable reordering [default = %s]\n", pPars->fReorder? "yes": "no" );
+    Abc_Print( -2, "\t-o     : toggles BDD variable reordering during image computation [default = %s]\n", pPars->fReorderImage? "yes": "no" );
+    Abc_Print( -2, "\t-y     : skip checking property outputs [default = %s]\n", pPars->fSkipOutCheck? "yes": "no" );
+    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandCone( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    Abc_Obj_t * pNode, * pNodeCo;
+    int c;
+    int fUseAllCis;
+    int fUseMffc;
+    int fSeq;
+    int Output;
+    int nRange;
+
+    extern Abc_Ntk_t * Abc_NtkMakeOnePo( Abc_Ntk_t * pNtk, int Output, int nRange );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    fUseAllCis = 0;
+    fUseMffc = 0;
+    fSeq = 0;
+    Output = -1;
+    nRange = -1;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "ORmash" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'O':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-O\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            Output = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( Output < 0 )
+                goto usage;
+            break;
+        case 'R':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nRange = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nRange < 0 )
+                goto usage;
+            break;
+        case 'm':
+            fUseMffc ^= 1;
+            break;
+        case 'a':
+            fUseAllCis ^= 1;
+            break;
+        case 's':
+            fSeq ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsLogic(pNtk) && !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Currently can only be applied to the logic network or an AIG.\n" );
+        return 1;
+    }
+
+    if ( argc > globalUtilOptind + 1 )
+    {
+        Abc_Print( -1, "Wrong number of auguments.\n" );
+        goto usage;
+    }
+
+    pNodeCo = NULL;
+    if ( argc == globalUtilOptind + 1 )
+    {
+        pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
+        if ( pNode == NULL )
+        {
+            Abc_Print( -1, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
+            return 1;
+        }
+        if ( fUseMffc )
+            pNtkRes = Abc_NtkCreateMffc( pNtk, pNode, argv[globalUtilOptind] );
+        else
+            pNtkRes = Abc_NtkCreateCone( pNtk, pNode, argv[globalUtilOptind], fUseAllCis );
+    }
+    else
+    {
+        if ( Output == -1 )
+        {
+            Abc_Print( -1, "The node is not specified.\n" );
+            return 1;
+        }
+        if ( Output >= Abc_NtkCoNum(pNtk) )
+        {
+            Abc_Print( -1, "The 0-based output number (%d) is larger than the number of outputs (%d).\n", Output, Abc_NtkCoNum(pNtk) );
+            return 1;
+        }
+        pNodeCo = Abc_NtkCo( pNtk, Output );
+        if ( fSeq )
+            pNtkRes = Abc_NtkMakeOnePo( pNtk, Output, nRange );
+        else if ( fUseMffc )
+            pNtkRes = Abc_NtkCreateMffc( pNtk, Abc_ObjFanin0(pNodeCo), Abc_ObjName(pNodeCo) );
+        else
+            pNtkRes = Abc_NtkCreateCone( pNtk, Abc_ObjFanin0(pNodeCo), Abc_ObjName(pNodeCo), fUseAllCis );
+    }
+    if ( pNodeCo && Abc_ObjFaninC0(pNodeCo) && !fSeq )
+    {
+        Abc_NtkPo(pNtkRes, 0)->fCompl0  ^= 1;
+//        Abc_Print( -1, "The extracted cone represents the complement function of the CO.\n" );
+    }
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Writing the logic cone of one node has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: cone [-OR num] [-amsh] <name>\n" );
+    Abc_Print( -2, "\t         replaces the current network by one logic cone\n" );
+    Abc_Print( -2, "\t-a     : toggle keeping all CIs or structral support only [default = %s]\n", fUseAllCis? "all": "structural" );
+    Abc_Print( -2, "\t-m     : toggle keeping only MFFC or complete TFI cone [default = %s]\n", fUseMffc? "MFFC": "TFI cone" );
+    Abc_Print( -2, "\t-s     : toggle comb or sequential cone (works with \"-O num\") [default = %s]\n", fSeq? "seq": "comb" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\t-O num : (optional) the 0-based number of the CO to extract\n");
+    Abc_Print( -2, "\t-R num : (optional) the number of outputs to extract\n");
+    Abc_Print( -2, "\tname   : (optional) the name of the node to extract\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandNode( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    Abc_Obj_t * pNode;
+    int c;
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+       case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsLogic(pNtk) )
+    {
+        Abc_Print( -1, "Currently can only be applied to a logic network.\n" );
+        return 1;
+    }
+
+    if ( argc != globalUtilOptind + 1 )
+    {
+        Abc_Print( -1, "Wrong number of auguments.\n" );
+        goto usage;
+    }
+
+    pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
+    if ( pNode == NULL )
+    {
+        Abc_Print( -1, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
+        return 1;
+    }
+
+    pNtkRes = Abc_NtkCreateFromNode( pNtk, pNode );
+//    pNtkRes = Abc_NtkDeriveFromBdd( pNtk->pManFunc, pNode->pData, NULL, NULL );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Splitting one node has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: node [-h] <name>\n" );
+    Abc_Print( -2, "\t         replaces the current network by the network composed of one node\n" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\tname   : the node name\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandTopmost( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c, nLevels;
+    extern Abc_Ntk_t * Abc_NtkTopmost( Abc_Ntk_t * pNtk, int nLevels );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    nLevels = 10;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Nh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nLevels = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLevels < 0 )
+                goto usage;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
+        return 0;
+    }
+
+    if ( Abc_NtkLatchNum(pNtk) > 0 )
+    {
+        Abc_Print( -1, "Currently can only works for combinational circuits.\n" );
+        return 0;
+    }
+    if ( Abc_NtkPoNum(pNtk) != 1 )
+    {
+        Abc_Print( -1, "Currently expects a single-output miter.\n" );
+        return 0;
+    }
+
+    pNtkRes = Abc_NtkTopmost( pNtk, nLevels );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "The command has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: topmost [-N num] [-h]\n" );
+    Abc_Print( -2, "\t         replaces the current network by several of its topmost levels\n" );
+    Abc_Print( -2, "\t-N num : max number of levels [default = %d]\n", nLevels );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\tname   : the node name\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandTopAnd( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c;
+    extern Abc_Ntk_t * Abc_NtkTopAnd( Abc_Ntk_t * pNtk );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
+        return 0;
+    }
+
+    if ( Abc_NtkLatchNum(pNtk) > 0 )
+    {
+        Abc_Print( -1, "Currently can only works for combinational circuits.\n" );
+        return 0;
+    }
+    if ( Abc_NtkPoNum(pNtk) != 1 )
+    {
+        Abc_Print( -1, "Currently expects a single-output miter.\n" );
+        return 0;
+    }
+    if ( Abc_ObjFaninC0(Abc_NtkPo(pNtk, 0)) )
+    {
+        Abc_Print( -1, "The PO driver is complemented. AND-decomposition is impossible.\n" );
+        return 0;
+    }
+    if ( !Abc_ObjIsNode(Abc_ObjChild0(Abc_NtkPo(pNtk, 0))) )
+    {
+        Abc_Print( -1, "The PO driver is not a node. AND-decomposition is impossible.\n" );
+        return 0;
+    }
+    pNtkRes = Abc_NtkTopAnd( pNtk );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "The command has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: topand [-h]\n" );
+    Abc_Print( -2, "\t         performs AND-decomposition of single-output combinational miter\n" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\tname   : the node name\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandTrim( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    Gia_Man_t * pGia, * pNew;
+    Aig_Man_t * pAig;
+    int c;
+    pNtk = Abc_FrameReadNtk(pAbc);
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Nh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Trimming works only for AIGs (run \"strash\").\n" );
+        return 1;
+    }
+    // convert to GIA
+    pAig = Abc_NtkToDar( pNtk, 0, 1 );
+    pGia = Gia_ManFromAigSimple( pAig );
+    Aig_ManStop( pAig );
+    // perform trimming
+    pNew = Gia_ManDupTrimmed( pGia, 1, 1, 0, -1 );
+    Gia_ManStop( pGia );
+    // convert back
+    pAig = Gia_ManToAigSimple( pNew );
+    Gia_ManStop( pNew );
+    pNtkRes = Abc_NtkFromAigPhase( pAig );
+    Aig_ManStop( pAig );
+    // duplicate the name and the spec
+    ABC_FREE( pNtkRes->pName );
+    ABC_FREE( pNtkRes->pSpec );
+    pNtkRes->pName = Extra_UtilStrsav(pNtk->pName);
+    pNtkRes->pSpec = Extra_UtilStrsav(pNtk->pSpec);
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: trim [-h]\n" );
+    Abc_Print( -2, "\t         removes POs fed by constants and PIs w/o fanout\n" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandShortNames( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    Abc_NtkShortNames( pNtk );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: short_names [-h]\n" );
+    Abc_Print( -2, "\t         replaces PI/PO/latch names by short char strings\n" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandMoveNames( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern void Abc_NtkMoveNames( Abc_Ntk_t * pNtk, Abc_Ntk_t * pOld );
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    Abc_Ntk_t * pNtk2;
+    char * FileName;
+    int c;
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    // get the second network
+    if ( argc != globalUtilOptind + 1 )
+    {
+        Abc_Print( -1, "The network to take names from is not given.\n" );
+        return 1;
+    }
+
+    // read the second network
+    FileName = argv[globalUtilOptind];
+    pNtk2 = Io_Read( FileName, Io_ReadFileType(FileName), 1, 0 );
+    if ( pNtk2 == NULL )
+        return 1;
+
+    // compare inputs/outputs
+    if ( Abc_NtkPiNum(pNtk) != Abc_NtkPiNum(pNtk2) )
+    {
+        Abc_NtkDelete( pNtk2 );
+        Abc_Print( -1, "The PI count (%d) of the first network is not equal to PI count (%d) of the second network.\n", Abc_NtkPiNum(pNtk), Abc_NtkPiNum(pNtk2) );
+        return 0;
+    }
+    // compare inputs/outputs
+    if ( Abc_NtkPoNum(pNtk) != Abc_NtkPoNum(pNtk2) )
+    {
+        Abc_NtkDelete( pNtk2 );
+        Abc_Print( -1, "The PO count (%d) of the first network is not equal to PO count (%d) of the second network.\n", Abc_NtkPoNum(pNtk), Abc_NtkPoNum(pNtk2) );
+        return 0;
+    }
+    // compare inputs/outputs
+    if ( Abc_NtkLatchNum(pNtk) != Abc_NtkLatchNum(pNtk2) )
+    {
+        Abc_NtkDelete( pNtk2 );
+        Abc_Print( -1, "The flop count (%d) of the first network is not equal to flop count (%d) of the second network.\n", Abc_NtkLatchNum(pNtk), Abc_NtkLatchNum(pNtk2) );
+        return 0;
+    }
+    Abc_NtkMoveNames( pNtk, pNtk2 );
+    Abc_NtkDelete( pNtk2 );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: move_names [-h] <file>\n" );
+    Abc_Print( -2, "\t         moves PI/PO/latch names from the other network\n" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\t<file> : file with network that has required names\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandExdcFree( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c;
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( pNtk->pExdc == NULL )
+    {
+        Abc_Print( -1, "The network has no EXDC.\n" );
+        return 1;
+    }
+
+    Abc_NtkDelete( pNtk->pExdc );
+    pNtk->pExdc = NULL;
+
+    // replace the current network
+    pNtkRes = Abc_NtkDup( pNtk );
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: exdc_free [-h]\n" );
+    Abc_Print( -2, "\t         frees the EXDC network of the current network\n" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandExdcGet( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c;
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( pNtk->pExdc == NULL )
+    {
+        Abc_Print( -1, "The network has no EXDC.\n" );
+        return 1;
+    }
+
+    // replace the current network
+    pNtkRes = Abc_NtkDup( pNtk->pExdc );
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: exdc_get [-h]\n" );
+    Abc_Print( -2, "\t         replaces the current network by the EXDC of the current network\n" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandExdcSet( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    FILE * pFile;
+    Abc_Ntk_t * pNtk, * pNtkNew, * pNtkRes;
+    char * FileName;
+    int c;
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( argc != globalUtilOptind + 1 )
+    {
+        goto usage;
+    }
+
+    // get the input file name
+    FileName = argv[globalUtilOptind];
+    if ( (pFile = fopen( FileName, "r" )) == NULL )
+    {
+        Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
+        if ( (FileName = Extra_FileGetSimilarName( FileName, ".mv", ".blif", ".pla", ".eqn", ".bench" )) )
+            Abc_Print( 1, "Did you mean \"%s\"?", FileName );
+        Abc_Print( 1, "\n" );
+        return 1;
+    }
+    fclose( pFile );
+
+    // set the new network
+    pNtkNew = Io_Read( FileName, Io_ReadFileType(FileName), 1, 0 );
+    if ( pNtkNew == NULL )
+    {
+        Abc_Print( -1, "Reading network from file has failed.\n" );
+        return 1;
+    }
+
+    // replace the EXDC
+    if ( pNtk->pExdc )
+    {
+        Abc_NtkDelete( pNtk->pExdc );
+        pNtk->pExdc = NULL;
+    }
+    pNtkRes = Abc_NtkDup( pNtk );
+    pNtkRes->pExdc = pNtkNew;
+
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: exdc_set [-h] <file>\n" );
+    Abc_Print( -2, "\t         sets the network from file as EXDC for the current network\n" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\t<file> : file with the new EXDC network\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandCareSet( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    FILE * pFile;
+    Abc_Ntk_t * pNtk, * pNtkNew, * pNtkRes;
+    char * FileName;
+    int c;
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( argc != globalUtilOptind + 1 )
+    {
+        goto usage;
+    }
+
+    // get the input file name
+    FileName = argv[globalUtilOptind];
+    if ( (pFile = fopen( FileName, "r" )) == NULL )
+    {
+        Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
+        if ( (FileName = Extra_FileGetSimilarName( FileName, ".mv", ".blif", ".pla", ".eqn", ".bench" )) )
+            Abc_Print( 1, "Did you mean \"%s\"?", FileName );
+        Abc_Print( 1, "\n" );
+        return 1;
+    }
+    fclose( pFile );
+
+    // set the new network
+    pNtkNew = Io_Read( FileName, Io_ReadFileType(FileName), 1, 0 );
+    if ( pNtkNew == NULL )
+    {
+        Abc_Print( -1, "Reading network from file has failed.\n" );
+        return 1;
+    }
+
+    // replace the EXDC
+    if ( pNtk->pExcare )
+    {
+        Abc_NtkDelete( (Abc_Ntk_t *)pNtk->pExcare );
+        pNtk->pExcare = NULL;
+    }
+    pNtkRes = Abc_NtkDup( pNtk );
+    pNtkRes->pExcare = pNtkNew;
+
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: care_set [-h] <file>\n" );
+    Abc_Print( -2, "\t         sets the network from file as a care for the current network\n" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\t<file> : file with the new care network\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandCut( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Cut_Params_t Params, * pParams = &Params;
+    Cut_Man_t * pCutMan;
+    Cut_Oracle_t * pCutOracle = NULL;
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int fOracle;
+    extern Cut_Man_t * Abc_NtkCuts( Abc_Ntk_t * pNtk, Cut_Params_t * pParams );
+    extern void Abc_NtkCutsOracle( Abc_Ntk_t * pNtk, Cut_Oracle_t * pCutOracle );
+
+    // set defaults
+    fOracle = 0;
+    memset( pParams, 0, sizeof(Cut_Params_t) );
+    pParams->nVarsMax    = 5;     // the max cut size ("k" of the k-feasible cuts)
+    pParams->nKeepMax    = 1000;  // the max number of cuts kept at a node
+    pParams->fTruth      = 1;     // compute truth tables
+    pParams->fFilter     = 1;     // filter dominated cuts
+    pParams->fDrop       = 0;     // drop cuts on the fly
+    pParams->fDag        = 1;     // compute DAG cuts
+    pParams->fTree       = 0;     // compute tree cuts
+    pParams->fGlobal     = 0;     // compute global cuts
+    pParams->fLocal      = 0;     // compute local cuts
+    pParams->fFancy      = 0;     // compute something fancy
+    pParams->fRecordAig  = 1;     // compute something fancy
+    pParams->fMap        = 0;     // compute mapping delay
+    pParams->fAdjust     = 0;     // removes useless fanouts
+    pParams->fNpnSave    = 0;     // enables dumping truth tables
+    pParams->fVerbose    = 0;     // the verbosiness flag
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "KMtfdxyglzamjvosh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pParams->nVarsMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pParams->nVarsMax < 0 )
+                goto usage;
+            break;
+        case 'M':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pParams->nKeepMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pParams->nKeepMax < 0 )
+                goto usage;
+            break;
+        case 't':
+            pParams->fTruth ^= 1;
+            break;
+        case 'f':
+            pParams->fFilter ^= 1;
+            break;
+        case 'd':
+            pParams->fDrop ^= 1;
+            break;
+        case 'x':
+            pParams->fDag ^= 1;
+            break;
+        case 'y':
+            pParams->fTree ^= 1;
+            break;
+        case 'g':
+            pParams->fGlobal ^= 1;
+            break;
+        case 'l':
+            pParams->fLocal ^= 1;
+            break;
+        case 'z':
+            pParams->fFancy ^= 1;
+            break;
+        case 'a':
+            pParams->fRecordAig ^= 1;
+            break;
+        case 'm':
+            pParams->fMap ^= 1;
+            break;
+        case 'j':
+            pParams->fAdjust ^= 1;
+            break;
+        case 'v':
+            pParams->fVerbose ^= 1;
+            break;
+        case 'o':
+            fOracle ^= 1;
+            break;
+        case 's':
+            pParams->fNpnSave ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Cut computation is available only for AIGs (run \"strash\").\n" );
+        return 1;
+    }
+    if ( pParams->nVarsMax < CUT_SIZE_MIN || pParams->nVarsMax > CUT_SIZE_MAX )
+    {
+        Abc_Print( -1, "Can only compute the cuts for %d <= K <= %d.\n", CUT_SIZE_MIN, CUT_SIZE_MAX );
+        return 1;
+    }
+    if ( pParams->fDag && pParams->fTree )
+    {
+        Abc_Print( -1, "Cannot compute both DAG cuts and tree cuts at the same time.\n" );
+        return 1;
+    }
+
+    if ( pParams->fNpnSave )
+    {
+        pParams->nVarsMax = 6;
+        pParams->fTruth = 1;
+    }
+
+    if ( fOracle )
+        pParams->fRecord = 1;
+    pCutMan = Abc_NtkCuts( pNtk, pParams );
+    if ( fOracle )
+        pCutOracle = Cut_OracleStart( pCutMan );
+    Cut_ManStop( pCutMan );
+    if ( fOracle )
+    {
+        assert(pCutOracle);
+        Abc_NtkCutsOracle( pNtk, pCutOracle );
+        Cut_OracleStop( pCutOracle );
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: cut [-K num] [-M num] [-tfdcovamjsvh]\n" );
+    Abc_Print( -2, "\t         computes k-feasible cuts for the AIG\n" );
+    Abc_Print( -2, "\t-K num : max number of leaves (%d <= num <= %d) [default = %d]\n",     CUT_SIZE_MIN, CUT_SIZE_MAX, pParams->nVarsMax );
+    Abc_Print( -2, "\t-M num : max number of cuts stored at a node [default = %d]\n",        pParams->nKeepMax );
+    Abc_Print( -2, "\t-t     : toggle truth table computation [default = %s]\n",             pParams->fTruth?   "yes": "no" );
+    Abc_Print( -2, "\t-f     : toggle filtering of duplicated/dominated [default = %s]\n",   pParams->fFilter?  "yes": "no" );
+    Abc_Print( -2, "\t-d     : toggle dropping when fanouts are done [default = %s]\n",      pParams->fDrop?    "yes": "no" );
+    Abc_Print( -2, "\t-x     : toggle computing only DAG cuts [default = %s]\n",             pParams->fDag?     "yes": "no" );
+    Abc_Print( -2, "\t-y     : toggle computing only tree cuts [default = %s]\n",            pParams->fTree?    "yes": "no" );
+    Abc_Print( -2, "\t-g     : toggle computing only global cuts [default = %s]\n",          pParams->fGlobal?  "yes": "no" );
+    Abc_Print( -2, "\t-l     : toggle computing only local cuts [default = %s]\n",           pParams->fLocal?   "yes": "no" );
+    Abc_Print( -2, "\t-z     : toggle fancy computations [default = %s]\n",                  pParams->fFancy?   "yes": "no" );
+    Abc_Print( -2, "\t-a     : toggle recording cut functions [default = %s]\n",             pParams->fRecordAig?"yes": "no" );
+    Abc_Print( -2, "\t-m     : toggle delay-oriented FPGA mapping [default = %s]\n",         pParams->fMap?     "yes": "no" );
+    Abc_Print( -2, "\t-j     : toggle removing fanouts due to XOR/MUX [default = %s]\n",     pParams->fAdjust?  "yes": "no" );
+    Abc_Print( -2, "\t-s     : toggle creating library of 6-var functions [default = %s]\n", pParams->fNpnSave?  "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n",        pParams->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandScut( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Cut_Params_t Params, * pParams = &Params;
+    Cut_Man_t * pCutMan;
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    extern Cut_Man_t * Abc_NtkSeqCuts( Abc_Ntk_t * pNtk, Cut_Params_t * pParams );
+
+    // set defaults
+    memset( pParams, 0, sizeof(Cut_Params_t) );
+    pParams->nVarsMax  = 5;     // the max cut size ("k" of the k-feasible cuts)
+    pParams->nKeepMax  = 1000;  // the max number of cuts kept at a node
+    pParams->fTruth    = 0;     // compute truth tables
+    pParams->fFilter   = 1;     // filter dominated cuts
+    pParams->fSeq      = 1;     // compute sequential cuts
+    pParams->fVerbose  = 0;     // the verbosiness flag
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "KMtvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pParams->nVarsMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pParams->nVarsMax < 0 )
+                goto usage;
+            break;
+        case 'M':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pParams->nKeepMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pParams->nKeepMax < 0 )
+                goto usage;
+            break;
+        case 't':
+            pParams->fTruth ^= 1;
+            break;
+        case 'v':
+            pParams->fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+/*
+    if ( !Abc_NtkIsSeq(pNtk) )
+    {
+        Abc_Print( -1, "Sequential cuts can be computed for sequential AIGs (run \"seq\").\n" );
+        return 1;
+    }
+*/
+    if ( pParams->nVarsMax < CUT_SIZE_MIN || pParams->nVarsMax > CUT_SIZE_MAX )
+    {
+        Abc_Print( -1, "Can only compute the cuts for %d <= K <= %d.\n", CUT_SIZE_MIN, CUT_SIZE_MAX );
+        return 1;
+    }
+
+    pCutMan = Abc_NtkSeqCuts( pNtk, pParams );
+    Cut_ManStop( pCutMan );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: scut [-K num] [-M num] [-tvh]\n" );
+    Abc_Print( -2, "\t         computes k-feasible cuts for the sequential AIG\n" );
+    Abc_Print( -2, "\t-K num : max number of leaves (%d <= num <= %d) [default = %d]\n",   CUT_SIZE_MIN, CUT_SIZE_MAX, pParams->nVarsMax );
+    Abc_Print( -2, "\t-M num : max number of cuts stored at a node [default = %d]\n",      pParams->nKeepMax );
+    Abc_Print( -2, "\t-t     : toggle truth table computation [default = %s]\n",           pParams->fTruth?   "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n",      pParams->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandEspresso( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int fVerbose;
+    extern void Abc_NtkEspresso( Abc_Ntk_t * pNtk, int fVerbose );
+
+    if ( argc == 2 && !strcmp(argv[1], "-h") )
+    {
+        Abc_Print( -2, "The espresso command is currently disabled.\n" );
+        return 1;
+    }
+
+    Abc_Print( -1, "This command is currently disabled.\n" );
+    return 0;
+
+    // set defaults
+    fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsLogic(pNtk) )
+    {
+        Abc_Print( -1, "SOP minimization is possible for logic networks (run \"renode\").\n" );
+        return 1;
+    }
+//    Abc_NtkEspresso( pNtk, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: espresso [-vh]\n" );
+    Abc_Print( -2, "\t         minimizes SOPs of the local functions using Espresso\n" );
+    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandGen( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+//    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int nVars;    // the number of variables
+    int nLutSize = -1; // the size of LUTs
+    int nLuts = -1;    // the number of LUTs
+    int fAdder;
+    int fSorter;
+    int fMesh;
+    int fMulti;
+    int fFpga;
+    int fOneHot;
+    int fRandom;
+    int fVerbose;
+    char * FileName;
+    char Command[1000];
+    extern void Abc_GenAdder( char * pFileName, int nVars );
+    extern void Abc_GenSorter( char * pFileName, int nVars );
+    extern void Abc_GenMesh( char * pFileName, int nVars );
+    extern void Abc_GenMulti( char * pFileName, int nVars );
+    extern void Abc_GenFpga( char * pFileName, int nLutSize, int nLuts, int nVars );
+    extern void Abc_GenOneHot( char * pFileName, int nVars );
+    extern void Abc_GenRandom( char * pFileName, int nPis );
+
+    // set defaults
+    nVars = 8;
+    fAdder = 0;
+    fSorter = 0;
+    fMesh = 0;
+    fMulti = 0;
+    fFpga = 0;
+    fOneHot = 0;
+    fRandom = 0;
+    fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "NKLasemftrvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nVars = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nVars < 0 )
+                goto usage;
+            break;
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nLutSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLutSize < 0 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nLuts = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLuts < 0 )
+                goto usage;
+            break;
+        case 'a':
+            fAdder ^= 1;
+            break;
+        case 's':
+            fSorter ^= 1;
+            break;
+        case 'e':
+            fMesh ^= 1;
+            break;
+        case 'm':
+            fMulti ^= 1;
+            break;
+        case 'f':
+            fFpga ^= 1;
+            break;
+        case 't':
+            fOneHot ^= 1;
+            break;
+        case 'r':
+            fRandom ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( argc != globalUtilOptind + 1 )
+    {
+        goto usage;
+    }
+    if ( nVars < 1 )
+    {
+        Abc_Print( -1, "The number of variables should be a positive integer.\n" );
+        return 0;
+    }
+    // get the input file name
+    FileName = argv[globalUtilOptind];
+    if ( fAdder )
+        Abc_GenAdder( FileName, nVars );
+    else if ( fSorter )
+        Abc_GenSorter( FileName, nVars );
+    else if ( fMesh )
+        Abc_GenMesh( FileName, nVars );
+    else if ( fMulti )
+        Abc_GenMulti( FileName, nVars );
+    else if ( fFpga )
+        Abc_GenFpga( FileName, nLutSize, nLuts, nVars );
+//        Abc_GenFpga( FileName, 2, 2, 3 );
+//        Abc_GenFpga( FileName, 3, 2, 5 );
+    else if ( fOneHot )
+        Abc_GenOneHot( FileName, nVars );
+    else if ( fRandom )
+        Abc_GenRandom( FileName, nVars );
+    else
+    {
+        Abc_Print( -1, "Type of circuit is not specified.\n" );
+        return 0;
+    }
+    // read the file just produced
+    sprintf(Command, "read %s", FileName );
+    Cmd_CommandExecute( pAbc, Command );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: gen [-NKL num] [-asemftrvh] <file>\n" );
+    Abc_Print( -2, "\t         generates simple circuits\n" );
+    Abc_Print( -2, "\t-N num : the number of variables [default = %d]\n", nVars );
+    Abc_Print( -2, "\t-K num : the LUT size (to be used with switch -f) [default = %d]\n", nLutSize );
+    Abc_Print( -2, "\t-L num : the LUT count (to be used with switch -f) [default = %d]\n", nLuts );
+    Abc_Print( -2, "\t-a     : generate ripple-carry adder [default = %s]\n", fAdder? "yes": "no" );
+    Abc_Print( -2, "\t-s     : generate a sorter [default = %s]\n", fSorter? "yes": "no" );
+    Abc_Print( -2, "\t-e     : generate a mesh [default = %s]\n", fMesh? "yes": "no" );
+    Abc_Print( -2, "\t-m     : generate a multiplier [default = %s]\n", fMulti? "yes": "no" );
+    Abc_Print( -2, "\t-f     : generate a LUT FPGA structure [default = %s]\n", fFpga? "yes": "no" );
+    Abc_Print( -2, "\t-t     : generate one-hotness conditions [default = %s]\n", fOneHot? "yes": "no" );
+    Abc_Print( -2, "\t-r     : generate random single-output function [default = %s]\n", fRandom? "yes": "no" );
+    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\t<file> : output file name\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandGenFsm( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern void Abc_GenFsm( char * pFileName, int nIns, int nOuts, int nStates, int nLines, int ProbI, int ProbO );
+    int c, nIns, nOuts, nStates, nLines, ProbI, ProbO, fVerbose;
+    char * FileName;
+    // set defaults
+    nIns     =   30;
+    nOuts    =    1;
+    nStates  =   20;
+    nLines   =  100;
+    ProbI    =   10;
+    ProbO    =  100;
+    fVerbose =    0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "IOSLPQvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'I':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nIns = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nIns < 0 )
+                goto usage;
+            break;
+        case 'O':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-O\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nOuts = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nOuts < 0 )
+                goto usage;
+            break;
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nStates = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nStates < 0 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nLines = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLines < 0 )
+                goto usage;
+            break;
+        case 'P':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            ProbI = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( ProbI < 0 )
+                goto usage;
+            break;
+        case 'Q':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-Q\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            ProbO = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( ProbO < 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( argc != globalUtilOptind + 1 )
+    {
+        goto usage;
+    }
+    if ( nIns < 1 || nStates < 1 || nLines < 1 || ProbI < 1 || ProbO < 1 )
+    {
+        Abc_Print( -1, "The number of inputs. states, lines, and probablity should be positive integers.\n" );
+        goto usage;
+    }
+    // get the input file name
+    FileName = argv[globalUtilOptind];
+    Abc_GenFsm( FileName, nIns, nOuts, nStates, nLines, ProbI, ProbO );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: genfsm [-IOSLPQ num] [-vh] <file>\n" );
+    Abc_Print( -2, "\t         generates random FSM in KISS format\n" );
+    Abc_Print( -2, "\t-I num : the number of input variables [default = %d]\n", nIns );
+    Abc_Print( -2, "\t-O num : the number of output variables [default = %d]\n", nOuts );
+    Abc_Print( -2, "\t-S num : the number of state variables [default = %d]\n", nStates );
+    Abc_Print( -2, "\t-L num : the number of lines (product terms) [default = %d]\n", nLines );
+    Abc_Print( -2, "\t-P num : percentage propability of a variable present in the input cube [default = %d]\n", ProbI );
+    Abc_Print( -2, "\t-Q num : percentage propability of a variable present in the output cube [default = %d]\n", ProbO );
+    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\t<file> : output file name\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandCover( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c;
+    int fVerbose;
+    int fUseSop;
+    int fUseEsop;
+    int fUseInvs;
+    int nFaninMax;
+    pNtk = Abc_FrameReadNtk(pAbc);
+
+    // set defaults
+    fUseSop   =  1;
+    fUseEsop  =  0;
+    fVerbose  =  0;
+    fUseInvs  =  1;
+    nFaninMax =  8;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Nsxivh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFaninMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFaninMax < 0 )
+                goto usage;
+            break;
+        case 's':
+            fUseSop ^= 1;
+            break;
+        case 'x':
+            fUseEsop ^= 1;
+            break;
+        case 'i':
+            fUseInvs ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Only works for strashed networks.\n" );
+        return 1;
+    }
+
+    // run the command
+    pNtkRes = Abc_NtkSopEsopCover( pNtk, nFaninMax, fUseEsop, fUseSop, fUseInvs, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Command has failed.\n" );
+        return 0;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: cover [-N num] [-sxvh]\n" );
+    Abc_Print( -2, "\t         decomposition into a network of SOP/ESOP PLAs\n" );
+    Abc_Print( -2, "\t-N num : maximum number of inputs [default = %d]\n", nFaninMax );
+    Abc_Print( -2, "\t-s     : toggle the use of SOPs [default = %s]\n", fUseSop? "yes": "no" );
+    Abc_Print( -2, "\t-x     : toggle the use of ESOPs [default = %s]\n", fUseEsop? "yes": "no" );
+//    Abc_Print( -2, "\t-i     : toggle the use of interters [default = %s]\n", fUseInvs? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandInter( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtk1, * pNtk2, * pNtkRes = NULL;
+    char ** pArgvNew;
+    int nArgcNew;
+    int c, fDelete1, fDelete2;
+    int fRelation;
+    int fVerbose;
+    extern Abc_Ntk_t * Abc_NtkInter( Abc_Ntk_t * pNtkOn, Abc_Ntk_t * pNtkOff, int fRelation, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    fRelation = 0;
+    fVerbose  = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "rvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'r':
+            fRelation ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    pArgvNew = argv + globalUtilOptind;
+    nArgcNew = argc - globalUtilOptind;
+    if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
+        return 1;
+    if ( nArgcNew == 0 )
+    {
+        Abc_Obj_t * pObj;
+        int i;
+        Abc_Print( -1, "Deriving new circuit structure for the current network.\n" );
+        Abc_NtkForEachPo( pNtk2, pObj, i )
+            Abc_ObjXorFaninC( pObj, 0 );
+    }
+    if ( fRelation && Abc_NtkCoNum(pNtk1) != 1 )
+    {
+        Abc_Print( -1, "Computation of interplants as a relation only works for single-output functions.\n" );
+        Abc_Print( -1, "Use command \"cone\" to extract one output cone from the multi-output network.\n" );
+    }
+    else
+        pNtkRes = Abc_NtkInter( pNtk1, pNtk2, fRelation, fVerbose );
+    if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
+    if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
+
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Command has failed.\n" );
+        return 0;
+    }
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: inter [-rvh] <onset.blif> <offset.blif>\n" );
+    Abc_Print( -2, "\t         derives interpolant of two networks representing onset and offset;\n" );
+    Abc_Print( -2, "\t-r     : toggle computing interpolant as a relation [default = %s]\n", fRelation? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\t         \n" );
+    Abc_Print( -2, "\t         Comments:\n" );
+    Abc_Print( -2, "\t         \n" );
+    Abc_Print( -2, "\t         The networks given on the command line should have the same CIs/COs.\n" );
+    Abc_Print( -2, "\t         If only one network is given on the command line, this network\n" );
+    Abc_Print( -2, "\t         is assumed to be the offset, while the current network is the onset.\n" );
+    Abc_Print( -2, "\t         If no network is given on the command line, the current network is\n" );
+    Abc_Print( -2, "\t         assumed to be the onset and its complement is taken to be the offset.\n" );
+    Abc_Print( -2, "\t         The resulting interpolant is stored as the current network.\n" );
+    Abc_Print( -2, "\t         To verify that the interpolant agrees with the onset and the offset,\n" );
+    Abc_Print( -2, "\t         save it in file \"inter.blif\" and run the following:\n" );
+    Abc_Print( -2, "\t         (a) \"miter -i <onset.blif> <inter.blif>; iprove\"\n" );
+    Abc_Print( -2, "\t         (b) \"miter -i <inter.blif> <offset_inv.blif>; iprove\"\n" );
+    Abc_Print( -2, "\t         where <offset_inv.blif> is the network derived by complementing the\n" );
+    Abc_Print( -2, "\t         outputs of <offset.blif>: \"r <offset.blif>; st -i; w <offset_inv.blif>\"\n" );
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandDouble( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c;
+    int nFrames;
+    int fVerbose;
+    extern Abc_Ntk_t * Abc_NtkDouble( Abc_Ntk_t * pNtk );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    nFrames    = 50;
+    fVerbose   =  0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFrames = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFrames < 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsSopLogic(pNtk) )
+    {
+        Abc_Print( -1, "Only works for logic SOP networks.\n" );
+        return 1;
+    }
+
+    pNtkRes = Abc_NtkDouble( pNtk );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Command has failed.\n" );
+        return 0;
+    }
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: double [-vh]\n" );
+    Abc_Print( -2, "\t         puts together two parallel copies of the current network\n" );
+//    Abc_Print( -2, "\t-F num : the number of frames to simulate [default = %d]\n", nFrames );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandBb2Wb( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern void Abc_NtkConvertBb2Wb( char * pFileNameIn, char * pFileNameOut, int fSeq, int fVerbose );
+    int c;
+    int fSeq;
+    int fVerbose;
+    // set defaults
+    fSeq = 0;
+    fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "svh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 's':
+            fSeq ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+    if ( argc != globalUtilOptind + 2 )
+    {
+        Abc_Print( -1, "Expecting two files names on the command line.\n" );
+        goto usage;
+    }
+    Abc_NtkConvertBb2Wb( argv[globalUtilOptind], argv[globalUtilOptind+1], fSeq, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: bb2wb [-svh] <file_in> <file_out>\n" );
+    Abc_Print( -2, "\t             replaces black boxes by white boxes with AND functions\n" );
+    Abc_Print( -2, "\t             (file names should have standard extensions, e.g. \"blif\")\n" );
+    Abc_Print( -2, "\t-s         : toggle using sequential white boxes [default = %s]\n", fSeq? "yes": "no" );
+    Abc_Print( -2, "\t-v         : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h         : print the command usage\n");
+    Abc_Print( -2, "\t<file_in>  : input file with design containing black boxes\n");
+    Abc_Print( -2, "\t<file_out> : output file with design containing white boxes\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandOutdec( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Abc_Ntk_t * Abc_NtkDarOutdec( Abc_Ntk_t * pNtk, int nLits, int fVerbose );
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    Abc_Ntk_t * pNtkRes;
+    int c, nLits = 1;
+    int fVerbose = 0;
+
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Lvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nLits = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLits < 1 || nLits > 2 )
+            {
+                Abc_Print( 1,"Currently, command \"outdec\" works for 1-lit and 2-lit primes only.\n" );
+                goto usage;
+            }
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Only works for strashed networks.\n" );
+        return 1;
+    }
+    pNtkRes = Abc_NtkDarOutdec( pNtk, nLits, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Command has failed.\n" );
+        return 0;
+    }
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: outdec [-Lvh]\n" );
+    Abc_Print( -2, "\t         performs prime decomposition of the first output\n" );
+    Abc_Print( -2, "\t-L num : the number of literals in the primes [default = %d]\n", nLits );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandNodeDup( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Abc_Ntk_t * Abc_NtkNodeDup( Abc_Ntk_t * pNtk, int nLimit, int fVerbose );
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    Abc_Ntk_t * pNtkRes;
+    int c, nLimit = 30;
+    int fVerbose = 0;
+
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Nvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Only works for logic networks.\n" );
+        return 1;
+    }
+    if ( nLimit < 2 )
+    {
+        Abc_Print( -1, "The fanout limit should be more than 1.\n" );
+        return 1;
+    }
+    pNtkRes = Abc_NtkNodeDup( pNtk, nLimit, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Command has failed.\n" );
+        return 0;
+    }
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: nodedup [-Nvh]\n" );
+    Abc_Print( -2, "\t         duplicates internal nodes with high fanout\n" );
+    Abc_Print( -2, "\t-N num : the number of fanouts to start duplication [default = %d]\n", nLimit );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandTestColor( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern void Abc_ColorTest();
+    Abc_ColorTest();
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+//    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int nCutMax      =  1;
+    int nLeafMax     =  4;
+    int nDivMax      =  2;
+    int nDecMax      = 20;
+    int nNumOnes     =  4;
+    int fNewAlgo     =  0;
+    int fNewOrder    =  0;
+    int fVerbose     =  0;
+    int fVeryVerbose =  0;
+    int c;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "CKDNMaovwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nCutMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nCutMax < 0 )
+                goto usage;
+            break;
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nLeafMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLeafMax < 0 )
+                goto usage;
+            break;
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nDivMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nDivMax < 0 )
+                goto usage;
+            break;
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nDecMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nDecMax < 0 )
+                goto usage;
+            break;
+        case 'M':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nNumOnes = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nNumOnes < 0 )
+                goto usage;
+            break;
+        case 'a':
+            fNewAlgo ^= 1;
+            break;
+        case 'o':
+            fNewOrder ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'w':
+            fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+/*
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for logic networks.\n" );
+        return 1;
+    }
+*/
+/*
+    if ( Abc_NtkLatchNum(pNtk) == 0 )
+    {
+        Abc_Print( -1, "Only works for sequential networks.\n" );
+        return 1;
+    }
+*/
+
+/*
+    if ( pNtk )
+    {
+        extern Abc_Ntk_t * Au_ManPerformTest( Abc_Ntk_t * p, int nCutMax, int nLeafMax, int nDivMax, int nDecMax, int fVerbose, int fVeryVerbose );
+        Abc_Ntk_t * pNtkRes = Au_ManPerformTest( pNtk, nCutMax, nLeafMax, nDivMax, nDecMax, fVerbose, fVeryVerbose );
+        if ( pNtkRes == NULL )
+        {
+            Abc_Print( -1, "Command has failed.\n" );
+            return 1;
+        }
+        Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    }
+*/
+/*
+    if ( pNtk )
+    {
+        Aig_Man_t * pAig = Abc_NtkToDar( pNtk, 0, 1 );
+        Saig_ManBmcTerSimTestPo( pAig );
+        Aig_ManStop( pAig );
+    }
+*/
+/*
+    if ( !Abc_NtkIsTopo(pNtk) )
+    {
+        Abc_Print( -1, "Current network is not in a topological order.\n" );
+        return 1;
+    }
+*/
+//    if ( pNtk )
+//        Abc_NtkMakeLegit( pNtk ); 
+    {
+//        extern void Ifd_ManDsdTest();
+//        Ifd_ManDsdTest();
+    }
+/*
+    {
+        extern void Abc_EnumerateCubeStates();
+        extern void Abc_EnumerateCubeStatesZdd();
+        if ( fNewAlgo )
+            Abc_EnumerateCubeStatesZdd();
+        else
+            Abc_EnumerateCubeStates();
+        return 0;
+    }
+*/
+    {
+//        extern void Abc_EnumerateFuncs( int nDecMax, int nDivMax, int fVerbose );
+//        Abc_EnumerateFuncs( nDecMax, nDivMax, fVerbose );
+    }
+/*
+    if ( fNewAlgo )
+    {
+        extern void Abc_SuppTest( int nOnes, int nVars, int fUseSimple, int fCheck, int fVerbose );
+        Abc_SuppTest( nNumOnes, nDecMax, fNewOrder, 0, fVerbose );
+    }
+    else
+    {
+        extern void Bmc_EcoMiterTest();
+        Bmc_EcoMiterTest();
+    }
+*/
+
+    {
+//        extern void Nf_ManPrepareLibraryTest();
+//        Nf_ManPrepareLibraryTest();
+//        return 0;
+    }
+/*
+    if ( pNtk )
+    {
+//        extern Abc_Ntk_t * Abc_NtkBarBufsOnOffTest( Abc_Ntk_t * pNtk );
+//        Abc_Ntk_t * pNtkRes = Abc_NtkBarBufsOnOffTest( pNtk );
+        extern Abc_Ntk_t * Abc_NtkPcmTest( Abc_Ntk_t * pNtk, int fNewAlgo, int fVerbose );
+//        extern Abc_Ntk_t * Abc_NtkPcmTestAig( Abc_Ntk_t * pNtk, int fVerbose );
+        Abc_Ntk_t * pNtkRes;
+//        if ( Abc_NtkIsLogic(pNtk) )
+            pNtkRes = Abc_NtkPcmTest( pNtk, fNewAlgo, fVerbose );
+//        else
+//            pNtkRes = Abc_NtkPcmTestAig( pNtk, fVerbose );
+        if ( pNtkRes == NULL )
+        {
+            Abc_Print( -1, "Command has failed.\n" );
+            return 1;
+        }
+        Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    }
+*/
+/*
+    {
+        extern void Abc_IsopTestNew();
+        Abc_IsopTestNew();
+    }
+*/
+    {
+//        extern void Cba_PrsReadBlifTest();
+//        Cba_PrsReadBlifTest();
+    }
+    return 0;
+usage:
+    Abc_Print( -2, "usage: test [-CKDNM] [-aovwh] <file_name>\n" );
+    Abc_Print( -2, "\t         testbench for new procedures\n" );
+    Abc_Print( -2, "\t-C num : the max number of cuts [default = %d]\n", nCutMax );
+    Abc_Print( -2, "\t-K num : the max number of leaves [default = %d]\n", nLeafMax );
+    Abc_Print( -2, "\t-D num : the max number of divisors [default = %d]\n", nDivMax );
+    Abc_Print( -2, "\t-N num : the max number of node inputs [default = %d]\n", nDecMax );
+    Abc_Print( -2, "\t-M num : the max number of ones in the vector [default = %d]\n", nNumOnes );
+    Abc_Print( -2, "\t-a     : toggle using new algorithm [default = %s]\n", fNewAlgo? "yes": "no" );
+    Abc_Print( -2, "\t-o     : toggle using new ordering [default = %s]\n", fNewOrder? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w     : toggle printing very verbose information [default = %s]\n", fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandQuaVar( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c, iVar, fUniv, fVerbose, RetValue;
+    extern int Abc_NtkQuantify( Abc_Ntk_t * pNtk, int fUniv, int iVar, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    iVar = 0;
+    fUniv = 0;
+    fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Iuvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'I':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            iVar = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( iVar < 0 )
+                goto usage;
+            break;
+        case 'u':
+            fUniv ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( Abc_NtkGetChoiceNum( pNtk ) )
+    {
+        Abc_Print( -1, "This command cannot be applied to an AIG with choice nodes.\n" );
+        return 1;
+    }
+
+    // get the strashed network
+    pNtkRes = Abc_NtkStrash( pNtk, 0, 1, 0 );
+    RetValue = Abc_NtkQuantify( pNtkRes, fUniv, iVar, fVerbose );
+    // clean temporary storage for the cofactors
+    Abc_NtkCleanData( pNtkRes );
+    Abc_AigCleanup( (Abc_Aig_t *)pNtkRes->pManFunc );
+    // check the result
+    if ( !RetValue )
+    {
+        Abc_Print( -1, "Command has failed.\n" );
+        return 0;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: qvar [-I num] [-uvh]\n" );
+    Abc_Print( -2, "\t         quantifies one variable using the AIG\n" );
+    Abc_Print( -2, "\t-I num : the zero-based index of a variable to quantify [default = %d]\n", iVar );
+    Abc_Print( -2, "\t-u     : toggle universal quantification [default = %s]\n", fUniv? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandQuaRel( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c, iVar, fInputs, fVerbose;
+    extern Abc_Ntk_t * Abc_NtkTransRel( Abc_Ntk_t * pNtk, int fInputs, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    iVar = 0;
+    fInputs = 1;
+    fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Iqvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'I':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            iVar = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( iVar < 0 )
+                goto usage;
+            break;
+        case 'q':
+            fInputs ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( Abc_NtkGetChoiceNum( pNtk ) )
+    {
+        Abc_Print( -1, "This command cannot be applied to an AIG with choice nodes.\n" );
+        return 1;
+    }
+    if ( Abc_NtkIsComb(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for sequential circuits.\n" );
+        return 1;
+    }
+
+    // get the strashed network
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        pNtk = Abc_NtkStrash( pNtk, 0, 1, 0 );
+        pNtkRes = Abc_NtkTransRel( pNtk, fInputs, fVerbose );
+        Abc_NtkDelete( pNtk );
+    }
+    else
+        pNtkRes = Abc_NtkTransRel( pNtk, fInputs, fVerbose );
+    // check if the result is available
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Command has failed.\n" );
+        return 0;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: qrel [-qvh]\n" );
+    Abc_Print( -2, "\t         computes transition relation of the sequential network\n" );
+//    Abc_Print( -2, "\t-I num : the zero-based index of a variable to quantify [default = %d]\n", iVar );
+    Abc_Print( -2, "\t-q     : perform quantification of inputs [default = %s]\n", fInputs? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandQuaReach( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c, nIters, fVerbose;
+    extern Abc_Ntk_t * Abc_NtkReachability( Abc_Ntk_t * pNtk, int nIters, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    nIters   = 256;
+    fVerbose =   0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Ivh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'I':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nIters = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nIters < 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( Abc_NtkGetChoiceNum( pNtk ) )
+    {
+        Abc_Print( -1, "This command cannot be applied to an AIG with choice nodes.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsComb(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for combinational transition relations.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for strashed networks.\n" );
+        return 1;
+    }
+    if ( Abc_NtkPoNum(pNtk) > 1 )
+    {
+        Abc_Print( -1, "The transition relation should have one output.\n" );
+        return 1;
+    }
+    if ( Abc_NtkPiNum(pNtk) % 2 != 0 )
+    {
+        Abc_Print( -1, "The transition relation should have an even number of inputs.\n" );
+        return 1;
+    }
+
+    pNtkRes = Abc_NtkReachability( pNtk, nIters, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Command has failed.\n" );
+        return 0;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: qreach [-I num] [-vh]\n" );
+    Abc_Print( -2, "\t         computes unreachable states using AIG-based quantification\n" );
+    Abc_Print( -2, "\t         assumes that the current network is a transition relation\n" );
+    Abc_Print( -2, "\t         assumes that the initial state is composed of all zeros\n" );
+    Abc_Print( -2, "\t-I num : the number of image computations to perform [default = %d]\n", nIters );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandSenseInput( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    Vec_Int_t * vResult;
+    int c, nConfLim, fVerbose;
+
+    extern Vec_Int_t * Abc_NtkSensitivity( Abc_Ntk_t * pNtk, int nConfLim, int fVerbose );
+    // set defaults
+    nConfLim   = 1000;
+    fVerbose   =    1;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Cvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nConfLim = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nConfLim < 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( Abc_NtkGetChoiceNum( pNtk ) )
+    {
+        Abc_Print( -1, "This command cannot be applied to an AIG with choice nodes.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsComb(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for combinational transition relations.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for strashed networks.\n" );
+        return 1;
+    }
+    if ( Abc_NtkPoNum(pNtk) < 2 )
+    {
+        Abc_Print( -1, "The network should have at least two outputs.\n" );
+        return 1;
+    }
+
+    vResult = Abc_NtkSensitivity( pNtk, nConfLim, fVerbose );
+    Vec_IntFree( vResult );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: senseinput [-C num] [-vh]\n" );
+    Abc_Print( -2, "\t         computes sensitivity of POs to PIs under constraint\n" );
+    Abc_Print( -2, "\t         constraint should be represented as the last PO\n" );
+    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", nConfLim );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandIStrash( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes, * pNtkTemp;
+    int c;
+    extern Abc_Ntk_t * Abc_NtkIvyStrash( Abc_Ntk_t * pNtk );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        pNtkTemp = Abc_NtkStrash( pNtk, 0, 1, 0 );
+        pNtkRes = Abc_NtkIvyStrash( pNtkTemp );
+        Abc_NtkDelete( pNtkTemp );
+    }
+    else
+        pNtkRes = Abc_NtkIvyStrash( pNtk );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Command has failed.\n" );
+        return 0;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: istrash [-h]\n" );
+    Abc_Print( -2, "\t         perform sequential structural hashing\n" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandICut( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c, nInputs;
+    extern void Abc_NtkIvyCuts( Abc_Ntk_t * pNtk, int nInputs );
+
+    // set defaults
+    nInputs = 5;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Kh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nInputs = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nInputs < 0 )
+                goto usage;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for strashed networks.\n" );
+        return 1;
+    }
+
+    Abc_NtkIvyCuts( pNtk, nInputs );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: icut [-K num] [-h]\n" );
+    Abc_Print( -2, "\t         computes sequential cuts of the given size\n" );
+    Abc_Print( -2, "\t-K num : the number of cut inputs (2 <= num <= 6) [default = %d]\n", nInputs );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandIRewrite( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c, fUpdateLevel, fUseZeroCost, fVerbose;
+    extern Abc_Ntk_t * Abc_NtkIvyRewrite( Abc_Ntk_t * pNtk, int fUpdateLevel, int fUseZeroCost, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    fUpdateLevel = 1;
+    fUseZeroCost = 0;
+    fVerbose     = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "lzvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'l':
+            fUpdateLevel ^= 1;
+            break;
+        case 'z':
+            fUseZeroCost ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for strashed networks.\n" );
+        return 1;
+    }
+
+    pNtkRes = Abc_NtkIvyRewrite( pNtk, fUpdateLevel, fUseZeroCost, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Command has failed.\n" );
+        return 0;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: irw [-lzvh]\n" );
+    Abc_Print( -2, "\t         perform combinational AIG rewriting\n" );
+    Abc_Print( -2, "\t-l     : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
+    Abc_Print( -2, "\t-z     : toggle using zero-cost replacements [default = %s]\n", fUseZeroCost? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandDRewrite( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    Dar_RwrPar_t Pars, * pPars = &Pars;
+    int c;
+
+    extern Abc_Ntk_t * Abc_NtkDRewrite( Abc_Ntk_t * pNtk, Dar_RwrPar_t * pPars );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    Dar_ManDefaultRwrParams( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "CNflzrvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nCutsMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nCutsMax < 0 )
+                goto usage;
+            break;
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nSubgMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nSubgMax < 0 )
+                goto usage;
+            break;
+        case 'f':
+            pPars->fFanout ^= 1;
+            break;
+        case 'l':
+            pPars->fUpdateLevel ^= 1;
+            break;
+        case 'z':
+            pPars->fUseZeros ^= 1;
+            break;
+        case 'r':
+            pPars->fRecycle ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'w':
+            pPars->fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for strashed networks.\n" );
+        return 1;
+    }
+    pNtkRes = Abc_NtkDRewrite( pNtk, pPars );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Command has failed.\n" );
+        return 0;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: drw [-C num] [-N num] [-lfzrvwh]\n" );
+    Abc_Print( -2, "\t         performs combinational AIG rewriting\n" );
+    Abc_Print( -2, "\t-C num : the max number of cuts at a node [default = %d]\n", pPars->nCutsMax );
+    Abc_Print( -2, "\t-N num : the max number of subgraphs tried [default = %d]\n", pPars->nSubgMax );
+    Abc_Print( -2, "\t-l     : toggle preserving the number of levels [default = %s]\n", pPars->fUpdateLevel? "yes": "no" );
+    Abc_Print( -2, "\t-f     : toggle representing fanouts [default = %s]\n", pPars->fFanout? "yes": "no" );
+    Abc_Print( -2, "\t-z     : toggle using zero-cost replacements [default = %s]\n", pPars->fUseZeros? "yes": "no" );
+    Abc_Print( -2, "\t-r     : toggle using cut recycling [default = %s]\n", pPars->fRecycle? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w     : toggle very verbose printout [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandDRefactor( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    Dar_RefPar_t Pars, * pPars = &Pars;
+    int c;
+
+    extern Abc_Ntk_t * Abc_NtkDRefactor( Abc_Ntk_t * pNtk, Dar_RefPar_t * pPars );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    Dar_ManDefaultRefParams( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "MKCelzvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'M':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nMffcMin = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nMffcMin < 0 )
+                goto usage;
+            break;
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nLeafMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nLeafMax < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nCutsMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nCutsMax < 0 )
+                goto usage;
+            break;
+        case 'e':
+            pPars->fExtend ^= 1;
+            break;
+        case 'l':
+            pPars->fUpdateLevel ^= 1;
+            break;
+        case 'z':
+            pPars->fUseZeros ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'w':
+            pPars->fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for strashed networks.\n" );
+        return 1;
+    }
+    if ( pPars->nLeafMax < 4 || pPars->nLeafMax > 15 )
+    {
+        Abc_Print( -1, "This command only works for cut sizes 4 <= K <= 15.\n" );
+        return 1;
+    }
+    pNtkRes = Abc_NtkDRefactor( pNtk, pPars );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Command has failed.\n" );
+        return 0;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: drf [-M num] [-K num] [-C num] [-elzvwh]\n" );
+    Abc_Print( -2, "\t         performs combinational AIG refactoring\n" );
+    Abc_Print( -2, "\t-M num : the min MFFC size to attempt refactoring [default = %d]\n", pPars->nMffcMin );
+    Abc_Print( -2, "\t-K num : the max number of cuts leaves [default = %d]\n", pPars->nLeafMax );
+    Abc_Print( -2, "\t-C num : the max number of cuts to try at a node [default = %d]\n", pPars->nCutsMax );
+    Abc_Print( -2, "\t-e     : toggle extending tbe cut below MFFC [default = %s]\n", pPars->fExtend? "yes": "no" );
+    Abc_Print( -2, "\t-l     : toggle preserving the number of levels [default = %s]\n", pPars->fUpdateLevel? "yes": "no" );
+    Abc_Print( -2, "\t-z     : toggle using zero-cost replacements [default = %s]\n", pPars->fUseZeros? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w     : toggle very verbose printout [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandDc2( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int fBalance, fVerbose, fUpdateLevel, fFanout, fPower, c;
+
+    extern Abc_Ntk_t * Abc_NtkDC2( Abc_Ntk_t * pNtk, int fBalance, int fUpdateLevel, int fFanout, int fPower, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    fBalance     = 0;
+    fVerbose     = 0;
+    fUpdateLevel = 0;
+    fFanout      = 1;
+    fPower       = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "blfpvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'b':
+            fBalance ^= 1;
+            break;
+        case 'l':
+            fUpdateLevel ^= 1;
+            break;
+        case 'f':
+            fFanout ^= 1;
+            break;
+        case 'p':
+            fPower ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for strashed networks.\n" );
+        return 1;
+    }
+    pNtkRes = Abc_NtkDC2( pNtk, fBalance, fUpdateLevel, fFanout, fPower, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Command has failed.\n" );
+        return 0;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: dc2 [-blfpvh]\n" );
+    Abc_Print( -2, "\t         performs combinational AIG optimization\n" );
+    Abc_Print( -2, "\t-b     : toggle internal balancing [default = %s]\n", fBalance? "yes": "no" );
+    Abc_Print( -2, "\t-l     : toggle updating level [default = %s]\n", fUpdateLevel? "yes": "no" );
+    Abc_Print( -2, "\t-f     : toggle representing fanouts [default = %s]\n", fFanout? "yes": "no" );
+    Abc_Print( -2, "\t-p     : toggle power-aware rewriting [default = %s]\n", fPower? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandDChoice( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int fBalance, fVerbose, fUpdateLevel, fConstruct, c;
+    int nConfMax, nLevelMax;
+
+    extern Abc_Ntk_t * Abc_NtkDChoice( Abc_Ntk_t * pNtk, int fBalance, int fUpdateLevel, int fConstruct, int nConfMax, int nLevelMax, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    fBalance     = 1;
+    fUpdateLevel = 1;
+    fConstruct   = 0;
+    nConfMax     = 1000;
+    nLevelMax    = 0;
+    fVerbose     = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "CLblcvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nConfMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nConfMax < 0 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nLevelMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLevelMax < 0 )
+                goto usage;
+            break;
+        case 'b':
+            fBalance ^= 1;
+            break;
+        case 'l':
+            fUpdateLevel ^= 1;
+            break;
+        case 'c':
+            fConstruct ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for strashed networks.\n" );
+        return 1;
+    }
+    pNtkRes = Abc_NtkDChoice( pNtk, fBalance, fUpdateLevel, fConstruct, nConfMax, nLevelMax, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Command has failed.\n" );
+        return 0;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: dchoice [-C num] [-L num] [-blcvh]\n" );
+    Abc_Print( -2, "\t         performs partitioned choicing using new AIG package\n" );
+    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", nConfMax );
+    Abc_Print( -2, "\t-L num : the max level of nodes to consider (0 = not used) [default = %d]\n", nLevelMax );
+    Abc_Print( -2, "\t-b     : toggle internal balancing [default = %s]\n", fBalance? "yes": "no" );
+    Abc_Print( -2, "\t-l     : toggle updating level [default = %s]\n", fUpdateLevel? "yes": "no" );
+    Abc_Print( -2, "\t-c     : toggle constructive computation of choices [default = %s]\n", fConstruct? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandDch( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Dch_Pars_t Pars, * pPars = &Pars;
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c;
+    extern Abc_Ntk_t * Abc_NtkDch( Abc_Ntk_t * pNtk, Dch_Pars_t * pPars );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    Dch_ManSetDefaultParams( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "WCSsptgcfrvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nWords = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nWords < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nBTLimit < 0 )
+                goto usage;
+            break;
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nSatVarMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nSatVarMax < 0 )
+                goto usage;
+            break;
+        case 's':
+            pPars->fSynthesis ^= 1;
+            break;
+        case 'p':
+            pPars->fPower ^= 1;
+            break;
+        case 't':
+            pPars->fSimulateTfo ^= 1;
+            break;
+        case 'g':
+            pPars->fUseGia ^= 1;
+            break;
+        case 'c':
+            pPars->fUseCSat ^= 1;
+            break;
+        case 'f':
+            pPars->fLightSynth ^= 1;
+            break;
+        case 'r':
+            pPars->fSkipRedSupp ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for strashed networks.\n" );
+        return 1;
+    }
+    pNtkRes = Abc_NtkDch( pNtk, pPars );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Command has failed.\n" );
+        return 0;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: dch [-WCS num] [-sptgcfrvh]\n" );
+    Abc_Print( -2, "\t         computes structural choices using a new approach\n" );
+    Abc_Print( -2, "\t-W num : the max number of simulation words [default = %d]\n", pPars->nWords );
+    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
+    Abc_Print( -2, "\t-S num : the max number of SAT variables [default = %d]\n", pPars->nSatVarMax );
+    Abc_Print( -2, "\t-s     : toggle synthesizing three snapshots [default = %s]\n", pPars->fSynthesis? "yes": "no" );
+    Abc_Print( -2, "\t-p     : toggle power-aware rewriting [default = %s]\n", pPars->fPower? "yes": "no" );
+    Abc_Print( -2, "\t-t     : toggle simulation of the TFO classes [default = %s]\n", pPars->fSimulateTfo? "yes": "no" );
+    Abc_Print( -2, "\t-g     : toggle using GIA to prove equivalences [default = %s]\n", pPars->fUseGia? "yes": "no" );
+    Abc_Print( -2, "\t-c     : toggle using circuit-based SAT vs. MiniSat [default = %s]\n", pPars->fUseCSat? "yes": "no" );
+    Abc_Print( -2, "\t-f     : toggle using faster logic synthesis [default = %s]\n", pPars->fLightSynth? "yes": "no" );
+    Abc_Print( -2, "\t-r     : toggle skipping choices with redundant support [default = %s]\n", pPars->fSkipRedSupp? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandDrwsat( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int fBalance, fVerbose, c;
+
+    extern Abc_Ntk_t * Abc_NtkDrwsat( Abc_Ntk_t * pNtk, int fBalance, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    fBalance = 0;
+    fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "bvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'b':
+            fBalance ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for strashed networks.\n" );
+        return 1;
+    }
+    pNtkRes = Abc_NtkDrwsat( pNtk, fBalance, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Command has failed.\n" );
+        return 0;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: drwsat [-bvh]\n" );
+    Abc_Print( -2, "\t         performs combinational AIG optimization for SAT\n" );
+    Abc_Print( -2, "\t-b     : toggle internal balancing [default = %s]\n", fBalance? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandIRewriteSeq( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c, fUpdateLevel, fUseZeroCost, fVerbose;
+    extern Abc_Ntk_t * Abc_NtkIvyRewriteSeq( Abc_Ntk_t * pNtk, int fUseZeroCost, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    fUpdateLevel = 0;
+    fUseZeroCost = 0;
+    fVerbose     = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "lzvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'l':
+            fUpdateLevel ^= 1;
+            break;
+        case 'z':
+            fUseZeroCost ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for strashed networks.\n" );
+        return 1;
+    }
+
+    pNtkRes = Abc_NtkIvyRewriteSeq( pNtk, fUseZeroCost, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Command has failed.\n" );
+        return 0;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: irws [-zvh]\n" );
+    Abc_Print( -2, "\t         perform sequential AIG rewriting\n" );
+//    Abc_Print( -2, "\t-l     : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
+    Abc_Print( -2, "\t-z     : toggle using zero-cost replacements [default = %s]\n", fUseZeroCost? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandIResyn( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c, fUpdateLevel, fVerbose;
+    extern Abc_Ntk_t * Abc_NtkIvyResyn( Abc_Ntk_t * pNtk, int fUpdateLevel, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    fUpdateLevel = 1;
+    fVerbose     = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "lzvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'l':
+            fUpdateLevel ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for strashed networks.\n" );
+        return 1;
+    }
+
+    pNtkRes = Abc_NtkIvyResyn( pNtk, fUpdateLevel, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Command has failed.\n" );
+        return 0;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: iresyn [-lvh]\n" );
+    Abc_Print( -2, "\t         performs combinational resynthesis\n" );
+    Abc_Print( -2, "\t-l     : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandISat( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c, fUpdateLevel, fVerbose;
+    int nConfLimit;
+
+    extern Abc_Ntk_t * Abc_NtkIvySat( Abc_Ntk_t * pNtk, int nConfLimit, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    nConfLimit   = 100000;
+    fUpdateLevel = 1;
+    fVerbose     = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Clzvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nConfLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nConfLimit < 0 )
+                goto usage;
+            break;
+        case 'l':
+            fUpdateLevel ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for strashed networks.\n" );
+        return 1;
+    }
+
+    pNtkRes = Abc_NtkIvySat( pNtk, nConfLimit, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Command has failed.\n" );
+        return 0;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: isat [-C num] [-vh]\n" );
+    Abc_Print( -2, "\t         tries to prove the miter constant 0\n" );
+    Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n",    nConfLimit );
+//    Abc_Print( -2, "\t-l     : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandIFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c, fProve, fVerbose, fDoSparse;
+    int nConfLimit;
+    int nPartSize;
+    int nLevelMax;
+
+    extern Abc_Ntk_t * Abc_NtkIvyFraig( Abc_Ntk_t * pNtk, int nConfLimit, int fDoSparse, int fProve, int fTransfer, int fVerbose );
+    extern Abc_Ntk_t * Abc_NtkDarFraigPart( Abc_Ntk_t * pNtk, int nPartSize, int nConfLimit, int nLevelMax, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    nPartSize    = 0;
+    nLevelMax    = 0;
+    nConfLimit   = 100;
+    fDoSparse    = 0;
+    fProve       = 0;
+    fVerbose     = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "PCLspvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'P':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nPartSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nPartSize < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nConfLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nConfLimit < 0 )
+                goto usage;
+            break;
+         case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nLevelMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLevelMax < 0 )
+                goto usage;
+            break;
+        case 's':
+            fDoSparse ^= 1;
+            break;
+        case 'p':
+            fProve ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for strashed networks.\n" );
+        return 1;
+    }
+
+    if ( nPartSize > 0 )
+        pNtkRes = Abc_NtkDarFraigPart( pNtk, nPartSize, nConfLimit, nLevelMax, fVerbose );
+    else
+        pNtkRes = Abc_NtkIvyFraig( pNtk, nConfLimit, fDoSparse, fProve, 0, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Command has failed.\n" );
+        return 0;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: ifraig [-P num] [-C num] [-L num] [-spvh]\n" );
+    Abc_Print( -2, "\t         performs fraiging using a new method\n" );
+    Abc_Print( -2, "\t-P num : partition size (0 = partitioning is not used) [default = %d]\n", nPartSize );
+    Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
+    Abc_Print( -2, "\t-L num : limit on node level to fraig (0 = fraig all nodes) [default = %d]\n", nLevelMax );
+    Abc_Print( -2, "\t-s     : toggle considering sparse functions [default = %s]\n", fDoSparse? "yes": "no" );
+    Abc_Print( -2, "\t-p     : toggle proving the miter outputs [default = %s]\n", fProve? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandDFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c, nConfLimit, fDoSparse, fProve, fSpeculate, fChoicing, fVerbose;
+
+    extern Abc_Ntk_t * Abc_NtkDarFraig( Abc_Ntk_t * pNtk, int nConfLimit, int fDoSparse, int fProve, int fTransfer, int fSpeculate, int fChoicing, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    nConfLimit   = 100;
+    fDoSparse    = 1;
+    fProve       = 0;
+    fSpeculate   = 0;
+    fChoicing    = 0;
+    fVerbose     = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Csprcvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nConfLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nConfLimit < 0 )
+                goto usage;
+            break;
+        case 's':
+            fDoSparse ^= 1;
+            break;
+        case 'p':
+            fProve ^= 1;
+            break;
+        case 'r':
+            fSpeculate ^= 1;
+            break;
+        case 'c':
+            fChoicing ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for strashed networks.\n" );
+        return 1;
+    }
+
+    pNtkRes = Abc_NtkDarFraig( pNtk, nConfLimit, fDoSparse, fProve, 0, fSpeculate, fChoicing, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Command has failed.\n" );
+        return 0;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: dfraig [-C num] [-sprcvh]\n" );
+    Abc_Print( -2, "\t         performs fraiging using a new method\n" );
+    Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
+    Abc_Print( -2, "\t-s     : toggle considering sparse functions [default = %s]\n", fDoSparse? "yes": "no" );
+    Abc_Print( -2, "\t-p     : toggle proving the miter outputs [default = %s]\n", fProve? "yes": "no" );
+    Abc_Print( -2, "\t-r     : toggle speculative reduction [default = %s]\n", fSpeculate? "yes": "no" );
+    Abc_Print( -2, "\t-c     : toggle accumulation of choices [default = %s]\n", fChoicing? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandCSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c, nCutsMax, nLeafMax, fVerbose;
+
+    extern Abc_Ntk_t * Abc_NtkCSweep( Abc_Ntk_t * pNtk, int nCutsMax, int nLeafMax, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    nCutsMax  =  8;
+    nLeafMax  =  6;
+    fVerbose  =  0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "CKvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nCutsMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nCutsMax < 0 )
+                goto usage;
+            break;
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nLeafMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLeafMax < 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( nCutsMax < 2 )
+    {
+        Abc_Print( -1, "The number of cuts cannot be less than 2.\n" );
+        return 1;
+    }
+
+    if ( nLeafMax < 3 || nLeafMax > 16 )
+    {
+        Abc_Print( -1, "The number of leaves is infeasible.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for strashed networks.\n" );
+        return 1;
+    }
+
+    pNtkRes = Abc_NtkCSweep( pNtk, nCutsMax, nLeafMax, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Command has failed.\n" );
+        return 0;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: csweep [-C num] [-K num] [-vh]\n" );
+    Abc_Print( -2, "\t         performs cut sweeping using a new method\n" );
+    Abc_Print( -2, "\t-C num : limit on the number of cuts (C >= 2) [default = %d]\n", nCutsMax );
+    Abc_Print( -2, "\t-K num : limit on the cut size (3 <= K <= 16) [default = %d]\n", nLeafMax );
+    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandIProve( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Prove_Params_t Params, * pParams = &Params;
+    Abc_Ntk_t * pNtk, * pNtkTemp;
+    int c, RetValue, iOut = -1;
+    abctime clk;
+
+    extern int Abc_NtkIvyProve( Abc_Ntk_t ** ppNtk, void * pPars );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    Prove_ParamsSetDefault( pParams );
+    pParams->fUseRewriting = 1;
+    pParams->fVerbose      = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "NCFGLIrfbvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pParams->nItersMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pParams->nItersMax < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pParams->nMiteringLimitStart = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pParams->nMiteringLimitStart < 0 )
+                goto usage;
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pParams->nFraigingLimitStart = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pParams->nFraigingLimitStart < 0 )
+                goto usage;
+            break;
+        case 'G':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-G\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pParams->nFraigingLimitMulti = (float)atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pParams->nFraigingLimitMulti < 0 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pParams->nMiteringLimitLast = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pParams->nMiteringLimitLast < 0 )
+                goto usage;
+            break;
+        case 'I':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pParams->nTotalInspectLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pParams->nTotalInspectLimit < 0 )
+                goto usage;
+            break;
+        case 'r':
+            pParams->fUseRewriting ^= 1;
+            break;
+        case 'f':
+            pParams->fUseFraiging ^= 1;
+            break;
+        case 'b':
+            pParams->fUseBdds ^= 1;
+            break;
+        case 'v':
+            pParams->fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( Abc_NtkLatchNum(pNtk) > 0 )
+    {
+        Abc_Print( -1, "The network has registers. Use \"dprove\".\n" );
+        return 1;
+    }
+
+    clk = Abc_Clock();
+
+    if ( Abc_NtkIsStrash(pNtk) )
+        pNtkTemp = Abc_NtkDup( pNtk );
+    else
+        pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
+
+    RetValue = Abc_NtkIvyProve( &pNtkTemp, pParams );
+
+    // verify that the pattern is correct
+    if ( RetValue == 0 )
+    {
+        Abc_Obj_t * pObj;
+        int i;
+        int * pSimInfo = Abc_NtkVerifySimulatePattern( pNtk, pNtkTemp->pModel );
+        Abc_NtkForEachCo( pNtk, pObj, i )
+            if ( pSimInfo[i] == 1 )
+            {
+                iOut = i;
+                break;
+            }
+        if ( i == Abc_NtkCoNum(pNtk) )
+            Abc_Print( 1, "ERROR in Abc_NtkMiterProve(): Generated counter-example is invalid.\n" );
+        ABC_FREE( pSimInfo );
+    }
+    pAbc->Status = RetValue;
+    if ( RetValue == -1 )
+        Abc_Print( 1, "UNDECIDED      " );
+    else if ( RetValue == 0 )
+        Abc_Print( 1, "SATISFIABLE (output = %d) ", iOut );
+    else
+        Abc_Print( 1, "UNSATISFIABLE  " );
+    //Abc_Print( -1, "\n" );
+
+    Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkTemp );
+    // update counter example
+    if ( RetValue == 0 && Abc_NtkLatchNum(pNtkTemp) == 0 )
+    {
+        Abc_Cex_t * pCex = Abc_CexDeriveFromCombModel( pNtkTemp->pModel, Abc_NtkPiNum(pNtkTemp), 0, iOut );
+        Abc_FrameReplaceCex( pAbc, &pCex );
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: iprove [-NCFGLI num] [-rfbvh]\n" );
+    Abc_Print( -2, "\t         performs CEC using a new method\n" );
+    Abc_Print( -2, "\t-N num : max number of iterations [default = %d]\n", pParams->nItersMax );
+    Abc_Print( -2, "\t-C num : max starting number of conflicts in mitering [default = %d]\n", pParams->nMiteringLimitStart );
+    Abc_Print( -2, "\t-F num : max starting number of conflicts in fraiging [default = %d]\n", pParams->nFraigingLimitStart );
+    Abc_Print( -2, "\t-G num : multiplicative coefficient for fraiging [default = %d]\n", (int)pParams->nFraigingLimitMulti );
+    Abc_Print( -2, "\t-L num : max last-gasp number of conflicts in mitering [default = %d]\n", pParams->nMiteringLimitLast );
+    Abc_Print( -2, "\t-I num : max number of clause inspections in all SAT calls [default = %d]\n", (int)pParams->nTotalInspectLimit );
+    Abc_Print( -2, "\t-r     : toggle the use of rewriting [default = %s]\n", pParams->fUseRewriting? "yes": "no" );
+    Abc_Print( -2, "\t-f     : toggle the use of FRAIGing [default = %s]\n", pParams->fUseFraiging? "yes": "no" );
+    Abc_Print( -2, "\t-b     : toggle the use of BDDs [default = %s]\n", pParams->fUseBdds? "yes": "no" );
+    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", pParams->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+/*
+int Abc_CommandHaig( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    FILE * stdout, * pErr;
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c;
+    int nIters;
+    int nSteps;
+    int fRetimingOnly;
+    int fAddBugs;
+    int fUseCnf;
+    int fVerbose;
+
+    extern Abc_Ntk_t * Abc_NtkDarHaigRecord( Abc_Ntk_t * pNtk, int nIters, int nSteps, int fRetimingOnly, int fAddBugs, int fUseCnf, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+
+
+
+    // set defaults
+    nIters        = 3;
+    nSteps        = 3000;
+    fRetimingOnly = 0;
+    fAddBugs      = 0;
+    fUseCnf       = 0;
+    fVerbose      = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "ISrbcvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'I':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-I\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            nIters = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nIters < 0 )
+                goto usage;
+            break;
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            nSteps = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nSteps < 0 )
+                goto usage;
+            break;
+        case 'r':
+            fRetimingOnly ^= 1;
+            break;
+        case 'b':
+            fAddBugs ^= 1;
+            break;
+        case 'c':
+            fUseCnf ^= 1;
+            break;
+        case 'v':
+            fUseCnf ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for strashed networks.\n" );
+        return 1;
+    }
+
+    pNtkRes = Abc_NtkDarHaigRecord( pNtk, nIters, nSteps, fRetimingOnly, fAddBugs, fUseCnf, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Command has failed.\n" );
+        return 0;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: haig [-IS num] [-rbcvh]\n" );
+    Abc_Print( -2, "\t         run a few rounds of comb+seq synthesis to test HAIG recording\n" );
+    Abc_Print( -2, "\t         the current network is set to be the result of synthesis performed\n" );
+    Abc_Print( -2, "\t         (this network can be verified using command \"dsec\")\n" );
+    Abc_Print( -2, "\t         HAIG is written out into the file \"haig.blif\"\n" );
+    Abc_Print( -2, "\t         (this HAIG can be proved using \"r haig.blif; st; dprove -abc -F 16\")\n" );
+    Abc_Print( -2, "\t-I num : the number of rounds of comb+seq synthesis [default = %d]\n", nIters );
+    Abc_Print( -2, "\t-S num : the number of forward retiming moves performed [default = %d]\n", nSteps );
+    Abc_Print( -2, "\t-r     : toggle the use of retiming only [default = %s]\n", fRetimingOnly? "yes": "no" );
+    Abc_Print( -2, "\t-b     : toggle bug insertion [default = %s]\n", fAddBugs? "yes": "no" );
+    Abc_Print( -2, "\t-c     : enable CNF-based proof (no speculative reduction) [default = %s]\n", fUseCnf? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+*/
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandQbf( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int nPars;
+    int nIters;
+    int fDumpCnf;
+    int fVerbose;
+
+    extern void Abc_NtkQbf( Abc_Ntk_t * pNtk, int nPars, int nIters, int fDumpCnf, int fVerbose );
+    // set defaults
+    nPars    =  -1;
+    nIters   = 500;
+    fDumpCnf =   0;
+    fVerbose =   0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "PIdvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'P':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nPars = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nPars < 0 )
+                goto usage;
+            break;
+        case 'I':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nIters = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nIters < 0 )
+                goto usage;
+            break;
+        case 'd':
+            fDumpCnf ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsComb(pNtk) )
+    {
+        Abc_Print( -1, "Works only for combinational networks.\n" );
+        return 1;
+    }
+    if ( Abc_NtkPoNum(pNtk) != 1 )
+    {
+        Abc_Print( -1, "The miter should have one primary output.\n" );
+        return 1;
+    }
+    if ( !(nPars > 0 && nPars < Abc_NtkPiNum(pNtk)) )
+    {
+        Abc_Print( -1, "The number of parameter variables is invalid (should be > 0 and < PI num).\n" );
+        return 1;
+    }
+    if ( Abc_NtkIsStrash(pNtk) )
+        Abc_NtkQbf( pNtk, nPars, nIters, fDumpCnf, fVerbose );
+    else
+    {
+        pNtk = Abc_NtkStrash( pNtk, 0, 1, 0 );
+        Abc_NtkQbf( pNtk, nPars, nIters, fDumpCnf, fVerbose );
+        Abc_NtkDelete( pNtk );
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: qbf [-PI num] [-dvh]\n" );
+    Abc_Print( -2, "\t         solves QBF problem EpVxM(p,x)\n" );
+    Abc_Print( -2, "\t-P num : number of parameters p (should be the first PIs) [default = %d]\n", nPars );
+    Abc_Print( -2, "\t-I num : quit after the given iteration even if unsolved [default = %d]\n", nIters );
+    Abc_Print( -2, "\t-d     : toggle dumping QDIMACS file instead of solving [default = %s]\n", fDumpCnf? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandNpnLoad( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern void Npn_ManLoad( char * pFileName );
+    char * pFileName;
+    int c;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( argc != globalUtilOptind + 1 )
+        goto usage;
+    pFileName = argv[globalUtilOptind];
+    Npn_ManLoad( pFileName );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: npnload <filename>\n" );
+    Abc_Print( -2, "\t         loads previously saved 6-input function library from file\n" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandNpnSave( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern void Npn_ManSave( char * pFileName );
+    char * pFileName;
+    int c;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( argc != globalUtilOptind + 1 )
+        goto usage;
+    pFileName = argv[globalUtilOptind];
+    Npn_ManSave( pFileName );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: npnsave <filename>\n" );
+    Abc_Print( -2, "\t         saves current 6-input function library into file\n" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandSendAig( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+//    const int BRIDGE_NETLIST = 106;
+//    const int BRIDGE_ABS_NETLIST = 107;
+
+    int c, fAndSpace = 1, fAbsNetlist = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "ah" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'a':
+            fAndSpace ^= 1;
+            break;
+        case 'b':
+            fAbsNetlist ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( !Abc_FrameIsBridgeMode() )
+    {
+        Abc_Print( -1, "The bridge mode is not available.\n" );
+        return 1;
+    }
+    if ( fAndSpace )
+    {
+        if ( pAbc->pGia == NULL )
+        {
+            Abc_Print( -1, "There is no AIG in the &-space.\n" );
+            return 1;
+        }
+        Gia_ManToBridgeAbsNetlist( stdout, pAbc->pGia, fAbsNetlist ? BRIDGE_ABS_NETLIST : BRIDGE_NETLIST );
+    }
+    else
+    {
+        Aig_Man_t * pAig;
+        Gia_Man_t * pGia;
+        if ( pAbc->pNtkCur == NULL )
+        {
+            Abc_Print( -1, "There is no network in the main-space.\n" );
+            return 1;
+        }
+        if ( !Abc_NtkIsStrash(pAbc->pNtkCur) )
+        {
+            Abc_Print( -1, "The main-space network is not an AIG.\n" );
+            return 1;
+        }
+        pAig = Abc_NtkToDar( pAbc->pNtkCur, 0, 1 );
+        pGia = Gia_ManFromAig( pAig );
+        Aig_ManStop( pAig );
+        Gia_ManToBridgeAbsNetlist( stdout, pGia, fAbsNetlist ? BRIDGE_ABS_NETLIST : BRIDGE_NETLIST  );
+        Gia_ManStop( pGia );
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: send_aig -a\n" );
+    Abc_Print( -2, "\t         sends current AIG to the bridge\n" );
+    Abc_Print( -2, "\t-a     : toggle sending AIG from &-space [default = %s]\n", fAndSpace? "yes": "no" );
+    Abc_Print( -2, "\t-b     : toggle sending netlist tagged as \"abstraction\". [default = %s]\n", fAbsNetlist? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandSendStatus( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern int Gia_ManToBridgeResult( FILE * pFile, int Result, Abc_Cex_t * pCex, int iPoProved );
+    int c;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( !Abc_FrameIsBridgeMode() )
+    {
+        Abc_Print( -1, "The bridge mode is not available.\n" );
+        return 1;
+    }
+    if ( pAbc->Status == 0 && pAbc->pCex == NULL )
+    {
+        Abc_Print( -1, "Status is \"sat\", but current CEX is not available.\n" );
+        return 1;
+    }
+    Gia_ManToBridgeResult( stdout, pAbc->Status, pAbc->pCex, 0 );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: send_status\n" );
+    Abc_Print( -2, "\t         sends current status to the bridge\n" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandBackup( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( pAbc->pNtkBackup )
+        Abc_NtkDelete( pAbc->pNtkBackup );
+    pAbc->pNtkBackup = Abc_NtkDup( pNtk );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: backup [-h]\n" );
+    Abc_Print( -2, "\t        backs up the current network\n" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+int Abc_CommandRestore( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    int c;
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pAbc->pNtkBackup == NULL )
+    {
+        Abc_Print( -1, "There is no backup network.\n" );
+        return 1;
+    }
+    Abc_FrameReplaceCurrentNetwork( pAbc, Abc_NtkDup(pAbc->pNtkBackup) );
+    pAbc->nFrames = -1;
+    pAbc->Status = -1;
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: restore [-h]\n" );
+    Abc_Print( -2, "\t        restores the current network\n" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandMinisat( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+#ifdef USE_MINISAT22
+    extern int MainSat(int argc, char** argv);
+    MainSat( argc, argv );
+#else
+    printf( "This command is currently disabled.\n" );
+#endif
+    return 1;
+}
+int Abc_CommandMinisimp( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+#ifdef USE_MINISAT22
+    extern int MainSimp(int argc, char** argv);
+    MainSimp( argc, argv );
+#else
+    printf( "This command is currently disabled.\n" );
+#endif
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    char Buffer[100];
+    Fraig_Params_t Params, * pParams = &Params;
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int fAllNodes;
+    int fExdc;
+    int c;
+    int fPartition = 0;
+    extern void Abc_NtkFraigPartitionedTime( Abc_Ntk_t * pNtk, void * pParams );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    fExdc     = 0;
+    fAllNodes = 0;
+    memset( pParams, 0, sizeof(Fraig_Params_t) );
+    pParams->nPatsRand  = 2048; // the number of words of random simulation info
+    pParams->nPatsDyna  = 2048; // the number of words of dynamic simulation info
+    pParams->nBTLimit   =  100; // the max number of backtracks to perform
+    pParams->fFuncRed   =    1; // performs only one level hashing
+    pParams->fFeedBack  =    1; // enables solver feedback
+    pParams->fDist1Pats =    1; // enables distance-1 patterns
+    pParams->fDoSparse  =    1; // performs equiv tests for sparse functions
+    pParams->fChoicing  =    0; // enables recording structural choices
+    pParams->fTryProve  =    0; // tries to solve the final miter
+    pParams->fVerbose   =    0; // the verbosiness flag
+    pParams->fVerboseP  =    0; // the verbosiness flag
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "RDCrscptvaeh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'R':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pParams->nPatsRand = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pParams->nPatsRand < 0 )
+                goto usage;
+            break;
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pParams->nPatsDyna = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pParams->nPatsDyna < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pParams->nBTLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pParams->nBTLimit < 0 )
+                goto usage;
+            break;
+
+        case 'r':
+            pParams->fFuncRed ^= 1;
+            break;
+        case 's':
+            pParams->fDoSparse ^= 1;
+            break;
+        case 'c':
+            pParams->fChoicing ^= 1;
+            break;
+        case 'p':
+            pParams->fTryProve ^= 1;
+            break;
+        case 'v':
+            pParams->fVerbose ^= 1;
+            break;
+        case 't':
+            fPartition ^= 1;
+            break;
+        case 'a':
+            fAllNodes ^= 1;
+            break;
+        case 'e':
+            fExdc ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsLogic(pNtk) && !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Can only fraig a logic network or an AIG.\n" );
+        return 1;
+    }
+
+    // report the proof
+    pParams->fVerboseP = pParams->fTryProve;
+
+    // get the new network
+    if ( fPartition )
+    {
+        pNtkRes = Abc_NtkDup( pNtk );
+        if ( Abc_NtkIsStrash(pNtk) )
+            Abc_NtkFraigPartitionedTime( pNtk, &Params );
+        else
+        {
+            pNtk = Abc_NtkStrash( pNtk, fAllNodes, !fAllNodes, 0 );
+            Abc_NtkFraigPartitionedTime( pNtk, &Params );
+            Abc_NtkDelete( pNtk );
+        }
+    }
+    else
+    {
+        if ( Abc_NtkIsStrash(pNtk) )
+            pNtkRes = Abc_NtkFraig( pNtk, &Params, fAllNodes, fExdc );
+        else
+        {
+            pNtk = Abc_NtkStrash( pNtk, fAllNodes, !fAllNodes, 0 );
+            pNtkRes = Abc_NtkFraig( pNtk, &Params, fAllNodes, fExdc );
+            Abc_NtkDelete( pNtk );
+        }
+    }
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Fraiging has failed.\n" );
+        return 1;
+    }
+
+    if ( pParams->fTryProve ) // report the result
+        Abc_NtkMiterReport( pNtkRes );
+
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    sprintf(Buffer, "%d", pParams->nBTLimit );
+    Abc_Print( -2, "usage: fraig [-R num] [-D num] [-C num] [-rscpvtah]\n" );
+    Abc_Print( -2, "\t         transforms a logic network into a functionally reduced AIG\n" );
+    Abc_Print( -2, "\t         (known bugs: takes an UNSAT miter and returns a SAT one)\n");
+    Abc_Print( -2, "\t         (there are newer fraiging commands, \"ifraig\" and \"dfraig\")\n" );
+    Abc_Print( -2, "\t-R num : number of random patterns (127 < num < 32769) [default = %d]\n",     pParams->nPatsRand );
+    Abc_Print( -2, "\t-D num : number of systematic patterns (127 < num < 32769) [default = %d]\n", pParams->nPatsDyna );
+    Abc_Print( -2, "\t-C num : number of backtracks for one SAT problem [default = %s]\n",    pParams->nBTLimit==-1? "infinity" : Buffer );
+    Abc_Print( -2, "\t-r     : toggle functional reduction [default = %s]\n",                 pParams->fFuncRed? "yes": "no" );
+    Abc_Print( -2, "\t-s     : toggle considering sparse functions [default = %s]\n",         pParams->fDoSparse? "yes": "no" );
+    Abc_Print( -2, "\t-c     : toggle accumulation of choices [default = %s]\n",              pParams->fChoicing? "yes": "no" );
+    Abc_Print( -2, "\t-p     : toggle proving the miter outputs [default = %s]\n",              pParams->fTryProve? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n",                       pParams->fVerbose?  "yes": "no" );
+    Abc_Print( -2, "\t-e     : toggle functional sweeping using EXDC [default = %s]\n",       fExdc? "yes": "no" );
+    Abc_Print( -2, "\t-a     : toggle between all nodes and DFS nodes [default = %s]\n",      fAllNodes? "all": "dfs" );
+    Abc_Print( -2, "\t-t     : toggle using partitioned representation [default = %s]\n",     fPartition? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandFraigTrust( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c;
+    int fDuplicate;
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    fDuplicate = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'd':
+            fDuplicate ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    // get the new network
+    pNtkRes = Abc_NtkFraigTrust( pNtk );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Fraiging in the trust mode has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: fraig_trust [-h]\n" );
+    Abc_Print( -2, "\t        transforms the current network into an AIG assuming it is FRAIG with choices\n" );
+//    Abc_Print( -2, "\t-d    : toggle duplication of logic [default = %s]\n", fDuplicate? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandFraigStore( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int fDuplicate;
+
+    // set defaults
+    fDuplicate = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'd':
+            fDuplicate ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    // get the new network
+    if ( !Abc_NtkFraigStore( pNtk ) )
+    {
+        Abc_Print( -1, "Fraig storing has failed.\n" );
+        return 1;
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: fraig_store [-h]\n" );
+    Abc_Print( -2, "\t        saves the current network in the AIG database\n" );
+//    Abc_Print( -2, "\t-d    : toggle duplication of logic [default = %s]\n", fDuplicate? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandFraigRestore( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c;
+    int fDuplicate;
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    fDuplicate = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'd':
+            fDuplicate ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    // get the new network
+    pNtkRes = Abc_NtkFraigRestore();
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Fraig restoring has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: fraig_restore [-h]\n" );
+    Abc_Print( -2, "\t        makes the current network by fraiging the AIG database\n" );
+//    Abc_Print( -2, "\t-d    : toggle duplication of logic [default = %s]\n", fDuplicate? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandFraigClean( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+//    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int fDuplicate;
+    // set defaults
+    fDuplicate = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'd':
+            fDuplicate ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    Abc_NtkFraigStoreClean();
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: fraig_clean [-h]\n" );
+    Abc_Print( -2, "\t        cleans the internal FRAIG storage\n" );
+//    Abc_Print( -2, "\t-d    : toggle duplication of logic [default = %s]\n", fDuplicate? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandFraigSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int fUseInv;
+    int fExdc;
+    int fVerbose;
+    int fVeryVerbose;
+    extern int Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fExdc, int fVerbose, int fVeryVerbose );
+    // set defaults
+    fUseInv   = 1;
+    fExdc     = 0;
+    fVerbose  = 0;
+    fVeryVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "ievwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'i':
+            fUseInv ^= 1;
+            break;
+        case 'e':
+            fExdc ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'w':
+            fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Cannot sweep AIGs (use \"fraig\").\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsLogic(pNtk) )
+    {
+        Abc_Print( -1, "Transform the current network into a logic network.\n" );
+        return 1;
+    }
+    // modify the current network
+    if ( !Abc_NtkFraigSweep( pNtk, fUseInv, fExdc, fVerbose, fVeryVerbose ) )
+    {
+        Abc_Print( -1, "Sweeping has failed.\n" );
+        return 1;
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: fraig_sweep [-evwh]\n" );
+    Abc_Print( -2, "\t        performs technology-dependent sweep\n" );
+    Abc_Print( -2, "\t-e    : toggle functional sweeping using EXDC [default = %s]\n", fExdc? "yes": "no" );
+    Abc_Print( -2, "\t-v    : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w    : prints equivalence class information [default = %s]\n", fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandFraigDress( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern void Abc_NtkDress( Abc_Ntk_t * pNtk, char * pFileName, int fVerbose );
+    extern void Abc_NtkDress2( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nConflictLimit, int fVerbose );
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc), * pNtk2;
+    char * pFileName;
+    int c;
+    int nConfs;
+    int fVerbose;
+    // set defaults
+    nConfs   = 1000;
+    fVerbose =    0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Cvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nConfs = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nConfs < 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for logic networks.\n" );
+        return 1;
+    }
+    if ( argc != globalUtilOptind && argc != globalUtilOptind + 1 )
+        goto usage;
+    if ( argc == globalUtilOptind && Abc_NtkSpec(pNtk) == NULL )
+    {
+        Abc_Print( -1, "The current network has no spec.\n" );
+        return 1;
+    }
+    // get the input file name
+    pFileName = (argc == globalUtilOptind + 1) ? argv[globalUtilOptind] : Abc_NtkSpec(pNtk);
+    // modify the current network
+//    Abc_NtkDress( pNtk, pFileName, fVerbose );
+    pNtk2 = Io_Read( pFileName, Io_ReadFileType(pFileName), 1, 0 );
+    Abc_NtkDress2( pNtk, pNtk2, nConfs, fVerbose );
+    Abc_NtkDelete( pNtk2 );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: dress [-C num] [-vh] <file>\n" );
+    Abc_Print( -2, "\t         transfers internal node names from file to the current network\n" );
+    Abc_Print( -2, "\t<file> : network with names (if not given, the current network spec is used)\n" );
+    Abc_Print( -2, "\t-C num : the maximum number of conflicts at each node [default = %d]\n", nConfs );
+    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandRecStart3( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    char * FileName, * pTemp;
+    char ** pArgvNew;
+    int c, nArgcNew;
+    FILE * pFile;
+    Gia_Man_t * pGia = NULL;
+    int nVars = 6;
+    int nCuts = 32;
+    int fFuncOnly = 0;
+    int fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "KCfvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nVars = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nVars < 1 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nCuts = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nCuts < 1 )
+                goto usage;
+            break;
+        case 'f':
+            fFuncOnly ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( !(nVars >= 3 && nVars <= 16) )
+    {
+        Abc_Print( -1, "The range of allowed values is 3 <= K <= 16.\n" );
+        return 0;
+    }
+    if ( Abc_NtkRecIsRunning3() )
+    {
+        Abc_Print( -1, "The AIG subgraph recording is already started.\n" );
+        return 0;
+    }
+    pArgvNew = argv + globalUtilOptind;
+    nArgcNew = argc - globalUtilOptind;
+    if ( nArgcNew != 1 )
+        Abc_Print( 1, "File name is not given on the command line. Starting a new record.\n" );
+    else
+    {
+        // get the input file name
+        FileName = pArgvNew[0];
+        // fix the wrong symbol
+        for ( pTemp = FileName; *pTemp; pTemp++ )
+            if ( *pTemp == '>' )
+                *pTemp = '\\';
+        if ( (pFile = fopen( FileName, "r" )) == NULL )
+        {
+            Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
+            if ( (FileName = Extra_FileGetSimilarName( FileName, ".aig", NULL, NULL, NULL, NULL )) )
+                Abc_Print( 1, "Did you mean \"%s\"?", FileName );
+            Abc_Print( 1, "\n" );
+            return 1;
+        }
+        fclose( pFile );
+        pGia = Gia_AigerRead( FileName, 1, 0 );
+        if ( pGia == NULL )
+        {
+            Abc_Print( -1, "Reading AIGER has failed.\n" );
+            return 0;
+        }
+    }
+    Abc_NtkRecStart3( pGia, nVars, nCuts, fFuncOnly, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: rec_start3 [-K num] [-C num] [-fvh] <file>\n" );
+    Abc_Print( -2, "\t         starts recording AIG subgraphs (should be called for\n" );
+    Abc_Print( -2, "\t         an empty network or after reading in a previous record)\n" );
+    Abc_Print( -2, "\t-K num : the largest number of inputs [default = %d]\n", nVars );
+    Abc_Print( -2, "\t-C num : the max number of cuts used at a node (0 < num < 2^12) [default = %d]\n", nCuts );
+    Abc_Print( -2, "\t-f     : toggles recording functions without AIG subgraphs [default = %s]\n", fFuncOnly? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggles additional verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\t<file> : AIGER file with the library\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandRecStop3( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    int c;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( !Abc_NtkRecIsRunning3() )
+    {
+        Abc_Print( -1, "This command works only after calling \"rec_start3\".\n" );
+        return 0;
+    }
+    Abc_NtkRecStop3();
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: rec_stop3 [-h]\n" );
+    Abc_Print( -2, "\t        cleans the internal storage for AIG subgraphs\n" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandRecPs3( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    int c, fPrintLib = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "ph" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'p':
+            fPrintLib ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( !Abc_NtkRecIsRunning3() )
+    {
+        Abc_Print( -1, "This command works for AIGs only after calling \"rec_start2\".\n" );
+        return 0;
+    }
+    Abc_NtkRecPs3(fPrintLib);
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: rec_ps3 [-h]\n" );
+    Abc_Print( -2, "\t        prints statistics about the recorded AIG subgraphs\n" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandRecAdd3( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int fUseSOPB = 0;
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "gh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'g':
+            fUseSOPB = 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works for AIGs.\n" );
+        return 0;
+    }
+    if ( !Abc_NtkRecIsRunning3() )
+    {
+        Abc_Print( -1, "This command works for AIGs after calling \"rec_start2\".\n" );
+        return 0;
+    }
+    Abc_NtkRecAdd3( pNtk, fUseSOPB );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: rec_add3 [-h]\n" );
+    Abc_Print( -2, "\t        adds subgraphs from the current network to the set\n" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandRecDump3( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern void Abc_NtkRecDumpTt3( char * pFileName, int fBinary );
+    char * FileName;
+    char ** pArgvNew;
+    int nArgcNew;
+    Gia_Man_t * pGia;
+    int fAscii = 0;
+    int fBinary = 0;
+    int c;
+
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "abh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'a':
+            fAscii ^= 1;
+            break;
+        case 'b':
+            fBinary ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( !Abc_NtkRecIsRunning3() )
+    {
+        Abc_Print( -1, "The AIG subgraph recording is not started.\n" );
+        return 1;
+    }
+
+    pArgvNew = argv + globalUtilOptind;
+    nArgcNew = argc - globalUtilOptind;
+    if ( nArgcNew != 1 )
+    {
+        Abc_Print( -1, "File name is not given on the command line.\n" );
+        return 1;
+    }
+    // get the input file name
+    FileName = pArgvNew[0];
+    if ( fAscii )
+        Abc_NtkRecDumpTt3( FileName, 0 );
+    else if ( fBinary )
+        Abc_NtkRecDumpTt3( FileName, 1 );
+    else
+    {
+        pGia = Abc_NtkRecGetGia3();
+        if( pGia == NULL )
+        {
+            Abc_Print( 0, "Library AIG is not available.\n" );
+            return 1;
+        }
+        if( Gia_ManPoNum(pGia) == 0 )
+        {
+            Abc_Print( 0, "No structure in the library.\n" );
+            return 1;
+        }
+        Gia_AigerWrite( pGia, FileName, 0, 0 );
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: rec_dump3 [-abh] <file>\n" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\t-a     : toggles dumping TTs into an ASCII file [default = %s]\n", fAscii? "yes": "no" );
+    Abc_Print( -2, "\t-b     : toggles dumping TTs into a binary file [default = %s]\n", fBinary? "yes": "no" );
+    Abc_Print( -2, "\t<file> : AIGER file to write the library\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandRecMerge3( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    int c;
+    char * FileName, * pTemp;
+    char ** pArgvNew;
+    int nArgcNew;
+    FILE * pFile;
+    Gia_Man_t * pGia = NULL;
+
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( !Abc_NtkRecIsRunning3() )
+    {
+        Abc_Print( -1, "This command works for AIGs only after calling \"rec_start3\".\n" );
+        return 0;
+    }
+    pArgvNew = argv + globalUtilOptind;
+    nArgcNew = argc - globalUtilOptind;
+    if ( nArgcNew != 1 )
+    {
+        Abc_Print( -1, "File name is not given on the command line.\n" );
+        return 1;
+    }
+    else
+    {
+        // get the input file name
+        FileName = pArgvNew[0];
+        // fix the wrong symbol
+        for ( pTemp = FileName; *pTemp; pTemp++ )
+            if ( *pTemp == '>' )
+                *pTemp = '\\';
+        if ( (pFile = fopen( FileName, "r" )) == NULL )
+        {
+            Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
+            if ( (FileName = Extra_FileGetSimilarName( FileName, ".aig", NULL, NULL, NULL, NULL )) )
+                Abc_Print( 1, "Did you mean \"%s\"?", FileName );
+            Abc_Print( 1, "\n" );
+            return 1;
+        }
+        fclose( pFile );
+        pGia = Gia_AigerRead( FileName, 1, 0 );
+        if ( pGia == NULL )
+        {
+            Abc_Print( -1, "Reading AIGER has failed.\n" );
+            return 0;
+        }
+    }
+    Abc_NtkRecLibMerge3(pGia);
+    Gia_ManStop( pGia );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: rec_merge3 [-h] <file>\n" );
+    Abc_Print( -2, "\t         merge libraries\n" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\t<file> : AIGER file with the library\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandMap( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    char Buffer[100];
+    double DelayTarget;
+    double AreaMulti;
+    double DelayMulti;
+    float LogFan = 0;
+    float Slew = 0; // choose based on the library
+    float Gain = 250;
+    int nGatesMin = 4;
+    int fAreaOnly;
+    int fRecovery;
+    int fSweep;
+    int fSwitching;
+    int fVerbose;
+    int c;
+    extern Abc_Ntk_t * Abc_NtkMap( Abc_Ntk_t * pNtk, double DelayTarget, double AreaMulti, double DelayMulti, float LogFan, float Slew, float Gain, int nGatesMin, int fRecovery, int fSwitching, int fVerbose );
+    extern int Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fExdc, int fVerbose, int fVeryVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    DelayTarget =-1;
+    AreaMulti   = 0;
+    DelayMulti  = 0;
+    fAreaOnly   = 0;
+    fRecovery   = 1;
+    fSweep      = 0;
+    fSwitching  = 0;
+    fVerbose    = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "DABFSGMarspvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            DelayTarget = (float)atof(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( DelayTarget <= 0.0 )
+                goto usage;
+            break;
+        case 'A':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-A\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            AreaMulti = (float)atof(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            break;
+        case 'B':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-B\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            DelayMulti = (float)atof(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            LogFan = (float)atof(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( LogFan < 0.0 )
+                goto usage;
+            break;
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            Slew = (float)atof(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( Slew <= 0.0 )
+                goto usage;
+            break;
+        case 'G':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-G\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            Gain = (float)atof(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( Gain <= 0.0 )
+                goto usage;
+            break;
+        case 'M':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-M\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            nGatesMin = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nGatesMin < 0 ) 
+                goto usage;
+            break;
+        case 'a':
+            fAreaOnly ^= 1;
+            break;
+        case 'r':
+            fRecovery ^= 1;
+            break;
+        case 's':
+            fSweep ^= 1;
+            break;
+        case 'p':
+            fSwitching ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( fAreaOnly )
+        DelayTarget = ABC_INFINITY;
+
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        pNtk = Abc_NtkStrash( pNtk, 0, 0, 0 );
+        if ( pNtk == NULL )
+        {
+            Abc_Print( -1, "Strashing before mapping has failed.\n" );
+            return 1;
+        }
+        pNtk = Abc_NtkBalance( pNtkRes = pNtk, 0, 0, 1 );
+        Abc_NtkDelete( pNtkRes );
+        if ( pNtk == NULL )
+        {
+            Abc_Print( -1, "Balancing before mapping has failed.\n" );
+            return 1;
+        }
+        Abc_Print( 0, "The network was strashed and balanced before mapping.\n" );
+        // get the new network
+        pNtkRes = Abc_NtkMap( pNtk, DelayTarget, AreaMulti, DelayMulti, LogFan, Slew, Gain, nGatesMin, fRecovery, fSwitching, fVerbose );
+        if ( pNtkRes == NULL )
+        {
+            Abc_NtkDelete( pNtk );
+            Abc_Print( -1, "Mapping has failed.\n" );
+            return 1;
+        }
+        Abc_NtkDelete( pNtk );
+    }
+    else
+    {
+        // get the new network
+        pNtkRes = Abc_NtkMap( pNtk, DelayTarget, AreaMulti, DelayMulti, LogFan, Slew, Gain, nGatesMin, fRecovery, fSwitching, fVerbose );
+        if ( pNtkRes == NULL )
+        {
+            Abc_Print( -1, "Mapping has failed.\n" );
+            return 1;
+        }
+    }
+
+    if ( fSweep )
+    {
+        Abc_NtkFraigSweep( pNtkRes, 0, 0, 0, 0 );
+        if ( Abc_NtkHasMapping(pNtkRes) )
+        {
+            pNtkRes = Abc_NtkDupDfs( pNtk = pNtkRes );
+            Abc_NtkDelete( pNtk );
+        }
+    }
+
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    if ( DelayTarget == -1 )
+        sprintf(Buffer, "not used" );
+    else
+        sprintf(Buffer, "%.3f", DelayTarget );
+    Abc_Print( -2, "usage: map [-DABFSG float] [-M num] [-arspvh]\n" );
+    Abc_Print( -2, "\t           performs standard cell mapping of the current network\n" );
+    Abc_Print( -2, "\t-D float : sets the global required times [default = %s]\n", Buffer );
+    Abc_Print( -2, "\t-A float : \"area multiplier\" to bias gate selection [default = %.2f]\n", AreaMulti );
+    Abc_Print( -2, "\t-B float : \"delay multiplier\" to bias gate selection [default = %.2f]\n", DelayMulti );
+    Abc_Print( -2, "\t-F float : the logarithmic fanout delay parameter [default = %.2f]\n", LogFan );
+    Abc_Print( -2, "\t-S float : the slew parameter used to generate the library [default = %.2f]\n", Slew );
+    Abc_Print( -2, "\t-G float : the gain parameter used to generate the library [default = %.2f]\n", Gain );
+    Abc_Print( -2, "\t-M num   : skip gate classes whose size is less than this [default = %d]\n", nGatesMin );
+    Abc_Print( -2, "\t-a       : toggles area-only mapping [default = %s]\n", fAreaOnly? "yes": "no" );
+    Abc_Print( -2, "\t-r       : toggles area recovery [default = %s]\n", fRecovery? "yes": "no" );
+    Abc_Print( -2, "\t-s       : toggles sweep after mapping [default = %s]\n", fSweep? "yes": "no" );
+    Abc_Print( -2, "\t-p       : optimizes power by minimizing switching [default = %s]\n", fSwitching? "yes": "no" );
+    Abc_Print( -2, "\t-v       : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAmap( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Amap_Par_t Pars, * pPars = &Pars;
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int fSweep;
+    int c;
+    extern Abc_Ntk_t * Abc_NtkDarAmap( Abc_Ntk_t * pNtk, Amap_Par_t * pPars );
+    extern int Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fExdc, int fVerbose, int fVeryVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    fSweep = 0;
+    Amap_ManSetDefaultParams( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "FACEQmxisvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            pPars->nIterFlow = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nIterFlow < 0 )
+                goto usage;
+            break;
+        case 'A':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-A\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            pPars->nIterArea = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nIterArea < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            pPars->nCutsMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nCutsMax < 0 )
+                goto usage;
+            break;
+        case 'E':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-E\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            pPars->fEpsilon = (float)atof(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->fEpsilon < 0.0 || pPars->fEpsilon > 1.0 )
+                goto usage;
+            break;
+        case 'Q':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-Q\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            pPars->fADratio = (float)atof(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->fADratio < 0.0 )
+                goto usage;
+            break;
+        case 'm':
+            pPars->fUseMuxes ^= 1;
+            break;
+        case 'x':
+            pPars->fUseXors ^= 1;
+            break;
+        case 'i':
+            pPars->fFreeInvs ^= 1;
+            break;
+        case 's':
+            fSweep ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        pNtk = Abc_NtkStrash( pNtk, 0, 0, 0 );
+        if ( pNtk == NULL )
+        {
+            Abc_Print( -1, "Strashing before mapping has failed.\n" );
+            return 1;
+        }
+        pNtk = Abc_NtkBalance( pNtkRes = pNtk, 0, 0, 1 );
+        Abc_NtkDelete( pNtkRes );
+        if ( pNtk == NULL )
+        {
+            Abc_Print( -1, "Balancing before mapping has failed.\n" );
+            return 1;
+        }
+        Abc_Print( 0, "The network was strashed and balanced before mapping.\n" );
+        // get the new network
+        pNtkRes = Abc_NtkDarAmap( pNtk, pPars );
+        if ( pNtkRes == NULL )
+        {
+            Abc_NtkDelete( pNtk );
+            Abc_Print( -1, "Mapping has failed.\n" );
+            return 1;
+        }
+        Abc_NtkDelete( pNtk );
+    }
+    else
+    {
+        // get the new network
+        pNtkRes = Abc_NtkDarAmap( pNtk, pPars );
+        if ( pNtkRes == NULL )
+        {
+            Abc_Print( -1, "Mapping has failed.\n" );
+            return 1;
+        }
+    }
+
+    if ( fSweep )
+    {
+        Abc_NtkFraigSweep( pNtkRes, 0, 0, 0, 0 );
+        if ( Abc_NtkHasMapping(pNtkRes) )
+        {
+            pNtkRes = Abc_NtkDupDfs( pNtk = pNtkRes );
+            Abc_NtkDelete( pNtk );
+        }
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: amap [-FAC <num>] [-EQ <float>] [-mxisvh]\n" );
+    Abc_Print( -2, "\t           performs standard cell mapping of the current network\n" );
+    Abc_Print( -2, "\t-F num   : the number of iterations of area flow [default = %d]\n", pPars->nIterFlow );
+    Abc_Print( -2, "\t-A num   : the number of iterations of exact area [default = %d]\n", pPars->nIterArea );
+    Abc_Print( -2, "\t-C num   : the maximum number of cuts at a node [default = %d]\n", pPars->nCutsMax );
+    Abc_Print( -2, "\t-E float : sets epsilon used for tie-breaking [default = %f]\n", pPars->fEpsilon );
+    Abc_Print( -2, "\t-Q float : area/delay preference ratio [default = %.2f (area-only)] \n", pPars->fADratio );
+    Abc_Print( -2, "\t-m       : toggles using MUX matching [default = %s]\n", pPars->fUseMuxes? "yes": "no" );
+    Abc_Print( -2, "\t-x       : toggles using XOR matching [default = %s]\n", pPars->fUseXors? "yes": "no" );
+    Abc_Print( -2, "\t-i       : toggles assuming inverters are free [default = %s]\n", pPars->fFreeInvs? "yes": "no" );
+    Abc_Print( -2, "\t-s       : toggles sweep after mapping [default = %s]\n", fSweep? "yes": "no" );
+    Abc_Print( -2, "\t-v       : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandUnmap( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkHasMapping(pNtk) )
+    {
+        Abc_Print( -1, "Cannot unmap the network that is not mapped.\n" );
+        return 1;
+    }
+
+    // get the new network
+    if ( !Abc_NtkMapToSop( pNtk ) )
+    {
+        Abc_Print( -1, "Unmapping has failed.\n" );
+        return 1;
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: unmap [-h]\n" );
+    Abc_Print( -2, "\t        replaces the library gates by the logic nodes represented using SOPs\n" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAttach( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsSopLogic(pNtk) )
+    {
+        Abc_Print( -1, "Can only attach gates if the nodes have SOP representations.\n" );
+        return 1;
+    }
+
+    // get the new network
+    if ( !Abc_NtkAttach( pNtk ) )
+    {
+        Abc_Print( -1, "Attaching gates has failed.\n" );
+        return 1;
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: attach [-h]\n" );
+    Abc_Print( -2, "\t        replaces the SOP functions by the gates from the library\n" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandSuperChoice( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c;
+    extern Abc_Ntk_t * Abc_NtkSuperChoice( Abc_Ntk_t * pNtk );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Superchoicing works only for the AIG representation (run \"strash\").\n" );
+        return 1;
+    }
+
+    // get the new network
+    pNtkRes = Abc_NtkSuperChoice( pNtk );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Superchoicing has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: superc [-h]\n" );
+    Abc_Print( -2, "\t      performs superchoicing\n" );
+    Abc_Print( -2, "\t      (accumulate: \"r file.blif; rsup; b; sc; f -ac; wb file_sc.blif\")\n" );
+    Abc_Print( -2, "\t      (map without supergate library: \"r file_sc.blif; ft; map\")\n" );
+    Abc_Print( -2, "\t-h  : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandSuperChoiceLut( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c;
+    int nLutSize;
+    int nCutSizeMax;
+    int fVerbose;
+    extern int Abc_NtkSuperChoiceLut( Abc_Ntk_t * pNtk, int nLutSize, int nCutSizeMax, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    fVerbose = 1;
+    nLutSize = 4;
+    nCutSizeMax = 10;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "KNh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            nLutSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLutSize < 0 )
+                goto usage;
+            break;
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            nCutSizeMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nCutSizeMax < 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Superchoicing works only for the AIG representation (run \"strash\").\n" );
+        return 1;
+    }
+
+    // convert the network into the SOP network
+    pNtkRes = Abc_NtkToLogic( pNtk );
+
+    // get the new network
+    if ( !Abc_NtkSuperChoiceLut( pNtkRes, nLutSize, nCutSizeMax, fVerbose ) )
+    {
+        Abc_NtkDelete( pNtkRes );
+        Abc_Print( -1, "Superchoicing has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: supercl [-K num] [-N num] [-vh]\n" );
+    Abc_Print( -2, "\t        performs superchoicing for K-LUTs\n" );
+    Abc_Print( -2, "\t        (accumulate: \"r file.blif; b; scl; f -ac; wb file_sc.blif\")\n" );
+    Abc_Print( -2, "\t        (FPGA map: \"r file_sc.blif; ft; read_lut lutlibK; fpga\")\n" );
+    Abc_Print( -2, "\t-K num : the number of LUT inputs [default = %d]\n", nLutSize );
+    Abc_Print( -2, "\t-N num : the max size of the cut [default = %d]\n", nCutSizeMax );
+    Abc_Print( -2, "\t-v     : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+#if 0 
+int Abc_CommandFpga( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    char Buffer[100];
+    char LutSize[100];
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c;
+    int fRecovery;
+    int fSwitching;
+    int fLatchPaths;
+    int fVerbose;
+    int nLutSize;
+    float DelayTarget;
+
+    extern Abc_Ntk_t * Abc_NtkFpga( Abc_Ntk_t * pNtk, float DelayTarget, int fRecovery, int fSwitching, int fLatchPaths, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    fRecovery   = 1;
+    fSwitching  = 0;
+    fLatchPaths = 0;
+    fVerbose    = 0;
+    DelayTarget =-1;
+    nLutSize    =-1;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "aplvhDK" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'a':
+            fRecovery ^= 1;
+            break;
+        case 'p':
+            fSwitching ^= 1;
+            break;
+        case 'l':
+            fLatchPaths ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            DelayTarget = (float)atof(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( DelayTarget <= 0.0 )
+                goto usage;
+            break;
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            nLutSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLutSize < 0 )
+                goto usage;
+            break;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    // create the new LUT library
+    if ( nLutSize >= 3 && nLutSize <= 10 )
+        Fpga_SetSimpleLutLib( nLutSize );
+/*
+    else
+    {
+        Abc_Print( -1, "Cannot perform FPGA mapping with LUT size %d.\n", nLutSize );
+        return 1;
+    }
+*/
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        // strash and balance the network
+        pNtk = Abc_NtkStrash( pNtk, 0, 0, 0 );
+        if ( pNtk == NULL )
+        {
+            Abc_Print( -1, "Strashing before FPGA mapping has failed.\n" );
+            return 1;
+        }
+        pNtk = Abc_NtkBalance( pNtkRes = pNtk, 0, 0, 1 );
+        Abc_NtkDelete( pNtkRes );
+        if ( pNtk == NULL )
+        {
+            Abc_Print( -1, "Balancing before FPGA mapping has failed.\n" );
+            return 1;
+        }
+        Abc_Print( 1, "The network was strashed and balanced before FPGA mapping.\n" );
+        // get the new network
+        pNtkRes = Abc_NtkFpga( pNtk, DelayTarget, fRecovery, fSwitching, fLatchPaths, fVerbose );
+        if ( pNtkRes == NULL )
+        {
+            Abc_NtkDelete( pNtk );
+            Abc_Print( -1, "FPGA mapping has failed.\n" );
+            return 1;
+        }
+        Abc_NtkDelete( pNtk );
+    }
+    else
+    {
+        // get the new network
+        pNtkRes = Abc_NtkFpga( pNtk, DelayTarget, fRecovery, fSwitching, fLatchPaths, fVerbose );
+        if ( pNtkRes == NULL )
+        {
+            Abc_Print( -1, "FPGA mapping has failed.\n" );
+            return 1;
+        }
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    if ( DelayTarget == -1 )
+        sprintf(Buffer, "best possible" );
+    else
+        sprintf(Buffer, "%.2f", DelayTarget );
+    if ( nLutSize == -1 )
+        sprintf(LutSize, "library" );
+    else
+        sprintf(LutSize, "%d", nLutSize );
+    Abc_Print( -2, "usage: fpga [-D float] [-K num] [-aplvh]\n" );
+    Abc_Print( -2, "\t           performs FPGA mapping of the current network\n" );
+    Abc_Print( -2, "\t-a       : toggles area recovery [default = %s]\n", fRecovery? "yes": "no" );
+    Abc_Print( -2, "\t-p       : optimizes power by minimizing switching activity [default = %s]\n", fSwitching? "yes": "no" );
+    Abc_Print( -2, "\t-l       : optimizes latch paths for delay, other paths for area [default = %s]\n", fLatchPaths? "yes": "no" );
+    Abc_Print( -2, "\t-D float : sets the required time for the mapping [default = %s]\n", Buffer );
+    Abc_Print( -2, "\t-K num   : the number of LUT inputs (2 < num < 11) [default = %s]%s\n", LutSize, (nLutSize == -1 ? " (type \"print_lut\")" : "") );
+    Abc_Print( -2, "\t-v       : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : prints the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandFpgaFast( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    char Buffer[100];
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c;
+    int fRecovery;
+    int fVerbose;
+    int nLutSize;
+    float DelayTarget;
+
+    extern Abc_Ntk_t * Abc_NtkFpgaFast( Abc_Ntk_t * pNtk, int nLutSize, int fRecovery, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    fRecovery   = 1;
+    fVerbose    = 0;
+    DelayTarget =-1;
+    nLutSize    = 5;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "avhDK" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'a':
+            fRecovery ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            DelayTarget = (float)atof(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( DelayTarget <= 0.0 )
+                goto usage;
+            break;
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            nLutSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLutSize < 0 )
+                goto usage;
+            break;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        // strash and balance the network
+        pNtk = Abc_NtkStrash( pNtk, 0, 0, 0 );
+        if ( pNtk == NULL )
+        {
+            Abc_Print( -1, "Strashing before FPGA mapping has failed.\n" );
+            return 1;
+        }
+        pNtk = Abc_NtkBalance( pNtkRes = pNtk, 0, 0, 1 );
+        Abc_NtkDelete( pNtkRes );
+        if ( pNtk == NULL )
+        {
+            Abc_Print( -1, "Balancing before FPGA mapping has failed.\n" );
+            return 1;
+        }
+        Abc_Print( 1, "The network was strashed and balanced before FPGA mapping.\n" );
+        // get the new network
+        pNtkRes = Abc_NtkFpgaFast( pNtk, nLutSize, fRecovery, fVerbose );
+        if ( pNtkRes == NULL )
+        {
+            Abc_NtkDelete( pNtk );
+            Abc_Print( -1, "FPGA mapping has failed.\n" );
+            return 1;
+        }
+        Abc_NtkDelete( pNtk );
+    }
+    else
+    {
+        // get the new network
+        pNtkRes = Abc_NtkFpgaFast( pNtk, nLutSize, fRecovery, fVerbose );
+        if ( pNtkRes == NULL )
+        {
+            Abc_Print( -1, "FPGA mapping has failed.\n" );
+            return 1;
+        }
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    if ( DelayTarget == -1 )
+        sprintf(Buffer, "not used" );
+    else
+        sprintf(Buffer, "%.2f", DelayTarget );
+    Abc_Print( -2, "usage: ffpga [-K num] [-avh]\n" );
+    Abc_Print( -2, "\t           performs fast FPGA mapping of the current network\n" );
+    Abc_Print( -2, "\t-a       : toggles area recovery [default = %s]\n", fRecovery? "yes": "no" );
+//    Abc_Print( -2, "\t-D float : sets the required time for the mapping [default = %s]\n", Buffer );
+    Abc_Print( -2, "\t-K num   : the number of LUT inputs (2 < num < 32) [default = %d]\n", nLutSize );
+    Abc_Print( -2, "\t-v       : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : prints the command usage\n");
+    return 1;
+}
+#endif
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Abc_Ntk_t * Abc_NtkIf( Abc_Ntk_t * pNtk, If_Par_t * pPars );
+    char Buffer[100], LutSize[100];
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    If_Par_t Pars, * pPars = &Pars;
+    int c;
+    pNtk = Abc_FrameReadNtk(pAbc);
+    If_ManSetDefaultPars( pPars );
+    pPars->pLutLib = (If_LibLut_t *)Abc_FrameReadLibLut();
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "KCFAGRNTDEWSqaflepmrsdbgxyojiktncvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nLutSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nLutSize < 0 )
+                goto usage;
+            // if the LUT size is specified, disable library
+            pPars->pLutLib = NULL;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nCutsMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nCutsMax < 0 )
+                goto usage;
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nFlowIters = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nFlowIters < 0 )
+                goto usage;
+            break;
+        case 'A':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-A\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nAreaIters = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nAreaIters < 0 )
+                goto usage;
+            break;
+        case 'G':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-G\" should be followed by a positive integer no less than 3.\n" );
+                goto usage;
+            }
+            pPars->nGateSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nGateSize < 2 )
+                goto usage;
+            break;
+        case 'R':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( 1, "Command line switch \"-R\" should be followed by a floating point number.\n" );
+                return 0;
+            }
+            pPars->nRelaxRatio = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nRelaxRatio < 0 ) 
+                goto usage;
+            break;
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by a positive integer no less than 3.\n" );
+                goto usage;
+            }
+            pPars->nNonDecLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nNonDecLimit < 2 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by a positive integer 0,1,or 2.\n" );
+                goto usage;
+            }
+            pPars->nStructType = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nStructType < 0 || pPars->nStructType > 2 )
+                goto usage;
+            break;
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            pPars->DelayTarget = (float)atof(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->DelayTarget <= 0.0 )
+                goto usage;
+            break;
+        case 'E':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-E\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            pPars->Epsilon = (float)atof(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->Epsilon < 0.0 || pPars->Epsilon > 1.0 )
+                goto usage;
+            break;
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            pPars->WireDelay = (float)atof(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->WireDelay < 0.0 )
+                goto usage;
+            break;
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by string.\n" );
+                goto usage;
+            }
+            pPars->pLutStruct = argv[globalUtilOptind];
+            globalUtilOptind++;
+            if ( strlen(pPars->pLutStruct) != 2 && strlen(pPars->pLutStruct) != 3 )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by a 2- or 3-char string (e.g. \"44\" or \"555\").\n" );
+                goto usage;
+            }
+            break;
+        case 'q':
+            pPars->fPreprocess ^= 1;
+            break;
+        case 'a':
+            pPars->fArea ^= 1;
+            break;
+        case 'r':
+            pPars->fExpRed ^= 1;
+            break;
+        case 'f':
+            pPars->fFancy ^= 1;
+            break;
+        case 'l':
+            pPars->fLatchPaths ^= 1;
+            break;
+        case 'e':
+            pPars->fEdge ^= 1;
+            break;
+        case 'p':
+            pPars->fPower ^= 1;
+            break;
+        case 'm':
+            pPars->fCutMin ^= 1;
+            break;
+        case 's':
+            pPars->fDelayOptLut ^= 1;
+            break;
+        case 'd':
+            pPars->fBidec ^= 1;
+            break;
+        case 'b':
+            pPars->fUseBat ^= 1;
+            break;
+        case 'g':
+            pPars->fDelayOpt ^= 1;
+            break;
+        case 'x':
+            pPars->fDsdBalance ^= 1;
+            break;
+        case 'y':
+            pPars->fUserRecLib ^= 1;
+            break;
+        case 'o':
+            pPars->fUseBuffs ^= 1;
+            break;
+        case 'j':
+            pPars->fEnableCheck07 ^= 1;
+            break;
+        case 'i':
+            pPars->fUseCofVars ^= 1;
+            break;
+        case 'k':
+            pPars->fUseDsdTune ^= 1;
+            break;
+        case 't':
+            pPars->fDoAverage ^= 1;
+            break;
+        case 'n':
+            pPars->fUseDsd ^= 1;
+            break;
+        case 'c':
+            pPars->fUseTtPerm ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'h':
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( pPars->nLutSize == -1 )
+    {
+        if ( pPars->pLutLib == NULL )
+        {
+            Abc_Print( -1, "The LUT library is not given.\n" );
+            return 1;
+        }
+        pPars->nLutSize = pPars->pLutLib->LutMax;
+    }
+
+    if ( pPars->nLutSize < 2 || pPars->nLutSize > IF_MAX_LUTSIZE )
+    {
+        Abc_Print( -1, "Incorrect LUT size (%d).\n", pPars->nLutSize );
+        return 1;
+    }
+
+    if ( pPars->nCutsMax < 1 || pPars->nCutsMax >= (1<<12) )
+    {
+        Abc_Print( -1, "Incorrect number of cuts.\n" );
+        return 1;
+    }
+
+    // enable truth table computation if choices are selected
+    if ( (c = Abc_NtkGetChoiceNum( pNtk )) )
+    {
+//        if ( !Abc_FrameReadFlag("silentmode") )
+//            Abc_Print( 0, "Performing LUT mapping with %d choices.\n", c );
+        pPars->fExpRed = 0;
+    }
+
+    if ( pPars->fUseBat )
+    {
+        if ( pPars->nLutSize < 4 || pPars->nLutSize > 6 )
+        {
+            Abc_Print( -1, "This feature only works for {4,5,6}-LUTs.\n" );
+            return 1;
+        }
+        pPars->fCutMin = 1;
+    }
+
+    if ( pPars->fEnableCheck07 + pPars->fUseCofVars + pPars->fUseDsdTune + (pPars->pLutStruct != NULL) > 1 )
+    {
+        Abc_Print( -1, "Only one additional check can be performed at the same time.\n" );
+        return 1;
+    }
+    if ( pPars->fEnableCheck07 )
+    {
+        if ( pPars->nLutSize < 6 || pPars->nLutSize > 7 )
+        {
+            Abc_Print( -1, "This feature only works for {6,7}-LUTs.\n" );
+            return 1;
+        }
+        pPars->pFuncCell = If_CutPerformCheck07;
+        pPars->fCutMin = 1;
+    }
+    if ( pPars->fUseCofVars )
+    {
+        if ( !(pPars->nLutSize & 1) )
+        {
+            Abc_Print( -1, "This feature only works for odd-sized LUTs.\n" );
+            return 1;
+        }
+        pPars->fCutMin = 1;
+    }
+    if ( pPars->fUseDsdTune )
+    {
+        If_DsdMan_t * pDsdMan = (If_DsdMan_t *)Abc_FrameReadManDsd();
+        if ( pDsdMan == NULL )
+        {
+            Abc_Print( -1, "DSD manager is not available.\n" );
+            return 1;
+        }
+        if ( pPars->nLutSize > If_DsdManVarNum(pDsdMan) )
+        {
+            Abc_Print( -1, "LUT size (%d) is more than the number of variables in the DSD manager (%d).\n", pPars->nLutSize, If_DsdManVarNum(pDsdMan) );
+            return 1;
+        }
+        if ( pPars->fDeriveLuts && If_DsdManGetCellStr(pDsdMan) == NULL )
+        {
+            Abc_Print( -1, "DSD manager is not matched with any particular cell.\n" );
+            return 1;
+        }
+        pPars->fCutMin = 1;
+        pPars->fUseDsd = 1;
+        If_DsdManSetNewAsUseless( pDsdMan );
+    }
+    if ( pPars->pLutStruct )
+    {
+        if ( pPars->fDsdBalance )
+        {
+            Abc_Print( -1, "Incompatible options (-S and -x).\n" );
+            return 1;
+        }
+        if ( pPars->nLutSize < 6 || pPars->nLutSize > 16 )
+        {
+            Abc_Print( -1, "This feature only works for [6;16]-LUTs.\n" );
+            return 1;
+        }
+        pPars->pFuncCell = pPars->fDelayOptLut ? NULL : If_CutPerformCheck16;
+        pPars->fCutMin = 1;
+    }
+
+    // enable truth table computation if cut minimization is selected
+    if ( pPars->fCutMin )
+    {
+        pPars->fTruth = 1;
+        pPars->fExpRed = 0;
+    }
+    // modify the subgraph recording
+    if ( pPars->fUserRecLib )
+    {
+        pPars->fTruth      =  1;
+        pPars->fCutMin     =  1;
+        pPars->fExpRed     =  0;
+        pPars->fUsePerm    =  1;
+        pPars->pLutLib     =  NULL;
+    }
+    // modify for delay optimization
+    if ( pPars->fDelayOpt || pPars->fDsdBalance || pPars->fDelayOptLut )
+    {
+        pPars->fTruth      =  1;
+        pPars->fCutMin     =  1;
+        pPars->fExpRed     =  0;
+        pPars->fUseDsd     =  pPars->fDsdBalance || pPars->fDelayOptLut;
+        pPars->pLutLib     =  NULL;
+    }
+    // modify for delay optimization
+    if ( pPars->nGateSize > 0 )
+    {
+        pPars->fTruth      =  1;
+        pPars->fCutMin     =  1;
+        pPars->fExpRed     =  0;
+        pPars->fUsePerm    =  1;
+        pPars->pLutLib     =  NULL;
+        pPars->nLutSize    =  pPars->nGateSize;
+    }
+
+    if ( pPars->fUseDsd || pPars->fUseTtPerm )
+    {
+        pPars->fTruth      =  1;
+        pPars->fCutMin     =  1;
+        pPars->fExpRed     =  0;
+    }
+
+    if ( pPars->fUseDsd )
+    {
+        int LutSize = (pPars->pLutStruct && pPars->pLutStruct[2] == 0)? pPars->pLutStruct[0] - '0' : 0;
+        If_DsdMan_t * p = (If_DsdMan_t *)Abc_FrameReadManDsd();
+        if ( pPars->pLutStruct && pPars->pLutStruct[2] != 0 )
+        {
+            printf( "DSD only works for LUT structures XY.\n" );
+            return 0;
+        }
+        if ( p && pPars->nLutSize > If_DsdManVarNum(p) )
+        {
+            printf( "DSD manager has incompatible number of variables.\n" );
+            return 0;
+        }
+        if ( p && LutSize != If_DsdManLutSize(p) && !pPars->fDsdBalance )
+        {
+            printf( "DSD manager has different LUT size.\n" );
+            return 0;
+        }
+        if ( p == NULL )
+        {
+            if ( LutSize > DAU_MAX_VAR || pPars->nLutSize > DAU_MAX_VAR )
+            {
+                printf( "Size of required DSD manager (%d) exceeds the precompiled limit (%d) (change parameter DAU_MAX_VAR).\n", LutSize, DAU_MAX_VAR );
+                return 0;
+            }
+            Abc_FrameSetManDsd( If_DsdManAlloc(pPars->nLutSize, LutSize) );
+        }
+    }
+
+    if ( pPars->fUserRecLib )
+    {
+        if ( !Abc_NtkRecIsRunning3() )
+        {
+            printf( "LMS manager is not running (use \"rec_start3\").\n" );
+            return 0;
+        }
+        if ( Abc_NtkRecInputNum3() != pPars->nLutSize )
+        {
+            printf( "The number of library inputs (%d) different from the K parameters (%d).\n", Abc_NtkRecInputNum3(), pPars->nLutSize );
+            return 0;
+        }
+    }
+ 
+    // complain if truth tables are requested but the cut size is too large
+    if ( pPars->fTruth && pPars->nLutSize > IF_MAX_FUNC_LUTSIZE )
+    {
+        Abc_Print( -1, "Truth tables cannot be computed for LUT larger than %d inputs.\n", IF_MAX_FUNC_LUTSIZE );
+        return 1;
+    }
+
+    // disable cut-expansion if edge-based heuristics are selected
+//    if ( pPars->fEdge )
+//        pPars->fExpRed = 0;
+
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        // strash and balance the network
+        pNtk = Abc_NtkStrash( pNtk, 0, 0, 0 );
+        if ( pNtk == NULL )
+        {
+            Abc_Print( -1, "Strashing before FPGA mapping has failed.\n" );
+            return 1;
+        }
+        pNtk = Abc_NtkBalance( pNtkRes = pNtk, 0, 0, 1 );
+        Abc_NtkDelete( pNtkRes );
+        if ( pNtk == NULL )
+        {
+            Abc_Print( -1, "Balancing before FPGA mapping has failed.\n" );
+            return 1;
+        }
+        if ( !Abc_FrameReadFlag("silentmode") )
+            Abc_Print( 1, "The network was strashed and balanced before FPGA mapping.\n" );
+        // get the new network
+        pNtkRes = Abc_NtkIf( pNtk, pPars );
+        if ( pNtkRes == NULL )
+        {
+            Abc_NtkDelete( pNtk );
+            Abc_Print( -1, "FPGA mapping has failed.\n" );
+            return 0;
+        }
+        Abc_NtkDelete( pNtk );
+    }
+    else
+    {
+        // get the new network
+        pNtkRes = Abc_NtkIf( pNtk, pPars );
+        if ( pNtkRes == NULL )
+        {
+            Abc_Print( -1, "FPGA mapping has failed.\n" );
+            return 0;
+        }
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    if ( pPars->DelayTarget == -1 )
+        sprintf(Buffer, "best possible" );
+    else
+        sprintf(Buffer, "%.2f", pPars->DelayTarget );
+    if ( pPars->nLutSize == -1 )
+        sprintf(LutSize, "library" );
+    else
+        sprintf(LutSize, "%d", pPars->nLutSize );
+    Abc_Print( -2, "usage: if [-KCFAGRNT num] [-DEW float] [-S str] [-qarlepmsdbgxyojiktncvh]\n" );
+    Abc_Print( -2, "\t           performs FPGA technology mapping of the network\n" );
+    Abc_Print( -2, "\t-K num   : the number of LUT inputs (2 < num < %d) [default = %s]\n", IF_MAX_LUTSIZE+1, LutSize );
+    Abc_Print( -2, "\t-C num   : the max number of priority cuts (0 < num < 2^12) [default = %d]\n", pPars->nCutsMax );
+    Abc_Print( -2, "\t-F num   : the number of area flow recovery iterations (num >= 0) [default = %d]\n", pPars->nFlowIters );
+    Abc_Print( -2, "\t-A num   : the number of exact area recovery iterations (num >= 0) [default = %d]\n", pPars->nAreaIters );
+    Abc_Print( -2, "\t-G num   : the max AND/OR gate size for mapping (0 = unused) [default = %d]\n", pPars->nGateSize );
+    Abc_Print( -2, "\t-R num   : the delay relaxation ratio (num >= 0) [default = %d]\n", pPars->nRelaxRatio );
+    Abc_Print( -2, "\t-N num   : the max size of non-decomposable nodes [default = unused]\n", pPars->nNonDecLimit );
+    Abc_Print( -2, "\t-T num   : the type of LUT structures [default = any]\n", pPars->nStructType );
+    Abc_Print( -2, "\t-D float : sets the delay constraint for the mapping [default = %s]\n", Buffer );
+    Abc_Print( -2, "\t-E float : sets epsilon used for tie-breaking [default = %f]\n", pPars->Epsilon );
+    Abc_Print( -2, "\t-W float : sets wire delay between adjects LUTs [default = %f]\n", pPars->WireDelay );
+    Abc_Print( -2, "\t-S str   : string representing the LUT structure [default = %s]\n", pPars->pLutStruct ? pPars->pLutStruct : "not used" );
+    Abc_Print( -2, "\t-q       : toggles preprocessing using several starting points [default = %s]\n", pPars->fPreprocess? "yes": "no" );
+    Abc_Print( -2, "\t-a       : toggles area-oriented mapping [default = %s]\n", pPars->fArea? "yes": "no" );
+    Abc_Print( -2, "\t-r       : enables expansion/reduction of the best cuts [default = %s]\n", pPars->fExpRed? "yes": "no" );
+    Abc_Print( -2, "\t-l       : optimizes latch paths for delay, other paths for area [default = %s]\n", pPars->fLatchPaths? "yes": "no" );
+    Abc_Print( -2, "\t-e       : uses edge-based cut selection heuristics [default = %s]\n", pPars->fEdge? "yes": "no" );
+    Abc_Print( -2, "\t-p       : uses power-aware cut selection heuristics [default = %s]\n", pPars->fPower? "yes": "no" );
+    Abc_Print( -2, "\t-m       : enables cut minimization by removing vacuous variables [default = %s]\n", pPars->fCutMin? "yes": "no" );
+    Abc_Print( -2, "\t-s       : toggles delay-oriented mapping used with -S <NN> [default = %s]\n", pPars->fDelayOptLut? "yes": "no" );
+    Abc_Print( -2, "\t-d       : toggles deriving local AIGs using bi-decomposition [default = %s]\n", pPars->fBidec? "yes": "no" );
+    Abc_Print( -2, "\t-b       : toggles the use of one special feature [default = %s]\n", pPars->fUseBat? "yes": "no" );
+    Abc_Print( -2, "\t-g       : toggles delay optimization by SOP balancing [default = %s]\n", pPars->fDelayOpt? "yes": "no" );
+    Abc_Print( -2, "\t-x       : toggles delay optimization by DSD balancing [default = %s]\n", pPars->fDsdBalance? "yes": "no" );
+    Abc_Print( -2, "\t-y       : toggles delay optimization with recorded library [default = %s]\n", pPars->fUserRecLib? "yes": "no" );
+    Abc_Print( -2, "\t-o       : toggles using buffers to decouple combinational outputs [default = %s]\n", pPars->fUseBuffs? "yes": "no" );
+    Abc_Print( -2, "\t-j       : toggles enabling additional check [default = %s]\n", pPars->fEnableCheck07? "yes": "no" );
+    Abc_Print( -2, "\t-i       : toggles using cofactoring variables [default = %s]\n", pPars->fUseCofVars? "yes": "no" );
+    Abc_Print( -2, "\t-k       : toggles matching based on precomputed DSD manager [default = %s]\n", pPars->fUseDsdTune? "yes": "no" );
+    Abc_Print( -2, "\t-t       : toggles optimizing average rather than maximum level [default = %s]\n", pPars->fDoAverage? "yes": "no" );
+    Abc_Print( -2, "\t-n       : toggles computing DSDs of the cut functions [default = %s]\n", pPars->fUseDsd? "yes": "no" );
+    Abc_Print( -2, "\t-c       : toggles computing truth tables in a new way [default = %s]\n", pPars->fUseTtPerm? "yes": "no" );
+    Abc_Print( -2, "\t-v       : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : prints the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandIfif( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern void Abc_NtkPerformIfif( Abc_Ntk_t * pNtk, Ifif_Par_t * pPars );
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    Ifif_Par_t Pars, * pPars = &Pars;
+    int c, fError;
+
+    pPars->nLutSize     =  -1;    // the LUT size
+    pPars->pLutLib      = (If_LibLut_t *)Abc_FrameReadLibLut();       // the LUT library
+    pPars->DelayWire    = (float)0.5;    // wire delay
+    pPars->nDegree      =   0;    // structure degree
+    pPars->fCascade     =   0;    // cascade
+    pPars->fVerbose     =   0;    // verbose
+    pPars->fVeryVerbose =   0;    // verbose
+
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "DNcvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            pPars->DelayWire = atof(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->DelayWire < 0.0 )
+                goto usage;
+            break;
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            pPars->nDegree = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nDegree < 0 )
+                goto usage;
+            break;
+        case 'c':
+            pPars->fCascade ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'w':
+            pPars->fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsLogic(pNtk) )
+    {
+        Abc_Print( -1, "Need mapped network.\n" );
+        return 1;
+    }
+    if ( pPars->pLutLib == NULL )
+    {
+        Abc_Print( -1, "LUT library is not given.\n" );
+        return 1;
+    }
+
+    pPars->nLutSize = Abc_NtkGetFaninMax( pNtk );
+    if ( pPars->nLutSize > pPars->pLutLib->LutMax )
+    {
+        Abc_Print( -1, "The max node size (%d) exceeds the LUT size (%d).\n", pPars->nLutSize, pPars->pLutLib->LutMax );
+        return 1;
+    }
+    if ( pPars->nLutSize < pPars->pLutLib->LutMax )
+        Abc_Print( 0, "Node size (%d) is less than LUT size (%d).\n", pPars->nLutSize, pPars->pLutLib->LutMax );
+    // check delay information
+    fError = 0;
+    for ( c = 0; c < pPars->pLutLib->LutMax; c++ )
+    {
+        pPars->pLutDelays[c] = ( pPars->pLutLib->fVarPinDelays ? pPars->pLutLib->pLutDelays[pPars->pLutLib->LutMax][c] : pPars->pLutLib->pLutDelays[pPars->pLutLib->LutMax][0] );
+        if ( pPars->DelayWire >= pPars->pLutDelays[c] )
+        {
+            fError = 1;
+            printf(" Wire delay (%.2f) exceeds pin+wire delay (%.2f) for pin %d in the LUT library.\n", pPars->DelayWire, pPars->pLutDelays[c], c );
+        }
+    }
+    if ( fError )
+        return 1;
+
+    // call the mapper
+    Abc_NtkPerformIfif( pNtk, pPars );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: ifif [-DNcvwh]\n" );
+    Abc_Print( -2, "\t           technology mapper into N-node K-LUT structures\n" );
+    Abc_Print( -2, "\t           (takes a LUT network and maps it into a delay-optimal network\n" );
+    Abc_Print( -2, "\t            of N-node K-LUT structures using the current LUT library)\n" );
+    Abc_Print( -2, "\t-D float : wire delay (should be less than the LUT delay) [default = %.2f]\n", pPars->DelayWire );
+    Abc_Print( -2, "\t-N num   : degree of the LUT structure [default = %d]\n", pPars->nDegree );
+    Abc_Print( -2, "\t-c       : toggles using LUT cascade vs LUT cluster [default = %s]\n", pPars->fCascade? "cascade": "cluster" );
+    Abc_Print( -2, "\t-v       : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w       : toggles very verbose output [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandDsdSave( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    char * FileName;
+    char ** pArgvNew;
+    int nArgcNew;
+    int c, fSecond = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "bh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'b':
+            fSecond ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    pArgvNew = argv + globalUtilOptind;
+    nArgcNew = argc - globalUtilOptind;
+    if ( nArgcNew != 1 )
+    {
+        Abc_Print( -1, "File name is not given on the command line.\n" );
+        return 1;
+    }
+    // get the input file name
+    FileName = (nArgcNew == 1) ? pArgvNew[0] : NULL;
+    if ( fSecond )
+    {
+        if ( !Abc_FrameReadManDsd2() )
+        {
+            Abc_Print( -1, "The DSD manager is not started.\n" );
+            return 1;
+        }
+        If_DsdManSave( (If_DsdMan_t *)Abc_FrameReadManDsd2(), FileName );
+    }
+    else
+    {
+        if ( !Abc_FrameReadManDsd() )
+        {
+            Abc_Print( -1, "The DSD manager is not started.\n" );
+            return 1;
+        }
+        If_DsdManSave( (If_DsdMan_t *)Abc_FrameReadManDsd(), FileName );
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: dsd_save [-bh] <file>\n" );
+    Abc_Print( -2, "\t         saves DSD manager into a file\n");
+    Abc_Print( -2, "\t-b     : toggles processing second manager [default = %s]\n", fSecond? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\t<file> : (optional) file name to write\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandDsdLoad( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    char * FileName, * pTemp;
+    char ** pArgvNew;
+    int c, nArgcNew, fSecond = 0;
+    FILE * pFile;
+    If_DsdMan_t * pDsdMan;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "bh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'b':
+            fSecond ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    pArgvNew = argv + globalUtilOptind;
+    nArgcNew = argc - globalUtilOptind;
+    if ( nArgcNew != 1 )
+    {
+        Abc_Print( -1, "File name is not given on the command line.\n" );
+        return 1;
+    }
+    // get the input file name
+    FileName = pArgvNew[0];
+    // fix the wrong symbol
+    for ( pTemp = FileName; *pTemp; pTemp++ )
+        if ( *pTemp == '>' )
+            *pTemp = '\\';
+    if ( (pFile = fopen( FileName, "r" )) == NULL )
+    {
+        Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
+        if ( (FileName = Extra_FileGetSimilarName( FileName, ".aig", NULL, NULL, NULL, NULL )) )
+            Abc_Print( 1, "Did you mean \"%s\"?", FileName );
+        Abc_Print( 1, "\n" );
+        return 1;
+    }
+    fclose( pFile );
+    if ( fSecond )
+    {
+        Abc_FrameSetManDsd2( NULL );
+        pDsdMan = If_DsdManLoad(FileName);
+        if ( pDsdMan == NULL )
+            return 1;
+        Abc_FrameSetManDsd2( pDsdMan );
+    }
+    else
+    {
+        Abc_FrameSetManDsd( NULL );
+        pDsdMan = If_DsdManLoad(FileName);
+        if ( pDsdMan == NULL )
+            return 1;
+        Abc_FrameSetManDsd( pDsdMan );
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: dsd_load [-bh] <file>\n" );
+    Abc_Print( -2, "\t         loads DSD manager from file\n");
+    Abc_Print( -2, "\t-b     : toggles processing second manager [default = %s]\n", fSecond? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\t<file> : file name to read\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandDsdFree( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    int c, fSecond = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "bh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'b':
+            fSecond ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( fSecond )
+    {
+        if ( !Abc_FrameReadManDsd2() )
+        {
+            Abc_Print( -1, "The DSD manager is not started.\n" );
+            return 0;
+        }
+        Abc_FrameSetManDsd2( NULL );
+    }
+    else
+    {
+        if ( !Abc_FrameReadManDsd() )
+        {
+            Abc_Print( -1, "The DSD manager is not started.\n" );
+            return 0;
+        }
+        Abc_FrameSetManDsd( NULL );
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: dsd_free [-bh]\n" );
+    Abc_Print( -2, "\t         deletes DSD manager\n" );
+    Abc_Print( -2, "\t-b     : toggles processing second manager [default = %s]\n", fSecond? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandDsdPs( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    int c, Number = 0, Support = 0, fOccurs = 0, fTtDump = 0, fSecond = 0, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "NSotbvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            Number = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( Number < 0 )
+                goto usage;
+            break;
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            Support = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( Support < 0 )
+                goto usage;
+            break;
+        case 'o':
+            fOccurs ^= 1;
+            break;
+        case 't':
+            fTtDump ^= 1;
+            break;
+        case 'b':
+            fSecond ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( fSecond )
+    {
+        if ( !Abc_FrameReadManDsd2() )
+        {
+            Abc_Print( -1, "The DSD manager is not started.\n" );
+            return 0;
+        }
+        If_DsdManPrint( (If_DsdMan_t *)Abc_FrameReadManDsd2(), NULL, Number, Support, fOccurs, fTtDump, fVerbose );
+    }
+    else
+    {
+        if ( !Abc_FrameReadManDsd() )
+        {
+            Abc_Print( -1, "The DSD manager is not started.\n" );
+            return 0;
+        }
+        If_DsdManPrint( (If_DsdMan_t *)Abc_FrameReadManDsd(), NULL, Number, Support, fOccurs, fTtDump, fVerbose );
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: dsd_ps [-NS num] [-obvh]\n" );
+    Abc_Print( -2, "\t         prints statistics of the DSD manager\n" );
+    Abc_Print( -2, "\t-N num : show structures whose ID divides by N [default = %d]\n",   Number );
+    Abc_Print( -2, "\t-S num : show structures whose support size is S [default = %d]\n", Support );
+    Abc_Print( -2, "\t-o     : toggles printing occurence distribution [default = %s]\n", fOccurs? "yes": "no" );
+    Abc_Print( -2, "\t-t     : toggles dumping truth tables [default = %s]\n",            fTtDump? "yes": "no" );
+    Abc_Print( -2, "\t-b     : toggles processing second manager [default = %s]\n",       fSecond? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggles verbose output [default = %s]\n",                  fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandDsdMatch( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    char * pStruct = NULL;
+    int c, fVerbose = 0, fFast = 0, fAdd = 0, fSpec = 0, LutSize = 0, nConfls = 10000, nProcs = 1;
+    If_DsdMan_t * pDsdMan = (If_DsdMan_t *)Abc_FrameReadManDsd();
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "KCPSfasvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            LutSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( LutSize < 4 || LutSize > 6 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            nConfls = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            break;
+        case 'P':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-P\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            nProcs = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            break;
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by string.\n" );
+                goto usage;
+            }
+            pStruct = argv[globalUtilOptind];
+            globalUtilOptind++;
+            break;
+        case 'f':
+            fFast ^= 1;
+            break;
+        case 'a':
+            fAdd ^= 1;
+            break;
+        case 's':
+            fSpec ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( !Abc_FrameReadManDsd() )
+    {
+        Abc_Print( -1, "The DSD manager is not started.\n" );
+        return 0;
+    }
+    if ( pStruct )
+    {
+        char * pStructCur = If_DsdManGetCellStr( pDsdMan );
+        if ( pStructCur && strcmp(pStructCur, pStruct) )
+        {
+            Abc_Print( -1, "DSD manager matched with cell %s should be cleaned by \"dsd_filter -m\" before matching with cell %s.\n", pStructCur, pStruct );
+            return 0;
+        }
+        Id_DsdManTuneStr( pDsdMan, pStruct, nConfls, nProcs, fVerbose );
+    }
+    else
+        If_DsdManTune( pDsdMan, LutSize, fFast, fAdd, fSpec, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: dsd_match [-KCP num] [-fasvh] [-S str]\n" );
+    Abc_Print( -2, "\t         matches DSD structures with the given cell\n" );
+    Abc_Print( -2, "\t-K num : LUT size used for tuning [default = %d]\n",        LutSize );
+    Abc_Print( -2, "\t-C num : the maximum number of conflicts [default = %d]\n", nConfls );
+    Abc_Print( -2, "\t-P num : the maximum number of processes [default = %d]\n", nProcs );
+    Abc_Print( -2, "\t-f     : toggles using fast check [default = %s]\n",        fFast? "yes": "no" );
+    Abc_Print( -2, "\t-a     : toggles adding tuning to the current one [default = %s]\n",    fAdd? "yes": "no" );
+    Abc_Print( -2, "\t-s     : toggles using specialized check [default = %s]\n", fSpec? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggles verbose output [default = %s]\n",          fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-S str : string representing programmable cell [default = %s]\n", pStruct ? pStruct : "not used" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandDsdMerge( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    char * FileName, * pTemp;
+    char ** pArgvNew;
+    int c, nArgcNew;
+    FILE * pFile;
+    If_DsdMan_t * pDsdMan;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( !Abc_FrameReadManDsd() )
+    {
+        Abc_Print( -1, "The DSD manager is not started.\n" );
+        return 0;
+    }
+    pArgvNew = argv + globalUtilOptind;
+    nArgcNew = argc - globalUtilOptind;
+    if ( nArgcNew != 1 )
+    {
+        Abc_Print( -1, "File name is not given on the command line.\n" );
+        return 1;
+    }
+    // get the input file name
+    FileName = pArgvNew[0];
+    // fix the wrong symbol
+    for ( pTemp = FileName; *pTemp; pTemp++ )
+        if ( *pTemp == '>' )
+            *pTemp = '\\';
+    if ( (pFile = fopen( FileName, "r" )) == NULL )
+    {
+        Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
+        if ( (FileName = Extra_FileGetSimilarName( FileName, ".aig", NULL, NULL, NULL, NULL )) )
+            Abc_Print( 1, "Did you mean \"%s\"?", FileName );
+        Abc_Print( 1, "\n" );
+        return 1;
+    }
+    fclose( pFile );
+    pDsdMan = If_DsdManLoad(FileName);
+    if ( pDsdMan == NULL )
+        return 1;
+    If_DsdManMerge( (If_DsdMan_t *)Abc_FrameReadManDsd(), pDsdMan );
+    If_DsdManFree( pDsdMan, 0 );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: dsd_merge [-h] <file>\n" );
+    Abc_Print( -2, "\t         merges DSD manager from file with the current one\n");
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\t<file> : file name to read\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandDsdFilter( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern void Id_DsdManTuneThresh( If_DsdMan_t * p, int fUnate, int fThresh, int fVerbose );
+    If_DsdMan_t * pDsd = (If_DsdMan_t *)Abc_FrameReadManDsd();
+    int c, nLimit = 0, nLutSize = -1, fCleanOccur = 0, fCleanMarks = 0, fInvMarks = 0, fUnate = 0, fThresh = 0, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "LKomiutvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            nLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            break;
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            nLutSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            break;
+        case 'o':
+            fCleanOccur ^= 1;
+            break;
+        case 'm':
+            fCleanMarks ^= 1;
+            break;
+        case 'i':
+            fInvMarks ^= 1;
+            break;
+        case 'u':
+            fUnate ^= 1;
+            break;
+        case 't':
+            fThresh ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pDsd == NULL )
+    {
+        Abc_Print( -1, "The DSD manager is not started.\n" );
+        return 0;
+    }
+    if ( nLimit > 0 )
+        Abc_FrameSetManDsd( If_DsdManFilter(pDsd, nLimit) );
+    if ( nLutSize >= 0 )
+        If_DsdManSetLutSize( pDsd, nLutSize );
+    if ( fCleanOccur )
+        If_DsdManCleanOccur( pDsd, fVerbose );
+    if ( fCleanMarks )
+        If_DsdManCleanMarks( pDsd, fVerbose );
+    if ( fInvMarks )
+        If_DsdManInvertMarks( pDsd, fVerbose );
+    if ( fUnate )
+        Id_DsdManTuneThresh( pDsd, 1, 0, fVerbose );
+    if ( fThresh )
+        Id_DsdManTuneThresh( pDsd, 0, 1, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: dsd_filter [-LK num] [-omiutvh]\n" );
+    Abc_Print( -2, "\t         filtering structured and modifying parameters of DSD manager\n" );
+    Abc_Print( -2, "\t-L num : remove structures with fewer occurrences that this [default = %d]\n", nLimit );
+    Abc_Print( -2, "\t-K num : new LUT size to set for the DSD manager [default = %d]\n",           nLutSize );
+    Abc_Print( -2, "\t-o     : toggles cleaning occurrence counters [default = %s]\n",              fCleanOccur? "yes": "no" );
+    Abc_Print( -2, "\t-m     : toggles cleaning matching marks [default = %s]\n",                   fCleanMarks? "yes": "no" );
+    Abc_Print( -2, "\t-i     : toggles inverting matching marks [default = %s]\n",                  fInvMarks? "yes": "no" );
+    Abc_Print( -2, "\t-u     : toggles marking unate functions [default = %s]\n",                   fUnate? "yes": "no" );
+    Abc_Print( -2, "\t-t     : toggles marking threshold functions [default = %s]\n",               fThresh? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggles verbose output [default = %s]\n",                            fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandInit( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    Abc_Obj_t * pObj;
+    char * pInitStr = NULL;
+    int fZeros    = 0;
+    int fOnes     = 0;
+    int fRandom   = 0;
+    int fDontCare = 0;
+    int fUseCexCs = 0;
+    int fUseCexNs = 0;
+    int c, i;
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Szordcnh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by a file name.\n" );
+                goto usage;
+            }
+            pInitStr = argv[globalUtilOptind];
+            globalUtilOptind++;
+            break;
+        case 'z':
+            fZeros ^= 1;
+            break;
+        case 'o':
+            fOnes ^= 1;
+            break;
+        case 'r':
+            fRandom ^= 1;
+            break;
+        case 'd':
+            fDontCare ^= 1;
+            break;
+        case 'c':
+            fUseCexCs ^= 1;
+            break;
+        case 'n':
+            fUseCexNs ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( Abc_NtkIsComb(pNtk) )
+    {
+        Abc_Print( -1, "The current network is combinational.\n" );
+        return 0;
+    }
+
+    if ( pInitStr != NULL )
+    {
+        if ( (int)strlen(pInitStr) != Abc_NtkLatchNum(pNtk) )
+        {
+            Abc_Print( -1, "The length of init string (%d) differs from the number of flops (%d).\n", strlen(pInitStr), Abc_NtkLatchNum(pNtk) );
+            return 1;
+        }
+        Abc_NtkForEachLatch( pNtk, pObj, i )
+            if ( pInitStr[i] == '0' )
+                Abc_LatchSetInit0( pObj );
+            else if ( pInitStr[i] == '1' )
+                Abc_LatchSetInit1( pObj );
+            else 
+                Abc_LatchSetInitDc( pObj );
+        return 0;
+    }
+
+    if ( fZeros )
+    {
+        Abc_NtkForEachLatch( pNtk, pObj, i )
+            Abc_LatchSetInit0( pObj );
+    }
+    else if ( fOnes )
+    {
+        Abc_NtkForEachLatch( pNtk, pObj, i )
+            Abc_LatchSetInit1( pObj );
+    }
+    else if ( fRandom )
+    {
+        srand( time(NULL) );
+        Abc_NtkForEachLatch( pNtk, pObj, i )
+            if ( rand() & 1 )
+                Abc_LatchSetInit1( pObj );
+            else
+                Abc_LatchSetInit0( pObj );
+    }
+    else if ( fDontCare )
+    {
+        Abc_NtkForEachLatch( pNtk, pObj, i )
+            Abc_LatchSetInitDc( pObj );
+    }
+    else if ( fUseCexCs || fUseCexNs )
+    {
+        extern Vec_Int_t * Saig_ManReturnFailingState( Aig_Man_t * pMan, Abc_Cex_t * p, int fNextOne );
+        Aig_Man_t * pMan;
+        Vec_Int_t * vFailState;
+        if ( fUseCexCs && fUseCexNs )
+        {
+            Abc_Print( -1, "The two options (-c and -n) are incompatible.\n" );
+            return 0;
+        }
+        if ( !Abc_NtkIsStrash(pNtk) )
+        {
+            Abc_Print( -1, "The current network should be an AIG.\n" );
+            return 0;
+        }
+        if ( pAbc->pCex == NULL )
+        {
+            Abc_Print( -1, "The current CEX is not available.\n" );
+            return 0;
+        }
+        pMan = Abc_NtkToDar( pNtk, 0, 1 );
+        vFailState = Saig_ManReturnFailingState( pMan, pAbc->pCex, fUseCexNs );
+        //Vec_IntPrint( vFailState );
+        Aig_ManStop( pMan );
+        Abc_NtkForEachLatch( pNtk, pObj, i )
+            if ( Vec_IntEntry( vFailState, i ) )
+                Abc_LatchSetInit1( pObj );
+            else
+                Abc_LatchSetInit0( pObj );
+        Vec_IntFree( vFailState );
+    }
+    else
+        Abc_Print( -1, "The initial states remain unchanged.\n" );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: init [-zordcnh] [-S <init_string>]\n" );
+    Abc_Print( -2, "\t         resets initial states of all latches\n" );
+    Abc_Print( -2, "\t-z     : set zeros initial states [default = %s]\n", fZeros? "yes": "no" );
+    Abc_Print( -2, "\t-o     : set ones initial states [default = %s]\n", fOnes? "yes": "no" );
+    Abc_Print( -2, "\t-d     : set don't-care initial states [default = %s]\n", fDontCare? "yes": "no" );
+    Abc_Print( -2, "\t-r     : set random initial states [default = %s]\n", fRandom? "yes": "no" );
+    Abc_Print( -2, "\t-c     : set failure current state from the CEX (and run \"zero\") [default = %s]\n", fUseCexCs? "yes": "no" );
+    Abc_Print( -2, "\t-n     : set next state after failure from the CEX (and run \"zero\") [default = %s]\n", fUseCexNs? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\t-S str : (optional) initial state  [default = unused]\n" );
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandZero( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c;
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( Abc_NtkIsComb(pNtk) )
+    {
+        Abc_Print( -1, "The current network is combinational.\n" );
+        return 0;
+    }
+
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for AIGs.\n" );
+        return 0;
+    }
+
+    // get the new network
+    pNtkRes = Abc_NtkRestrashZero( pNtk, 0 );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Converting to sequential AIG has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: zero [-h]\n" );
+    Abc_Print( -2, "\t        converts latches to have const-0 initial value\n" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandUndc( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c, fUseCex = 0;
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'c':
+            fUseCex ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( fUseCex )
+    {
+        char * pInit; 
+        Abc_Cex_t * pTemp;
+        int k, nFlopsX = 0;
+        if ( pAbc->pCex == NULL )
+        {
+            Abc_Print( -1, "Current CEX is not available.\n" );
+            return 1;
+        }
+        pInit = Abc_NtkCollectLatchValuesStr( pAbc->pNtkCur );
+        // count the number of X-valued flops
+        for ( k = 0; k < Abc_NtkLatchNum(pAbc->pNtkCur); k++ )
+            nFlopsX += (int)(pInit[k] == 'x');
+        // compare this value
+        if ( Abc_NtkPiNum(pNtk) + nFlopsX != pAbc->pCex->nPis )
+        {
+            Abc_Print( -1, "The number of PIs (%d) plus X-valued flops (%d) in the original network does not match the number of PIs in the current CEX (%d).\n", 
+                Abc_NtkPiNum(pNtk), Abc_NtkLatchNum(pNtk), pAbc->pCex->nPis );
+            return 1;
+        }
+        pAbc->pCex = Abc_CexTransformUndc( pTemp = pAbc->pCex, pInit );
+        assert( pAbc->pCex->nPis == Abc_NtkPiNum(pAbc->pNtkCur) );
+        assert( pAbc->pCex->nRegs == Abc_NtkLatchNum(pAbc->pNtkCur) );
+        Abc_CexFree( pTemp );
+        ABC_FREE( pInit );
+        return 0;
+    }
+
+    if ( Abc_NtkIsComb(pNtk) )
+    {
+        Abc_Print( -1, "The current network is combinational.\n" );
+        return 0;
+    }
+
+    if ( !Abc_NtkIsLogic(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for logic networks.\n" );
+        return 0;
+    }
+
+    // get the new network
+    Abc_NtkConvertDcLatches( pNtk );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: undc [-ch]\n" );
+    Abc_Print( -2, "\t        converts latches with DC init values into free PIs\n" );
+    Abc_Print( -2, "\t-c    : toggles transforming CEX after \"logic;undc;st;zero\" [default = %s]\n", fUseCex? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandOneHot( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c;
+    extern Abc_Ntk_t * Abc_NtkConvertOnehot( Abc_Ntk_t * pNtk );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( Abc_NtkIsComb(pNtk) )
+    {
+        Abc_Print( -1, "The current network is combinational.\n" );
+        return 0;
+    }
+    if ( !Abc_NtkIsLogic(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for logic networks.\n" );
+        return 0;
+    }
+    // get the new network
+    pNtkRes = Abc_NtkConvertOnehot( pNtk );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Converting to one-hot encoding has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: onehot [-h]\n" );
+    Abc_Print( -2, "\t        converts natural encoding into one-hot encoding\n" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandPipe( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int nLatches;
+    extern void Abc_NtkLatchPipe( Abc_Ntk_t * pNtk, int nLatches );
+    // set defaults
+    nLatches = 5;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Lh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            nLatches = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLatches < 0 )
+                goto usage;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( Abc_NtkIsComb(pNtk) )
+    {
+        Abc_Print( -1, "The current network is combinational.\n" );
+        return 0;
+    }
+
+    // update the network
+    Abc_NtkLatchPipe( pNtk, nLatches );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: pipe [-L num] [-h]\n" );
+    Abc_Print( -2, "\t         inserts the given number of latches at each PI for pipelining\n" );
+    Abc_Print( -2, "\t-L num : the number of latches to insert [default = %d]\n", nLatches );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandSeq( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c;
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( Abc_NtkLatchNum(pNtk) == 0 )
+    {
+        Abc_Print( -1, "The network has no latches.\n" );
+        return 0;
+    }
+
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Conversion to sequential AIG works only for combinational AIGs (run \"strash\").\n" );
+        return 1;
+    }
+
+    // get the new network
+//    pNtkRes = Abc_NtkAigToSeq( pNtk );
+    pNtkRes = NULL;
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Converting to sequential AIG has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: seq [-h]\n" );
+    Abc_Print( -2, "\t        converts AIG into sequential AIG\n" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandUnseq( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c;
+    int fShare;
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    fShare = 1;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "sh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 's':
+            fShare ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+/*
+    if ( !Abc_NtkIsSeq(pNtk) )
+    {
+        Abc_Print( -1, "Conversion to combinational AIG works only for sequential AIG (run \"seq\").\n" );
+        return 1;
+    }
+*/
+    // share the latches on the fanout edges
+//    if ( fShare )
+//        Seq_NtkShareFanouts(pNtk);
+
+    // get the new network
+//    pNtkRes = Abc_NtkSeqToLogicSop( pNtk );
+    pNtkRes = NULL;
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Converting sequential AIG into an SOP logic network has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: unseq [-sh]\n" );
+    Abc_Print( -2, "\t        converts sequential AIG into an SOP logic network\n" );
+    Abc_Print( -2, "\t-s    : toggle sharing latches [default = %s]\n", fShare? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c, nMaxIters;
+    int fForward;
+    int fBackward;
+    int fOneStep;
+    int fVerbose;
+    int Mode;
+    int nDelayLim;
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    Mode      =  5;
+    nDelayLim =  0;
+    fForward  =  0;
+    fBackward =  0;
+    fOneStep  =  0;
+    fVerbose  =  0;
+    nMaxIters = 15;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "MDfbsvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'M':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-M\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            Mode = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( Mode < 0 )
+                goto usage;
+            break;
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            nDelayLim = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nDelayLim < 0 )
+                goto usage;
+            break;
+        case 'f':
+            fForward ^= 1;
+            break;
+        case 'b':
+            fBackward ^= 1;
+            break;
+        case 's':
+            fOneStep ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( fForward && fBackward )
+    {
+        Abc_Print( -1, "Only one switch \"-f\" or \"-b\" can be selected at a time.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkLatchNum(pNtk) )
+    {
+//        Abc_Print( -1, "The network has no latches. Retiming is not performed.\n" );
+        return 0;
+    }
+
+    if ( Mode < 0 || Mode > 6 )
+    {
+        Abc_Print( -1, "The mode (%d) is incorrect. Retiming is not performed.\n", Mode );
+        return 0;
+    }
+
+    if ( Abc_NtkIsStrash(pNtk) )
+    {
+        if ( Abc_NtkGetChoiceNum(pNtk) )
+        {
+            Abc_Print( -1, "Retiming with choice nodes is not implemented.\n" );
+            return 0;
+        }
+        // convert the network into an SOP network
+        pNtkRes = Abc_NtkToLogic( pNtk );
+        // perform the retiming
+        Abc_NtkRetime( pNtkRes, Mode, nDelayLim, fForward, fBackward, fOneStep, fVerbose );
+        // replace the current network
+        Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+        return 0;
+    }
+
+    // get the network in the SOP form
+    if ( !Abc_NtkToSop(pNtk, 0) )
+    {
+        Abc_Print( -1, "Converting to SOPs has failed.\n" );
+        return 0;
+    }
+
+    if ( !Abc_NtkIsLogic(pNtk) )
+    {
+        Abc_Print( -1, "The network is not a logic network. Retiming is not performed.\n" );
+        return 0;
+    }
+
+    // perform the retiming
+    Abc_NtkRetime( pNtk, Mode, nDelayLim, fForward, fBackward, fOneStep, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: retime [-MD num] [-fbvh]\n" );
+    Abc_Print( -2, "\t         retimes the current network using one of the algorithms:\n" );
+    Abc_Print( -2, "\t             1: most forward retiming\n" );
+    Abc_Print( -2, "\t             2: most backward retiming\n" );
+    Abc_Print( -2, "\t             3: forward and backward min-area retiming\n" );
+    Abc_Print( -2, "\t             4: forward and backward min-delay retiming\n" );
+    Abc_Print( -2, "\t             5: mode 3 followed by mode 4\n" );
+    Abc_Print( -2, "\t             6: Pan's optimum-delay retiming using binary search\n" );
+    Abc_Print( -2, "\t-M num : the retiming algorithm to use [default = %d]\n", Mode );
+    Abc_Print( -2, "\t-D num : the minimum delay target (0=unused) [default = %d]\n", nDelayLim );
+    Abc_Print( -2, "\t-f     : enables forward-only retiming in modes 3,4,5 [default = %s]\n", fForward? "yes": "no" );
+    Abc_Print( -2, "\t-b     : enables backward-only retiming in modes 3,4,5 [default = %s]\n", fBackward? "yes": "no" );
+    Abc_Print( -2, "\t-s     : enables retiming one step only in mode 4 [default = %s]\n", fOneStep? "yes": "no" );
+    Abc_Print( -2, "\t-v     : enables verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+//    Abc_Print( -2, "\t-I num : max number of iterations of l-value computation [default = %d]\n", nMaxIters );
+//    Abc_Print( -2, "\t-f     : toggle forward retiming (for AIGs) [default = %s]\n", fForward? "yes": "no" );
+//    Abc_Print( -2, "\t-b     : toggle backward retiming (for AIGs) [default = %s]\n", fBackward? "yes": "no" );
+//    Abc_Print( -2, "\t-i     : toggle computation of initial state [default = %s]\n", fInitial? "yes": "no" );
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandDRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int fMinArea;
+    int fForwardOnly;
+    int fBackwardOnly;
+    int fInitial;
+    int nStepsMax;
+    int fFastAlgo;
+    int fVerbose;
+    int c, nMaxIters;
+    extern Abc_Ntk_t * Abc_NtkDarRetime( Abc_Ntk_t * pNtk, int nStepsMax, int fVerbose );
+    extern Abc_Ntk_t * Abc_NtkDarRetimeF( Abc_Ntk_t * pNtk, int nStepsMax, int fVerbose );
+    extern Abc_Ntk_t * Abc_NtkDarRetimeMinArea( Abc_Ntk_t * pNtk, int nMaxIters, int fForwardOnly, int fBackwardOnly, int fInitial, int fVerbose );
+    extern Abc_Ntk_t * Abc_NtkDarRetimeMostFwd( Abc_Ntk_t * pNtk, int nMaxIters, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    fMinArea  = 1;
+    fForwardOnly = 0;
+    fBackwardOnly = 0;
+    fInitial = 1;
+    nStepsMax = 100000;
+    fFastAlgo = 0;
+    nMaxIters = 20;
+    fVerbose  = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "NSmfbiavh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            nMaxIters = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nMaxIters < 0 )
+                goto usage;
+            break;
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            nStepsMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nStepsMax < 0 )
+                goto usage;
+            break;
+        case 'm':
+            fMinArea ^= 1;
+            break;
+        case 'f':
+            fForwardOnly ^= 1;
+            break;
+        case 'b':
+            fBackwardOnly ^= 1;
+            break;
+        case 'i':
+            fInitial ^= 1;
+            break;
+        case 'a':
+            fFastAlgo ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkLatchNum(pNtk) )
+    {
+//        Abc_Print( -1, "The network has no latches. Retiming is not performed.\n" );
+        return 0;
+    }
+
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for structrally hashed networks. Run \"st\".\n" );
+        return 0;
+    }
+
+    // perform the retiming
+    if ( fMinArea )
+        pNtkRes = Abc_NtkDarRetimeMinArea( pNtk, nMaxIters, fForwardOnly, fBackwardOnly, fInitial, fVerbose );
+    else if ( fFastAlgo )
+        pNtkRes = Abc_NtkDarRetime( pNtk, nStepsMax, fVerbose );
+    else
+//        pNtkRes = Abc_NtkDarRetimeF( pNtk, nStepsMax, fVerbose );
+        pNtkRes = Abc_NtkDarRetimeMostFwd( pNtk, nMaxIters, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Retiming has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: dretime [-NS num] [-mfbiavh]\n" );
+    Abc_Print( -2, "\t         new implementation of min-area (or most-forward) retiming\n" );
+    Abc_Print( -2, "\t-m     : toggle min-area retiming and most-forward retiming [default = %s]\n", fMinArea? "min-area": "most-fwd" );
+    Abc_Print( -2, "\t-f     : enables forward-only retiming [default = %s]\n", fForwardOnly? "yes": "no" );
+    Abc_Print( -2, "\t-b     : enables backward-only retiming [default = %s]\n", fBackwardOnly? "yes": "no" );
+    Abc_Print( -2, "\t-i     : enables init state computation [default = %s]\n", fInitial? "yes": "no" );
+    Abc_Print( -2, "\t-N num : the max number of one-frame iterations to perform [default = %d]\n", nMaxIters );
+    Abc_Print( -2, "\t-S num : the max number of forward retiming steps to perform [default = %d]\n", nStepsMax );
+    Abc_Print( -2, "\t-a     : enables a fast most-forward algorithm [default = %s]\n", fFastAlgo? "yes": "no" );
+    Abc_Print( -2, "\t-v     : enables verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandFlowRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c, nMaxIters;
+    int fForward;
+    int fBackward;
+    int fVerbose;
+    int fComputeInit, fGuaranteeInit, fBlockConst;
+    int fFastButConservative;
+    int maxDelay;
+
+    if ( argc == 2 && !strcmp(argv[1], "-h") )
+    {
+        Abc_Print( -2, "The fretime command is temporarily disabled.\n" );
+        return 1;
+    }
+
+    Abc_Print( -1, "This command is temporarily disabled.\n" );
+    return 0;
+//    extern Abc_Ntk_t* Abc_FlowRetime_MinReg( Abc_Ntk_t * pNtk, int fVerbose,
+//                                             int fComputeInit, int fGuaranteeInit, int fBlockConst,
+//                                             int fForward, int fBackward, int nMaxIters,
+//                                             int maxDelay, int fFastButConservative);
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    fForward  =  0;
+    fFastButConservative = 0;
+    fBackward =  0;
+    fComputeInit =  1;
+    fGuaranteeInit =  0;
+    fVerbose  =  0;
+    fBlockConst  =  0;
+    nMaxIters = 999;
+    maxDelay  = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "MDfcgbkivh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'M':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-M\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            nMaxIters = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nMaxIters < 0 )
+                goto usage;
+            break;
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            maxDelay = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( maxDelay < 0 )
+                goto usage;
+           break;
+        case 'f':
+            fForward ^= 1;
+            break;
+        case 'c':
+            fFastButConservative ^= 1;
+            break;
+        case 'i':
+            fComputeInit ^= 1;
+            break;
+        case 'b':
+            fBackward ^= 1;
+            break;
+        case 'g':
+            fGuaranteeInit ^= 1;
+            break;
+        case 'k':
+            fBlockConst ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( fForward && fBackward )
+    {
+        Abc_Print( -1, "Only one switch \"-f\" or \"-b\" can be selected at a time.\n" );
+        return 1;
+    }
+
+    if ( fGuaranteeInit && !fComputeInit )
+    {
+      Abc_Print( -1, "Initial state guarantee (-g) requires initial state computation (-i).\n" );
+      return 1;
+    }
+
+    if ( !Abc_NtkLatchNum(pNtk) )
+    {
+//        Abc_Print( -1, "The network has no latches. Retiming is not performed.\n" );
+        return 0;
+    }
+
+    if ( Abc_NtkGetChoiceNum(pNtk) )
+      {
+        Abc_Print( -1, "Retiming with choice nodes is not implemented.\n" );
+        return 0;
+      }
+
+    // perform the retiming
+//    pNtkRes = Abc_FlowRetime_MinReg( pNtk, fVerbose, fComputeInit,
+//                                     fGuaranteeInit, fBlockConst,
+//                                     fForward, fBackward,
+//                                     nMaxIters, maxDelay, fFastButConservative );
+
+    if (pNtkRes != pNtk)
+      Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: fretime [-M num] [-D num] [-fbvih]\n" );
+    Abc_Print( -2, "\t         retimes the current network using flow-based algorithm\n" );
+    Abc_Print( -2, "\t-M num : the maximum number of iterations [default = %d]\n", nMaxIters );
+    Abc_Print( -2, "\t-D num : the maximum delay [default = none]\n" );
+    Abc_Print( -2, "\t-i     : enables init state computation [default = %s]\n", fComputeInit? "yes": "no" );
+    Abc_Print( -2, "\t-k     : blocks retiming over const nodes [default = %s]\n", fBlockConst? "yes": "no" );
+    Abc_Print( -2, "\t-g     : guarantees init state computation [default = %s]\n", fGuaranteeInit? "yes": "no" );
+    Abc_Print( -2, "\t-c     : very fast (but conserv.) delay constraints [default = %s]\n", fFastButConservative? "yes": "no" );
+    Abc_Print( -2, "\t-f     : enables forward-only retiming  [default = %s]\n", fForward? "yes": "no" );
+    Abc_Print( -2, "\t-b     : enables backward-only retiming [default = %s]\n", fBackward? "yes": "no" );
+    Abc_Print( -2, "\t-v     : enables verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandCRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c;
+    int fVerbose;
+    extern Abc_Ntk_t * Abc_NtkCRetime( Abc_Ntk_t * pNtk, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    fVerbose    = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Only works for logic networks.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkLatchNum(pNtk) )
+    {
+        Abc_Print( -1, "The network is combinational.\n" );
+        return 0;
+    }
+    // modify the current network
+    pNtkRes = Abc_NtkCRetime( pNtk, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Sequential cleanup has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: cretime [-vh]\n" );
+    Abc_Print( -2, "\t         performs most-forward retiming with equiv classes\n" );
+    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandSeqFpga( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkNew, * pNtkRes;
+    int c, nMaxIters;
+    int fVerbose;
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    nMaxIters = 15;
+    fVerbose  =  0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Ivh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'I':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-I\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            nMaxIters = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nMaxIters < 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( Abc_NtkHasAig(pNtk) )
+    {
+/*
+        // quit if there are choice nodes
+        if ( Abc_NtkGetChoiceNum(pNtk) )
+        {
+            Abc_Print( -1, "Currently cannot map/retime networks with choice nodes.\n" );
+            return 0;
+        }
+*/
+//        if ( Abc_NtkIsStrash(pNtk) )
+//            pNtkNew = Abc_NtkAigToSeq(pNtk);
+//        else
+//            pNtkNew = Abc_NtkDup(pNtk);
+        pNtkNew = NULL;
+    }
+    else
+    {
+        // strash and balance the network
+        pNtkNew = Abc_NtkStrash( pNtk, 0, 0, 0 );
+        if ( pNtkNew == NULL )
+        {
+            Abc_Print( -1, "Strashing before FPGA mapping/retiming has failed.\n" );
+            return 1;
+        }
+
+        pNtkNew = Abc_NtkBalance( pNtkRes = pNtkNew, 0, 0, 1 );
+        Abc_NtkDelete( pNtkRes );
+        if ( pNtkNew == NULL )
+        {
+            Abc_Print( -1, "Balancing before FPGA mapping has failed.\n" );
+            return 1;
+        }
+
+        // convert into a sequential AIG
+//        pNtkNew = Abc_NtkAigToSeq( pNtkRes = pNtkNew );
+        pNtkNew = NULL;
+        Abc_NtkDelete( pNtkRes );
+        if ( pNtkNew == NULL )
+        {
+            Abc_Print( -1, "Converting into a seq AIG before FPGA mapping/retiming has failed.\n" );
+            return 1;
+        }
+
+        Abc_Print( 1, "The network was strashed and balanced before FPGA mapping/retiming.\n" );
+    }
+
+    // get the new network
+//    pNtkRes = Seq_NtkFpgaMapRetime( pNtkNew, nMaxIters, fVerbose );
+    pNtkRes = NULL;
+    if ( pNtkRes == NULL )
+    {
+//        Abc_Print( -1, "Sequential FPGA mapping has failed.\n" );
+        Abc_NtkDelete( pNtkNew );
+        return 0;
+    }
+    Abc_NtkDelete( pNtkNew );
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: sfpga [-I num] [-vh]\n" );
+    Abc_Print( -2, "\t         performs integrated sequential FPGA mapping/retiming\n" );
+    Abc_Print( -2, "\t-I num : max number of iterations of l-value computation [default = %d]\n", nMaxIters );
+    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandSeqMap( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkNew, * pNtkRes;
+    int c, nMaxIters;
+    int fVerbose;
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    nMaxIters = 15;
+    fVerbose  =  0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Ivh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'I':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-I\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            nMaxIters = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nMaxIters < 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( Abc_NtkHasAig(pNtk) )
+    {
+/*
+        // quit if there are choice nodes
+        if ( Abc_NtkGetChoiceNum(pNtk) )
+        {
+            Abc_Print( -1, "Currently cannot map/retime networks with choice nodes.\n" );
+            return 0;
+        }
+*/
+//        if ( Abc_NtkIsStrash(pNtk) )
+//            pNtkNew = Abc_NtkAigToSeq(pNtk);
+//        else
+//            pNtkNew = Abc_NtkDup(pNtk);
+        pNtkNew = NULL;
+    }
+    else
+    {
+        // strash and balance the network
+        pNtkNew = Abc_NtkStrash( pNtk, 0, 0, 0 );
+        if ( pNtkNew == NULL )
+        {
+            Abc_Print( -1, "Strashing before SC mapping/retiming has failed.\n" );
+            return 1;
+        }
+
+        pNtkNew = Abc_NtkBalance( pNtkRes = pNtkNew, 0, 0, 1 );
+        Abc_NtkDelete( pNtkRes );
+        if ( pNtkNew == NULL )
+        {
+            Abc_Print( -1, "Balancing before SC mapping/retiming has failed.\n" );
+            return 1;
+        }
+
+        // convert into a sequential AIG
+//        pNtkNew = Abc_NtkAigToSeq( pNtkRes = pNtkNew );
+        pNtkNew = NULL;
+        Abc_NtkDelete( pNtkRes );
+        if ( pNtkNew == NULL )
+        {
+            Abc_Print( -1, "Converting into a seq AIG before SC mapping/retiming has failed.\n" );
+            return 1;
+        }
+
+        Abc_Print( -1, "The network was strashed and balanced before SC mapping/retiming.\n" );
+    }
+
+    // get the new network
+//    pNtkRes = Seq_MapRetime( pNtkNew, nMaxIters, fVerbose );
+    pNtkRes = NULL;
+    if ( pNtkRes == NULL )
+    {
+//        Abc_Print( -1, "Sequential FPGA mapping has failed.\n" );
+        Abc_NtkDelete( pNtkNew );
+        return 0;
+    }
+    Abc_NtkDelete( pNtkNew );
+
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: smap [-I num] [-vh]\n" );
+    Abc_Print( -2, "\t         performs integrated sequential standard-cell mapping/retiming\n" );
+    Abc_Print( -2, "\t-I num : max number of iterations of l-value computation [default = %d]\n", nMaxIters );
+    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandSeqSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    Fra_Ssw_t Pars, * pPars = &Pars;
+    int c;
+    extern Abc_Ntk_t * Abc_NtkDarSeqSweep( Abc_Ntk_t * pNtk, Fra_Ssw_t * pPars );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    pPars->nPartSize  = 0;
+    pPars->nOverSize  = 0;
+    pPars->nFramesP   = 0;
+    pPars->nFramesK   = 1;
+    pPars->nMaxImps   = 5000;
+    pPars->nMaxLevs   = 0;
+    pPars->fUseImps   = 0;
+    pPars->fRewrite   = 0;
+    pPars->fFraiging  = 0;
+    pPars->fLatchCorr = 0;
+    pPars->fWriteImps = 0;
+    pPars->fUse1Hot   = 0;
+    pPars->fVerbose   = 0;
+    pPars->TimeLimit  = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "PQNFILirfletvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'P':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nPartSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nPartSize < 2 )
+                goto usage;
+            break;
+        case 'Q':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-Q\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nOverSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nOverSize < 0 )
+                goto usage;
+            break;
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nFramesP = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nFramesP < 0 )
+                goto usage;
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nFramesK = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nFramesK <= 0 )
+                goto usage;
+            break;
+        case 'I':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nMaxImps = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nMaxImps <= 0 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nMaxLevs = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nMaxLevs <= 0 )
+                goto usage;
+            break;
+        case 'i':
+            pPars->fUseImps ^= 1;
+            break;
+        case 'r':
+            pPars->fRewrite ^= 1;
+            break;
+        case 'f':
+            pPars->fFraiging ^= 1;
+            break;
+        case 'l':
+            pPars->fLatchCorr ^= 1;
+            break;
+        case 'e':
+            pPars->fWriteImps ^= 1;
+            break;
+        case 't':
+            pPars->fUse1Hot ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( Abc_NtkIsComb(pNtk) )
+    {
+        Abc_Print( -1, "The network is combinational (run \"fraig\" or \"fraig_sweep\").\n" );
+        return 0;
+    }
+
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for structrally hashed networks. Run \"st\".\n" );
+        return 0;
+    }
+
+    if ( pPars->nFramesK > 1 && pPars->fUse1Hot )
+    {
+        Abc_Print( -1, "Currrently can only use one-hotness for simple induction (K=1).\n" );
+        return 0;
+    }
+
+    if ( pPars->nFramesP && pPars->fUse1Hot )
+    {
+        Abc_Print( -1, "Currrently can only use one-hotness without prefix.\n" );
+        return 0;
+    }
+
+    // get the new network
+    pNtkRes = Abc_NtkDarSeqSweep( pNtk, pPars );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Sequential sweeping has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: ssweep [-PQNFL <num>] [-lrfetvh]\n" );
+    Abc_Print( -2, "\t         performs sequential sweep using K-step induction\n" );
+    Abc_Print( -2, "\t-P num : max partition size (0 = no partitioning) [default = %d]\n", pPars->nPartSize );
+    Abc_Print( -2, "\t-Q num : partition overlap (0 = no overlap) [default = %d]\n", pPars->nOverSize );
+    Abc_Print( -2, "\t-N num : number of time frames to use as the prefix [default = %d]\n", pPars->nFramesP );
+    Abc_Print( -2, "\t-F num : number of time frames for induction (1=simple) [default = %d]\n", pPars->nFramesK );
+    Abc_Print( -2, "\t-L num : max number of levels to consider (0=all) [default = %d]\n", pPars->nMaxLevs );
+//    Abc_Print( -2, "\t-I num : max number of implications to consider [default = %d]\n", pPars->nMaxImps );
+//    Abc_Print( -2, "\t-i     : toggle using implications [default = %s]\n", pPars->fUseImps? "yes": "no" );
+    Abc_Print( -2, "\t-l     : toggle latch correspondence only [default = %s]\n", pPars->fLatchCorr? "yes": "no" );
+    Abc_Print( -2, "\t-r     : toggle AIG rewriting [default = %s]\n", pPars->fRewrite? "yes": "no" );
+    Abc_Print( -2, "\t-f     : toggle fraiging (combinational SAT sweeping) [default = %s]\n", pPars->fFraiging? "yes": "no" );
+    Abc_Print( -2, "\t-e     : toggle writing implications as assertions [default = %s]\n", pPars->fWriteImps? "yes": "no" );
+    Abc_Print( -2, "\t-t     : toggle using one-hotness conditions [default = %s]\n", pPars->fUse1Hot? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandSeqSweep2( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    Ssw_Pars_t Pars, * pPars = &Pars;
+    int nConstrs = 0;
+    int c;
+    extern Abc_Ntk_t * Abc_NtkDarSeqSweep2( Abc_Ntk_t * pNtk, Ssw_Pars_t * pPars );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    Ssw_ManSetDefaultParams( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "PQFCLSIVMNcmplkofdseqvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'P':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nPartSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nPartSize < 2 )
+                goto usage;
+            break;
+        case 'Q':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-Q\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nOverSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nOverSize < 0 )
+                goto usage;
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nFramesK = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nFramesK <= 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nBTLimit <= 0 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nMaxLevs = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nMaxLevs <= 0 )
+                goto usage;
+            break;
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nFramesAddSim = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nFramesAddSim < 0 )
+                goto usage;
+            break;
+        case 'I':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nItersStop = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nItersStop < 0 )
+                goto usage;
+            break;
+        case 'V':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-V\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nSatVarMax2 = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nSatVarMax2 < 0 )
+                goto usage;
+            break;
+        case 'M':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nRecycleCalls2 = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nRecycleCalls2 < 0 )
+                goto usage;
+            break;
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nConstrs = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nConstrs < 0 )
+                goto usage;
+            break;
+        case 'c':
+            pPars->fConstrs ^= 1;
+            break;
+        case 'm':
+            pPars->fMergeFull ^= 1;
+            break;
+        case 'p':
+            pPars->fPolarFlip ^= 1;
+            break;
+        case 'l':
+            pPars->fLatchCorr ^= 1;
+            break;
+        case 'k':
+            pPars->fConstCorr ^= 1;
+            break;
+        case 'o':
+            pPars->fOutputCorr ^= 1;
+            break;
+        case 'f':
+            pPars->fSemiFormal ^= 1;
+            break;
+        case 'd':
+            pPars->fDynamic ^= 1;
+            break;
+        case 's':
+            pPars->fLocalSim ^= 1;
+            break;
+        case 'e':
+            pPars->fEquivDump ^= 1;
+            break;
+        case 'q':
+            pPars->fStopWhenGone ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'w':
+            pPars->fFlopVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( Abc_NtkIsComb(pNtk) )
+    {
+        Abc_Print( -1, "The network is combinational (run \"fraig\" or \"fraig_sweep\").\n" );
+        return 0;
+    }
+
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for structrally hashed networks. Run \"st\".\n" );
+        return 0;
+    }
+
+    if ( Abc_NtkPiNum(pNtk) == 0 )
+    {
+        Abc_Print( 0, "This command works only for designs with primary inputs.\n" );
+        return 0;
+    }
+
+    // if constraints are to be used, network should have no constraints
+    if ( nConstrs > 0 )
+    {
+        if ( Abc_NtkConstrNum(pNtk) > 0 )
+        {
+            Abc_Print( -1, "The network already has %d constraints.\n", Abc_NtkConstrNum(pNtk) );
+            return 0;
+        }
+        else
+        {
+            Abc_Print( 0, "Setting the number of constraints to be %d.\n", nConstrs );
+            pNtk->nConstrs = nConstrs;
+        }
+    }
+
+    if ( pPars->fConstrs )
+    {
+        if ( Abc_NtkConstrNum(pNtk) > 0 )
+            Abc_Print( 0, "Performing scorr with %d constraints.\n", Abc_NtkConstrNum(pNtk) );
+        else
+            Abc_Print( 0, "Performing constraint-based scorr without constraints.\n" );
+    }
+
+    // get the new network
+    pNtkRes = Abc_NtkDarSeqSweep2( pNtk, pPars );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Sequential sweeping has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: scorr [-PQFCLSIVMN <num>] [-cmplkodseqvwh]\n" );
+    Abc_Print( -2, "\t         performs sequential sweep using K-step induction\n" );
+    Abc_Print( -2, "\t-P num : max partition size (0 = no partitioning) [default = %d]\n", pPars->nPartSize );
+    Abc_Print( -2, "\t-Q num : partition overlap (0 = no overlap) [default = %d]\n", pPars->nOverSize );
+    Abc_Print( -2, "\t-F num : number of time frames for induction (1=simple) [default = %d]\n", pPars->nFramesK );
+    Abc_Print( -2, "\t-C num : max number of conflicts at a node (0=inifinite) [default = %d]\n", pPars->nBTLimit );
+    Abc_Print( -2, "\t-L num : max number of levels to consider (0=all) [default = %d]\n", pPars->nMaxLevs );
+    Abc_Print( -2, "\t-N num : number of last POs treated as constraints (0=none) [default = %d]\n", pPars->fConstrs );
+    Abc_Print( -2, "\t-S num : additional simulation frames for c-examples (0=none) [default = %d]\n", pPars->nFramesAddSim );
+    Abc_Print( -2, "\t-I num : iteration number to stop and output SR-model (-1=none) [default = %d]\n", pPars->nItersStop );
+    Abc_Print( -2, "\t-V num : min var num needed to recycle the SAT solver [default = %d]\n", pPars->nSatVarMax2 );
+    Abc_Print( -2, "\t-M num : min call num needed to recycle the SAT solver [default = %d]\n", pPars->nRecycleCalls2 );
+    Abc_Print( -2, "\t-N num : set last <num> POs to be constraints (use with -c) [default = %d]\n", nConstrs );
+    Abc_Print( -2, "\t-c     : toggle using explicit constraints [default = %s]\n", pPars->fConstrs? "yes": "no" );
+    Abc_Print( -2, "\t-m     : toggle full merge if constraints are present [default = %s]\n", pPars->fMergeFull? "yes": "no" );
+    Abc_Print( -2, "\t-p     : toggle aligning polarity of SAT variables [default = %s]\n", pPars->fPolarFlip? "yes": "no" );
+    Abc_Print( -2, "\t-l     : toggle doing latch correspondence [default = %s]\n", pPars->fLatchCorr? "yes": "no" );
+    Abc_Print( -2, "\t-k     : toggle doing constant correspondence [default = %s]\n", pPars->fConstCorr? "yes": "no" );
+    Abc_Print( -2, "\t-o     : toggle doing \'PO correspondence\' [default = %s]\n", pPars->fOutputCorr? "yes": "no" );
+//    Abc_Print( -2, "\t-f     : toggle filtering using iterative BMC [default = %s]\n", pPars->fSemiFormal? "yes": "no" );
+    Abc_Print( -2, "\t-d     : toggle dynamic addition of constraints [default = %s]\n", pPars->fDynamic? "yes": "no" );
+    Abc_Print( -2, "\t-s     : toggle local simulation in the cone of influence [default = %s]\n", pPars->fLocalSim? "yes": "no" );
+    Abc_Print( -2, "\t-e     : toggle dumping disproved internal equivalences [default = %s]\n", pPars->fEquivDump? "yes": "no" );
+    Abc_Print( -2, "\t-q     : toggle quitting when PO is not a constant candidate [default = %s]\n", pPars->fStopWhenGone? "yes": "no" );
+    Abc_Print( -2, "\t-w     : toggle printout of flop equivalences [default = %s]\n", pPars->fFlopVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandTestSeqSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    char * pFileName;
+    Fra_Ssw_t Pars, * pPars = &Pars;
+    int c;
+//    extern Abc_Ntk_t * Abc_NtkDarSeqSweep( Abc_Ntk_t * pNtk, Fra_Ssw_t * pPars );
+    extern int Fra_FraigInductionTest( char * pFileName, Fra_Ssw_t * pParams );
+
+    // set defaults
+    pPars->nPartSize  = 0;
+    pPars->nOverSize  = 0;
+    pPars->nFramesP   = 0;
+    pPars->nFramesK   = 1;
+    pPars->nMaxImps   = 5000;
+    pPars->nMaxLevs   = 0;
+    pPars->fUseImps   = 0;
+    pPars->fRewrite   = 0;
+    pPars->fFraiging  = 0;
+    pPars->fLatchCorr = 0;
+    pPars->fWriteImps = 0;
+    pPars->fUse1Hot   = 0;
+    pPars->fVerbose   = 0;
+    pPars->TimeLimit  = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "PQNFILirfletvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'P':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nPartSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nPartSize < 2 )
+                goto usage;
+            break;
+        case 'Q':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-Q\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nOverSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nOverSize < 0 )
+                goto usage;
+            break;
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nFramesP = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nFramesP < 0 )
+                goto usage;
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nFramesK = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nFramesK <= 0 )
+                goto usage;
+            break;
+        case 'I':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nMaxImps = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nMaxImps <= 0 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nMaxLevs = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nMaxLevs <= 0 )
+                goto usage;
+            break;
+        case 'i':
+            pPars->fUseImps ^= 1;
+            break;
+        case 'r':
+            pPars->fRewrite ^= 1;
+            break;
+        case 'f':
+            pPars->fFraiging ^= 1;
+            break;
+        case 'l':
+            pPars->fLatchCorr ^= 1;
+            break;
+        case 'e':
+            pPars->fWriteImps ^= 1;
+            break;
+        case 't':
+            pPars->fUse1Hot ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    // get the input file name
+    if ( argc == globalUtilOptind + 1 )
+        pFileName = argv[globalUtilOptind];
+    else
+    {
+        Abc_Print( -1, "File name should be given on the command line.\n" );
+        return 1;
+    }
+    Fra_FraigInductionTest( pFileName, pPars );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: testssw [-PQNFL num] [-lrfetvh] <file>\n" );
+    Abc_Print( -2, "\t         performs sequential sweep using K-step induction\n" );
+    Abc_Print( -2, "\t         (outputs a file with a set of pairs of equivalent nodes)\n" );
+    Abc_Print( -2, "\t-P num : max partition size (0 = no partitioning) [default = %d]\n", pPars->nPartSize );
+    Abc_Print( -2, "\t-Q num : partition overlap (0 = no overlap) [default = %d]\n", pPars->nOverSize );
+    Abc_Print( -2, "\t-N num : number of time frames to use as the prefix [default = %d]\n", pPars->nFramesP );
+    Abc_Print( -2, "\t-F num : number of time frames for induction (1=simple) [default = %d]\n", pPars->nFramesK );
+    Abc_Print( -2, "\t-L num : max number of levels to consider (0=all) [default = %d]\n", pPars->nMaxLevs );
+//    Abc_Print( -2, "\t-I num : max number of implications to consider [default = %d]\n", pPars->nMaxImps );
+//    Abc_Print( -2, "\t-i     : toggle using implications [default = %s]\n", pPars->fUseImps? "yes": "no" );
+    Abc_Print( -2, "\t-l     : toggle latch correspondence only [default = %s]\n", pPars->fLatchCorr? "yes": "no" );
+    Abc_Print( -2, "\t-r     : toggle AIG rewriting [default = %s]\n", pPars->fRewrite? "yes": "no" );
+    Abc_Print( -2, "\t-f     : toggle fraiging (combinational SAT sweeping) [default = %s]\n", pPars->fFraiging? "yes": "no" );
+    Abc_Print( -2, "\t-e     : toggle writing implications as assertions [default = %s]\n", pPars->fWriteImps? "yes": "no" );
+    Abc_Print( -2, "\t-t     : toggle using one-hotness conditions [default = %s]\n", pPars->fUse1Hot? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandTestScorr( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Abc_Ntk_t * Abc_NtkTestScorr( char * pFileNameIn, char * pFileNameOut, int nStepsMax, int nBTLimit, int fNewAlgo, int fFlopOnly, int fFfNdOnly, int fVerbose );
+
+    Abc_Ntk_t * pNtkRes;
+    int c;
+    int nConfMax;
+    int nStepsMax;
+    int fNewAlgo;
+    int fFlopOnly;
+    int fFfNdOnly;
+    int fVerbose;
+    // set defaults
+    nConfMax  = 100;
+    nStepsMax =  -1;
+    fNewAlgo  =   0;
+    fFlopOnly =   0;
+    fFfNdOnly =   0;
+    fVerbose  =   0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "CSnfsvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nConfMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nConfMax < 0 )
+                goto usage;
+            break;
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nStepsMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nStepsMax < 0 )
+                goto usage;
+            break;
+        case 'n':
+            fNewAlgo ^= 1;
+            break;
+        case 'f':
+            fFlopOnly ^= 1;
+            break;
+        case 's':
+            fFfNdOnly ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+    if ( argc != globalUtilOptind + 2 )
+    {
+        Abc_Print( -1, "Expecting two files names on the command line.\n" );
+        goto usage;
+    }
+    if ( fFlopOnly && fFfNdOnly )
+    {
+        Abc_Print( -1, "These two options (-f and -s) are incompatible.\n" );
+        goto usage;
+    }
+    // get the new network
+    pNtkRes = Abc_NtkTestScorr( argv[globalUtilOptind], argv[globalUtilOptind+1], nStepsMax, nConfMax, fNewAlgo, fFlopOnly, fFfNdOnly, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Sequential sweeping has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: testscorr [-CS num] [-nfsvh] <file_in> <file_out>\n" );
+    Abc_Print( -2, "\t             outputs the list of sequential equivalences into a file\n" );
+    Abc_Print( -2, "\t             (if <file_in> is in BENCH, init state file should be the same directory)\n" );
+    Abc_Print( -2, "\t-C num     : limit on the number of conflicts [default = %d]\n", nConfMax );
+    Abc_Print( -2, "\t-S num     : limit on refinement iterations (-1=no limit, 0=after BMC, etc) [default = %d]\n", nStepsMax );
+    Abc_Print( -2, "\t-n         : toggle between \"scorr\" and \"&scorr\" [default = %s]\n", fNewAlgo? "&scorr": "scorr" );
+    Abc_Print( -2, "\t-f         : toggle reporting only flop/flop equivs [default = %s]\n", fFlopOnly? "yes": "no" );
+    Abc_Print( -2, "\t-s         : toggle reporting only flop/flop and flop/node equivs [default = %s]\n", fFfNdOnly? "yes": "no" );
+    Abc_Print( -2, "\t-v         : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h         : print the command usage\n");
+    Abc_Print( -2, "\t<file_in>  : input file with design for sequential equivalence computation\n");
+    Abc_Print( -2, "\t<file_out> : output file with the list of pairs of equivalent signals\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandLcorr( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c;
+    int nFramesP;
+    int nConfMax;
+    int nVarsMax;
+    int fNewAlgor;
+    int fVerbose;
+    extern Abc_Ntk_t * Abc_NtkDarLcorr( Abc_Ntk_t * pNtk, int nFramesP, int nConfMax, int fVerbose );
+    extern Abc_Ntk_t * Abc_NtkDarLcorrNew( Abc_Ntk_t * pNtk, int nVarsMax, int nConfMax, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+
+
+
+    // set defaults
+    nFramesP   =     0;
+    nConfMax   =  1000;
+    nVarsMax   =  1000;
+    fNewAlgor  =     1;
+    fVerbose   =     0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "PCSnvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'P':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFramesP = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFramesP < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nConfMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nConfMax < 0 )
+                goto usage;
+            break;
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nVarsMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nVarsMax < 0 )
+                goto usage;
+            break;
+        case 'n':
+            fNewAlgor ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( Abc_NtkIsComb(pNtk) )
+    {
+        Abc_Print( -1, "The network is combinational (run \"fraig\" or \"fraig_sweep\").\n" );
+        return 0;
+    }
+
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for structrally hashed networks. Run \"st\".\n" );
+        return 0;
+    }
+
+    // get the new network
+    if ( fNewAlgor )
+        pNtkRes = Abc_NtkDarLcorrNew( pNtk, nVarsMax, nConfMax, fVerbose );
+    else
+        pNtkRes = Abc_NtkDarLcorr( pNtk, nFramesP, nConfMax, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Sequential sweeping has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: lcorr [-PCS num] [-nvh]\n" );
+    Abc_Print( -2, "\t         computes latch correspondence using 1-step induction\n" );
+    Abc_Print( -2, "\t-P num : number of time frames to use as the prefix [default = %d]\n", nFramesP );
+    Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfMax );
+    Abc_Print( -2, "\t-S num : the max number of SAT variables [default = %d]\n", nVarsMax );
+    Abc_Print( -2, "\t-n     : toggle using new algorithm [default = %s]\n", fNewAlgor? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandSeqCleanup( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int c;
+    int fLatchConst  =   1;
+    int fLatchEqual  =   1;
+    int fSaveNames   =   1;
+    int fUseMvSweep  =   0;
+    int nFramesSymb  =   1;
+    int nFramesSatur = 512;
+    int fVerbose     =   0;
+    int fVeryVerbose =   0;
+    pNtk = Abc_FrameReadNtk(pAbc);
+
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "cenmFSvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'c':
+            fLatchConst ^= 1;
+            break;
+        case 'e':
+            fLatchEqual ^= 1;
+            break;
+        case 'n':
+            fSaveNames ^= 1;
+            break;
+        case 'm':
+            fUseMvSweep ^= 1;
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFramesSymb = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFramesSymb < 0 )
+                goto usage;
+            break;
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFramesSatur = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFramesSatur < 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'w':
+            fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Only works for structrally hashed networks.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkLatchNum(pNtk) )
+    {
+        Abc_Print( -1, "The network is combinational.\n" );
+        return 0;
+    }
+    // modify the current network
+    pNtkRes = Abc_NtkDarLatchSweep( pNtk, fLatchConst, fLatchEqual, fSaveNames, fUseMvSweep, nFramesSymb, nFramesSatur, fVerbose, fVeryVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Sequential cleanup has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: scleanup [-cenmFSvwh]\n" );
+    Abc_Print( -2, "\t         performs sequential cleanup of the current network\n" );
+    Abc_Print( -2, "\t         by removing nodes and latches that do not feed into POs\n" );
+    Abc_Print( -2, "\t-c     : sweep stuck-at latches detected by ternary simulation [default = %s]\n", fLatchConst? "yes": "no" );
+    Abc_Print( -2, "\t-e     : merge equal latches (same data inputs and init states) [default = %s]\n", fLatchEqual? "yes": "no" );
+    Abc_Print( -2, "\t-n     : toggle preserving latch names [default = %s]\n", fSaveNames? "yes": "no" );
+    Abc_Print( -2, "\t-m     : toggle using hybrid ternary/symbolic simulation [default = %s]\n", fUseMvSweep? "yes": "no" );
+    Abc_Print( -2, "\t-F num : the number of first frames simulated symbolically [default = %d]\n", nFramesSymb );
+    Abc_Print( -2, "\t-S num : the number of frames when symbolic saturation begins [default = %d]\n", nFramesSatur );
+    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w     : toggle very verbose output [default = %s]\n", fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandCycle( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int nFrames;
+    int fUseXval;
+    int fVerbose;
+    extern void Abc_NtkCycleInitState( Abc_Ntk_t * pNtk, int nFrames, int fUseXval, int fVerbose );
+    extern void Abc_NtkCycleInitStateSop( Abc_Ntk_t * pNtk, int nFrames, int fVerbose );
+    // set defaults
+    nFrames    = 100;
+    fUseXval   =   0;
+    fVerbose   =   0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Fxvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFrames = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFrames < 0 )
+                goto usage;
+            break;
+        case 'x':
+            fUseXval ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsStrash(pNtk) && !Abc_NtkIsSopLogic(pNtk) )
+    {
+        Abc_Print( -1, "Only works for strashed networks or logic SOP networks.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkLatchNum(pNtk) )
+    {
+        Abc_Print( -1, "The network is combinational.\n" );
+        return 0;
+    }
+    if ( fUseXval && !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "X-valued simulation only works for AIGs. Run \"strash\".\n" );
+        return 0;
+    }
+    if ( fUseXval )
+        Abc_NtkCycleInitState( pNtk, nFrames, 1, fVerbose );
+    else if ( Abc_NtkIsStrash(pNtk) )
+        Abc_NtkCycleInitState( pNtk, nFrames, 0, fVerbose );
+    else
+        Abc_NtkCycleInitStateSop( pNtk, nFrames, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: cycle [-F num] [-xvh]\n" );
+    Abc_Print( -2, "\t         cycles sequential circuit for the given number of timeframes\n" );
+    Abc_Print( -2, "\t         to derive a new initial state (which may be on the envelope)\n" );
+    Abc_Print( -2, "\t-F num : the number of frames to simulate [default = %d]\n", nFrames );
+    Abc_Print( -2, "\t-x     : use x-valued primary inputs [default = %s]\n", fUseXval? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandXsim( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int nFrames;
+    int fXInputs;
+    int fXState;
+    int fVerbose;
+    extern void Abc_NtkXValueSimulate( Abc_Ntk_t * pNtk, int nFrames, int fXInputs, int fXState, int fVerbose );
+    // set defaults
+    nFrames    = 10;
+    fXInputs   =  0;
+    fXState    =  0;
+    fVerbose   =  0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Fisvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFrames = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFrames < 0 )
+                goto usage;
+            break;
+        case 'i':
+            fXInputs ^= 1;
+            break;
+        case 's':
+            fXState ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Only works for strashed networks.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkLatchNum(pNtk) )
+    {
+        Abc_Print( -1, "The network is combinational.\n" );
+        return 0;
+    }
+    Abc_NtkXValueSimulate( pNtk, nFrames, fXInputs, fXState, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: xsim [-F num] [-isvh]\n" );
+    Abc_Print( -2, "\t         performs X-valued simulation of the AIG\n" );
+    Abc_Print( -2, "\t-F num : the number of frames to simulate [default = %d]\n", nFrames );
+    Abc_Print( -2, "\t-i     : toggle X-valued representation of inputs [default = %s]\n", fXInputs? "yes": "no" );
+    Abc_Print( -2, "\t-s     : toggle X-valued representation of state [default = %s]\n", fXState? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandSim( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int fNew;
+    int fComb;
+    int nFrames;
+    int nWords;
+    int TimeOut;
+    int fMiter;
+    int fVerbose;
+    char * pFileSim;
+    extern int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, int fNew, int fMiter, int fVerbose, char * pFileSim );
+    // set defaults
+    fNew       =  0;
+    fComb      =  0;
+    nFrames    = 32;
+    nWords     =  8;
+    TimeOut    = 30;
+    fMiter     =  1;
+    fVerbose   =  0;
+    pFileSim   = NULL;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "FWTAnmvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFrames = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFrames < 0 )
+                goto usage;
+            break;
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nWords = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nWords < 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            TimeOut = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( TimeOut < 0 )
+                goto usage;
+            break;
+        case 'A':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-A\" should be followed by a file name.\n" );
+                goto usage;
+            }
+            pFileSim = argv[globalUtilOptind];
+            globalUtilOptind++;
+            break;
+        case 'n':
+            fNew ^= 1;
+            break;
+        case 'm':
+            fMiter ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Only works for strashed networks.\n" );
+        return 1;
+    }
+    if ( pFileSim != NULL && Abc_NtkLatchNum(pNtk) )
+    {
+        Abc_Print( -1, "Currently simulation with user-specified patterns works only for comb miters.\n" );
+        return 1;
+    }
+    ABC_FREE( pNtk->pSeqModel );
+    pAbc->Status = Abc_NtkDarSeqSim( pNtk, nFrames, nWords, TimeOut, fNew, fMiter, fVerbose, pFileSim );
+    Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: sim [-FWT num] [-A file] [-nmvh]\n" );
+    Abc_Print( -2, "\t          performs random simulation of the sequential miter\n" );
+    Abc_Print( -2, "\t-F num  : the number of frames to simulate [default = %d]\n", nFrames );
+    Abc_Print( -2, "\t-W num  : the number of words to simulate [default = %d]\n", nWords );
+    Abc_Print( -2, "\t-T num  : approximate runtime limit in seconds [default = %d]\n", TimeOut );
+    Abc_Print( -2, "\t-A file : text file name with user's patterns [default = random simulation]\n" );
+    Abc_Print( -2, "\t          (patterns are listed, one per line, as sequences of 0s and 1s)\n" );
+    Abc_Print( -2, "\t-n      : toggle new vs. old implementation [default = %s]\n", fNew? "new": "old" );
+    Abc_Print( -2, "\t-m      : toggle miter vs. any circuit [default = %s]\n", fMiter? "miter": "circuit" );
+    Abc_Print( -2, "\t-v      : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h      : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandSim3( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern int Abc_NtkDarSeqSim3( Abc_Ntk_t * pNtk, Ssw_RarPars_t * pPars );
+    Ssw_RarPars_t Pars, * pPars = &Pars;
+    Abc_Ntk_t * pNtkRes, * pNtk = Abc_FrameReadNtk(pAbc);
+    Vec_Ptr_t * vSeqModelVec; 
+    int c;
+    Ssw_RarSetDefaultParams( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "FWBRSNTGadivzh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nFrames = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nFrames < 0 )
+                goto usage;
+            break;
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nWords = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nWords < 0 )
+                goto usage;
+            break;
+        case 'B':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nBinSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nBinSize < 0 )
+                goto usage;
+            break;
+        case 'R':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nRounds = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nRounds < 0 )
+                goto usage;
+            break;
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nRestart = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nRestart < 0 )
+                goto usage;
+            break;
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nRandSeed = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nRandSeed < 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->TimeOut = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->TimeOut < 0 )
+                goto usage;
+            break;
+        case 'G':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-G\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->TimeOutGap = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->TimeOutGap < 0 )
+                goto usage;
+            break;
+        case 'a':
+            pPars->fSolveAll ^= 1;
+            break;
+        case 'd':
+            pPars->fDropSatOuts ^= 1;
+            break;
+        case 'i':
+            pPars->fSetLastState ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'z':
+            pPars->fNotVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Only works for strashed networks.\n" );
+        return 1;
+    }
+    if ( Abc_NtkLatchNum(pNtk) == 0 )
+    {
+        Abc_Print( -1, "Only works for sequential networks.\n" );
+        return 1;
+    }
+    ABC_FREE( pNtk->pSeqModel );
+    pAbc->Status = Abc_NtkDarSeqSim3( pNtk, pPars );
+    Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
+    vSeqModelVec = pNtk->vSeqModelVec;  pNtk->vSeqModelVec = NULL;
+    if ( pPars->fSetLastState && pAbc->pNtkCur->pData )
+    {
+        Abc_Obj_t * pObj;
+        Vec_Int_t * vInit = (Vec_Int_t *)pAbc->pNtkCur->pData;
+        pAbc->pNtkCur->pData = NULL;
+        Abc_NtkForEachLatch( pAbc->pNtkCur, pObj, c )
+            if ( Vec_IntEntry(vInit, c) )
+                Abc_LatchSetInit1( pObj );
+        Vec_IntFree( vInit );
+        pNtkRes = Abc_NtkRestrashZero( pAbc->pNtkCur, 0 );
+        if ( pNtkRes == NULL )
+        {
+            Abc_Print( -1, "Removing SAT outputs has failed.\n" );
+            return 1;
+        }
+        Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+        pNtk = Abc_FrameReadNtk(pAbc);
+    }
+    if ( pPars->fSolveAll && pPars->fDropSatOuts )
+    {
+        if ( vSeqModelVec == NULL )
+            Abc_Print( 1,"The array of counter-examples is not available.\n" );
+        else if ( Vec_PtrSize(vSeqModelVec) != Abc_NtkPoNum(pNtk) )
+            Abc_Print( 1,"The array size does not match the number of outputs.\n" );
+        else
+        {
+            extern void Abc_NtkDropSatOutputs( Abc_Ntk_t * pNtk, Vec_Ptr_t * vCexes, int fVerbose );
+            Abc_NtkDropSatOutputs( pNtk, vSeqModelVec, pPars->fVerbose );
+            pNtkRes = Abc_NtkDarLatchSweep( pNtk, 1, 1, 1, 0, -1, -1, 0, 0 );
+            if ( pNtkRes == NULL )
+            {
+                Abc_Print( -1, "Removing SAT outputs has failed.\n" );
+                return 1;
+            }
+            Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+        }
+    }
+    if ( vSeqModelVec )
+    {
+        Abc_FrameReplaceCexVec( pAbc, &vSeqModelVec );
+        pAbc->nFrames = -1;
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: sim3 [-FWBRSNTG num] [-advzh]\n" );
+    Abc_Print( -2, "\t         performs random simulation of the sequential miter\n" );
+    Abc_Print( -2, "\t-F num : the number of frames to simulate [default = %d]\n",                         pPars->nFrames );
+    Abc_Print( -2, "\t-W num : the number of words to simulate [default = %d]\n",                          pPars->nWords );
+    Abc_Print( -2, "\t-B num : the number of flops in one bin [default = %d]\n",                           pPars->nBinSize );
+    Abc_Print( -2, "\t-R num : the number of simulation rounds [default = %d]\n",                          pPars->nRounds );
+    Abc_Print( -2, "\t-S num : the number of rounds before a restart [default = %d]\n",                    pPars->nRestart );
+    Abc_Print( -2, "\t-N num : random number seed (1 <= num <= 1000) [default = %d]\n",                    pPars->nRandSeed );
+    Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n",                     pPars->TimeOut );
+    Abc_Print( -2, "\t-G num : approximate runtime gap in seconds since the last CEX [default = %d]\n",    pPars->TimeOutGap );
+    Abc_Print( -2, "\t-a     : toggle solving all outputs (do not stop when one is SAT) [default = %s]\n", pPars->fSolveAll?    "yes": "no" );
+    Abc_Print( -2, "\t-d     : toggle dropping (replacing by 0) SAT outputs [default = %s]\n",             pPars->fDropSatOuts? "yes": "no" );
+    Abc_Print( -2, "\t-i     : toggle changing init state to a last rare state [default = %s]\n",          pPars->fVerbose?     "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n",                      pPars->fVerbose?     "yes": "no" );
+    Abc_Print( -2, "\t-z     : toggle suppressing report about solved outputs [default = %s]\n",           pPars->fNotVerbose?  "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandDarPhase( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int nFrames, nPref;
+    int fIgnore;
+    int fPrint;
+    int fUpdateCex;
+    int c, fVerbose;
+    extern Abc_Ntk_t * Abc_NtkPhaseAbstract( Abc_Ntk_t * pNtk, int nFrames, int nPref, int fIgnore, int fPrint, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    nFrames     = 0;
+    nPref       = 0;
+    fIgnore     = 0;
+    fPrint      = 0;
+    fUpdateCex  = 0;
+    fVerbose    = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "FPipcvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFrames = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFrames < 0 )
+                goto usage;
+            break;
+        case 'P':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nPref = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nPref < 0 )
+                goto usage;
+            break;
+        case 'i':
+            fIgnore ^= 1;
+            break;
+        case 'p':
+            fPrint ^= 1;
+            break;
+        case 'c':
+            fUpdateCex ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Only works for structrally hashed networks.\n" );
+        return 1;
+    }
+    if ( fUpdateCex )
+    {
+        Abc_Cex_t * pCexNew;
+        if ( pAbc->pCex == NULL )
+        {
+            Abc_Print( -1, "Counter-example is not available.\n" );
+            return 1;
+        }
+        if ( pAbc->pCex->nPis % Abc_NtkPiNum(pNtk) != 0 )
+        {
+            Abc_Print( -1, "PI count of the CEX is not a multiple of PI count of the current AIG.\n" );
+            return 1;
+        }
+        pCexNew = Abc_CexTransformPhase( pAbc->pCex, Abc_NtkPiNum(pNtk), Abc_NtkPoNum(pNtk), Abc_NtkLatchNum(pNtk) );
+        {
+            Aig_Man_t * pAig = Abc_NtkToDar( pNtk, 0, 1 );
+            Gia_Man_t * pGia = Gia_ManFromAig( pAig );
+            int iPo = Gia_ManSetFailedPoCex( pGia, pCexNew );
+            Gia_ManStop( pGia );
+            Aig_ManStop( pAig );
+            if ( iPo == -1 )
+            {
+                Abc_Print( -1, "The counter-example does not fail any of the outputs of the original AIG.\n" );
+                return 1;
+            }
+        }
+        Abc_FrameReplaceCex( pAbc, &pCexNew );
+        return 0;
+    }
+    if ( !Abc_NtkLatchNum(pNtk) )
+    {
+        Abc_Print( -1, "The network is combinational.\n" );
+        return 0;
+    }
+    if ( fPrint )
+    {
+        Abc_NtkPhaseAbstract( pNtk, 0, nPref, fIgnore, 1, fVerbose );
+        return 0;
+    }
+    // modify the current network
+    pNtkRes = Abc_NtkPhaseAbstract( pNtk, nFrames, nPref, fIgnore, 0, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+//        Abc_Print( -1, "Phase abstraction has failed.\n" );
+        return 0;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: phase [-FP <num>] [-ipcvh]\n" );
+    Abc_Print( -2, "\t         performs sequential cleanup of the current network\n" );
+    Abc_Print( -2, "\t         by removing nodes and latches that do not feed into POs\n" );
+    Abc_Print( -2, "\t-F num : the number of frames to abstract [default = %d]\n", nFrames );
+    Abc_Print( -2, "\t-P num : the number of prefix frames to skip [default = %d]\n", nPref );
+    Abc_Print( -2, "\t-i     : toggle ignoring the initial state [default = %s]\n", fIgnore? "yes": "no" );
+    Abc_Print( -2, "\t-p     : toggle printing statistics about generators [default = %s]\n", fPrint? "yes": "no" );
+    Abc_Print( -2, "\t-c     : update the current CEX derived for a new AIG after \"phase\"\n" );
+    Abc_Print( -2, "\t         to match the current AIG (the one before \"phase\") [default = %s]\n", fUpdateCex? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandSynch( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtkRes, * pNtk1, * pNtk2, * pNtk;
+    char ** pArgvNew;
+    int nArgcNew;
+    int fDelete1, fDelete2;
+    int c;
+    int nWords;
+    int fVerbose;
+
+    extern Abc_Ntk_t * Abc_NtkDarSynch( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nWords, int fVerbose );
+    extern Abc_Ntk_t * Abc_NtkDarSynchOne( Abc_Ntk_t * pNtk, int nWords, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    nWords   =  32;
+    fVerbose =   1;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Wvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nWords = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nWords <= 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    pArgvNew = argv + globalUtilOptind;
+    nArgcNew = argc - globalUtilOptind;
+    if ( nArgcNew == 0 )
+    {
+        if ( pNtk == NULL )
+        {
+            Abc_Print( -1, "Empty network.\n" );
+            return 1;
+        }
+        pNtkRes = Abc_NtkDarSynchOne( pNtk, nWords, fVerbose );
+    }
+    else
+    {
+        if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
+            return 1;
+        if ( Abc_NtkLatchNum(pNtk1) == 0 || Abc_NtkLatchNum(pNtk2) == 0 )
+        {
+            if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
+            if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
+            Abc_Print( -1, "The network has no latches..\n" );
+            return 0;
+        }
+
+        // modify the current network
+        pNtkRes = Abc_NtkDarSynch( pNtk1, pNtk2, nWords, fVerbose );
+        if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
+        if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
+    }
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Synchronization has failed.\n" );
+        return 0;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: synch [-W <num>] [-vh] <file1> <file2>\n" );
+    Abc_Print( -2, "\t         derives and applies synchronization sequence\n" );
+    Abc_Print( -2, "\t-W num : the number of simulation words [default = %d]\n", nWords );
+    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\tfile1  : (optional) the file with the first design\n");
+    Abc_Print( -2, "\tfile2  : (optional) the file with the second design\n\n");
+    Abc_Print( -2, "\t         If no designs are given on the command line,\n" );
+    Abc_Print( -2, "\t         assumes the current network has no initial state,\n" );
+    Abc_Print( -2, "\t         derives synchronization sequence and applies it.\n\n" );
+    Abc_Print( -2, "\t         If two designs are given on the command line\n" );
+    Abc_Print( -2, "\t         assumes both of them have no initial state,\n" );
+    Abc_Print( -2, "\t         derives sequences for both designs, synchorinizes\n" );
+    Abc_Print( -2, "\t         them, and creates SEC miter comparing two designs.\n\n" );
+    Abc_Print( -2, "\t         If only one design is given on the command line,\n" );
+    Abc_Print( -2, "\t         considers the second design to be the current network,\n" );
+    Abc_Print( -2, "\t         and derives SEC miter for them, as described above.\n" );
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandClockGate( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Cgt_Par_t Pars, * pPars = &Pars;
+    Abc_Ntk_t * pNtkRes, * pNtk, * pNtkCare;
+    int c;
+
+    extern Abc_Ntk_t * Abc_NtkDarClockGate( Abc_Ntk_t * pNtk, Abc_Ntk_t * pCare, Cgt_Par_t * pPars );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    Cgt_SetDefaultParams( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "LNDCVKavwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nLevelMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nLevelMax <= 0 )
+                goto usage;
+            break;
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nCandMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nCandMax <= 0 )
+                goto usage;
+            break;
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nOdcMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nOdcMax <= 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nConfMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nConfMax <= 0 )
+                goto usage;
+            break;
+        case 'V':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-V\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nVarsMin = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nVarsMin <= 0 )
+                goto usage;
+            break;
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nFlopsMin = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nFlopsMin <= 0 )
+                goto usage;
+            break;
+        case 'a':
+            pPars->fAreaOnly ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'w':
+            pPars->fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( argc == globalUtilOptind + 1 )
+    {
+        pNtkCare = Io_Read( argv[globalUtilOptind], Io_ReadFileType(argv[globalUtilOptind]), 1, 0 );
+        if ( pNtkCare == NULL )
+        {
+            Abc_Print( -1, "Reading care network has failed.\n" );
+            return 1;
+        }
+        // modify the current network
+        pNtkRes = Abc_NtkDarClockGate( pNtk, pNtkCare, pPars );
+        Abc_NtkDelete( pNtkCare );
+    }
+    else if ( argc == globalUtilOptind )
+    {
+        pNtkRes = Abc_NtkDarClockGate( pNtk, NULL, pPars );
+    }
+    else
+    {
+        Abc_Print( -1, "Wrong number of arguments.\n" );
+        return 0;
+    }
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Clock gating has failed.\n" );
+        return 0;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: clockgate [-LNDCVK <num>] [-avwh] <file>\n" );
+    Abc_Print( -2, "\t         sequential clock gating with observability don't-cares\n" );
+    Abc_Print( -2, "\t-L num : max level number of a clock gate [default = %d]\n", pPars->nLevelMax );
+    Abc_Print( -2, "\t-N num : max number of candidates for a flop [default = %d]\n", pPars->nCandMax );
+    Abc_Print( -2, "\t-D num : max number of ODC levels to consider [default = %d]\n", pPars->nOdcMax );
+    Abc_Print( -2, "\t-C num : max number of conflicts at a node [default = %d]\n", pPars->nConfMax );
+    Abc_Print( -2, "\t-V num : min number of vars to recycle SAT solver [default = %d]\n", pPars->nVarsMin );
+    Abc_Print( -2, "\t-K num : min number of flops to recycle SAT solver [default = %d]\n", pPars->nFlopsMin );
+    Abc_Print( -2, "\t-a     : toggle minimizing area-only [default = %s]\n", pPars->fAreaOnly? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w     : toggle even more detailed output [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\tfile   : (optional) constraints for primary inputs and register outputs\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandExtWin( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtkRes, * pNtk;
+    int c;
+    int nObjId;
+    int nDist;
+    int fVerbose;
+
+    extern Abc_Ntk_t * Abc_NtkDarExtWin( Abc_Ntk_t * pNtk, int nObjId, int nDist, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    nObjId   = -1;
+    nDist    =  5;
+    fVerbose =  0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "NDvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nObjId = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nObjId <= 0 )
+                goto usage;
+            break;
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nDist = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nDist <= 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Only works for structrally hashed networks.\n" );
+        return 1;
+    }
+
+    if ( argc != globalUtilOptind )
+    {
+        Abc_Print( -1, "Not enough command-line arguments.\n" );
+        return 1;
+    }
+    // modify the current network
+    pNtkRes = Abc_NtkDarExtWin( pNtk, nObjId, nDist, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Extracting sequential window has failed.\n" );
+        return 0;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: extwin [-ND <num>] [-vh]\n" );
+    Abc_Print( -2, "\t         extracts sequential window from the AIG\n" );
+    Abc_Print( -2, "\t-N num : the ID of the object to use as the center [default = %d]\n", nObjId );
+    Abc_Print( -2, "\t-D num : the \"radius\" of the window [default = %d]\n", nDist );
+    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandInsWin( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtkRes, * pNtk, * pNtkCare;
+    int c;
+    int nObjId;
+    int nDist;
+    int fVerbose;
+
+    extern Abc_Ntk_t * Abc_NtkDarInsWin( Abc_Ntk_t * pNtk, Abc_Ntk_t * pWnd, int nObjId, int nDist, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    nObjId   = -1;
+    nDist    =  5;
+    fVerbose =  0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "NDvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nObjId = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nObjId <= 0 )
+                goto usage;
+            break;
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nDist = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nDist <= 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Only works for structrally hashed networks.\n" );
+        return 1;
+    }
+
+    if ( argc != globalUtilOptind + 1 )
+    {
+        Abc_Print( -1, "Not enough command-line arguments.\n" );
+        return 1;
+    }
+    pNtkCare = Io_Read( argv[globalUtilOptind], Io_ReadFileType(argv[globalUtilOptind]), 1, 0 );
+    if ( pNtkCare == NULL )
+    {
+        Abc_Print( -1, "Reading care network has failed.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtkCare) )
+    {
+        Abc_Ntk_t * pNtkTemp;
+        pNtkCare = Abc_NtkStrash( pNtkTemp = pNtkCare, 0, 1, 0 );
+        Abc_NtkDelete( pNtkTemp );
+    }
+    // modify the current network
+    pNtkRes = Abc_NtkDarInsWin( pNtk, pNtkCare, nObjId, nDist, fVerbose );
+    Abc_NtkDelete( pNtkCare );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Inserting sequential window has failed.\n" );
+        return 0;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: inswin [-ND <num>] [-vh] <file>\n" );
+    Abc_Print( -2, "\t         inserts sequential window into the AIG\n" );
+    Abc_Print( -2, "\t-N num : the ID of the object to use as the center [default = %d]\n", nObjId );
+    Abc_Print( -2, "\t-D num : the \"radius\" of the window [default = %d]\n", nDist );
+    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\tfile   : file with the AIG to be inserted\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandPermute( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Abc_Ntk_t * Abc_NtkRestrashRandom( Abc_Ntk_t * pNtk );
+    Abc_Ntk_t * pNtk = pAbc->pNtkCur, * pNtkRes = NULL;
+    char * pFlopPermFile = NULL;
+    int fInputs = 1;
+    int fOutputs = 1;
+    int fFlops = 1;
+    int fNodes = 1;
+    int c;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Fiofnh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by a file name.\n" );
+                goto usage;
+            }
+            pFlopPermFile = argv[globalUtilOptind];
+            globalUtilOptind++;
+            break;
+        case 'i':
+            fInputs ^= 1;
+            break;
+        case 'o':
+            fOutputs ^= 1;
+            break;
+        case 'f':
+            fFlops ^= 1;
+            break;
+        case 'n':
+            fNodes ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            Abc_Print( -2, "Unknown switch.\n");
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( fNodes && !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "To permute nodes, the network should be structurally hashed.\n" );
+        return 1;
+    }
+    if ( fNodes )
+        pNtkRes = Abc_NtkRestrashRandom( pNtk );
+    else
+        pNtkRes = Abc_NtkDup( pNtk );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Command \"permute\" has failed.\n" );
+        return 1;
+    }
+    Abc_NtkPermute( pNtkRes, fInputs, fOutputs, fFlops, pFlopPermFile );
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: permute [-iofnh] [-F filename]\n" );
+    Abc_Print( -2, "\t                performs random permutation of inputs/outputs/flops\n" );
+    Abc_Print( -2, "\t-i            : toggle permuting primary inputs [default = %s]\n", fInputs? "yes": "no" );
+    Abc_Print( -2, "\t-o            : toggle permuting primary outputs [default = %s]\n", fOutputs? "yes": "no" );
+    Abc_Print( -2, "\t-f            : toggle permuting flip-flops [default = %s]\n", fFlops? "yes": "no" );
+    Abc_Print( -2, "\t-n            : toggle deriving new topological ordering of nodes [default = %s]\n", fNodes? "yes": "no" );
+    Abc_Print( -2, "\t-h            : print the command usage\n");
+    Abc_Print( -2, "\t-F <filename> : (optional) file with the flop permutation\n" );
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandUnpermute( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = pAbc->pNtkCur, * pNtkRes = NULL;
+    int c;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            Abc_Print( -2, "Unknown switch.\n");
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    pNtkRes = Abc_NtkDup( pNtk );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Command \"unpermute\" has failed.\n" );
+        return 1;
+    }
+    Abc_NtkUnpermute( pNtkRes );
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: unpermute [-h]\n" );
+    Abc_Print( -2, "\t        restores inputs/outputs/flops before the last permutation\n" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandCubeEnum( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern void Abc_EnumerateCubeStates();
+    extern void Abc_EnumerateCubeStatesZdd();
+    int c, fZddAlgo = 0, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "zvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'z':
+            fZddAlgo ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            Abc_Print( -2, "Unknown switch.\n");
+            goto usage;
+        }
+    }
+    if ( fZddAlgo )
+        Abc_EnumerateCubeStatesZdd();
+    else
+        Abc_EnumerateCubeStates();
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: cubeenum [-vh]\n" );
+    Abc_Print( -2, "\t         enumerates reachable states of 2x2x2 cube\n" );
+    Abc_Print( -2, "\t         (http://en.wikipedia.org/wiki/Pocket_Cube)\n" );
+    Abc_Print( -2, "\t-z     : toggle using ZDD-based algorithm [default = %s]\n", fZddAlgo? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandCec( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    char Buffer[16];
+    Abc_Ntk_t * pNtk, * pNtk1, * pNtk2;
+    int fDelete1, fDelete2;
+    char ** pArgvNew;
+    int nArgcNew;
+    int c;
+    int fSat;
+    int fVerbose;
+    int nSeconds;
+    int nPartSize;
+    int nConfLimit;
+    int nInsLimit;
+    int fPartition;
+    int fIgnoreNames;
+
+    extern void Abc_NtkCecSat( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nConfLimit, int nInsLimit );
+    extern void Abc_NtkCecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds, int fVerbose );
+    extern void Abc_NtkCecFraigPart( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds, int nPartSize, int fVerbose );
+    extern void Abc_NtkCecFraigPartAuto( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    fSat     =  0;
+    fVerbose =  0;
+    nSeconds = 20;
+    nPartSize  = 0;
+    nConfLimit = 10000;
+    nInsLimit  = 0;
+    fPartition = 0;
+    fIgnoreNames = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "TCIPpsnvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nSeconds = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nSeconds < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nConfLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nConfLimit < 0 )
+                goto usage;
+            break;
+        case 'I':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nInsLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nInsLimit < 0 )
+                goto usage;
+            break;
+        case 'P':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nPartSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nPartSize < 0 )
+                goto usage;
+            break;
+        case 'p':
+            fPartition ^= 1;
+            break;
+        case 's':
+            fSat ^= 1;
+            break;
+        case 'n':
+            fIgnoreNames ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk && pNtk->vPhases != NULL )
+    {
+        Abc_Print( -1, "Cannot compare networks with phases defined.\n" );
+        return 1;
+    }
+
+    pArgvNew = argv + globalUtilOptind;
+    nArgcNew = argc - globalUtilOptind;
+    if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
+        return 1;
+
+    if ( fIgnoreNames )
+    {
+        if ( !fDelete1 )
+        {
+            pNtk1 = Abc_NtkStrash( pNtk1, 0, 1, 0 );
+            fDelete1 = 1;
+        }
+        if ( !fDelete2 )
+        {
+            pNtk2 = Abc_NtkStrash( pNtk2, 0, 1, 0 );
+            fDelete2 = 1;
+        }
+        Abc_NtkShortNames( pNtk1 );
+        Abc_NtkShortNames( pNtk2 );
+    }
+
+    // perform equivalence checking
+    if ( fPartition )
+        Abc_NtkCecFraigPartAuto( pNtk1, pNtk2, nSeconds, fVerbose );
+    else if ( nPartSize )
+        Abc_NtkCecFraigPart( pNtk1, pNtk2, nSeconds, nPartSize, fVerbose );
+    else if ( fSat )
+        Abc_NtkCecSat( pNtk1, pNtk2, nConfLimit, nInsLimit );
+    else
+        Abc_NtkCecFraig( pNtk1, pNtk2, nSeconds, fVerbose );
+
+    if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
+    if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
+    return 0;
+
+usage:
+    if ( nPartSize == 0 )
+        strcpy( Buffer, "unused" );
+    else
+        sprintf(Buffer, "%d", nPartSize );
+    Abc_Print( -2, "usage: cec [-T num] [-C num] [-I num] [-P num] [-psnvh] <file1> <file2>\n" );
+    Abc_Print( -2, "\t         performs combinational equivalence checking\n" );
+    Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", nSeconds );
+    Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n",    nConfLimit );
+    Abc_Print( -2, "\t-I num : limit on the number of clause inspections [default = %d]\n", nInsLimit );
+    Abc_Print( -2, "\t-P num : partition size for multi-output networks [default = %s]\n", Buffer );
+    Abc_Print( -2, "\t-p     : toggle automatic partitioning [default = %s]\n", fPartition? "yes": "no" );
+    Abc_Print( -2, "\t-s     : toggle \"SAT only\" and \"FRAIG + SAT\" [default = %s]\n", fSat? "SAT only": "FRAIG + SAT" );
+    Abc_Print( -2, "\t-n     : toggle ignoring names when matching CIs/COs [default = %s]\n", fIgnoreNames? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\tfile1  : (optional) the file with the first network\n");
+    Abc_Print( -2, "\tfile2  : (optional) the file with the second network\n");
+    Abc_Print( -2, "\t         if no files are given, uses the current network and its spec\n");
+    Abc_Print( -2, "\t         if one file is given, uses the current network and the file\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandDCec( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtk1, * pNtk2;
+    int fDelete1, fDelete2;
+    char ** pArgvNew;
+    int nArgcNew;
+    int c;
+    int fSat;
+    int fVerbose;
+    int nSeconds;
+    int nConfLimit;
+    int nInsLimit;
+    int fPartition;
+    int fMiter;
+
+    extern int Abc_NtkDSat( Abc_Ntk_t * pNtk, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, int nLearnedStart, int nLearnedDelta, int nLearnedPerce, int fAlignPol, int fAndOuts, int fNewSolver, int fVerbose );
+    extern int Abc_NtkDarCec( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nConfLimit, int fPartition, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    fSat     =  0;
+    fVerbose =  0;
+    nSeconds = 20;
+    nConfLimit = 10000;
+    nInsLimit  = 0;
+    fPartition = 0;
+    fMiter     = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "TCIpmsvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nSeconds = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nSeconds < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nConfLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nConfLimit < 0 )
+                goto usage;
+            break;
+        case 'I':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nInsLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nInsLimit < 0 )
+                goto usage;
+            break;
+        case 'p':
+            fPartition ^= 1;
+            break;
+        case 'm':
+            fMiter ^= 1;
+            break;
+        case 's':
+            fSat ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+
+    pArgvNew = argv + globalUtilOptind;
+    nArgcNew = argc - globalUtilOptind;
+    if ( fMiter )
+    {
+        if ( pNtk == NULL )
+        {
+            Abc_Print( -1, "Empty network.\n" );
+            return 1;
+        }
+        if ( Abc_NtkIsStrash(pNtk) )
+        {
+            pNtk1 = pNtk;
+            fDelete1 = 0;
+        }
+        else
+        {
+            pNtk1 = Abc_NtkStrash( pNtk, 0, 1, 0 );
+            fDelete1 = 1;
+        }
+        pNtk2 = NULL;
+        fDelete2 = 0;
+    }
+    else
+    {
+        if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
+            return 1;
+    }
+
+    if ( (pNtk1 && Abc_NtkLatchNum(pNtk1)) || (pNtk2 && Abc_NtkLatchNum(pNtk2)) )
+    {
+        if ( pNtk1 && fDelete1 ) Abc_NtkDelete( pNtk1 );
+        if ( pNtk2 && fDelete2 ) Abc_NtkDelete( pNtk2 );
+        Abc_Print( -1, "Currently this command only works for networks without latches. Run \"comb\".\n" );
+        return 1;
+    }
+
+    // perform equivalence checking
+    if ( fSat && fMiter )
+        Abc_NtkDSat( pNtk1, nConfLimit, nInsLimit, 0, 0, 0, 0, 0, 0, fVerbose );
+    else
+        Abc_NtkDarCec( pNtk1, pNtk2, nConfLimit, fPartition, fVerbose );
+
+    if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
+    if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: dcec [-T num] [-C num] [-I num] [-mpsvh] <file1> <file2>\n" );
+    Abc_Print( -2, "\t         performs combinational equivalence checking\n" );
+    Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", nSeconds );
+    Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n",    nConfLimit );
+    Abc_Print( -2, "\t-I num : limit on the number of clause inspections [default = %d]\n", nInsLimit );
+    Abc_Print( -2, "\t-m     : toggle working on two networks or a miter [default = %s]\n", fMiter? "miter": "two networks" );
+    Abc_Print( -2, "\t-p     : toggle automatic partitioning [default = %s]\n", fPartition? "yes": "no" );
+    Abc_Print( -2, "\t-s     : toggle \"SAT only\" (miter) or \"FRAIG + SAT\" [default = %s]\n", fSat? "SAT only": "FRAIG + SAT" );
+    Abc_Print( -2, "\t-v     : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\tfile1  : (optional) the file with the first network\n");
+    Abc_Print( -2, "\tfile2  : (optional) the file with the second network\n");
+    Abc_Print( -2, "\t         if no files are given, uses the current network and its spec\n");
+    Abc_Print( -2, "\t         if one file is given, uses the current network and the file\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandDSec( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Fra_Sec_t SecPar, * pSecPar = &SecPar;
+    Abc_Ntk_t * pNtk, * pNtk1, * pNtk2;
+    int fDelete1, fDelete2;
+    char ** pArgvNew;
+    int nArgcNew;
+    int c;
+    int fIgnoreNames;
+
+    extern int Abc_NtkDarSec( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, Fra_Sec_t * p );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    Fra_SecSetDefaultParams( pSecPar );
+    pSecPar->TimeLimit = 0;
+    fIgnoreNames = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "FTarmfnwvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pSecPar->nFramesMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pSecPar->nFramesMax < 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pSecPar->TimeLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pSecPar->TimeLimit < 0 )
+                goto usage;
+            break;
+        case 'a':
+            pSecPar->fPhaseAbstract ^= 1;
+            break;
+        case 'r':
+            pSecPar->fRetimeFirst ^= 1;
+            break;
+        case 'm':
+            pSecPar->fRetimeRegs ^= 1;
+            break;
+        case 'f':
+            pSecPar->fFraiging ^= 1;
+            break;
+        case 'n':
+            fIgnoreNames ^= 1;
+            break;
+        case 'w':
+            pSecPar->fVeryVerbose ^= 1;
+            break;
+        case 'v':
+            pSecPar->fVerbose ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+
+    pArgvNew = argv + globalUtilOptind;
+    nArgcNew = argc - globalUtilOptind;
+    if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
+        return 1;
+    if ( Abc_NtkLatchNum(pNtk1) == 0 || Abc_NtkLatchNum(pNtk2) == 0 )
+    {
+        if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
+        if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
+        Abc_Print( -1, "The network has no latches. Used combinational command \"cec\".\n" );
+        return 0;
+    }
+
+    if ( fIgnoreNames )
+    {
+        if ( !fDelete1 )
+        {
+            pNtk1 = Abc_NtkStrash( pNtk1, 0, 1, 0 );
+            fDelete1 = 1;
+        }
+        if ( !fDelete2 )
+        {
+            pNtk2 = Abc_NtkStrash( pNtk2, 0, 1, 0 );
+            fDelete2 = 1;
+        }
+        Abc_NtkShortNames( pNtk1 );
+        Abc_NtkShortNames( pNtk2 );
+    }
+
+    // perform verification
+    Abc_NtkDarSec( pNtk1, pNtk2, pSecPar );
+
+    if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
+    if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: dsec [-F num] [-T num] [-armfnwvh] <file1> <file2>\n" );
+    Abc_Print( -2, "\t         performs inductive sequential equivalence checking\n" );
+    Abc_Print( -2, "\t-F num : the limit on the depth of induction [default = %d]\n", pSecPar->nFramesMax );
+    Abc_Print( -2, "\t-T num : the approximate runtime limit (in seconds) [default = %d]\n", pSecPar->TimeLimit );
+    Abc_Print( -2, "\t-a     : toggles the use of phase abstraction [default = %s]\n", pSecPar->fPhaseAbstract? "yes": "no" );
+    Abc_Print( -2, "\t-r     : toggles forward retiming at the beginning [default = %s]\n", pSecPar->fRetimeFirst? "yes": "no" );
+    Abc_Print( -2, "\t-m     : toggles min-register retiming [default = %s]\n", pSecPar->fRetimeRegs? "yes": "no" );
+    Abc_Print( -2, "\t-f     : toggles the internal use of fraiging [default = %s]\n", pSecPar->fFraiging? "yes": "no" );
+    Abc_Print( -2, "\t-n     : toggle ignoring names when matching PIs/POs [default = %s]\n", fIgnoreNames? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggles verbose output [default = %s]\n", pSecPar->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w     : toggles additional verbose output [default = %s]\n", pSecPar->fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\tfile1  : (optional) the file with the first network\n");
+    Abc_Print( -2, "\tfile2  : (optional) the file with the second network\n");
+    Abc_Print( -2, "\t         if no files are given, uses the current network and its spec\n");
+    Abc_Print( -2, "\t         if one file is given, uses the current network and the file\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandDProve( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Fra_Sec_t SecPar, * pSecPar = &SecPar;
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    char * pLogFileName = NULL;
+    int nBmcFramesMax = 20;
+    int nBmcConfMax = 2000;
+
+    extern void Fra_SecSetDefaultParams( Fra_Sec_t * p );
+    extern int Abc_NtkDarProve( Abc_Ntk_t * pNtk, Fra_Sec_t * pSecPar, int nBmcFramesMax, int nBmcConfMax );
+    // set defaults
+    Fra_SecSetDefaultParams( pSecPar );
+//    pSecPar->TimeLimit = 300;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "cbAEFCGDVBRTLarmfijkoupwvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'c':
+            pSecPar->fTryComb ^= 1;
+            break;
+        case 'b':
+            pSecPar->fTryBmc ^= 1;
+            break;
+        case 'A':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-A\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nBmcFramesMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nBmcFramesMax < 0 )
+                goto usage;
+            break;
+        case 'E':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-E\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nBmcConfMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nBmcConfMax < 0 )
+                goto usage;
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pSecPar->nFramesMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pSecPar->nFramesMax < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pSecPar->nBTLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pSecPar->nBTLimit < 0 )
+                goto usage;
+            break;
+        case 'G':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-G\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pSecPar->nBTLimitGlobal = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pSecPar->nBTLimitGlobal < 0 )
+                goto usage;
+            break;
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pSecPar->nBTLimitInter = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pSecPar->nBTLimitInter < 0 )
+                goto usage;
+            break;
+        case 'V':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-V\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pSecPar->nBddVarsMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pSecPar->nBddVarsMax < 0 )
+                goto usage;
+            break;
+        case 'B':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pSecPar->nBddMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pSecPar->nBddMax < 0 )
+                goto usage;
+            break;
+        case 'R':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pSecPar->nBddIterMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pSecPar->nBddIterMax < 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pSecPar->nPdrTimeout = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pSecPar->nPdrTimeout < 0 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by a file name.\n" );
+                goto usage;
+            }
+            pLogFileName = argv[globalUtilOptind];
+            globalUtilOptind++;
+            break;
+        case 'a':
+            pSecPar->fPhaseAbstract ^= 1;
+            break;
+        case 'r':
+            pSecPar->fRetimeFirst ^= 1;
+            break;
+        case 'm':
+            pSecPar->fRetimeRegs ^= 1;
+            break;
+        case 'f':
+            pSecPar->fFraiging ^= 1;
+            break;
+        case 'i':
+            pSecPar->fInduction ^= 1;
+            break;
+        case 'j':
+            pSecPar->fInterpolation ^= 1;
+            break;
+        case 'k':
+            pSecPar->fInterSeparate ^= 1;
+            break;
+        case 'o':
+            pSecPar->fReorderImage ^= 1;
+            break;
+        case 'u':
+            pSecPar->fReadUnsolved ^= 1;
+            break;
+        case 'p':
+            pSecPar->fUsePdr ^= 1;
+            break;
+        case 'w':
+            pSecPar->fVeryVerbose ^= 1;
+            break;
+        case 'v':
+            pSecPar->fVerbose ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for structrally hashed networks. Run \"st\".\n" );
+        return 0;
+    }
+
+    // perform verification
+    pAbc->Status = Abc_NtkDarProve( pNtk, pSecPar, nBmcFramesMax, nBmcConfMax );
+    Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
+    if ( pLogFileName )
+        Abc_NtkWriteLogFile( pLogFileName, pAbc->pCex, pAbc->Status, pAbc->nFrames, "dprove" );
+
+    // read back the resulting unsolved reduced sequential miter
+    if ( pSecPar->fReadUnsolved && pSecPar->nSMnumber >= 0 )
+    {
+        char FileName[100];
+        sprintf(FileName, "sm%02d.aig", pSecPar->nSMnumber );
+        pNtk = Io_Read( FileName, Io_ReadFileType(FileName), 1, 0 );
+        if ( pNtk == NULL )
+            Abc_Print( -1, "Cannot read back unsolved reduced sequential miter \"%s\",\n", FileName );
+        else
+            Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: dprove [-AEFCGDVBRT num] [-L file] [-cbarmfijoupvwh]\n" );
+    Abc_Print( -2, "\t         performs SEC on the sequential miter\n" );
+    Abc_Print( -2, "\t-A num : the limit on the depth of BMC [default = %d]\n", nBmcFramesMax );
+    Abc_Print( -2, "\t-E num : the conflict limit during BMC [default = %d]\n", nBmcConfMax );
+    Abc_Print( -2, "\t-F num : the limit on the depth of induction [default = %d]\n", pSecPar->nFramesMax );
+    Abc_Print( -2, "\t-C num : the conflict limit at a node during induction [default = %d]\n", pSecPar->nBTLimit );
+    Abc_Print( -2, "\t-G num : the global conflict limit during induction [default = %d]\n", pSecPar->nBTLimitGlobal );
+    Abc_Print( -2, "\t-D num : the conflict limit during interpolation [default = %d]\n", pSecPar->nBTLimitInter );
+    Abc_Print( -2, "\t-V num : the flop count limit for BDD-based reachablity [default = %d]\n", pSecPar->nBddVarsMax );
+    Abc_Print( -2, "\t-B num : the BDD size limit in BDD-based reachablity [default = %d]\n", pSecPar->nBddMax );
+    Abc_Print( -2, "\t-R num : the max number of reachability iterations [default = %d]\n", pSecPar->nBddIterMax );
+    Abc_Print( -2, "\t-T num : the timeout for property directed reachability [default = %d]\n", pSecPar->nPdrTimeout );
+    Abc_Print( -2, "\t-L file: the log file name [default = %s]\n", pLogFileName ? pLogFileName : "no logging" );
+    Abc_Print( -2, "\t-c     : toggles using CEC before attempting SEC [default = %s]\n", pSecPar->fTryComb? "yes": "no" );
+    Abc_Print( -2, "\t-b     : toggles using BMC before attempting SEC [default = %s]\n", pSecPar->fTryBmc? "yes": "no" );
+    Abc_Print( -2, "\t-a     : toggles the use of phase abstraction [default = %s]\n", pSecPar->fPhaseAbstract? "yes": "no" );
+    Abc_Print( -2, "\t-r     : toggles forward retiming at the beginning [default = %s]\n", pSecPar->fRetimeFirst? "yes": "no" );
+    Abc_Print( -2, "\t-m     : toggles min-register retiming [default = %s]\n", pSecPar->fRetimeRegs? "yes": "no" );
+    Abc_Print( -2, "\t-f     : toggles the internal use of fraiging [default = %s]\n", pSecPar->fFraiging? "yes": "no" );
+    Abc_Print( -2, "\t-i     : toggles the use of induction [default = %s]\n", pSecPar->fInduction? "yes": "no" );
+    Abc_Print( -2, "\t-j     : toggles the use of interpolation [default = %s]\n", pSecPar->fInterpolation? "yes": "no" );
+    Abc_Print( -2, "\t-k     : toggles applying interpolation to each output [default = %s]\n", pSecPar->fInterSeparate? "yes": "no" );
+    Abc_Print( -2, "\t-o     : toggles using BDD variable reordering during image computation [default = %s]\n", pSecPar->fReorderImage? "yes": "no" );
+    Abc_Print( -2, "\t-u     : toggles reading back unsolved reduced sequential miter [default = %s]\n", pSecPar->fReadUnsolved? "yes": "no" );
+    Abc_Print( -2, "\t-p     : toggles trying property directed reachability in the end [default = %s]\n", pSecPar->fUsePdr? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggles verbose output [default = %s]\n", pSecPar->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w     : toggles additional verbose output [default = %s]\n", pSecPar->fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\tCommand \"dprove\" can also be used for sequential synthesis (dprove -brjopu)\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbSec( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtk1, * pNtk2;
+    int fDelete1, fDelete2;
+    char ** pArgvNew;
+    int nArgcNew;
+    int fMiter, nFrames, fVerbose, c;
+
+    extern int Abc_NtkDarAbSec( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nFrames, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    fMiter   = 1;
+    nFrames  = 2;
+    fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Fmvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFrames = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFrames < 0 )
+                goto usage;
+            break;
+        case 'm':
+            fMiter ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( fMiter )
+    {
+//        pNtk = Io_Read( argv[globalUtilOptind], Io_ReadFileType(argv[globalUtilOptind]), 1, 0 );
+        if ( argc == globalUtilOptind + 1 )
+        {
+            Abc_Print( -1, "The miter cannot be given on the command line. Use \"read\".\n" );
+            return 0;
+        }
+        if ( !Abc_NtkIsStrash(pNtk) )
+        {
+            Abc_Print( -1, "The miter should be structurally hashed. Use \"st\"\n" );
+            return 0;
+        }
+        if ( Abc_NtkDarAbSec( pNtk, NULL, nFrames, fVerbose ) == 1 )
+            pAbc->Status = 1;
+        else
+            pAbc->Status = -1;
+    }
+    else
+    {
+        pArgvNew = argv + globalUtilOptind;
+        nArgcNew = argc - globalUtilOptind;
+        if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
+            return 1;
+        if ( Abc_NtkLatchNum(pNtk1) == 0 || Abc_NtkLatchNum(pNtk2) == 0 )
+        {
+            if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
+            if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
+            Abc_Print( -1, "The network has no latches. Used combinational command \"cec\".\n" );
+            return 0;
+        }
+        // perform verification
+        if ( Abc_NtkDarAbSec( pNtk1, pNtk2, nFrames, fVerbose ) == 1 )
+            pAbc->Status = 1;
+        else
+            pAbc->Status = -1;
+        if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
+        if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: absec [-F num] [-mv] <file1> <file2>\n" );
+    Abc_Print( -2, "\t         performs SEC by applying CEC to several timeframes\n" );
+    Abc_Print( -2, "\t-F num : the total number of timeframes to use [default = %d]\n", nFrames );
+    Abc_Print( -2, "\t-m     : toggles miter vs. two networks [default = %s]\n", fMiter? "miter": "two networks" );
+    Abc_Print( -2, "\t-v     : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\tfile1  : (optional) the file with the first network\n");
+    Abc_Print( -2, "\tfile2  : (optional) the file with the second network\n");
+    Abc_Print( -2, "\t         if no files are given, uses the current network and its spec\n");
+    Abc_Print( -2, "\t         if one file is given, uses the current network and the file\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandSimSec( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Ssw_Pars_t Pars, * pPars = &Pars;
+    Abc_Ntk_t * pNtk, * pNtk1, * pNtk2;
+    int fDelete1, fDelete2;
+    char ** pArgvNew;
+    int nArgcNew, c;
+    int fMiter;
+
+    extern int Abc_NtkDarSimSec( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, Ssw_Pars_t * pPars );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    fMiter = 1;
+    Ssw_ManSetDefaultParams( pPars );
+    pPars->fPartSigCorr = 1;
+    pPars->fVerbose     = 1;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "FDcymvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nFramesK = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nFramesK < 0 )
+                goto usage;
+            break;
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nIsleDist = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nIsleDist < 0 )
+                goto usage;
+            break;
+        case 'm':
+            fMiter ^= 1;
+            break;
+        case 'c':
+            pPars->fPartSigCorr ^= 1;
+            break;
+        case 'y':
+            pPars->fDumpSRInit ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( fMiter )
+    {
+//        Abc_Ntk_t * pNtkA, * pNtkB;
+        if ( !Abc_NtkIsStrash(pNtk) )
+        {
+            Abc_Print( -1, "This command works only for structrally hashed networks. Run \"st\".\n" );
+            return 0;
+        }
+        Abc_NtkDarSimSec( pNtk, NULL, pPars );
+/*
+        pNtkA = Abc_NtkDup( pNtk );
+        pNtkB = Abc_NtkDup( pNtk );
+        Abc_NtkDarSimSec( pNtkA, pNtkB, pPars );
+        Abc_NtkDelete( pNtkA );
+        Abc_NtkDelete( pNtkB );
+*/
+    }
+    else
+    {
+        pArgvNew = argv + globalUtilOptind;
+        nArgcNew = argc - globalUtilOptind;
+        if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
+            return 1;
+        if ( Abc_NtkLatchNum(pNtk1) == 0 || Abc_NtkLatchNum(pNtk2) == 0 )
+        {
+            if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
+            if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
+            Abc_Print( -1, "The network has no latches. Used combinational command \"cec\".\n" );
+            return 0;
+        }
+        // perform verification
+        Abc_NtkDarSimSec( pNtk1, pNtk2, pPars );
+        if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
+        if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: simsec [-FD num] [-mcyv] <file1> <file2>\n" );
+    Abc_Print( -2, "\t         performs SEC using structural similarity\n" );
+    Abc_Print( -2, "\t-F num : the limit on the depth of induction [default = %d]\n", pPars->nFramesK );
+    Abc_Print( -2, "\t-D num : the distance for extending islands [default = %d]\n", pPars->nIsleDist );
+    Abc_Print( -2, "\t-m     : toggles miter vs. two networks [default = %s]\n", fMiter? "miter": "two networks" );
+    Abc_Print( -2, "\t-c     : uses partial vs. full signal correspondence [default = %s]\n", pPars->fPartSigCorr? "partial": "full" );
+    Abc_Print( -2, "\t-y     : dumps speculatively reduced miter of the classes [default = %s]\n", pPars->fDumpSRInit? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\tfile1  : (optional) the file with the first network\n");
+    Abc_Print( -2, "\tfile2  : (optional) the file with the second network\n");
+    Abc_Print( -2, "\t         if no files are given, uses the current network and its spec\n");
+    Abc_Print( -2, "\t         if one file is given, uses the current network and the file\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandMatch( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtk1, * pNtk2, * pNtkRes;
+    int fDelete1, fDelete2;
+    char ** pArgvNew;
+    int nArgcNew, c;
+    int fMiter;
+    int nDist;
+    int fVerbose;
+
+    extern Abc_Ntk_t * Abc_NtkDarMatch( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nDist, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    fMiter = 0;
+    nDist = 0;
+    fVerbose = 1;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Dmvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nDist = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nDist < 0 )
+                goto usage;
+            break;
+        case 'm':
+            fMiter ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( fMiter )
+    {
+//        Abc_Ntk_t * pNtkA, * pNtkB;
+        if ( !Abc_NtkIsStrash(pNtk) )
+        {
+            Abc_Print( -1, "This command works only for structrally hashed networks. Run \"st\".\n" );
+            return 0;
+        }
+        pNtkRes = Abc_NtkDarMatch( pNtk, NULL, nDist, fVerbose );
+/*
+        pNtkA = Abc_NtkDup( pNtk );
+        pNtkB = Abc_NtkDup( pNtk );
+        Abc_NtkDarSimSec( pNtkA, pNtkB, pPars );
+        Abc_NtkDelete( pNtkA );
+        Abc_NtkDelete( pNtkB );
+*/
+    }
+    else
+    {
+        pArgvNew = argv + globalUtilOptind;
+        nArgcNew = argc - globalUtilOptind;
+        if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
+            return 1;
+        if ( Abc_NtkLatchNum(pNtk1) == 0 || Abc_NtkLatchNum(pNtk2) == 0 )
+        {
+            if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
+            if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
+            Abc_Print( -1, "The network has no latches. Used combinational command \"cec\".\n" );
+            return 0;
+        }
+        // perform verification
+        pNtkRes = Abc_NtkDarMatch( pNtk1, pNtk2, nDist, fVerbose );
+        if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
+        if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
+    }
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Matching has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: match [-D num] [-mv] <file1> <file2>\n" );
+    Abc_Print( -2, "\t         detects structural similarity using simulation\n" );
+    Abc_Print( -2, "\t         replaces the current network by the miter of differences\n" );
+    Abc_Print( -2, "\t-D num : the distance for extending differences [default = %d]\n", nDist );
+    Abc_Print( -2, "\t-m     : toggles miter vs. two networks [default = %s]\n", fMiter? "miter": "two networks" );
+    Abc_Print( -2, "\t-v     : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\tfile1  : (optional) the file with the first network\n");
+    Abc_Print( -2, "\tfile2  : (optional) the file with the second network\n");
+    Abc_Print( -2, "\t         if no files are given, uses the current network and its spec\n");
+    Abc_Print( -2, "\t         if one file is given, uses the current network and the file\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandSat( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int RetValue;
+    int fVerbose;
+    int nConfLimit;
+    int nInsLimit;
+    abctime clk;
+    // set defaults
+    fVerbose   = 0;
+    nConfLimit = 0;
+    nInsLimit  = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "CIvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nConfLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nConfLimit < 0 )
+                goto usage;
+            break;
+        case 'I':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nInsLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nInsLimit < 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( Abc_NtkLatchNum(pNtk) > 0 )
+    {
+        Abc_Print( -1, "Currently can only solve the miter for combinational circuits.\n" );
+        return 0;
+    }
+
+    clk = Abc_Clock();
+    if ( Abc_NtkIsStrash(pNtk) )
+    {
+        RetValue = Abc_NtkMiterSat( pNtk, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)nInsLimit, fVerbose, NULL, NULL );
+    }
+    else
+    {
+        assert( Abc_NtkIsLogic(pNtk) );
+        Abc_NtkToBdd( pNtk );
+        RetValue = Abc_NtkMiterSat( pNtk, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)nInsLimit, fVerbose, NULL, NULL );
+    }
+
+    // verify that the pattern is correct
+    if ( RetValue == 0 && Abc_NtkPoNum(pNtk) == 1 )
+    {
+        //int i;
+        //Abc_Obj_t * pObj;
+        int * pSimInfo = Abc_NtkVerifySimulatePattern( pNtk, pNtk->pModel );
+        if ( pSimInfo[0] != 1 )
+            Abc_Print( 1, "ERROR in Abc_NtkMiterSat(): Generated counter example is invalid.\n" );
+        ABC_FREE( pSimInfo );
+        /*
+        // print model
+        Abc_NtkForEachPi( pNtk, pObj, i )
+        {
+            Abc_Print( -1, "%d", (int)(pNtk->pModel[i] > 0) );
+            if ( i == 70 )
+                break;
+        }
+        Abc_Print( -1, "\n" );
+        */
+    }
+    pAbc->Status = RetValue;
+    if ( RetValue == -1 )
+        Abc_Print( 1, "UNDECIDED      " );
+    else if ( RetValue == 0 )
+        Abc_Print( 1, "SATISFIABLE    " );
+    else
+        Abc_Print( 1, "UNSATISFIABLE  " );
+    //Abc_Print( -1, "\n" );
+    Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: sat [-C num] [-I num] [-vh]\n" );
+    Abc_Print( -2, "\t         solves the combinational miter using SAT solver MiniSat-1.14\n" );
+    Abc_Print( -2, "\t         derives CNF from the current network and leave it unchanged\n" );
+    Abc_Print( -2, "\t         (there is also a newer SAT solving command \"dsat\")\n" );
+    Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n",    nConfLimit );
+    Abc_Print( -2, "\t-I num : limit on the number of inspections [default = %d]\n", nInsLimit );
+    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandDSat( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int RetValue;
+    int fAlignPol;
+    int fAndOuts;
+    int fNewSolver;
+    int fVerbose;
+    int nConfLimit;
+    int nLearnedStart;
+    int nLearnedDelta;
+    int nLearnedPerce;
+    int nInsLimit;
+    abctime clk;
+
+    extern int Abc_NtkDSat( Abc_Ntk_t * pNtk, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, int nLearnedStart, int nLearnedDelta, int nLearnedPerce, int fAlignPol, int fAndOuts, int fNewSolver, int fVerbose );
+    // set defaults
+    fAlignPol  = 0;
+    fAndOuts   = 0;
+    fNewSolver = 0;
+    fVerbose   = 0;
+    nConfLimit = 0;
+    nInsLimit  = 0;
+    nLearnedStart = 0;
+    nLearnedDelta = 0;
+    nLearnedPerce = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "CILDEpanvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nConfLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nConfLimit < 0 )
+                goto usage;
+            break;
+        case 'I':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nInsLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nInsLimit < 0 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nLearnedStart = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLearnedStart < 0 )
+                goto usage;
+            break;
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nLearnedDelta = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLearnedDelta < 0 )
+                goto usage;
+            break;
+        case 'E':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-E\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nLearnedPerce = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLearnedPerce < 0 )
+                goto usage;
+            break;
+        case 'p':
+            fAlignPol ^= 1;
+            break;
+        case 'a':
+            fAndOuts ^= 1;
+            break;
+        case 'n':
+            fNewSolver ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( argc == globalUtilOptind + 1 )
+    {
+        extern int Cnf_DataSolveFromFile( char * pFileName, int nConfLimit, int fVerbose );
+        // get the input file name
+        char * pFileName = argv[globalUtilOptind];
+        FILE * pFile = fopen( pFileName, "rb" );
+        if ( pFile == NULL )
+        {
+            printf( "Cannot open file \"%s\" for writing.\n", pFileName );
+            return 0;
+        }
+        fclose( pFile );
+        Cnf_DataSolveFromFile( pFileName, nConfLimit, fVerbose );
+        return 0;
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( Abc_NtkLatchNum(pNtk) > 0 )
+    {
+        Abc_Print( -1, "Currently can only solve the miter for combinational circuits.\n" );
+        return 0;
+    }
+
+    if ( Abc_NtkPoNum(pNtk) != 1 )
+    {
+        Abc_Print( -1, "Currently expects a single-output miter.\n" );
+        return 0;
+    }
+
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
+        return 0;
+    }
+    clk = Abc_Clock();
+    RetValue = Abc_NtkDSat( pNtk, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)nInsLimit, nLearnedStart, nLearnedDelta, nLearnedPerce, fAlignPol, fAndOuts, fNewSolver, fVerbose );
+    // verify that the pattern is correct
+    if ( RetValue == 0 && Abc_NtkPoNum(pNtk) == 1 )
+    {
+        int * pSimInfo = Abc_NtkVerifySimulatePattern( pNtk, pNtk->pModel );
+        if ( pSimInfo[0] != 1 )
+            Abc_Print( 1, "ERROR in Abc_NtkMiterSat(): Generated counter example is invalid.\n" );
+        ABC_FREE( pSimInfo );
+        pAbc->pCex = Abc_CexCreate( 0, Abc_NtkPiNum(pNtk), pNtk->pModel, 0, 0, 0 );
+    }
+    pAbc->Status = RetValue;
+    if ( RetValue == -1 )
+        Abc_Print( 1, "UNDECIDED      " );
+    else if ( RetValue == 0 )
+        Abc_Print( 1, "SATISFIABLE    " );
+    else
+        Abc_Print( 1, "UNSATISFIABLE  " );
+    //Abc_Print( -1, "\n" );
+    Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: dsat [-CILDE num] [-panvh]\n" );
+    Abc_Print( -2, "\t         solves the combinational miter using SAT solver MiniSat-1.14\n" );
+    Abc_Print( -2, "\t         derives CNF from the current network and leaves it unchanged\n" );
+    Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n",    nConfLimit );
+    Abc_Print( -2, "\t-I num : limit on the number of inspections [default = %d]\n", nInsLimit );
+    Abc_Print( -2, "\t-L num : starting value for learned clause removal [default = %d]\n", nLearnedStart );
+    Abc_Print( -2, "\t-D num : delta value for learned clause removal [default = %d]\n", nLearnedDelta );
+    Abc_Print( -2, "\t-E num : ratio percentage for learned clause removal [default = %d]\n", nLearnedPerce );
+    Abc_Print( -2, "\t-p     : align polarity of SAT variables [default = %s]\n", fAlignPol? "yes": "no" );
+    Abc_Print( -2, "\t-a     : toggle ANDing/ORing of miter outputs [default = %s]\n", fAndOuts? "ANDing": "ORing" );
+    Abc_Print( -2, "\t-n     : toggle using new solver [default = %s]\n", fNewSolver? "yes": "no" );
+    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandPSat( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int RetValue;
+    int c;
+    int nAlgo;
+    int nPartSize;
+    int nConfPart;
+    int nConfTotal;
+    int fAlignPol;
+    int fSynthesize;
+    int fVerbose;
+    abctime clk;
+
+    extern int Abc_NtkPartitionedSat( Abc_Ntk_t * pNtk, int nAlgo, int nPartSize, int nConfPart, int nConfTotal, int fAlignPol, int fSynthesize, int fVerbose );
+    // set defaults
+    nAlgo       =        0;
+    nPartSize   =    10000;
+    nConfPart   =        0;
+    nConfTotal  =  1000000;
+    fAlignPol   =        1;
+    fSynthesize =        0;
+    fVerbose    =        1;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "APCpsvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'A':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-A\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nAlgo = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nAlgo < 0 )
+                goto usage;
+            break;
+        case 'P':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nPartSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nPartSize < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nConfTotal = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nConfTotal < 0 )
+                goto usage;
+            break;
+        case 'p':
+            fAlignPol ^= 1;
+            break;
+        case 's':
+            fSynthesize ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( Abc_NtkLatchNum(pNtk) > 0 )
+    {
+        Abc_Print( -1, "Currently can only solve the miter for combinational circuits.\n" );
+        return 0;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
+        return 0;
+    }
+
+    clk = Abc_Clock();
+    RetValue = Abc_NtkPartitionedSat( pNtk, nAlgo, nPartSize, nConfPart, nConfTotal, fAlignPol, fSynthesize, fVerbose );
+    // verify that the pattern is correct
+    if ( RetValue == 0 && Abc_NtkPoNum(pNtk) == 1 )
+    {
+        //int i;
+        //Abc_Obj_t * pObj;
+        int * pSimInfo = Abc_NtkVerifySimulatePattern( pNtk, pNtk->pModel );
+        if ( pSimInfo[0] != 1 )
+            Abc_Print( 1, "ERROR in Abc_NtkMiterSat(): Generated counter example is invalid.\n" );
+        ABC_FREE( pSimInfo );
+        /*
+        // print model
+        Abc_NtkForEachPi( pNtk, pObj, i )
+        {
+            Abc_Print( -1, "%d", (int)(pNtk->pModel[i] > 0) );
+            if ( i == 70 )
+                break;
+        }
+        Abc_Print( -1, "\n" );
+        */
+    }
+
+    if ( RetValue == -1 )
+        Abc_Print( 1, "UNDECIDED      " );
+    else if ( RetValue == 0 )
+        Abc_Print( 1, "SATISFIABLE    " );
+    else
+        Abc_Print( 1, "UNSATISFIABLE  " );
+    //Abc_Print( -1, "\n" );
+    Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: psat [-APC num] [-psvh]\n" );
+    Abc_Print( -2, "\t         solves the combinational miter using partitioning\n" );
+    Abc_Print( -2, "\t         (derives CNF from the current network and leave it unchanged)\n" );
+    Abc_Print( -2, "\t         for multi-output miters, tries to prove that the AND of POs is always 0\n" );
+    Abc_Print( -2, "\t         (if POs should be ORed instead of ANDed, use command \"orpos\")\n" );
+    Abc_Print( -2, "\t-A num : partitioning algorithm [default = %d]\n", nAlgo );
+    Abc_Print( -2, "\t         0 : no partitioning\n" );
+    Abc_Print( -2, "\t         1 : partitioning by level\n" );
+    Abc_Print( -2, "\t         2 : DFS post-order\n" );
+    Abc_Print( -2, "\t         3 : DFS pre-order\n" );
+    Abc_Print( -2, "\t         4 : bit-slicing\n" );
+    Abc_Print( -2, "\t         partitions are ordered by level (high level first)\n" );
+    Abc_Print( -2, "\t-P num : limit on the partition size [default = %d]\n", nPartSize );
+    Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfTotal );
+    Abc_Print( -2, "\t-p     : align polarity of SAT variables [default = %s]\n", fAlignPol? "yes": "no" );
+    Abc_Print( -2, "\t-s     : apply logic synthesis to each partition [default = %s]\n", fSynthesize? "yes": "no" );
+    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandProve( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkTemp;
+    Prove_Params_t Params, * pParams = &Params;
+    int c, RetValue;
+    abctime clk;
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    Prove_ParamsSetDefault( pParams );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "NCFGLIrfbvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pParams->nItersMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pParams->nItersMax < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pParams->nMiteringLimitStart = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pParams->nMiteringLimitStart < 0 )
+                goto usage;
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pParams->nFraigingLimitStart = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pParams->nFraigingLimitStart < 0 )
+                goto usage;
+            break;
+        case 'G':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-G\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pParams->nFraigingLimitMulti = (float)atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pParams->nFraigingLimitMulti < 0 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pParams->nMiteringLimitLast = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pParams->nMiteringLimitLast < 0 )
+                goto usage;
+            break;
+        case 'I':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pParams->nTotalInspectLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pParams->nTotalInspectLimit < 0 )
+                goto usage;
+            break;
+        case 'r':
+            pParams->fUseRewriting ^= 1;
+            break;
+        case 'f':
+            pParams->fUseFraiging ^= 1;
+            break;
+        case 'b':
+            pParams->fUseBdds ^= 1;
+            break;
+        case 'v':
+            pParams->fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( Abc_NtkLatchNum(pNtk) > 0 )
+    {
+        Abc_Print( -1, "Currently can only solve the miter for combinational circuits.\n" );
+        return 0;
+    }
+    if ( Abc_NtkCoNum(pNtk) != 1 )
+    {
+        Abc_Print( -1, "Currently can only solve the miter with one output.\n" );
+        return 0;
+    }
+    clk = Abc_Clock();
+
+    if ( Abc_NtkIsStrash(pNtk) )
+        pNtkTemp = Abc_NtkDup( pNtk );
+    else
+        pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
+
+    RetValue = Abc_NtkMiterProve( &pNtkTemp, pParams );
+
+    // verify that the pattern is correct
+    if ( RetValue == 0 )
+    {
+        int * pSimInfo = Abc_NtkVerifySimulatePattern( pNtk, pNtkTemp->pModel );
+        if ( pSimInfo[0] != 1 )
+            Abc_Print( 1, "ERROR in Abc_NtkMiterProve(): Generated counter-example is invalid.\n" );
+        ABC_FREE( pSimInfo );
+    }
+    pAbc->Status = RetValue;
+    if ( RetValue == -1 )
+        Abc_Print( 1, "UNDECIDED      " );
+    else if ( RetValue == 0 )
+        Abc_Print( 1, "SATISFIABLE    " );
+    else
+        Abc_Print( 1, "UNSATISFIABLE  " );
+    //Abc_Print( -1, "\n" );
+
+    Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: prove [-NCFGLI num] [-rfbvh]\n" );
+    Abc_Print( -2, "\t         solves combinational miter by rewriting, FRAIGing, and SAT\n" );
+    Abc_Print( -2, "\t         replaces the current network by the cone modified by rewriting\n" );
+    Abc_Print( -2, "\t         (there is also newer CEC command \"iprove\")\n" );
+    Abc_Print( -2, "\t-N num : max number of iterations [default = %d]\n", pParams->nItersMax );
+    Abc_Print( -2, "\t-C num : max starting number of conflicts in mitering [default = %d]\n", pParams->nMiteringLimitStart );
+    Abc_Print( -2, "\t-F num : max starting number of conflicts in fraiging [default = %d]\n", pParams->nFraigingLimitStart );
+    Abc_Print( -2, "\t-G num : multiplicative coefficient for fraiging [default = %d]\n", (int)pParams->nFraigingLimitMulti );
+    Abc_Print( -2, "\t-L num : max last-gasp number of conflicts in mitering [default = %d]\n", pParams->nMiteringLimitLast );
+    Abc_Print( -2, "\t-I num : max number of clause inspections in all SAT calls [default = %d]\n", (int)pParams->nTotalInspectLimit );
+    Abc_Print( -2, "\t-r     : toggle the use of rewriting [default = %s]\n", pParams->fUseRewriting? "yes": "no" );
+    Abc_Print( -2, "\t-f     : toggle the use of FRAIGing [default = %s]\n", pParams->fUseFraiging? "yes": "no" );
+    Abc_Print( -2, "\t-b     : toggle the use of BDDs [default = %s]\n", pParams->fUseBdds? "yes": "no" );
+    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", pParams->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandDebug( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    extern void Abc_NtkAutoDebug( Abc_Ntk_t * pNtk, int (*pFuncError) (Abc_Ntk_t *) );
+    extern int Abc_NtkRetimeDebug( Abc_Ntk_t * pNtk );
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsLogic(pNtk) )
+    {
+        Abc_Print( -1, "This command is applicable to logic networks.\n" );
+        return 1;
+    }
+
+    Abc_NtkAutoDebug( pNtk, Abc_NtkRetimeDebug );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: debug [-h]\n" );
+    Abc_Print( -2, "\t        performs automated debugging of the given procedure\n" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandBmc( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int nFrames;
+    int nSizeMax;
+    int nBTLimit;
+    int nBTLimitAll;
+    int nNodeDelta;
+    int fRewrite;
+    int fNewAlgo;
+    int nCofFanLit;
+    int fVerbose;
+    int iFrames;
+    char * pLogFileName = NULL;
+
+    extern int Abc_NtkDarBmc( Abc_Ntk_t * pNtk, int nStart, int nFrames, int nSizeMax, int nNodeDelta, int nTimeOut, int nBTLimit, int nBTLimitAll, int fRewrite, int fNewAlgo, int fOrDecomp, int nCofFanLit, int fVerbose, int * piFrames );
+    // set defaults
+    nFrames     =       20;
+    nSizeMax    =   100000;
+    nBTLimit    =        0;
+    nBTLimitAll =        0;
+    nNodeDelta  =     1000;
+    fRewrite    =        0;
+    fNewAlgo    =        1;
+    nCofFanLit  =        0;
+    fVerbose    =        0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "FNCGDLrvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFrames = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFrames < 0 )
+                goto usage;
+            break;
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nSizeMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nSizeMax < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nBTLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nBTLimit < 0 )
+                goto usage;
+            break;
+        case 'G':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-G\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nBTLimitAll = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nBTLimitAll < 0 )
+                goto usage;
+            break;
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nNodeDelta = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nNodeDelta < 0 )
+                goto usage;
+            break;
+/*
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nCofFanLit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nCofFanLit < 0 )
+                goto usage;
+            break;
+*/
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by a file name.\n" );
+                goto usage;
+            }
+            pLogFileName = argv[globalUtilOptind];
+            globalUtilOptind++;
+            break;
+        case 'r':
+            fRewrite ^= 1;
+            break;
+        case 'a':
+            fNewAlgo ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
+        return 0;
+    }
+    if ( Abc_NtkLatchNum(pNtk) == 0 )
+    {
+        Abc_Print( -1, "Does not work for combinational networks.\n" );
+        return 0;
+    }
+    pAbc->Status = Abc_NtkDarBmc( pNtk, 0, nFrames, nSizeMax, nNodeDelta, 0, nBTLimit, nBTLimitAll, fRewrite, fNewAlgo, 0, nCofFanLit, fVerbose, &iFrames );
+    pAbc->nFrames = iFrames;
+    Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
+    if ( pLogFileName )
+        Abc_NtkWriteLogFile( pLogFileName, pAbc->pCex, pAbc->Status, pAbc->nFrames, "bmc" );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: bmc [-FNC num] [-L file] [-rcvh]\n" );
+    Abc_Print( -2, "\t         performs bounded model checking with static unrolling\n" );
+    Abc_Print( -2, "\t-F num : the number of time frames [default = %d]\n", nFrames );
+    Abc_Print( -2, "\t-N num : the max number of nodes in the frames [default = %d]\n", nSizeMax );
+    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", nBTLimit );
+//    Abc_Print( -2, "\t-L num : the limit on fanout count of resets/enables to cofactor [default = %d]\n", nCofFanLit );
+    Abc_Print( -2, "\t-L file: the log file name [default = %s]\n", pLogFileName ? pLogFileName : "no logging" );
+    Abc_Print( -2, "\t-r     : toggle the use of rewriting [default = %s]\n", fRewrite? "yes": "no" );
+//    Abc_Print( -2, "\t-a     : toggle SAT sweeping and SAT solving [default = %s]\n", fNewAlgo? "SAT solving": "SAT sweeping" );
+    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandBmc2( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    int nStart;
+    int nFrames;
+    int nSizeMax;
+    int nBTLimit;
+    int nBTLimitAll;
+    int nNodeDelta;
+    int nTimeOut;
+    int fRewrite;
+    int fNewAlgo;
+    int fOrDecomp;
+    int fVerbose;
+    int iFrames;
+    char * pLogFileName = NULL;
+
+    extern int Abc_NtkDarBmc( Abc_Ntk_t * pNtk, int nStart, int nFrames, int nSizeMax, int nNodeDelta, int nTimeOut, int nBTLimit, int nBTLimitAll, int fRewrite, int fNewAlgo, int fOrDecomp, int nCofFanLit, int fVerbose, int * piFrames );
+
+    // set defaults
+    nStart      =        0;
+    nFrames     =        0;
+    nSizeMax    =   200000;
+    nBTLimit    =        0;
+    nBTLimitAll =        0;
+    nNodeDelta  =     2000;
+    nTimeOut    =        0;
+    fRewrite    =        0;
+    fNewAlgo    =        0;
+    fOrDecomp   =        0;
+    fVerbose    =        0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "SFNTCGDLruvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nStart = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nStart < 0 )
+                goto usage;
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFrames = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFrames < 0 )
+                goto usage;
+            break;
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nSizeMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nSizeMax < 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nTimeOut = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nTimeOut < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nBTLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nBTLimit < 0 )
+                goto usage;
+            break;
+        case 'G':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-G\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nBTLimitAll = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nBTLimitAll < 0 )
+                goto usage;
+            break;
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nNodeDelta = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nNodeDelta < 0 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by a file name.\n" );
+                goto usage;
+            }
+            pLogFileName = argv[globalUtilOptind];
+            globalUtilOptind++;
+            break;
+        case 'r':
+            fRewrite ^= 1;
+            break;
+        case 'a':
+            fNewAlgo ^= 1;
+            break;
+        case 'u':
+            fOrDecomp ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
+        return 0;
+    }
+    if ( Abc_NtkLatchNum(pNtk) == 0 )
+    {
+        Abc_Print( -1, "Does not work for combinational networks.\n" );
+        return 0;
+    }
+    pAbc->Status = Abc_NtkDarBmc( pNtk, nStart, nFrames, nSizeMax, nNodeDelta, nTimeOut, nBTLimit, nBTLimitAll, fRewrite, fNewAlgo, fOrDecomp, 0, fVerbose, &iFrames );
+    pAbc->nFrames = iFrames;
+    Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
+    if ( pLogFileName )
+        Abc_NtkWriteLogFile( pLogFileName, pAbc->pCex, pAbc->Status, pAbc->nFrames, "bmc2" );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: bmc2 [-SFTCGD num] [-L file] [-uvh]\n" );
+    Abc_Print( -2, "\t         performs bounded model checking with dynamic unrolling\n" );
+    Abc_Print( -2, "\t-S num : the starting time frame [default = %d]\n", nStart );
+    Abc_Print( -2, "\t-F num : the max number of time frames (0 = unused) [default = %d]\n", nFrames );
+    Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", nTimeOut );
+    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", nBTLimit );
+    Abc_Print( -2, "\t-G num : the max number of conflicts globally [default = %d]\n", nBTLimitAll );
+    Abc_Print( -2, "\t-D num : the delta in the number of nodes [default = %d]\n", nNodeDelta );
+    Abc_Print( -2, "\t-L file: the log file name [default = %s]\n", pLogFileName ? pLogFileName : "no logging" );
+    Abc_Print( -2, "\t-u     : toggle performing structural OR-decomposition [default = %s]\n", fOrDecomp? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandBmc3( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern int Abc_NtkDarBmc3( Abc_Ntk_t * pNtk, Saig_ParBmc_t * pPars, int fOrDecomp );
+    Saig_ParBmc_t Pars, * pPars = &Pars;
+    Abc_Ntk_t * pNtkRes, * pNtk = Abc_FrameReadNtk(pAbc);
+    Vec_Ptr_t * vSeqModelVec = NULL;
+    Vec_Int_t * vStatuses = NULL;
+    char * pLogFileName = NULL;
+    int fOrDecomp = 0;
+    int c;
+    Saig_ParBmcSetDefaultParams( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "SFTHGCDJIPQRLWaxdruvzh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nStart = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nStart < 0 )
+                goto usage;
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nFramesMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nFramesMax < 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nTimeOut = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nTimeOut < 0 )
+                goto usage;
+            break;
+        case 'H':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-H\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nTimeOutOne = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nTimeOutOne < 0 )
+                goto usage;
+            break;
+        case 'G':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-G\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nTimeOutGap = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nTimeOutGap < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nConfLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nConfLimit < 0 )
+                goto usage;
+            break;
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nConfLimitJump = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nConfLimitJump < 0 )
+                goto usage;
+            break;
+        case 'J':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-J\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nFramesJump = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nFramesJump < 0 )
+                goto usage;
+            break;
+        case 'I':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nPisAbstract = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nPisAbstract < 0 )
+                goto usage;
+            break;
+        case 'P':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nLearnedStart = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nLearnedStart < 0 )
+                goto usage;
+            break;
+        case 'Q':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-Q\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nLearnedDelta = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nLearnedDelta < 0 )
+                goto usage;
+            break;
+        case 'R':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nLearnedPerce = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nLearnedPerce < 0 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by a file name.\n" );
+                goto usage;
+            }
+            pLogFileName = argv[globalUtilOptind];
+            globalUtilOptind++;
+            break;
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by a file name.\n" );
+                goto usage;
+            }
+            pPars->pLogFileName = argv[globalUtilOptind];
+            globalUtilOptind++;
+            break;
+        case 'a':
+            pPars->fSolveAll ^= 1;
+            break;
+        case 'x':
+            pPars->fStoreCex ^= 1;
+            break;
+        case 'd':
+            pPars->fDropSatOuts ^= 1;
+            break;
+        case 'u':
+            fOrDecomp ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'z':
+            pPars->fNotVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
+        return 0;
+    }
+    if ( Abc_NtkLatchNum(pNtk) == 0 )
+    {
+        Abc_Print( -1, "Does not work for combinational networks.\n" );
+        return 0;
+    }
+    if ( Abc_NtkConstrNum(pNtk) > 0 )
+    {
+        Abc_Print( -1, "Constraints have to be folded (use \"fold\").\n" );
+        return 0;
+    }
+    pPars->fUseBridge = pAbc->fBridgeMode;
+    pAbc->Status = Abc_NtkDarBmc3( pNtk, pPars, fOrDecomp );
+    pAbc->nFrames = pNtk->vSeqModelVec ? -1 : pPars->iFrame;
+    if ( pLogFileName )
+        Abc_NtkWriteLogFile( pLogFileName, pAbc->pCex, pAbc->Status, pAbc->nFrames, "bmc3" );
+    vSeqModelVec = pNtk->vSeqModelVec;  pNtk->vSeqModelVec = NULL;
+    if ( pPars->fSolveAll && pPars->fDropSatOuts )
+    {
+        if ( vSeqModelVec == NULL )
+            Abc_Print( 1,"The array of counter-examples is not available.\n" );
+        else if ( Vec_PtrSize(vSeqModelVec) != Abc_NtkPoNum(pNtk) )
+            Abc_Print( 1,"The array size does not match the number of outputs.\n" );
+        else
+        {
+            extern void Abc_NtkDropSatOutputs( Abc_Ntk_t * pNtk, Vec_Ptr_t * vCexes, int fVerbose );
+            Abc_NtkDropSatOutputs( pNtk, vSeqModelVec, pPars->fVerbose );
+            pNtkRes = Abc_NtkDarLatchSweep( pNtk, 1, 1, 1, 0, -1, -1, 0, 0 );
+            if ( pNtkRes == NULL )
+            {
+                Abc_Print( -1, "Removing SAT outputs has failed.\n" );
+                return 1;
+            }
+            Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+        }
+    }
+    vStatuses = Abc_FrameDeriveStatusArray( vSeqModelVec );
+    Abc_FrameReplacePoStatuses( pAbc, &vStatuses );        
+    if ( vSeqModelVec )
+        Abc_FrameReplaceCexVec( pAbc, &vSeqModelVec );
+    else
+        Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: bmc3 [-SFTHGCDJIPQR num] [-LW file] [-axduvzh]\n" );
+    Abc_Print( -2, "\t         performs bounded model checking with dynamic unrolling\n" );
+    Abc_Print( -2, "\t-S num : the starting time frame [default = %d]\n", pPars->nStart );
+    Abc_Print( -2, "\t-F num : the max number of time frames (0 = unused) [default = %d]\n",      pPars->nFramesMax );
+    Abc_Print( -2, "\t-T num : runtime limit, in seconds [default = %d]\n",                       pPars->nTimeOut );
+    Abc_Print( -2, "\t-H num : runtime limit per output, in miliseconds (with \"-a\") [default = %d]\n",    pPars->nTimeOutOne );
+    Abc_Print( -2, "\t-G num : runtime gap since the last CEX, in seconds [default = %d]\n",      pPars->nTimeOutGap );
+    Abc_Print( -2, "\t-C num : max conflicts at an output [default = %d]\n",                      pPars->nConfLimit );
+    Abc_Print( -2, "\t-D num : max conflicts after jumping (0 = infinity) [default = %d]\n",      pPars->nConfLimitJump );
+    Abc_Print( -2, "\t-J num : the number of timeframes to jump (0 = not used) [default = %d]\n", pPars->nFramesJump );
+    Abc_Print( -2, "\t-I num : the number of PIs to abstract [default = %d]\n",                   pPars->nPisAbstract );
+    Abc_Print( -2, "\t-P num : the max number of learned clauses to keep (0=unused) [default = %d]\n", pPars->nLearnedStart );
+    Abc_Print( -2, "\t-Q num : delta value for learned clause removal [default = %d]\n",          pPars->nLearnedDelta );
+    Abc_Print( -2, "\t-R num : percentage to keep for learned clause removal [default = %d]\n",   pPars->nLearnedPerce );
+    Abc_Print( -2, "\t-L file: the log file name [default = %s]\n",                               pLogFileName ? pLogFileName : "no logging" );
+    Abc_Print( -2, "\t-W file: the log file name with per-output details [default = %s]\n",       pPars->pLogFileName ? pPars->pLogFileName : "no logging" );
+    Abc_Print( -2, "\t-a     : solve all outputs (do not stop when one is SAT) [default = %s]\n", pPars->fSolveAll? "yes": "no" );
+    Abc_Print( -2, "\t-x     : toggle storing CEXes when solving all outputs [default = %s]\n",   pPars->fStoreCex? "yes": "no" );
+    Abc_Print( -2, "\t-d     : toggle dropping (replacing by 0) SAT outputs [default = %s]\n",    pPars->fDropSatOuts? "yes": "no" );
+    Abc_Print( -2, "\t-u     : toggle performing structural OR-decomposition [default = %s]\n",   fOrDecomp? "yes": "not" );
+    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n",                           pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-z     : toggle suppressing report about solved outputs [default = %s]\n",  pPars->fNotVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandBmcInter( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Inter_ManParams_t Pars, * pPars = &Pars;
+    Abc_Ntk_t * pNtkRes, * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    char * pLogFileName = NULL;
+
+    extern int Abc_NtkDarBmcInter( Abc_Ntk_t * pNtk, Inter_ManParams_t * pPars, Abc_Ntk_t ** ppNtkRes );
+    // set defaults
+    Inter_ManSetDefaultParams( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "CFTKLIrtpomcgbqkdivh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nBTLimit < 0 )
+                goto usage;
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nFramesMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nFramesMax < 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nSecLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nSecLimit < 0 )
+                goto usage;
+            break;
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nFramesK = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nFramesK < 0 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by a file name.\n" );
+                goto usage;
+            }
+            pLogFileName = argv[globalUtilOptind];
+            globalUtilOptind++;
+            break;
+        case 'I':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-I\" should be followed by a file name.\n" );
+                goto usage;
+            }
+            pPars->pFileName = argv[globalUtilOptind];
+            globalUtilOptind++;
+            break;
+        case 'r':
+            pPars->fRewrite ^= 1;
+            break;
+        case 't':
+            pPars->fTransLoop ^= 1;
+            break;
+        case 'p':
+            pPars->fUsePudlak ^= 1;
+            break;
+        case 'o':
+            pPars->fUseOther ^= 1;
+            break;
+        case 'm':
+            pPars->fUseMiniSat ^= 1;
+            break;
+        case 'c':
+            pPars->fCheckKstep ^= 1;
+            break;
+        case 'g':
+            pPars->fUseBias ^= 1;
+            break;
+        case 'b':
+            pPars->fUseBackward ^= 1;
+            break;
+        case 'q':
+            pPars->fUseTwoFrames ^= 1;
+            break;
+        case 'k':
+            pPars->fUseSeparate ^= 1;
+            break;
+        case 'd':
+            pPars->fDropSatOuts ^= 1;
+            break;
+        case 'i':
+            pPars->fDropInvar ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
+        return 0;
+    }
+    if ( Abc_NtkLatchNum(pNtk) == 0 )
+    {
+        Abc_Print( -1, "Does not work for combinational networks.\n" );
+        return 0;
+    }
+    if ( Abc_NtkConstrNum(pNtk) > 0 )
+    {
+        Abc_Print( -1, "Cannot run interpolation with constraints. Use \"fold\".\n" );
+        return 0;
+    }
+    if ( Abc_NtkPoNum(pNtk)-Abc_NtkConstrNum(pNtk) != 1 )
+    {
+        if ( Abc_NtkConstrNum(pNtk) > 0 )
+        {
+            Abc_Print( 1,"Cannot solve multiple-output miter with constraints.\n" );
+            return 0;
+        }
+        if ( pPars->fUseSeparate )
+        {
+            Abc_Print( 0, "Each of %d outputs will be solved separately.\n", Abc_NtkPoNum(pNtk) );
+            pAbc->Status = Abc_NtkDarBmcInter( pNtk, pPars, &pNtkRes );
+            Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
+            if ( pNtkRes == NULL )
+            {
+                Abc_Print( -1, "Generating resulting network has failed.\n" );
+                return 0;
+            }
+            Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+        }
+        else
+        {
+            Abc_Ntk_t * pNtkNew = Abc_NtkDup( pNtk );
+            Abc_Print( 0, "All %d outputs will be ORed together.\n", Abc_NtkPoNum(pNtk) );
+            if ( !Abc_NtkCombinePos( pNtkNew, 0, 0 ) )
+            {
+                Abc_NtkDelete( pNtkNew );
+                Abc_Print( -1, "ORing outputs has failed.\n" );
+                return 0;
+            }
+            pAbc->Status = Abc_NtkDarBmcInter( pNtkNew, pPars, NULL );
+            if ( pAbc->Status == 0 )
+            {
+                Aig_Man_t * pMan = Abc_NtkToDar( pNtk, 0, 1 );
+                pNtkNew->pSeqModel->iPo = Saig_ManFindFailedPoCex( pMan, pNtkNew->pSeqModel );
+                Aig_ManStop( pMan );
+            }
+            Abc_FrameReplaceCex( pAbc, &pNtkNew->pSeqModel );
+            Abc_NtkDelete( pNtkNew );
+        }
+        pAbc->nFrames = -1;
+    }
+    else
+    {
+        pAbc->Status  = Abc_NtkDarBmcInter( pNtk, pPars, NULL );
+        pAbc->nFrames = pPars->iFrameMax;
+        Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
+    }
+    if ( pLogFileName )
+        Abc_NtkWriteLogFile( pLogFileName, pAbc->pCex, pAbc->Status, pAbc->nFrames, "int" );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: int [-CFTK num] [-LI file] [-irtpomcgbqkdvh]\n" );
+    Abc_Print( -2, "\t         uses interpolation to prove the property\n" );
+    Abc_Print( -2, "\t-C num : the limit on conflicts for one SAT run [default = %d]\n", pPars->nBTLimit );
+    Abc_Print( -2, "\t-F num : the limit on number of frames to unroll [default = %d]\n", pPars->nFramesMax );
+    Abc_Print( -2, "\t-T num : the limit on runtime per output in seconds [default = %d]\n", pPars->nSecLimit );
+    Abc_Print( -2, "\t-K num : the number of steps in inductive checking [default = %d]\n", pPars->nFramesK );
+    Abc_Print( -2, "\t         (K = 1 works in all cases; K > 1 works without -t and -b)\n" );
+    Abc_Print( -2, "\t-L file: the log file name [default = %s]\n", pLogFileName ? pLogFileName : "no logging" );
+    Abc_Print( -2, "\t-I file: the file name for dumping interpolant [default = \"%s\"]\n", pPars->pFileName ? pPars->pFileName : "invar.aig" );
+    Abc_Print( -2, "\t-i     : toggle dumping interpolant/invariant into a file [default = %s]\n", pPars->fDropInvar? "yes": "no" );
+    Abc_Print( -2, "\t-r     : toggle rewriting of the unrolled timeframes [default = %s]\n", pPars->fRewrite? "yes": "no" );
+    Abc_Print( -2, "\t-t     : toggle adding transition into the initial state [default = %s]\n", pPars->fTransLoop? "yes": "no" );
+    Abc_Print( -2, "\t-p     : toggle using original Pudlak's interpolation procedure [default = %s]\n", pPars->fUsePudlak? "yes": "no" );
+    Abc_Print( -2, "\t-o     : toggle using optimized Pudlak's interpolation procedure [default = %s]\n", pPars->fUseOther? "yes": "no" );
+    Abc_Print( -2, "\t-m     : toggle using MiniSat-1.14p (now, Windows-only) [default = %s]\n", pPars->fUseMiniSat? "yes": "no" );
+    Abc_Print( -2, "\t-c     : toggle using inductive containment check [default = %s]\n", pPars->fCheckKstep? "yes": "no" );
+    Abc_Print( -2, "\t-g     : toggle using bias for global variables using SAT [default = %s]\n", pPars->fUseBias? "yes": "no" );
+    Abc_Print( -2, "\t-b     : toggle using backward interpolation (works with -t) [default = %s]\n", pPars->fUseBackward? "yes": "no" );
+    Abc_Print( -2, "\t-q     : toggle using property in two last timeframes [default = %s]\n", pPars->fUseTwoFrames? "yes": "no" );
+    Abc_Print( -2, "\t-k     : toggle solving each output separately [default = %s]\n", pPars->fUseSeparate? "yes": "no" );
+    Abc_Print( -2, "\t-d     : toggle dropping (replacing by 0) SAT outputs (with -k is used) [default = %s]\n", pPars->fDropSatOuts? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandIndcut( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int nFrames;
+    int nPref;
+    int nClauses;
+    int nLutSize;
+    int nLevels;
+    int nCutsMax;
+    int nBatches;
+    int fStepUp;
+    int fBmc;
+    int fRegs;
+    int fTarget;
+    int fVerbose;
+    int fVeryVerbose;
+    int c;
+    extern int Abc_NtkDarClau( Abc_Ntk_t * pNtk, int nFrames, int nPref, int nClauses, int nLutSize, int nLevels, int nCutsMax, int nBatches, int fStepUp, int fBmc, int fRegs, int fTarget, int fVerbose, int fVeryVerbose );
+    // set defaults
+    nFrames      =    1;
+    nPref        =    0;
+    nClauses     = 5000;
+    nLutSize     =    4;
+    nLevels      =    8;
+    nCutsMax     =   16;
+    nBatches     =    1;
+    fStepUp      =    0;
+    fBmc         =    1;
+    fRegs        =    1;
+    fTarget      =    1;
+    fVerbose     =    0;
+    fVeryVerbose =    0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "FPCMLNBsbrtvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFrames = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFrames < 0 )
+                goto usage;
+            break;
+        case 'P':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nPref = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nPref < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nClauses = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nClauses < 0 )
+                goto usage;
+            break;
+        case 'M':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nLutSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLutSize < 0 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nLevels = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLevels < 0 )
+                goto usage;
+            break;
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nCutsMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nCutsMax < 0 )
+                goto usage;
+            break;
+        case 'B':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nBatches = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nBatches < 0 )
+                goto usage;
+            break;
+        case 's':
+            fStepUp ^= 1;
+            break;
+        case 'b':
+            fBmc ^= 1;
+            break;
+        case 'r':
+            fRegs ^= 1;
+            break;
+        case 't':
+            fTarget ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'w':
+            fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( Abc_NtkIsComb(pNtk) )
+    {
+        Abc_Print( -1, "The network is combinational.\n" );
+        return 0;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
+        return 0;
+    }
+    if ( nLutSize > 12 )
+    {
+        Abc_Print( -1, "The cut size should be not exceed 12.\n" );
+        return 0;
+    }
+    Abc_NtkDarClau( pNtk, nFrames, nPref, nClauses, nLutSize, nLevels, nCutsMax, nBatches, fStepUp, fBmc, fRegs, fTarget, fVerbose, fVeryVerbose );
+    return 0;
+usage:
+    Abc_Print( -2, "usage: indcut [-FPCMLNB num] [-sbrtvh]\n" );
+    Abc_Print( -2, "\t         K-step induction strengthened with cut properties\n" );
+    Abc_Print( -2, "\t-F num : number of time frames for induction (1=simple) [default = %d]\n", nFrames );
+    Abc_Print( -2, "\t-P num : number of time frames in the prefix (0=no prefix) [default = %d]\n", nPref );
+    Abc_Print( -2, "\t-C num : the max number of clauses to use for strengthening [default = %d]\n", nClauses );
+    Abc_Print( -2, "\t-M num : the cut size (2 <= M <= 12) [default = %d]\n", nLutSize );
+    Abc_Print( -2, "\t-L num : the max number of levels for cut computation [default = %d]\n", nLevels );
+    Abc_Print( -2, "\t-N num : the max number of cuts to compute at a node [default = %d]\n", nCutsMax );
+    Abc_Print( -2, "\t-B num : the max number of invariant batches to try [default = %d]\n", nBatches );
+    Abc_Print( -2, "\t-s     : toggle increment cut size in each batch [default = %s]\n", fStepUp? "yes": "no" );
+    Abc_Print( -2, "\t-b     : toggle enabling BMC check [default = %s]\n", fBmc? "yes": "no" );
+    Abc_Print( -2, "\t-r     : toggle enabling register clauses [default = %s]\n", fRegs? "yes": "no" );
+    Abc_Print( -2, "\t-t     : toggle proving target / computing don't-cares [default = %s]\n", fTarget? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+//    Abc_Print( -2, "\t-w     : toggle printing very verbose information [default = %s]\n", fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandEnlarge( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int nFrames;
+    int fVerbose;
+    int c;
+    extern Abc_Ntk_t * Abc_NtkDarEnlarge( Abc_Ntk_t * pNtk, int nFrames, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    nFrames      = 5;
+    fVerbose     = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Fvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFrames = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFrames < 1 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( Abc_NtkIsComb(pNtk) )
+    {
+        Abc_Print( -1, "The network is combinational.\n" );
+        return 0;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
+        return 0;
+    }
+
+    // modify the current network
+    pNtkRes = Abc_NtkDarEnlarge( pNtk, nFrames, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Target enlargement has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+usage:
+    Abc_Print( -2, "usage: enlarge [-F <num>] [-vh]\n" );
+    Abc_Print( -2, "\t           performs structural K-step target enlargement\n" );
+    Abc_Print( -2, "\t-F <num> : the number of timeframes to unroll (<num> > 0) [default = %d]\n", nFrames );
+    Abc_Print( -2, "\t-v       : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandTempor( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Abc_Ntk_t * Abc_NtkDarTempor( Abc_Ntk_t * pNtk, int nFrames, int TimeOut, int nConfLimit, int fUseBmc, int fUseTransSigs, int fVerbose, int fVeryVerbose );
+    Abc_Ntk_t * pNtkRes, * pNtk = Abc_FrameReadNtk(pAbc);
+    int nFrames       =       0;
+    int TimeOut       =     300;
+    int nConfMax      =  100000;
+    int fUseBmc       =       1;
+    int fUseTransSigs =       0;
+    int fUpdateCex    =       0;
+    int fVerbose      =       0;
+    int fVeryVerbose  =       0;
+    int c;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "FTCbscvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFrames = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFrames < 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            TimeOut = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( TimeOut < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nConfMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nConfMax < 0 )
+                goto usage;
+            break;
+        case 'b':
+            fUseBmc ^= 1;
+            break;
+        case 's':
+            fUseTransSigs ^= 1;
+            break;
+        case 'c':
+            fUpdateCex ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'w':
+            fVeryVerbose ^= 1;
+            break;
+        case 'h':
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -2, "There is no current network.\n");
+        return 0;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -2, "The current network is not an AIG (run \"strash\").\n");
+        return 0;
+    }
+    if ( Abc_NtkLatchNum(pNtk) == 0 )
+    {
+        Abc_Print( -2, "The current network is combinational.\n");
+        return 0;
+    }
+    if ( fUpdateCex )
+    {
+        Abc_Cex_t * pCexNew;
+        if ( pAbc->pCex == NULL )
+        {
+            Abc_Print( -1, "Counter-example is not available.\n" );
+            return 1;
+        }
+        if ( pAbc->pCex->nPis % Abc_NtkPiNum(pNtk) != 0 )
+        {
+            Abc_Print( -1, "PI count of the CEX is not a multiple of PI count of the current AIG.\n" );
+            return 1;
+        }
+        pCexNew = Abc_CexTransformTempor( pAbc->pCex, Abc_NtkPiNum(pNtk), Abc_NtkPoNum(pNtk), Abc_NtkLatchNum(pNtk) );
+        Abc_FrameReplaceCex( pAbc, &pCexNew );
+        return 0;
+    }
+    // modify the current network
+    pNtkRes = Abc_NtkDarTempor( pNtk, nFrames, TimeOut, nConfMax, fUseBmc, fUseTransSigs, fVerbose, fVeryVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( -1, "Temporal decomposition has failed.\n" );
+        return 1;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: tempor [-FTC <num>] [-bscvwh]\n" );
+    Abc_Print( -2, "\t           performs temporal decomposition\n" );
+    Abc_Print( -2, "\t-F <num> : init logic timeframe count (0 = use leading length) [default = %d]\n", nFrames );
+    Abc_Print( -2, "\t-T <num> : runtime limit in seconds for BMC (0=unused) [default = %d]\n", TimeOut );
+    Abc_Print( -2, "\t-C <num> : max number of SAT conflicts in BMC (0=unused) [default = %d]\n", nConfMax );
+    Abc_Print( -2, "\t-b       : toggle running BMC2 on the init frames [default = %s]\n", fUseBmc? "yes": "no" );
+    Abc_Print( -2, "\t-s       : toggle using transient signals [default = %s]\n", fUseTransSigs? "yes": "no" );
+    Abc_Print( -2, "\t-c       : update the current CEX derived for a new AIG after \"tempor\"\n" );
+    Abc_Print( -2, "\t           to match the current AIG (the one before \"tempor\") [default = %s]\n", fUpdateCex? "yes": "no" );
+    Abc_Print( -2, "\t-v       : toggle printing verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w       : toggle printing ternary state space [default = %s]\n", fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandInduction( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int nTimeOut;
+    int nFramesMax;
+    int nConfMax;
+    int fUnique;
+    int fUniqueAll;
+    int fGetCex;
+    int fVerbose;
+    int fVeryVerbose;
+    int c;
+    extern int Abc_NtkDarInduction( Abc_Ntk_t * pNtk, int nTimeOut, int nFramesMax, int nConfMax, int fUnique, int fUniqueAll, int fGetCex, int fVerbose, int fVeryVerbose );
+    // set defaults
+    nTimeOut     =     0;
+    nFramesMax   =     0;
+    nConfMax     =     0;
+    fUnique      =     0;
+    fUniqueAll   =     0;
+    fGetCex      =     0;
+    fVerbose     =     0;
+    fVeryVerbose =     0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "FCTuaxvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFramesMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFramesMax < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nConfMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nConfMax < 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nTimeOut = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nTimeOut < 0 )
+                goto usage;
+            break;
+        case 'u':
+            fUnique ^= 1;
+            break;
+        case 'a':
+            fUniqueAll ^= 1;
+            break;
+        case 'x':
+            fGetCex ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'w':
+            fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( Abc_NtkIsComb(pNtk) )
+    {
+        Abc_Print( -1, "The network is combinational.\n" );
+        return 0;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
+        return 0;
+    }
+    if ( Abc_NtkPoNum(pNtk) != 1 )
+    {
+        Abc_Print( -1, "Currently this command works only for single-output miter.\n" );
+        return 0;
+    }
+    if ( fUnique && fUniqueAll )
+    {
+        Abc_Print( -1, "Only one of the options, \"-u\" or \"-a\", should be selected.\n" );
+        return 0;
+    }
+
+    // modify the current network
+    pAbc->Status = Abc_NtkDarInduction( pNtk, nTimeOut, nFramesMax, nConfMax, fUnique, fUniqueAll, fGetCex, fVerbose, fVeryVerbose );
+    if ( fGetCex )
+    {
+        Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
+        Abc_Print( 1,"The current CEX in ABC is set to be the CEX to induction.\n" );
+    }
+    return 0;
+usage:
+    Abc_Print( -2, "usage: ind [-FCT num] [-uaxvwh]\n" );
+    Abc_Print( -2, "\t         runs the inductive case of the K-step induction\n" );
+    Abc_Print( -2, "\t-F num : the max number of timeframes [default = %d]\n", nFramesMax );
+    Abc_Print( -2, "\t-C num : the max number of conflicts by SAT solver [default = %d]\n", nConfMax );
+    Abc_Print( -2, "\t-T num : the limit on runtime per output in seconds [default = %d]\n", nTimeOut );
+    Abc_Print( -2, "\t-u     : toggle adding uniqueness constraints on demand [default = %s]\n", fUnique? "yes": "no" );
+    Abc_Print( -2, "\t-a     : toggle adding uniqueness constraints always [default = %s]\n", fUniqueAll? "yes": "no" );
+    Abc_Print( -2, "\t-x     : toggle returning CEX to induction for the top frame [default = %s]\n", fGetCex? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w     : toggle printing additional verbose information [default = %s]\n", fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandConstr( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk;
+    int c;
+    int nFrames;
+    int nConfs;
+    int nProps;
+    int fRemove;
+    int fStruct;
+    int fInvert;
+    int fOldAlgo;
+    int fVerbose;
+    int nConstrs;
+    extern void Abc_NtkDarConstr( Abc_Ntk_t * pNtk, int nFrames, int nConfs, int nProps, int fStruct, int fOldAlgo, int fVerbose );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    nFrames   =      1;
+    nConfs    =   1000;
+    nProps    =   1000;
+    fRemove   =      0;
+    fStruct   =      0;
+    fInvert   =      0;
+    fOldAlgo  =      0;
+    fVerbose  =      0;
+    nConstrs  =     -1;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "FCPNrsiavh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFrames = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFrames < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nConfs = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nConfs < 0 )
+                goto usage;
+            break;
+        case 'P':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nProps = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nProps < 0 )
+                goto usage;
+            break;
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nConstrs = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nConstrs < 0 )
+                goto usage;
+            break;
+        case 'r':
+            fRemove ^= 1;
+            break;
+        case 's':
+            fStruct ^= 1;
+            break;
+        case 'i':
+            fInvert ^= 1;
+            break;
+        case 'a':
+            fOldAlgo ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
+        return 0;
+    }
+    if ( fRemove )
+    {
+        if ( Abc_NtkConstrNum(pNtk) == 0 )
+        {
+            Abc_Print( -1, "Constraints are not defined.\n" );
+            return 0;
+        }
+        Abc_Print( 1, "Constraints are converted to be primary outputs.\n" );
+        pNtk->nConstrs = 0;
+        return 0;
+    }
+    // consider the case of manual constraint definition
+    if ( nConstrs >= 0 )
+    {
+        if ( Abc_NtkIsComb(pNtk) )
+            Abc_Print( 0, "The network is combinational.\n" );
+        if ( Abc_NtkConstrNum(pNtk) > 0 )
+            Abc_Print( 0, "The network currently has %d constraints.\n", Abc_NtkConstrNum(pNtk) );
+        if ( nConstrs >= Abc_NtkPoNum(pNtk) )
+        {
+            Abc_Print( -1, "The number of constraints specified (%d) should be less than POs (%d).\n", nConstrs, Abc_NtkPoNum(pNtk) );
+            return 0;
+        }
+        Abc_Print( 1, "Setting the last %d POs as constraint outputs.\n", nConstrs );
+        pNtk->nConstrs = nConstrs;
+        return 0;
+    }
+    // consider the case of already defined constraints
+    if ( Abc_NtkConstrNum(pNtk) > 0 )
+    {
+        extern void Abc_NtkDarConstrProfile( Abc_Ntk_t * pNtk, int fVerbose );
+        if ( fInvert )
+        {
+            Abc_NtkInvertConstraints( pNtk );
+            if ( Abc_NtkConstrNum(pNtk) == 1 )
+                Abc_Print( 1, "The output of %d constraint is complemented.\n", Abc_NtkConstrNum(pNtk) );
+            else
+                Abc_Print( 1, "The outputs of %d constraints are complemented.\n", Abc_NtkConstrNum(pNtk) );
+        }
+        if ( fVerbose )
+            Abc_NtkDarConstrProfile( pNtk, fVerbose );
+        return 0;
+    }
+    if ( Abc_NtkIsComb(pNtk) )
+    {
+        Abc_Print( -1, "The network is combinational.\n" );
+        return 0;
+    }
+    // detect constraints using functional/structural methods
+    Abc_NtkDarConstr( pNtk, nFrames, nConfs, nProps, fStruct, fOldAlgo, fVerbose );
+    return 0;
+usage:
+    Abc_Print( -2, "usage: constr [-FCPN num] [-risavh]\n" );
+    Abc_Print( -2, "\t         a toolkit for constraint manipulation\n" );
+    Abc_Print( -2, "\t         if constraints are absent, detect them functionally\n" );
+    Abc_Print( -2, "\t         if constraints are present, profiles them using random simulation\n" );
+    Abc_Print( -2, "\t-F num : the max number of timeframes to consider [default = %d]\n", nFrames );
+    Abc_Print( -2, "\t-C num : the max number of conflicts in SAT solving [default = %d]\n", nConfs );
+    Abc_Print( -2, "\t-P num : the max number of propagations in SAT solving [default = %d]\n", nProps );
+    Abc_Print( -2, "\t-N num : manually set the last <num> POs to be constraints [default = %d]\n", nConstrs );
+    Abc_Print( -2, "\t-r     : manually remove the constraints [default = %s]\n", fRemove? "yes": "no" );
+    Abc_Print( -2, "\t-i     : toggle inverting already defined constraints [default = %s]\n", fInvert? "yes": "no" );
+    Abc_Print( -2, "\t-s     : toggle using structural detection methods [default = %s]\n", fStruct? "yes": "no" );
+    Abc_Print( -2, "\t-a     : toggle fast implication detection [default = %s]\n", !fOldAlgo? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandUnfold( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int nFrames;
+    int nConfs;
+    int nProps;
+    int fStruct;
+    int fOldAlgo;
+    int fVerbose;
+    int c;
+    extern Abc_Ntk_t * Abc_NtkDarUnfold( Abc_Ntk_t * pNtk, int nFrames, int nConfs, int nProps, int fStruct, int fOldAlgo, int fVerbose );
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    nFrames   =      1;
+    nConfs    =   1000;
+    nProps    =   1000;
+    fStruct   =      0;
+    fOldAlgo  =      0;
+    fVerbose  =      0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "FCPsavh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFrames = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFrames < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nConfs = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nConfs < 0 )
+                goto usage;
+            break;
+        case 'P':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nProps = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nProps < 0 )
+                goto usage;
+            break;
+        case 's':
+            fStruct ^= 1;
+            break;
+        case 'a':
+            fOldAlgo ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( Abc_NtkIsComb(pNtk) && Abc_NtkPoNum(pNtk) > 1 )
+    {
+        Abc_Print( -1, "Combinational miter has more than one PO.\n" );
+        return 0;
+    }
+    if ( Abc_NtkIsComb(pNtk) )
+    {
+        extern Gia_Man_t * Gia_ManDupWithConstr( Gia_Man_t * p );
+        Gia_Man_t * pNew;
+        Aig_Man_t * pAig = Abc_NtkToDar( pNtk, 0, 0 );
+        Gia_Man_t * pGia = Gia_ManFromAigSimple( pAig );
+        Aig_ManStop( pAig );
+        pNew = Gia_ManDupWithConstr( pGia );
+        if ( pNew == NULL )
+        {
+            Abc_Print( -1, "Cannot extract constrains from the miter.\n" );
+            return 0;
+        }
+        Gia_ManStop( pGia );
+        pAig = Gia_ManToAigSimple( pNew );
+        Gia_ManStop( pNew );
+        pNtkRes = Abc_NtkFromAigPhase( pAig );
+        Aig_ManStop( pAig );
+        ABC_FREE( pNtkRes->pName );
+        pNtkRes->pName = Extra_UtilStrsav( pNtk->pName );
+        // replace the current network
+        Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+        return 0;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
+        return 0;
+    }
+    if ( Abc_NtkConstrNum(pNtk) > 0 )
+    {
+        Abc_Print( -1, "Constraints are already extracted.\n" );
+        return 0;
+    }
+    if ( Abc_NtkPoNum(pNtk) > 1 && !fStruct )
+    {
+        Abc_Print( -1, "Functional constraint extraction works for single-output miters (use \"orpos\").\n" );
+        return 0;
+    }
+    // modify the current network
+    pNtkRes = Abc_NtkDarUnfold( pNtk, nFrames, nConfs, nProps, fStruct, fOldAlgo, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( 1,"Transformation has failed.\n" );
+        return 0;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+usage:
+    Abc_Print( -2, "usage: unfold [-FCP num] [-savh]\n" );
+    Abc_Print( -2, "\t         unfold hidden constraints as separate outputs\n" );
+    Abc_Print( -2, "\t-F num : the max number of timeframes to consider [default = %d]\n", nFrames );
+    Abc_Print( -2, "\t-C num : the max number of conflicts in SAT solving [default = %d]\n", nConfs );
+    Abc_Print( -2, "\t-P num : the max number of constraint propagations [default = %d]\n", nProps );
+    Abc_Print( -2, "\t-s     : toggle detecting structural constraints [default = %s]\n", fStruct? "yes": "no" );
+    Abc_Print( -2, "\t-a     : toggle fast implication detection [default = %s]\n", !fOldAlgo? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandFold( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkRes;
+    int fCompl;
+    int fVerbose;
+    int c;
+    extern Abc_Ntk_t * Abc_NtkDarFold( Abc_Ntk_t * pNtk, int fCompl, int fVerbose );
+    pNtk = Abc_FrameReadNtk(pAbc);
+    // set defaults
+    fCompl    =   0;
+    fVerbose  =   0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "cvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'c':
+            fCompl ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
+        return 0;
+    }
+    if ( Abc_NtkConstrNum(pNtk) == 0 )
+    {
+        Abc_Print( 0, "The network has no constraints.\n" );
+        return 0;
+    }
+    if ( Abc_NtkIsComb(pNtk) )
+        Abc_Print( 0, "The network is combinational.\n" );
+    // modify the current network
+    pNtkRes = Abc_NtkDarFold( pNtk, fCompl, fVerbose );
+    if ( pNtkRes == NULL )
+    {
+        Abc_Print( 1,"Transformation has failed.\n" );
+        return 0;
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+    return 0;
+usage:
+    Abc_Print( -2, "usage: fold [-cvh]\n" );
+    Abc_Print( -2, "\t         folds constraints represented as separate outputs\n" );
+    Abc_Print( -2, "\t-c     : toggle complementing constraints while folding [default = %s]\n", fCompl? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandBm( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    FILE * pOut, * pErr;
+    Abc_Ntk_t *pNtk, *pNtk1, *pNtk2;
+    int fDelete1, fDelete2;
+    char ** pArgvNew;
+    int c, nArgcNew;
+    int p_equivalence = FALSE;
+    extern void bmGateWay( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int p_equivalence );
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    pOut = Abc_FrameReadOut(pAbc);
+    pErr = Abc_FrameReadErr(pAbc);
+
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Ph" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        case 'P':
+            p_equivalence = 1;
+            break;
+        default:
+            Abc_Print( -2, "Unknown switch.\n");
+            goto usage;
+        }
+    }
+
+    pArgvNew = argv + globalUtilOptind;
+    nArgcNew = argc - globalUtilOptind;
+    if ( !Abc_NtkPrepareTwoNtks( pErr, pNtk, pArgvNew, nArgcNew , &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
+        return 1;
+
+    if( (unsigned)Abc_NtkPiNum(pNtk1) != (unsigned)Abc_NtkPiNum(pNtk2) || (unsigned)Abc_NtkPoNum(pNtk1) != (unsigned)Abc_NtkPoNum(pNtk2) )
+    {
+        Abc_Print( -2, "Mismatch in the number of inputs or outputs\n");
+        if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
+        if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
+        return 1;
+    }
+
+    bmGateWay( pNtk1, pNtk2, p_equivalence );
+
+    if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
+    if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: bm [-P] <file1> <file2>\n" );
+    Abc_Print( -2, "\t        performs Boolean matching (P-equivalence & PP-equivalence)\n" );
+    Abc_Print( -2, "\t        for equivalent circuits, I/O matches are printed in IOmatch.txt\n" );
+    Abc_Print( -2, "\t-P    : performs P-equivalnce checking\n");
+    Abc_Print( -2, "\t        default is PP-equivalence checking (when -P is not provided)\n" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    Abc_Print( -2, "\tfile1 : the file with the first network\n");
+    Abc_Print( -2, "\tfile2 : the file with the second network\n");
+
+    Abc_Print( -2, "\t        \n" );
+    Abc_Print( -2, "\t        This command was contributed by Hadi Katebi from U Michigan.\n" );
+    Abc_Print( -2, "\t        The paper describing the method: H. Katebi and I. L. Markov.\n" );
+    Abc_Print( -2, "\t        \"Large-scale Boolean matching\". Proc. DATE 2010. \n" );
+    Abc_Print( -2, "\t        http://www.eecs.umich.edu/~imarkov/pubs/conf/date10-match.pdf\n" );
+//    Abc_Print( -2, "\t        \n" );
+
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandBm2( Abc_Frame_t * pAbc, int argc, char ** argv )
+{   
+    FILE * pOut, * pErr;
+    Abc_Ntk_t *pNtk, *pNtk1, *pNtk2;
+    int fDelete1, fDelete2; 
+    Abc_Obj_t * pObj;
+    char ** pArgvNew;
+    int c, nArgcNew, i; 
+
+    extern void saucyGateWay( Abc_Ntk_t * pNtk, Abc_Obj_t * pNodePo, FILE * gFile, int fBooleanMatching,
+                              int fLookForSwaps, int fFixOutputs, int fFixInputs, int fQuiet, int fPrintTree);
+
+    pNtk = Abc_FrameReadNtk(pAbc);
+    pOut = Abc_FrameReadOut(pAbc);
+    pErr = Abc_FrameReadErr(pAbc);  
+    
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;        
+        default:
+            Abc_Print( -2, "Unknown switch.\n");
+            goto usage;
+        }
+    }
+    
+    pArgvNew = argv + globalUtilOptind;
+    nArgcNew = argc - globalUtilOptind;
+    if ( !Abc_NtkPrepareTwoNtks( pErr, pNtk, pArgvNew, nArgcNew , &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
+        return 1;
+        
+    if( (unsigned)Abc_NtkPiNum(pNtk1) != (unsigned)Abc_NtkPiNum(pNtk2) || 
+        (unsigned)Abc_NtkPoNum(pNtk1) != (unsigned)Abc_NtkPoNum(pNtk2) )
+    {
+        Abc_Print( -2, "Mismatch in the number of inputs or outputs\n");
+        Abc_Print( -2, "*** Networks are NOT equivalent ***\n");
+        if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
+        if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
+        return 1;
+    }
+    
+    Abc_NtkPermute(pNtk2, 1, 1, 0, NULL );
+    Abc_NtkShortNames(pNtk2);
+
+    Abc_NtkForEachCi( pNtk1, pObj, i ) {
+        char * newName = Abc_ObjNamePrefix( pObj, "N1:" );
+        Nm_ManDeleteIdName( pNtk1->pManName, pObj->Id);
+        Abc_ObjAssignName( pObj, newName, NULL );
+    }
+    Abc_NtkForEachCo( pNtk1, pObj, i ) {
+        char * newName = Abc_ObjNamePrefix( pObj, "N1:" );
+        Nm_ManDeleteIdName( pNtk1->pManName, pObj->Id);
+        Abc_ObjAssignName( pObj, newName, NULL );
+    }
+
+    Abc_NtkForEachCi( pNtk2, pObj, i ) {
+        char * newName = Abc_ObjNamePrefix( pObj, "N2:" );
+        Nm_ManDeleteIdName( pNtk2->pManName, pObj->Id);
+        Abc_ObjAssignName( pObj, newName, NULL );
+    }
+    Abc_NtkForEachCo( pNtk2, pObj, i ) {
+        char * newName = Abc_ObjNamePrefix( pObj, "N2:" );
+        Nm_ManDeleteIdName( pNtk2->pManName, pObj->Id);
+        Abc_ObjAssignName( pObj, newName, NULL );
+    }
+
+    Abc_NtkAppend( pNtk1, pNtk2, 1 );
+    saucyGateWay( pNtk1, NULL, NULL, 1, 0, 0, 0, 0, 0);
+
+    if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
+    if ( fDelete2 ) Abc_NtkDelete( pNtk2 );     
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: bm2  <file1> <file2>\n" );
+    Abc_Print( -2, "\t        performs Boolean matching (PP-equivalence)\n" );
+    Abc_Print( -2, "\t        for equivalent circuits, permutation that maps one circuit\n" );
+    Abc_Print( -2, "\t        to another is printed to standard output (PIs and POs of the\n" );
+    Abc_Print( -2, "\t        first network have prefix \"N1:\", while PIs and POs of the\n" ); 
+    Abc_Print( -2, "\t        second network have prefix \"N2:\")\n" ); 
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    Abc_Print( -2, "\tfile1 : the file with the first network\n");
+    Abc_Print( -2, "\tfile2 : the file with the second network\n");
+
+    Abc_Print( -2, "\t        \n" );
+    Abc_Print( -2, "\t        This command was contributed by Hadi Katebi from U Michigan.\n" );
+    Abc_Print( -2, "\t        The paper describing the method: H. Katebi, K. Sakallah and\n");
+    Abc_Print( -2, "\t        I. L. Markov.\n" );
+    Abc_Print( -2, "\t        \"Generalized Boolean Symmetries Through Nested Partition\n");
+    Abc_Print( -2, "\t        Refinement\". Proc. ICCAD 2013. \n" );
+    //Abc_Print( -2, "\t        http://www.eecs.umich.edu/~imarkov/pubs/conf/date10-match.pdf\n" );
+//    Abc_Print( -2, "\t        \n" );
+
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandSaucy( Abc_Frame_t * pAbc, int argc, char ** argv )
+{   
+    Abc_Ntk_t *pNtk;
+    char * outputName = NULL;
+    FILE * gFile = NULL;
+    int fOutputsOneAtTime = 0;
+    int fFixOutputs = 0;
+    int fFixInputs = 0;
+    int fLookForSwaps = 0;
+    int fQuiet = 0;
+    int fPrintTree = 0;
+    int c;
+
+    extern void saucyGateWay( Abc_Ntk_t * pNtk, Abc_Obj_t * pNodePo, FILE * gFile, int fBooleanMatching,
+                              int fLookForSwaps, int fFixOutputs, int fFixInputs, int fQuiet, int fPrintTree);
+
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "OFiosqvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'O':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-O\" should be followed by an output name or the keyword all.\n" );
+                goto usage;
+            }
+            outputName = argv[globalUtilOptind];
+            if ( !strcmp(argv[globalUtilOptind], "all") )
+                fOutputsOneAtTime ^= 1;
+            globalUtilOptind++;         
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by a file name.\n" );
+                goto usage;
+            }           
+            if ( (gFile = fopen( argv[globalUtilOptind], "w" )) == NULL )
+            {
+                Abc_Print( -1, "Cannot create output file \"%s\". ", argv[globalUtilOptind] );              
+                return 1;
+            }
+            globalUtilOptind++;         
+            break;
+        case 'i':
+            fFixOutputs ^= 1;
+            break;
+        case 'o':
+            fFixInputs ^= 1;
+            break;
+        case 's':
+            fLookForSwaps ^= 1;
+            break;
+        case 'q':
+            fQuiet ^= 1;
+            break;
+        case 'v':
+            fPrintTree ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            Abc_Print( -2, "Unknown switch.\n");
+            goto usage;
+        }
+    }    
+    
+    pNtk = Abc_FrameReadNtk(pAbc);  
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command works only for AIGs (run \"strash\").\n" );
+        return 1;
+    }
+
+    pNtk = Abc_NtkDup( pNtk );
+    Abc_NtkOrderObjsByName( pNtk, 1 );
+
+    if (fOutputsOneAtTime) {
+        int i;
+        Abc_Obj_t * pNodePo;
+        FILE * hadi = fopen("hadi.txt", "w");
+        Abc_NtkForEachPo( pNtk, pNodePo, i ) {
+            printf("Ouput %s\n\n", Abc_ObjName(pNodePo));
+            saucyGateWay( pNtk, pNodePo, gFile, 0, fLookForSwaps, fFixOutputs, fFixInputs, fQuiet, fPrintTree );
+            printf("----------------------------------------\n");           
+        }
+        fclose(hadi);
+    } else if (outputName != NULL) {
+        int i;
+        Abc_Obj_t * pNodePo;        
+        Abc_NtkForEachPo( pNtk, pNodePo, i ) {
+            if (!strcmp(Abc_ObjName(pNodePo), outputName)) {
+                saucyGateWay( pNtk, pNodePo, gFile, 0, fLookForSwaps, fFixOutputs, fFixInputs, fQuiet, fPrintTree );
+                Abc_NtkDelete( pNtk );
+                return 0;
+            }   
+        }
+        Abc_Print( -1, "Output not found\n" );
+        return 1;       
+    } else
+        saucyGateWay( pNtk, NULL, gFile, 0, fLookForSwaps, fFixOutputs, fFixInputs, fQuiet, fPrintTree );
+
+    if (gFile != NULL) fclose(gFile);
+    Abc_NtkDelete( pNtk );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: saucy3 [-O <name>] [-F <file>] [-iosqvh]\n\n" );
+    Abc_Print( -2, "\t            computes functional symmetries of the netowrk\n" );
+    Abc_Print( -2, "\t            prints symmetry generators to the standard output\n" );   
+    Abc_Print( -2, "\t-O <name> : (optional) compute symmetries only for output given by name\n");
+    Abc_Print( -2, "\t            only inputs in the output cone are permuted\n");  
+    Abc_Print( -2, "\t            (special case) name=all, compute symmetries for each\n" );
+    Abc_Print( -2, "\t            output, but only one output at a time\n" );
+    Abc_Print( -2, "\t            [default = compute symmetries by permuting all I/Os]\n" );
+    Abc_Print( -2, "\t-F <file> : print symmetry generators to file [default = stdout]\n");
+    Abc_Print( -2, "\t-i        : permute just the inputs (fix the outputs) [default = no]\n");
+    Abc_Print( -2, "\t-o        : permute just the outputs (fix the inputs) [default = no]\n");
+    Abc_Print( -2, "\t-s        : only look for swaps of inputs [default = no]\n");
+    Abc_Print( -2, "\t-q        : quiet (do not print symmetry generators) [default = no]\n");
+    Abc_Print( -2, "\t-v        : verbose (print the search tree) [default = no]\n");   
+    Abc_Print( -2, "\t-h        : print the command usage\n"); 
+
+    Abc_Print( -2, "\t            \n" );
+    Abc_Print( -2, "\t            This command was contributed by Hadi Katebi from U Michigan.\n" );
+    Abc_Print( -2, "\t            The paper describing the method: H. Katebi, K. Sakallah and\n");
+    Abc_Print( -2, "\t            I. L. Markov.\n" );
+    Abc_Print( -2, "\t            \"Generalized Boolean Symmetries Through Nested Partition\n");
+    Abc_Print( -2, "\t            Refinement\". Proc. ICCAD 2013. \n" );
+    //Abc_Print( -2, "\t          http://www.eecs.umich.edu/~imarkov/pubs/conf/date10-match.pdf\n" );
+    Abc_Print( -2, "\t            Saucy webpage: http://vlsicad.eecs.umich.edu/BK/SAUCY/\n" );
+
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandTestCex( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk;
+    int c;
+    int nOutputs = 0;
+    int fCheckAnd = 1;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Oah" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'O':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-O\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nOutputs = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nOutputs < 0 )
+                goto usage;
+            break;
+        case 'a':
+            fCheckAnd ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            Abc_Print( -2, "Unknown switch.\n");
+            goto usage;
+        }
+    }
+
+    if ( pAbc->pCex == NULL )
+    {
+        Abc_Print( 1, "There is no current cex.\n");
+        return 0;
+    }
+
+    if ( !fCheckAnd )
+    {
+        // check the main AIG
+        pNtk = Abc_FrameReadNtk(pAbc);
+        if ( pNtk == NULL )
+            Abc_Print( 1, "Main AIG: There is no current network.\n");
+        else if ( !Abc_NtkIsStrash(pNtk) )
+            Abc_Print( 1, "Main AIG: The current network is not an AIG.\n");
+        else if ( Abc_NtkPiNum(pNtk) != pAbc->pCex->nPis )
+            Abc_Print( 1, "Main AIG: The number of PIs (%d) is different from cex (%d).\n", Abc_NtkPiNum(pNtk), pAbc->pCex->nPis );
+        else
+        {
+            extern int Abc_NtkVerifyCex( Abc_Ntk_t * pNtk, Abc_Cex_t * p );
+            int iPoOld = pAbc->pCex->iPo;
+            pAbc->pCex->iPo = Abc_NtkVerifyCex( pNtk, pAbc->pCex );
+            if ( pAbc->pCex->iPo == -1 )
+                Abc_Print( 1, "Main AIG: The cex does not fail any outputs.\n" );
+            else if ( iPoOld != pAbc->pCex->iPo )
+                Abc_Print( 1, "Main AIG: The cex refined PO %d instead of PO %d.\n", pAbc->pCex->iPo, iPoOld );
+            else
+                Abc_Print( 1, "Main AIG: The cex is correct.\n" );
+        }
+    }
+    else
+    {
+        // check the AND AIG
+        if ( pAbc->pGia == NULL )
+            Abc_Print( 1, "And  AIG: There is no current network.\n");
+        else if ( Gia_ManPiNum(pAbc->pGia) != pAbc->pCex->nPis )
+            Abc_Print( 1, "And  AIG: The number of PIs (%d) is different from cex (%d).\n", Gia_ManPiNum(pAbc->pGia), pAbc->pCex->nPis );
+        else
+        {
+            int iPoOld = pAbc->pCex->iPo;
+            pAbc->pCex->iPo = Gia_ManFindFailedPoCex( pAbc->pGia, pAbc->pCex, nOutputs );
+            if ( pAbc->pCex->iPo == -1 )
+                Abc_Print( 1, "And  AIG: The cex does not fail any outputs.\n" );
+            else if ( iPoOld != pAbc->pCex->iPo )
+                Abc_Print( 1, "And  AIG: The cex refined PO %d instead of PO %d.\n", pAbc->pCex->iPo, iPoOld );
+            else
+                Abc_Print( 1, "And  AIG: The cex is correct.\n" );
+        }
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: testcex [-O num] [-ah]\n" );
+    Abc_Print( -2, "\t         tests the current cex against the current AIG or the &-AIG\n" );
+    Abc_Print( -2, "\t-O num : the number of real POs in the PO list [default = %d]\n", nOutputs );
+    Abc_Print( -2, "\t-a     : toggle checking the current AIG or the &-AIG [default = %s]\n", fCheckAnd ? "&-AIG": "current AIG" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandPdr( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern int Abc_NtkDarPdr( Abc_Ntk_t * pNtk, Pdr_Par_t * pPars );
+    Pdr_Par_t Pars, * pPars = &Pars;
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    Pdr_ManSetDefaultParams( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "MFCRTHGaxrmsipdgvwzh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'M':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nRecycle = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nRecycle < 0 )
+                goto usage;
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nFrameMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nFrameMax < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nConfLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nConfLimit < 0 )
+                goto usage;
+            break;
+        case 'R':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nRestLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nRestLimit < 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nTimeOut = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nTimeOut < 0 )
+                goto usage;
+            break;
+        case 'H':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-H\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nTimeOutOne = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nTimeOutOne < 0 )
+                goto usage;
+            break;
+        case 'G':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-G\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nTimeOutGap = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nTimeOutGap < 0 )
+                goto usage;
+            break;
+        case 'a':
+            pPars->fSolveAll ^= 1;
+            break;
+        case 'x':
+            pPars->fStoreCex ^= 1;
+            break;
+        case 'r':
+            pPars->fTwoRounds ^= 1;
+            break;
+        case 'm':
+            pPars->fMonoCnf ^= 1;
+            break;
+        case 's':
+            pPars->fShortest ^= 1;
+            break;
+        case 'i':
+            pPars->fShiftStart ^= 1;
+            break;
+        case 'p':
+            pPars->fReuseProofOblig ^= 1;
+            break;
+        case 'd':
+            pPars->fDumpInv ^= 1;
+            break;
+        case 'g':
+            pPars->fSkipGeneral ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'w':
+            pPars->fVeryVerbose ^= 1;
+            break;
+        case 'z':
+            pPars->fNotVerbose ^= 1;
+            break;
+        case 'h':
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -2, "There is no current network.\n");
+        return 0;
+    }
+    if ( Abc_NtkLatchNum(pNtk) == 0 )
+    {
+        Abc_Print( -2, "The current network is combinational.\n");
+        return 0;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -2, "The current network is not an AIG (run \"strash\").\n");
+        return 0;
+    }
+    // run the procedure
+    pPars->fUseBridge = pAbc->fBridgeMode;
+    pAbc->Status  = Abc_NtkDarPdr( pNtk, pPars );
+    pAbc->nFrames = pNtk->vSeqModelVec ? -1 : pPars->iFrame;
+    Abc_FrameReplacePoStatuses( pAbc, &pPars->vOutMap );
+    if ( pNtk->vSeqModelVec )
+        Abc_FrameReplaceCexVec( pAbc, &pNtk->vSeqModelVec );
+    else
+        Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: pdr [-MFCRTHG <num>] [-axrmsipdgvwzh]\n" );
+    Abc_Print( -2, "\t         model checking using property directed reachability (aka IC3)\n" );
+    Abc_Print( -2, "\t         pioneered by Aaron Bradley (http://ecee.colorado.edu/~bradleya/ic3/)\n" );
+    Abc_Print( -2, "\t         with improvements by Niklas Een (http://een.se/niklas/)\n" );
+    Abc_Print( -2, "\t-M num : limit on unused vars to trigger SAT solver recycling [default = %d]\n",       pPars->nRecycle );
+    Abc_Print( -2, "\t-F num : limit on timeframes explored to stop computation [default = %d]\n",           pPars->nFrameMax );
+    Abc_Print( -2, "\t-C num : limit on conflicts in one SAT call (0 = no limit) [default = %d]\n",          pPars->nConfLimit );
+    Abc_Print( -2, "\t-R num : limit on proof obligations before a restart (0 = no limit) [default = %d]\n", pPars->nRestLimit );
+    Abc_Print( -2, "\t-T num : runtime limit, in seconds (0 = no limit) [default = %d]\n",                   pPars->nTimeOut );
+    Abc_Print( -2, "\t-H num : runtime limit per output, in miliseconds (with \"-a\") [default = %d]\n",     pPars->nTimeOutOne );
+    Abc_Print( -2, "\t-G num : runtime gap since the last CEX (0 = no limit) [default = %d]\n",              pPars->nTimeOutGap );
+    Abc_Print( -2, "\t-a     : toggle solving all outputs even if one of them is SAT [default = %s]\n",      pPars->fSolveAll? "yes": "no" );
+    Abc_Print( -2, "\t-x     : toggle storing CEXes when solving all outputs [default = %s]\n",              pPars->fStoreCex? "yes": "no" );
+    Abc_Print( -2, "\t-r     : toggle using more effort in generalization [default = %s]\n",                 pPars->fTwoRounds? "yes": "no" );
+    Abc_Print( -2, "\t-m     : toggle using monolythic CNF computation [default = %s]\n",                    pPars->fMonoCnf? "yes": "no" );
+    Abc_Print( -2, "\t-s     : toggle creating only shortest counter-examples [default = %s]\n",             pPars->fShortest? "yes": "no" );
+    Abc_Print( -2, "\t-i     : toggle clause pushing from an intermediate timeframe [default = %s]\n",       pPars->fShiftStart? "yes": "no" );
+    Abc_Print( -2, "\t-p     : toggle reusing proof-obligations in the last timeframe [default = %s]\n",     pPars->fReuseProofOblig? "yes": "no" );
+    Abc_Print( -2, "\t-d     : toggle dumping invariant (valid if init state is all-0) [default = %s]\n",    pPars->fDumpInv? "yes": "no" );
+    Abc_Print( -2, "\t-g     : toggle skipping expensive generalization step [default = %s]\n",              pPars->fSkipGeneral? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing optimization summary [default = %s]\n",                       pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w     : toggle printing detailed stats default = %s]\n",                              pPars->fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-z     : toggle suppressing report about solved outputs [default = %s]\n",             pPars->fNotVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandReconcile( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Abc_Cex_t * Llb4_Nonlin4NormalizeCex( Aig_Man_t * pAigOrg, Aig_Man_t * pAigRpm, Abc_Cex_t * pCexRpm );
+    Abc_Cex_t * pCex;
+    Abc_Ntk_t * pNtk1 = NULL, * pNtk2 = NULL;
+    Aig_Man_t * pAig1 = NULL, * pAig2 = NULL;
+    int c;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            Abc_Print( -2, "Unknown switch.\n");
+            goto usage;
+        }
+    }
+
+    if ( argc != globalUtilOptind + 2 && argc != globalUtilOptind )
+    {
+        Abc_Print( 1,"Does not seen to have two files names as arguments.\n" );
+        return 1;
+    }
+    if ( pAbc->pCex == NULL )
+    {
+        Abc_Print( 1,"There is no current counter-example.\n" );
+        return 1;
+    }
+
+    if ( argc == globalUtilOptind + 2 )
+    {
+        // derive networks
+        pNtk1 = Io_Read( argv[globalUtilOptind], Io_ReadFileType(argv[globalUtilOptind]), 1, 0 );
+        if ( pNtk1 == NULL )
+            return 1;
+        pNtk2 = Io_Read( argv[globalUtilOptind+1], Io_ReadFileType(argv[globalUtilOptind+1]), 1, 0 );
+        if ( pNtk2 == NULL )
+        {
+            Abc_NtkDelete( pNtk1 );
+            return 1;
+        }
+        // create counter-examples
+        pAig1 = Abc_NtkToDar( pNtk1, 0, 0 );
+        pAig2 = Abc_NtkToDar( pNtk2, 0, 0 );
+    }
+    else if ( argc == globalUtilOptind )
+    {
+        if ( pAbc->pNtkCur == NULL )
+        {
+            Abc_Print( 1, "There is no AIG in the main-space.\n");
+            return 0;
+        }
+        if ( pAbc->pGia == NULL )
+        {
+            Abc_Print( 1, "There is no AIG in the &-space.\n");
+            return 0;
+        }
+        // create counter-examples
+        pAig1 = Abc_NtkToDar( pAbc->pNtkCur, 0, 0 );
+        pAig2 = Gia_ManToAigSimple( pAbc->pGia );
+    }
+    else assert( 0 );
+    pCex = Llb4_Nonlin4NormalizeCex( pAig1, pAig2, pAbc->pCex );
+    Aig_ManStop( pAig1 );
+    Aig_ManStop( pAig2 );
+    if ( pNtk2 )  Abc_NtkDelete( pNtk2 );
+    if ( pCex == NULL )
+    {
+        Abc_Print( 1,"Counter-example computation has failed.\n" );
+        if ( pNtk1 )  Abc_NtkDelete( pNtk1 );
+        return 1;
+    }
+
+    // replace the current network
+    if ( pNtk1 )
+        Abc_FrameReplaceCurrentNetwork( pAbc, pNtk1 );
+    // update the counter-example
+    pAbc->nFrames = pCex->iFrame;
+    Abc_FrameReplaceCex( pAbc, &pCex );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: reconcile [-h] <fileOrigin> <fileReparam>\n" );
+    Abc_Print( -2, "\t        reconciles current CEX with <fileOrigin>\n" );
+    Abc_Print( -2, "\t        More specifically:\n" );
+    Abc_Print( -2, "\t        (i) assumes that <fileReparam> is an AIG derived by input\n" );
+    Abc_Print( -2, "\t        reparametrization of <fileOrigin> without seq synthesis;\n" );
+    Abc_Print( -2, "\t        (ii) assumes that current CEX is valid for <fileReparam>;\n" );
+    Abc_Print( -2, "\t        (iii) derives new CEX for <fileOrigin> and sets this CEX\n" );
+    Abc_Print( -2, "\t        and <fileOrigin> to be current CEX and current network\n" );
+    Abc_Print( -2, "\t<fileOrigin>   : file name with the original AIG\n");
+    Abc_Print( -2, "\t<fileReparam>  : file name with the reparametrized AIG\n");
+    Abc_Print( -2, "\t        (if both file names are not given on the command line,\n");
+    Abc_Print( -2, "\t        original/reparam AIG has to be in the main-space/&-space)\n");
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandCexSave( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    int c;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pCex == NULL )
+    {
+        Abc_Print( -1, "Current CEX is not available..\n" );
+        return 1;
+    }
+    ABC_FREE( pAbc->pCex2 );
+    pAbc->pCex2 = Abc_CexDup( pAbc->pCex, -1 );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: cexsave [-h]\n" );
+    Abc_Print( -2, "\t        saves the current CEX into the internal storage\n" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandCexLoad( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    int c;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pCex2 == NULL )
+    {
+        Abc_Print( -1, "Saved CEX is not available.\n" );
+        return 1;
+    }
+    ABC_FREE( pAbc->pCex );
+    pAbc->pCex = Abc_CexDup( pAbc->pCex2, -1 );
+    // update status
+    pAbc->nFrames = pAbc->pCex2->iFrame;
+    pAbc->Status = 0;
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: cexload [-h]\n" );
+    Abc_Print( -2, "\t        loads the current CEX from the internal storage\n" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandCexCut( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtkNew;
+    int c, iFrStart = 0;
+    int iFrStop     = ABC_INFINITY;
+    int fCombOnly   = 0;
+    int fUseOne     = 0;
+    int fAllFrames  = 0;
+    int fVerbose    = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "FGcnmvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            iFrStart = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( iFrStart < 0 )
+                goto usage;
+            break;
+        case 'G':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-G\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            iFrStop = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( iFrStop < 0 )
+                goto usage;
+            break;
+        case 'c':
+            fCombOnly ^= 1;
+            break;
+        case 'n':
+            fUseOne ^= 1;
+            break;
+        case 'm':
+            fAllFrames ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            Abc_Print( -2, "Unknown switch.\n");
+            goto usage;
+        }
+    }
+
+    if ( pAbc->pCex == NULL )
+    {
+        Abc_Print( 1, "There is no current cex.\n");
+        return 0;
+    }
+    if ( pAbc->pNtkCur == NULL )
+    {
+        Abc_Print( 1, "There is no AIG in the &-space.\n");
+        return 0;
+    }
+    if ( !Abc_NtkIsStrash(pAbc->pNtkCur) )
+    {
+        Abc_Print( 1, "Current network is not an AIG.\n");
+        return 0;
+    }
+    if ( iFrStop == ABC_INFINITY )
+        iFrStop = pAbc->pCex->iFrame;
+
+    {
+        Aig_Man_t * pAig = Abc_NtkToDar( pAbc->pNtkCur, 0, 1 );
+        Aig_Man_t * pAigNew = Bmc_AigTargetStates( pAig, pAbc->pCex, iFrStart, iFrStop, fCombOnly, fUseOne, fAllFrames, fVerbose );
+        Aig_ManStop( pAig );
+        if ( pAigNew == NULL )
+        {
+            Abc_Print( 1, "Command has failed.\n");
+            return 0;
+        }
+        pNtkNew = Abc_NtkFromAigPhase( pAigNew );
+        pNtkNew->pName = Extra_UtilStrsav( pAbc->pNtkCur->pName );
+        Aig_ManStop( pAigNew );
+        // update the network
+        Abc_FrameReplaceCurrentNetwork( pAbc, pNtkNew );
+    }
+/*
+    pGiaNew = Bmc_GiaTargetStates( pAbc->pGia, pAbc->pCex, iFrStart, iFrStop, fCombOnly, fUseOne, fVerbose );
+    if ( pGiaNew == NULL )
+    {
+        Abc_Print( 1, "Command has failed.\n");
+        return 0;
+    }
+    Abc_FrameUpdateGia( pAbc, pGiaNew );
+*/
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: cexcut [-FG num] [-cnmvh]\n" );
+    Abc_Print( -2, "\t         creates logic for bad states using the current CEX\n" );
+    Abc_Print( -2, "\t-F num : 0-based number of the starting frame [default = %d]\n", iFrStart );
+    Abc_Print( -2, "\t-G num : 0-based number of the ending frame [default = %d]\n",   iFrStop );
+    Abc_Print( -2, "\t-c     : toggle outputting unate combinational circuit [default = %s]\n",  fCombOnly? "yes": "no" );
+    Abc_Print( -2, "\t-n     : toggle generating only one bad state [default = %s]\n", fUseOne? "yes": "no" );
+    Abc_Print( -2, "\t-m     : toggle generating bad states for all frames after G [default = %s]\n", fAllFrames? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n",  fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandCexMerge( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Cex_t * pCexNew;
+    int c;
+    int iFrStart = 0;
+    int iFrStop  = ABC_INFINITY;
+    int fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "FGvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            iFrStart = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( iFrStart < 0 )
+                goto usage;
+            break;
+        case 'G':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-G\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            iFrStop = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( iFrStop < 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            Abc_Print( -2, "Unknown switch.\n");
+            goto usage;
+        }
+    }
+
+    if ( pAbc->pCex == NULL )
+    {
+        Abc_Print( 1, "There is no current cex.\n");
+        return 0;
+    }
+    if ( pAbc->pCex2 == NULL )
+    {
+        Abc_Print( 1, "There is no saved cex.\n");
+        return 0;
+    }
+    if ( iFrStop - iFrStart + pAbc->pCex->iPo < pAbc->pCex->iFrame )
+    {
+        Abc_Print( 1, "Current CEX does not allow to shorten the saved CEX.\n");
+        return 0;
+    }
+    pCexNew = Abc_CexMerge( pAbc->pCex2, pAbc->pCex, iFrStart, iFrStop );
+    if ( pCexNew == NULL )
+    {
+        Abc_Print( 1, "Merging CEXes has failed.\n");
+        return 0;
+    }
+    // replace the saved CEX
+    ABC_FREE( pAbc->pCex2 );
+    pAbc->pCex2 = pCexNew;
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: cexmerge [-FG num] [-vh]\n" );
+    Abc_Print( -2, "\t         merges the current CEX into the saved one\n" );
+    Abc_Print( -2, "\t         and sets the resulting CEX as the saved one\n" );
+    Abc_Print( -2, "\t-F num : 0-based number of the starting frame [default = %d]\n", iFrStart );
+    Abc_Print( -2, "\t-G num : 0-based number of the ending frame [default = %d]\n",   iFrStop );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandCexMin( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk;
+    Abc_Cex_t * vCexNew = NULL;
+    int c;
+    int nConfLimit = 1000;
+    int nRounds    =    1;
+    int fVerbose   =    0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "CRvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nConfLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nConfLimit < 0 )
+                goto usage;
+            break;
+        case 'R':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nRounds = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nRounds < 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            Abc_Print( -2, "Unknown switch.\n");
+            goto usage;
+        }
+    }
+
+    if ( pAbc->pCex == NULL )
+    {
+        Abc_Print( 1, "There is no current cex.\n");
+        return 0;
+    }
+
+    // check the main AIG
+    pNtk = Abc_FrameReadNtk(pAbc);
+    if ( pNtk == NULL )
+        Abc_Print( 1, "Main AIG: There is no current network.\n");
+    else if ( !Abc_NtkIsStrash(pNtk) )
+        Abc_Print( 1, "Main AIG: The current network is not an AIG.\n");
+    else if ( Abc_NtkPiNum(pNtk) != pAbc->pCex->nPis )
+        Abc_Print( 1, "Main AIG: The number of PIs (%d) is different from cex (%d).\n", Abc_NtkPiNum(pNtk), pAbc->pCex->nPis );
+//      else if ( Abc_NtkLatchNum(pNtk) != pAbc->pCex->nRegs )
+//          Abc_Print( 1, "Main AIG: The number of registers (%d) is different from cex (%d).\n", Abc_NtkLatchNum(pNtk), pAbc->pCex->nRegs );
+//      else if ( Abc_NtkPoNum(pNtk) <= pAbc->pCex->iPo )
+//          Abc_Print( 1, "Main AIG: The number of POs (%d) is less than the PO index in cex (%d).\n", Abc_NtkPoNum(pNtk), pAbc->pCex->iPo );
+    else
+    {
+        Aig_Man_t * pAig = Abc_NtkToDar( pNtk, 0, 1 );
+        Gia_Man_t * pGia = Gia_ManFromAigSimple( pAig );
+//        if ( !Gia_ManVerifyCex( pGia, pAbc->pCex, 0 ) )
+        int iPoOld = pAbc->pCex->iPo;
+        pAbc->pCex->iPo = Gia_ManFindFailedPoCex( pGia, pAbc->pCex, 0 );
+        Gia_ManStop( pGia );
+        if ( pAbc->pCex->iPo == -1 )
+        {
+            pAbc->pCex->iPo = iPoOld;
+            Abc_Print( -1, "Main AIG: The cex does not fail any outputs.\n" );
+            return 0;
+        }
+        else if ( iPoOld != pAbc->pCex->iPo )
+            Abc_Print( 0, "Main AIG: The cex refined PO %d instead of PO %d.\n", pAbc->pCex->iPo, iPoOld );
+        // perform minimization
+        vCexNew = Saig_ManCexMinPerform( pAig, pAbc->pCex );
+        Aig_ManStop( pAig );
+        Abc_CexFree( vCexNew );
+//        Abc_FrameReplaceCex( pAbc, &vCexNew );
+
+//        Abc_Print( 1,"Implementation of this command is not finished.\n" );
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: cexmin [-CR num] [-vh]\n" );
+    Abc_Print( -2, "\t         reduces the length of the counter-example\n" );
+    Abc_Print( -2, "\t-C num : the maximum number of conflicts [default = %d]\n", nConfLimit );
+    Abc_Print( -2, "\t-R num : the number of minimization rounds [default = %d]\n", nRounds );
+    Abc_Print( -2, "\t-v     : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandDualRail( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Vec_Int_t * Abc_NtkFindDcLatches( Abc_Ntk_t * pNtk );
+    Abc_Ntk_t * pNtk, * pNtkNew = NULL;
+    Aig_Man_t * pAig, * pAigNew;
+    Vec_Int_t * vDcFlops = NULL;
+    int c;
+    int nDualPis   = 0;
+    int fDualFfs   = 0;
+    int fDualDcFfs = 0;
+    int fMiterFfs  = 0;
+    int fComplPo   = 0;
+    int fCheckZero = 0;
+    int fCheckOne  = 0;
+    int fVerbose   = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Itxfczovh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'I':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nDualPis = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nDualPis < 0 )
+                goto usage;
+            break;
+        case 't':
+            fDualFfs ^= 1;
+            break;
+        case 'x':
+            fDualDcFfs ^= 1;
+            break;
+        case 'f':
+            fMiterFfs ^= 1;
+            break;
+        case 'c':
+            fComplPo ^= 1;
+            break;
+        case 'z':
+            fCheckZero ^= 1;
+            break;
+        case 'o':
+            fCheckOne ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            Abc_Print( -2, "Unknown switch.\n");
+            goto usage;
+        }
+    }
+
+    // check the main AIG
+    pNtk = Abc_FrameReadNtk(pAbc);
+    if ( pNtk == NULL )
+    {
+        Abc_Print( 1, "Main AIG: There is no current network.\n");
+        return 0;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( 1, "Main AIG: The current network is not an AIG.\n");
+        return 0;
+    }
+
+    if ( fDualDcFfs )
+        vDcFlops = Abc_NtkFindDcLatches( pNtk );
+
+    // transform
+    pAig = Abc_NtkToDar( pNtk, 0, 1 );
+    pAigNew = Saig_ManDupDual( pAig, vDcFlops, nDualPis, fDualFfs, fMiterFfs, fComplPo, fCheckZero, fCheckOne );
+    Aig_ManStop( pAig );
+    pNtkNew = Abc_NtkFromAigPhase( pAigNew );
+    pNtkNew->pName = Extra_UtilStrsav(pNtk->pName);
+    Aig_ManStop( pAigNew );
+    Vec_IntFreeP( &vDcFlops );
+
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkNew );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: dualrail [-I num] [-txfczovh]\n" );
+    Abc_Print( -2, "\t         transforms the current AIG into a dual-rail miter\n" );
+    Abc_Print( -2, "\t         expressing the property \"at least one PO has ternary value\"\n" );
+    Abc_Print( -2, "\t         (to compute an initialization sequence, use switches \"-tfc\")\n" );
+    Abc_Print( -2, "\t-I num : the number of first PIs interpreted as ternary [default = %d]\n", nDualPis );
+    Abc_Print( -2, "\t-t     : toggle ternary flop init values for all flops [default = %s]\n", fDualFfs? "yes": "const0 init values" );
+    Abc_Print( -2, "\t-x     : toggle ternary flop init values for DC-valued flops [default = %s]\n", fDualDcFfs? "yes": "const0 init values" );
+    Abc_Print( -2, "\t-f     : toggle mitering flops instead of POs [default = %s]\n", fMiterFfs? "flops": "POs" );
+    Abc_Print( -2, "\t-c     : toggle complementing the miter output [default = %s]\n", fComplPo? "yes": "no" );
+    Abc_Print( -2, "\t-z     : toggle checking PO==0 instead of PO==X [default = %s]\n", fCheckZero? "yes": "no" );
+    Abc_Print( -2, "\t-o     : toggle checking PO==1 instead of PO==X [default = %s]\n", fCheckOne? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandBlockPo( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkNew = NULL;
+    Aig_Man_t * pAig;
+    int c;
+    int nCycles = 0;
+    int fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Fvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nCycles = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nCycles < 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            Abc_Print( -2, "Unknown switch.\n");
+            goto usage;
+        }
+    }
+
+    // check the main AIG
+    pNtk = Abc_FrameReadNtk(pAbc);
+    if ( pNtk == NULL )
+    {
+        Abc_Print( 1, "Main AIG: There is no current network.\n");
+        return 0;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( 1, "Main AIG: The current network is not an AIG.\n");
+        return 0;
+    }
+    if ( nCycles == 0 )
+    {
+        Abc_Print( 1, "The number of time frame is 0. The circuit is left unchanged.\n" );
+        return 0;
+    }
+
+    // transform
+    pAig = Abc_NtkToDar( pNtk, 0, 1 );
+    Saig_ManBlockPo( pAig, nCycles );
+    pNtkNew = Abc_NtkFromAigPhase( pAig );
+    Aig_ManStop( pAig );
+    // transfer the name
+    pNtkNew->pName = Extra_UtilStrsav(pNtk->pName);
+    pNtkNew->pSpec = Extra_UtilStrsav(pNtk->pSpec);
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkNew );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: blockpo [-F num] [-fvh]\n" );
+    Abc_Print( -2, "\t         forces the miter outputs to be \"true\" in the first F frames\n" );
+    Abc_Print( -2, "\t-F num : the number of time frames [default = %d]\n", nCycles );
+    Abc_Print( -2, "\t-v     : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandIso( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk, * pNtkNew = NULL;
+    Aig_Man_t * pAig, * pTemp;
+    Vec_Ptr_t * vPosEquivs = NULL;
+    int c, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            Abc_Print( -2, "Unknown switch.\n");
+            goto usage;
+        }
+    }
+
+    // check the main AIG
+    pNtk = Abc_FrameReadNtk(pAbc);
+    if ( pNtk == NULL )
+    {
+        Abc_Print( 1, "Main AIG: There is no current network.\n");
+        return 0;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( 1, "Main AIG: The current network is not an AIG.\n");
+        return 0;
+    }
+    if ( Abc_NtkPoNum(pNtk) == 1 )
+    {
+        Abc_Print( 1, "Current AIG has only one PO. Transformation is not performed.\n");
+        return 0;
+    }
+
+    // transform
+    pAig = Abc_NtkToDar( pNtk, 0, 1 );
+    pTemp = Saig_ManIsoReduce( pAig, &vPosEquivs, fVerbose );
+    pNtkNew = Abc_NtkFromAigPhase( pTemp );
+    Aig_ManStop( pTemp );
+    Aig_ManStop( pAig );
+
+    // update the internal storage of PO equivalences
+    Abc_FrameReplacePoEquivs( pAbc, &vPosEquivs );
+
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtkNew );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: iso [-vh]\n" );
+    Abc_Print( -2, "\t         removes POs with isomorphic sequential COI\n" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandTraceStart( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command is applicable to AIGs.\n" );
+        return 1;
+    }
+/*
+    Abc_HManStart();
+    if ( !Abc_HManPopulate( pNtk ) )
+    {
+        Abc_Print( -1, "Failed to start the tracing database.\n" );
+        return 1;
+    }
+*/
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: trace_start [-h]\n" );
+    Abc_Print( -2, "\t        starts verification tracing\n" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandTraceCheck( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c;
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash(pNtk) )
+    {
+        Abc_Print( -1, "This command is applicable to AIGs.\n" );
+        return 1;
+    }
+/*
+    if ( !Abc_HManIsRunning(pNtk) )
+    {
+        Abc_Print( -1, "The tracing database is not available.\n" );
+        return 1;
+    }
+
+    if ( !Abc_HManVerify( 1, pNtk->Id ) )
+        Abc_Print( -1, "Verification failed.\n" );
+    Abc_HManStop();
+*/
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: trace_check [-h]\n" );
+    Abc_Print( -2, "\t        checks the current network using verification trace\n" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Read( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern void Abc3_ReadShowHie( char * pFileName, int fFlat );
+    Gia_Man_t * pAig = NULL;
+    FILE * pFile;
+    char ** pArgvNew;
+    char * FileName, * pTemp;
+    int c, nArgcNew;
+    int fUseMini = 0;
+    int fVerbose = 0;
+    int fSkipStrash = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "smvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 's':
+            fSkipStrash ^= 1;
+            break;
+        case 'm':
+            fUseMini ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+    pArgvNew = argv + globalUtilOptind;
+    nArgcNew = argc - globalUtilOptind;
+    if ( nArgcNew != 1 )
+    {
+        Abc_Print( -1, "There is no file name.\n" );
+        return 1;
+    }
+
+    // get the input file name
+    FileName = pArgvNew[0];
+    // fix the wrong symbol
+    for ( pTemp = FileName; *pTemp; pTemp++ )
+        if ( *pTemp == '>' )
+            *pTemp = '\\';
+    if ( (pFile = fopen( FileName, "r" )) == NULL )
+    {
+        Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
+        if ( (FileName = Extra_FileGetSimilarName( FileName, ".aig", ".blif", ".pla", ".eqn", ".bench" )) )
+            Abc_Print( 1, "Did you mean \"%s\"?", FileName );
+        Abc_Print( 1, "\n" );
+        return 1;
+    }
+    fclose( pFile );
+
+    if ( fUseMini )
+        pAig = Gia_ManReadMiniAig( FileName );
+//    else if ( Extra_FileIsType( FileName, ".v", NULL, NULL ) )
+//        Abc3_ReadShowHie( FileName, fSkipStrash );
+    else 
+        pAig = Gia_AigerRead( FileName, fSkipStrash, 0 );
+    if ( pAig )
+        Abc_FrameUpdateGia( pAbc, pAig );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &r [-smvh] <file>\n" );
+    Abc_Print( -2, "\t         reads the current AIG from the AIGER file\n" );
+    Abc_Print( -2, "\t-s     : toggles structural hashing while reading [default = %s]\n", !fSkipStrash? "yes": "no" );
+    Abc_Print( -2, "\t-m     : toggles reading MiniAIG rather than AIGER file [default = %s]\n", fUseMini? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggles additional verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\t<file> : the file name\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9ReadBlif( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Gia_Man_t * Abc_NtkHieCecTest( char * pFileName, int fVerbose );
+    Gia_Man_t * pAig;
+    FILE * pFile;
+    char ** pArgvNew;
+    char * FileName, * pTemp;
+    int nArgcNew;
+    int c, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+    pArgvNew = argv + globalUtilOptind;
+    nArgcNew = argc - globalUtilOptind;
+    if ( nArgcNew != 1 )
+    {
+        Abc_Print( -1, "There is no file name.\n" );
+        return 1;
+    }
+
+    // get the input file name
+    FileName = pArgvNew[0];
+    // fix the wrong symbol
+    for ( pTemp = FileName; *pTemp; pTemp++ )
+        if ( *pTemp == '>' )
+            *pTemp = '\\';
+    if ( (pFile = fopen( FileName, "r" )) == NULL )
+    {
+        Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
+        if ( (FileName = Extra_FileGetSimilarName( FileName, ".blif", NULL, NULL, NULL, NULL )) )
+            Abc_Print( 1, "Did you mean \"%s\"?", FileName );
+        Abc_Print( 1, "\n" );
+        return 1;
+    }
+    fclose( pFile );
+
+    pAig = Abc_NtkHieCecTest( FileName, fVerbose );
+    Abc_FrameUpdateGia( pAbc, pAig );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &read_blif [-vh] <file>\n" );
+    Abc_Print( -2, "\t         a specialized reader for hierarchical BLIF files\n" );
+    Abc_Print( -2, "\t         (for general-purpose BLIFs, please use \"read_blif\")\n" );
+    Abc_Print( -2, "\t-v     : toggles additional verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\t<file> : the file name\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9ReadCBlif( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Gia_Man_t * Abc_NtkHieCecTest2( char * pFileName, char * pModelName, int fVerbose );
+    Gia_Man_t * pAig;
+    FILE * pFile;
+    char ** pArgvNew;
+    char * FileName, * pTemp;
+    char * pModelName = NULL;
+    int nArgcNew;
+    int c, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Mvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'M':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-M\" should be followed by a file name.\n" );
+                goto usage;
+            }
+            pModelName = argv[globalUtilOptind];
+            globalUtilOptind++;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+    pArgvNew = argv + globalUtilOptind;
+    nArgcNew = argc - globalUtilOptind;
+    if ( nArgcNew != 1 )
+    {
+        Abc_Print( -1, "There is no file name.\n" );
+        return 1;
+    }
+
+    // get the input file name
+    FileName = pArgvNew[0];
+    // fix the wrong symbol
+    for ( pTemp = FileName; *pTemp; pTemp++ )
+        if ( *pTemp == '>' )
+            *pTemp = '\\';
+    if ( (pFile = fopen( FileName, "r" )) == NULL )
+    {
+        Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
+        if ( (FileName = Extra_FileGetSimilarName( FileName, ".cblif", NULL, NULL, NULL, NULL )) )
+            Abc_Print( 1, "Did you mean \"%s\"?", FileName );
+        Abc_Print( 1, "\n" );
+        return 1;
+    }
+    fclose( pFile );
+
+    pAig = Abc_NtkHieCecTest2( FileName, pModelName, fVerbose );
+    Abc_FrameUpdateGia( pAbc, pAig );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &read_cblif [-M name] [-vh] <file>\n" );
+    Abc_Print( -2, "\t         reads CBLIF file and collapse it into an AIG\n" );
+    Abc_Print( -2, "\t-M name: module name to collapse [default = <root_module>]\n" );
+    Abc_Print( -2, "\t-v     : toggles additional verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\t<file> : the file name\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9ReadStg( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pAig;
+    FILE * pFile;
+    char * FileName, ** pArgvNew;
+    int c, nArgcNew;
+    int kHot = 1;
+    int fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Kvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            kHot = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( kHot < 1 || kHot > 5 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+    pArgvNew = argv + globalUtilOptind;
+    nArgcNew = argc - globalUtilOptind;
+    if ( nArgcNew != 1 )
+    {
+        Abc_Print( -1, "There is no file name.\n" );
+        return 1;
+    }
+
+    // get the input file name
+    FileName = pArgvNew[0];
+    if ( (pFile = fopen( FileName, "r" )) == NULL )
+    {
+        Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
+        return 1;
+    }
+    fclose( pFile );
+
+    pAig = Gia_ManStgRead( FileName, kHot, fVerbose );
+    Abc_FrameUpdateGia( pAbc, pAig );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &read_stg [-K <num>] [-vh] <file>\n" );
+    Abc_Print( -2, "\t         reads STG file and generates K-hot-encoded AIG\n" );
+    Abc_Print( -2, "\t-K num : the K parameter for hotness of the encoding (1 <= K <= 5) [default = %d]\n", kHot );
+    Abc_Print( -2, "\t-v     : toggles printing state codes [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\t<file> : the file name\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9ReadVer( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Abc_Ntk_t * pNtk;
+    Gia_Man_t * pAig;
+    FILE * pFile;
+    char ** pArgvNew;
+    char * pFileName, * pTemp;
+    int nArgcNew;
+    int c, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+    pArgvNew = argv + globalUtilOptind;
+    nArgcNew = argc - globalUtilOptind;
+    if ( nArgcNew != 1 )
+    {
+        Abc_Print( -1, "There is no file name.\n" );
+        return 1;
+    }
+
+    // get the input file name
+    pFileName = pArgvNew[0];
+    // fix the wrong symbol
+    for ( pTemp = pFileName; *pTemp; pTemp++ )
+        if ( *pTemp == '>' )
+            *pTemp = '\\';
+    if ( (pFile = fopen( pFileName, "r" )) == NULL )
+    {
+        Abc_Print( -1, "Cannot open input file \"%s\". ", pFileName );
+        if ( (pFileName = Extra_FileGetSimilarName( pFileName, ".v", ".blif", NULL, NULL, NULL )) )
+            Abc_Print( 1, "Did you mean \"%s\"?", pFileName );
+        Abc_Print( 1, "\n" );
+        return 1;
+    }
+    fclose( pFile );
+    // read hierarchical Verilog
+    pNtk = Io_ReadNetlist( pFileName, Io_ReadFileType(pFileName), 0 );
+    if ( pNtk == NULL )
+    {
+        Abc_Print( -1, "Reading hierarchical Verilog has failed.\n" );
+        return 1;
+    }
+    pAig = Abc_NtkFlattenHierarchyGia( pNtk, NULL, fVerbose );
+    Abc_NtkDelete( pNtk );
+    Abc_FrameUpdateGia( pAbc, pAig );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &read_ver [-vh] <file>\n" );
+    Abc_Print( -2, "\t         a specialized reader for hierarchical Verilog files\n" );
+    Abc_Print( -2, "\t-v     : toggles additional verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\t<file> : the file name\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Get( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Aig_Man_t * Abc_NtkToDarChoices( Abc_Ntk_t * pNtk );
+    extern Vec_Ptr_t * Abc_NtkCollectCiNames( Abc_Ntk_t * pNtk );
+    extern Vec_Ptr_t * Abc_NtkCollectCoNames( Abc_Ntk_t * pNtk );
+    Abc_Ntk_t * pStrash;
+    Aig_Man_t * pAig;
+    Gia_Man_t * pGia, * pTemp;
+    char * pInits;
+    int c, fMapped = 0, fNames = 0, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "mnvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'm':
+            fMapped ^= 1;
+            break;
+        case 'n':
+            fNames ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pNtkCur == NULL )
+    {
+        Abc_Print( -1, "There is no current network\n" );
+        return 1;
+    }
+    if ( !Abc_NtkIsStrash( pAbc->pNtkCur ) )
+    {
+        if ( fMapped )
+        {
+            assert( Abc_NtkIsLogic(pAbc->pNtkCur) );
+            Abc_NtkToAig( pAbc->pNtkCur );
+            pGia = Abc_NtkAigToGia( pAbc->pNtkCur );
+        }
+        else
+        {
+            // derive comb GIA
+            pStrash = Abc_NtkStrash( pAbc->pNtkCur, 0, 1, 0 );
+            pAig = Abc_NtkToDar( pStrash, 0, 0 );
+            Abc_NtkDelete( pStrash );
+            pGia = Gia_ManFromAig( pAig );
+            Aig_ManStop( pAig );
+            // perform undc/zero
+            pInits = Abc_NtkCollectLatchValuesStr( pAbc->pNtkCur );
+            pGia = Gia_ManDupZeroUndc( pTemp = pGia, pInits, fVerbose );
+            Gia_ManStop( pTemp );
+            ABC_FREE( pInits );
+        }
+    }
+    else
+    {
+        if ( Abc_NtkGetChoiceNum(pAbc->pNtkCur) )
+            pAig = Abc_NtkToDarChoices( pAbc->pNtkCur );
+        else
+            pAig = Abc_NtkToDar( pAbc->pNtkCur, 0, 1 );
+        pGia = Gia_ManFromAig( pAig );
+        Aig_ManStop( pAig );
+    }
+    // replace
+    if ( fNames )
+    {
+        pGia->vNamesIn  = Abc_NtkCollectCiNames( pAbc->pNtkCur );
+        pGia->vNamesOut = Abc_NtkCollectCoNames( pAbc->pNtkCur );
+    }
+    Abc_FrameUpdateGia( pAbc, pGia );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &get [-mnvh] <file>\n" );
+    Abc_Print( -2, "\t         converts the current network into GIA and moves it to the &-space\n" );
+    Abc_Print( -2, "\t         (if the network is a sequential logic network, normalizes the flops\n" );
+    Abc_Print( -2, "\t         to have const-0 initial values, equivalent to \"undc; st; zero\")\n" );
+    Abc_Print( -2, "\t-m     : toggles preserving the current mapping [default = %s]\n", fMapped? "yes": "no" );
+    Abc_Print( -2, "\t-n     : toggles saving CI/CO names of the AIG [default = %s]\n", fNames? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggles additional verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\t<file> : the file name\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Put( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Abc_Ntk_t * Abc_NtkFromDarChoices( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan );
+    Aig_Man_t * pMan;
+    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    int c, fVerbose = 0;
+    int fStatusClear = 1;
+
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "svh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 's':
+            fStatusClear ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( Gia_ManHasMapping(pAbc->pGia) || pAbc->pGia->pMuxes )
+    {
+        extern Abc_Ntk_t * Abc_NtkFromMappedGia( Gia_Man_t * p );
+        pNtk = Abc_NtkFromMappedGia( pAbc->pGia );
+    }
+    else if ( Gia_ManHasCellMapping(pAbc->pGia) )
+    {
+        extern Abc_Ntk_t * Abc_NtkFromCellMappedGia( Gia_Man_t * p );
+        pNtk = Abc_NtkFromCellMappedGia( pAbc->pGia );
+    }
+    else if ( Gia_ManHasDangling(pAbc->pGia) == 0 )
+    {
+        pMan = Gia_ManToAig( pAbc->pGia, 0 );
+        pNtk = Abc_NtkFromAigPhase( pMan );
+        pNtk->pName = Extra_UtilStrsav(pMan->pName);
+        Aig_ManStop( pMan );
+    }
+    else
+    {
+        Abc_Ntk_t * pNtkNoCh;
+//        Abc_Print( -1, "Transforming AIG with %d choice nodes.\n", Gia_ManEquivCountClasses(pAbc->pGia) );
+        // create network without choices
+        pMan = Gia_ManToAig( pAbc->pGia, 0 );
+        pNtkNoCh = Abc_NtkFromAigPhase( pMan );
+        pNtkNoCh->pName = Extra_UtilStrsav(pMan->pName);
+        Aig_ManStop( pMan );
+        // derive network with choices
+        pMan = Gia_ManToAig( pAbc->pGia, 1 );
+        pNtk = Abc_NtkFromDarChoices( pNtkNoCh, pMan );
+        Abc_NtkDelete( pNtkNoCh );
+        Aig_ManStop( pMan );
+    }
+    // transfer PI names to pNtk
+    if ( pAbc->pGia->vNamesIn )
+    {
+        Abc_Obj_t * pObj;
+        int i;
+        Abc_NtkForEachCi( pNtk, pObj, i ) {
+            if (i < Vec_PtrSize(pAbc->pGia->vNamesIn)) {
+                Nm_ManDeleteIdName(pNtk->pManName, pObj->Id);
+                Abc_ObjAssignName( pObj, (char *)Vec_PtrEntry(pAbc->pGia->vNamesIn, i), NULL );
+            }
+        }
+    }
+    // transfer PO names to pNtk
+    if ( pAbc->pGia->vNamesOut )
+    {
+        Abc_Obj_t * pObj;
+        int i;
+        Abc_NtkForEachCo( pNtk, pObj, i ) {
+            if (i < Vec_PtrSize(pAbc->pGia->vNamesOut)) {
+                Nm_ManDeleteIdName(pNtk->pManName, pObj->Id);
+                Abc_ObjAssignName( pObj, (char *)Vec_PtrEntry(pAbc->pGia->vNamesOut, i), NULL );
+            }
+        }
+    }
+    // replace the current network
+    Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
+    if ( fStatusClear )
+        Abc_FrameClearVerifStatus( pAbc );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &put [-svh]\n" );
+    Abc_Print( -2, "\t         transfer the current network into the old ABC\n" );
+    Abc_Print( -2, "\t-s     : toggle clearning verification status [default = %s]\n", fStatusClear? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    [Compares to versions of the design and finds the best.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Gia_ManCompareWithBest( Gia_Man_t * pBest, Gia_Man_t * p, int * pnBestLuts, int * pnBestEdges, int * pnBestLevels )
+{
+    int nCurLuts, nCurEdges, nCurLevels;
+    Gia_ManLutParams( p, &nCurLuts, &nCurEdges, &nCurLevels );
+    if ( pBest == NULL ||
+         Gia_ManPiNum(pBest) != Gia_ManPiNum(p) || 
+         Gia_ManPoNum(pBest) != Gia_ManPoNum(p) || 
+         Gia_ManRegNum(pBest) != Gia_ManRegNum(p) ||
+         strcmp(Gia_ManName(pBest), Gia_ManName(p)) ||
+        (*pnBestLevels > nCurLevels) ||
+        (*pnBestLevels == nCurLevels && 2*(*pnBestLuts) + *pnBestEdges > 2*nCurLuts + nCurEdges) )
+    {
+        *pnBestLuts = nCurLuts;
+        *pnBestEdges = nCurEdges;
+        *pnBestLevels = nCurLevels;
+        return 1;
+    }
+    return 0;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Save( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    int c;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Empty network.\n" );
+        return 1;
+    }
+    if ( !Gia_ManHasMapping(pAbc->pGia) )
+    {
+        Abc_Print( -1, "GIA has no mapping.\n" );
+        return 1;
+    }
+    if ( !Gia_ManCompareWithBest( pAbc->pGiaBest, pAbc->pGia, &pAbc->nBestLuts, &pAbc->nBestEdges, &pAbc->nBestLevels ) )
+        return 0;
+    // save the design as best
+    Gia_ManStopP( &pAbc->pGiaBest );
+    pAbc->pGiaBest = Gia_ManDupWithAttributes( pAbc->pGia );
+    return 0; 
+
+usage:
+    Abc_Print( -2, "usage: &save [-h]\n" );
+    Abc_Print( -2, "\t        compares and possibly saves AIG with mapping\n" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Load( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    int c;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    // restore from best
+    if ( pAbc->pGiaBest == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Load(): There is no best design saved.\n" );
+        return 1;
+    }
+    Gia_ManStopP( &pAbc->pGia );
+    pAbc->pGia = Gia_ManDupWithAttributes( pAbc->pGiaBest );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &load [-h]\n" );
+    Abc_Print( -2, "\t        loads previously saved AIG with mapping" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Write( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    char * pFileName;
+    char ** pArgvNew;
+    int c, nArgcNew;
+    int fUnique = 0;
+    int fMiniAig = 0;
+    int fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "umvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'u':
+            fUnique ^= 1;
+            break;
+        case 'm':
+            fMiniAig ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    pArgvNew = argv + globalUtilOptind;
+    nArgcNew = argc - globalUtilOptind;
+    if ( nArgcNew != 1 )
+    {
+        Abc_Print( -1, "There is no file name.\n" );
+        return 1;
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Write(): There is no AIG to write.\n" );
+        return 1;
+    }
+    pFileName = argv[globalUtilOptind];
+    if ( fUnique )
+    {
+        Gia_Man_t * pGia = Gia_ManIsoCanonicize( pAbc->pGia, fVerbose );
+        Gia_AigerWriteSimple( pGia, pFileName );
+        Gia_ManStop( pGia );
+    }
+    else if ( fMiniAig )
+        Gia_ManWriteMiniAig( pAbc->pGia, pFileName );
+    else
+        Gia_AigerWrite( pAbc->pGia, pFileName, 0, 0 );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &w [-umvh] <file>\n" );
+    Abc_Print( -2, "\t         writes the current AIG into the AIGER file\n" );
+    Abc_Print( -2, "\t-u     : toggle writing canonical AIG structure [default = %s]\n", fUnique? "yes" : "no" );
+    Abc_Print( -2, "\t-m     : toggle writing MiniAIG rather than AIGER [default = %s]\n", fMiniAig? "yes" : "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\t<file> : the file name\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9WriteVer( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    char * pFileSpec = NULL;
+    Abc_Ntk_t * pNtkSpec = NULL;
+    char * pFileName;
+    char ** pArgvNew;
+    int c, nArgcNew;
+    int fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Svh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by a file name.\n" );
+                goto usage;
+            }
+            pFileSpec = argv[globalUtilOptind];
+            globalUtilOptind++;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    pArgvNew = argv + globalUtilOptind;
+    nArgcNew = argc - globalUtilOptind;
+    if ( nArgcNew != 1 )
+    {
+        Abc_Print( -1, "Expecting output file name on the command line.\n" );
+        return 1;
+    }
+    pFileName = argv[globalUtilOptind];
+    if ( pAbc->pNtkCur == NULL )
+    {
+        Abc_Print( -1, "There is no mapped file to write.\n" );
+        return 1;
+    }
+    if ( pFileSpec == NULL )
+    {
+        Abc_Print( -1, "The specification file is not given.\n" );
+        return 1;
+    }
+    pNtkSpec = Io_ReadNetlist( pFileSpec, Io_ReadFileType(pFileSpec), 0 );
+    if ( pNtkSpec == NULL )
+    {
+        Abc_Print( -1, "Reading hierarchical Verilog for the specification has failed.\n" );
+        return 1;
+    }
+    Abc_NtkInsertHierarchyGia( pNtkSpec, pAbc->pNtkCur, fVerbose );
+    Io_WriteVerilog( pNtkSpec, pFileName );
+    Abc_NtkDelete( pNtkSpec );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &write_ver [-S <file>] [-vh] <file>\n" );
+    Abc_Print( -2, "\t          writes hierarchical Verilog after mapping\n" );
+    Abc_Print( -2, "\t-S file : file name for the original hierarchical design (required)\n" );
+    Abc_Print( -2, "\t-v      : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h      : print the command usage\n");
+    Abc_Print( -2, "\t<file>  : the file name\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Ps( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gps_Par_t Pars, * pPars = &Pars;
+    int c, fBest = 0;
+    memset( pPars, 0, sizeof(Gps_Par_t) );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Dtpcnlmasbh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 't':
+            pPars->fTents ^= 1;
+            break;
+        case 'p':
+            pPars->fSwitch ^= 1;
+            break;
+        case 'c':
+            pPars->fCut ^= 1;
+            break;
+        case 'n':
+            pPars->fNpn ^= 1;
+            break;
+        case 'l':
+            pPars->fLutProf ^= 1;
+            break;
+        case 'm':
+            pPars->fMuxXor ^= 1;
+            break;
+        case 'a':
+            pPars->fMiter ^= 1;
+            break;
+        case 's':
+            pPars->fSkipMap ^= 1;
+            break;
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by a file name.\n" );
+                goto usage;
+            }
+            pPars->pDumpFile = argv[globalUtilOptind];
+            globalUtilOptind++;
+            break;
+        case 'b':
+            fBest ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( fBest )
+    {
+        if ( pAbc->pGiaBest == NULL )
+        {
+            Abc_Print( -1, "Abc_CommandAbc9Ps(): There is no AIG.\n" );
+            return 1;
+        }
+        Gia_ManPrintStats( pAbc->pGiaBest, pPars );
+    }
+    else
+    {
+        if ( pAbc->pGia == NULL )
+        {
+            Abc_Print( -1, "Abc_CommandAbc9Ps(): There is no AIG.\n" );
+            return 1;
+        }
+        Gia_ManPrintStats( pAbc->pGia, pPars );
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &ps [-tpcnlmasbh] [-D file]\n" );
+    Abc_Print( -2, "\t          prints stats of the current AIG\n" );
+    Abc_Print( -2, "\t-t      : toggle printing BMC tents [default = %s]\n",                pPars->fTents? "yes": "no" );
+    Abc_Print( -2, "\t-p      : toggle printing switching activity [default = %s]\n",       pPars->fSwitch? "yes": "no" );
+    Abc_Print( -2, "\t-c      : toggle printing the size of frontier cut [default = %s]\n", pPars->fCut? "yes": "no" );
+    Abc_Print( -2, "\t-n      : toggle printing NPN classes of functions [default = %s]\n", pPars->fNpn? "yes": "no" );
+    Abc_Print( -2, "\t-l      : toggle printing LUT size profile [default = %s]\n",         pPars->fLutProf? "yes": "no" );
+    Abc_Print( -2, "\t-m      : toggle printing MUX/XOR statistics [default = %s]\n",       pPars->fMuxXor? "yes": "no" );
+    Abc_Print( -2, "\t-a      : toggle printing miter statistics [default = %s]\n",         pPars->fMiter? "yes": "no" );
+    Abc_Print( -2, "\t-s      : skip mapping statistics even if mapped [default = %s]\n",   pPars->fSkipMap? "yes": "no" );
+    Abc_Print( -2, "\t-b      : toggle printing saved AIG statistics [default = %s]\n",     fBest? "yes": "no" );
+    Abc_Print( -2, "\t-D file : file name to dump statistics [default = none]\n" );
+    Abc_Print( -2, "\t-h      : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9PFan( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    int c;
+    int nNodes = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Nh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nNodes = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nNodes < 0 )
+                goto usage;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9PFan(): There is no AIG.\n" );
+        return 1;
+    }
+    Gia_ManPrintFanio( pAbc->pGia, nNodes );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &pfan [-N num] [-h]\n" );
+    Abc_Print( -2, "\t         prints fanin/fanout statistics\n" );
+    Abc_Print( -2, "\t-N num : the number of high-fanout nodes to explore [default = %d]\n", nNodes );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9PSig( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    int c;
+    int fSetReset = 1;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "rh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'r':
+            fSetReset ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9PSigs(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9PSigs(): Works only for sequential circuits.\n" );
+        return 1;
+    }
+    Gia_ManDetectSeqSignals( pAbc->pGia, fSetReset, 1 );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &psig [-rh]\n" );
+    Abc_Print( -2, "\t         prints enable/set/reset statistics\n" );
+    Abc_Print( -2, "\t-r     : toggle printing set/reset signals [default = %s]\n", fSetReset? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Status( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    int c;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Status(): There is no AIG.\n" );
+        return 1;
+    }
+    Gia_ManPrintMiterStatus( pAbc->pGia );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &status [-h]\n" );
+    Abc_Print( -2, "\t         prints status of the miter\n" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9MuxProfile( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern void Gia_ManMuxProfiling( Gia_Man_t * p );
+    int c;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9MuxProfile(): There is no AIG.\n" );
+        return 1;
+    }
+    Gia_ManMuxProfiling( pAbc->pGia );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &mux_profile [-h]\n" );
+    Abc_Print( -2, "\t         profile MUXes appearing in the design\n" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Show( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Aig_Man_t * pMan;
+    int c;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Show(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( Gia_ManBufNum(pAbc->pGia) )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Show(): Cannot show GIA with barrier buffers.\n" );
+        return 1;
+    }
+    pMan = Gia_ManToAigSimple( pAbc->pGia );
+    Aig_ManShow( pMan, 0, NULL );
+    Aig_ManStop( pMan );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &show [-h]\n" );
+    Abc_Print( -2, "\t        shows the current AIG using GSView\n" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9SetRegNum( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    int c, nRegNum = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Nh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nRegNum = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nRegNum < 0 )
+                goto usage;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9SetRegNum(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( nRegNum >= Gia_ManCiNum(pAbc->pGia) )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9SetRegNum(): The number of registers should be less than the number of CIs.\n" );
+        return 1;
+    }
+    if ( nRegNum >= Gia_ManCoNum(pAbc->pGia) )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9SetRegNum(): The number of registers should be less than the number of COs.\n" );
+        return 1;
+    }
+    pAbc->pGia->nRegs = nRegNum;
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &setregnum [-N num] [-h]\n" );
+    Abc_Print( -2, "\t         manually sets the number of registers to combine the last PI/PO pairs\n" );
+    Abc_Print( -2, "\t-N num : set the number of registers to be the given number [default = %d]\n", nRegNum );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Strash( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pTemp;
+    int c, Limit = 2;
+    int fAddStrash = 0;
+    int fCollapse = 0;
+    int fAddMuxes = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Lacmh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            Limit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( Limit < 0 )
+                goto usage;
+            break;
+        case 'a':
+            fAddStrash ^= 1;
+            break;
+        case 'c':
+            fCollapse ^= 1;
+            break;
+        case 'm':
+            fAddMuxes ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Strash(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( Gia_ManHasMapping(pAbc->pGia) )
+    {
+        pTemp = (Gia_Man_t *)Dsm_ManDeriveGia( pAbc->pGia, fAddMuxes );
+//        if ( !Abc_FrameReadFlag("silentmode") )
+//            printf( "Performed delay-oriented unmapping.\n" );
+    }
+    else if ( fAddMuxes )
+    {
+        if ( pAbc->pGia->pMuxes )
+        {
+            Abc_Print( -1, "Abc_CommandAbc9Strash(): The AIG already has MUXes.\n" );
+            return 1;
+        }
+        pTemp = Gia_ManDupMuxes( pAbc->pGia, Limit );
+        if ( !Abc_FrameReadFlag("silentmode") )
+            printf( "Generated AND/XOR/MUX graph.\n" );
+    }
+    else if ( fCollapse && pAbc->pGia->pAigExtra )
+    {
+        assert( !Gia_ManBufNum(pAbc->pGia) );
+        if ( Gia_ManIsSeqWithBoxes(pAbc->pGia) || Gia_ManRegBoxNum(pAbc->pGia) )
+        {
+            Gia_Man_t * pUnshuffled = Gia_ManDupUnshuffleInputs( pAbc->pGia );
+            Gia_ManTransferTiming( pUnshuffled, pAbc->pGia );
+            pTemp = Gia_ManDupCollapse( pUnshuffled, pUnshuffled->pAigExtra, NULL, Gia_ManRegBoxNum(pUnshuffled) > 0 );
+            Gia_ManTransferTiming( pAbc->pGia, pUnshuffled );
+            Gia_ManStop( pUnshuffled );
+        }
+        else
+            pTemp = Gia_ManDupCollapse( pAbc->pGia, pAbc->pGia->pAigExtra, NULL, 0 );
+        if ( !Abc_FrameReadFlag("silentmode") )
+            printf( "Collapsed AIG with boxes and logic of the boxes.\n" );
+    }
+    else if ( pAbc->pGia->pMuxes )
+    {
+        pTemp = Gia_ManDupNoMuxes( pAbc->pGia );
+        if ( !Abc_FrameReadFlag("silentmode") )
+            printf( "Generated AIG from AND/XOR/MUX graph.\n" );
+    }
+    else
+    {
+        pTemp = Gia_ManRehash( pAbc->pGia, fAddStrash );
+//        if ( !Abc_FrameReadFlag("silentmode") )
+//            printf( "Rehashed the current AIG.\n" );
+    }
+    if ( !(fCollapse && pAbc->pGia->pAigExtra) )
+        Gia_ManTransferTiming( pTemp, pAbc->pGia );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &st [-L num] [-acmh]\n" );
+    Abc_Print( -2, "\t         performs structural hashing\n" );
+    Abc_Print( -2, "\t-a     : toggle additional hashing [default = %s]\n", fAddStrash? "yes": "no" );
+    Abc_Print( -2, "\t-c     : toggle collapsing hierarchical AIG [default = %s]\n", fCollapse? "yes": "no" );
+    Abc_Print( -2, "\t-m     : toggle converting to larger gates [default = %s]\n", fAddMuxes? "yes": "no" );
+    Abc_Print( -2, "\t-L num : create MUX when sum of refs does not exceed this limit [default = %d]\n", Limit );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Topand( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pTemp;
+    int c, fVerbose = 1;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Topand(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( Gia_ManRegNum(pAbc->pGia) > 0 )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Topand(): Can only be applied to a combinational miter.\n" );
+        return 1;
+    }
+    pTemp = Gia_ManDupTopAnd( pAbc->pGia, fVerbose );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &topand [-vh]\n" );
+    Abc_Print( -2, "\t        performs AND decomposition for combinational miter\n" );
+    Abc_Print( -2, "\t-v    : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Add1Hot( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pTemp;
+    int c, fVerbose = 1;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Add1Hot(): There is no AIG.\n" );
+        return 1;
+    }
+    pTemp = Gia_ManDupOneHot( pAbc->pGia );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &add1hot [-vh]\n" );
+    Abc_Print( -2, "\t        adds 1-hotness constraints as additional primary outputs\n" );
+    Abc_Print( -2, "\t-v    : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Cof( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pTemp;
+    int c, fVerbose = 0;
+    int iVar = 0, nLimFan = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "VLvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'V':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-V\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            iVar = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( iVar < 0 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nLimFan = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLimFan < 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Cof(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( nLimFan )
+    {
+        Abc_Print( -1, "Cofactoring all variables whose fanout count is higher than %d.\n", nLimFan );
+        pTemp = Gia_ManDupCofAll( pAbc->pGia, nLimFan, fVerbose );
+        Abc_FrameUpdateGia( pAbc, pTemp );
+    }
+    else if ( iVar )
+    {
+        Abc_Print( -1, "Cofactoring one variable with object ID %d.\n", iVar );
+        pTemp = Gia_ManDupCof( pAbc->pGia, iVar );
+        Abc_FrameUpdateGia( pAbc, pTemp );
+    }
+    else
+    {
+        Abc_Print( -1, "One of the parameters, -V <num> or -L <num>, should be set on the command line.\n" );
+        goto usage;
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &cof [-VL num] [-vh]\n" );
+    Abc_Print( -2, "\t         performs cofactoring w.r.t. variable(s)\n" );
+    Abc_Print( -2, "\t-V num : the zero-based ID of one variable to cofactor [default = %d]\n", iVar );
+    Abc_Print( -2, "\t-L num : cofactor vars with fanout count higher than this [default = %d]\n", nLimFan );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Trim( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pTemp, * pTemp2;
+    int c;
+    int OutValue = -1;
+    int fTrimCis = 1;
+    int fTrimCos = 1;
+    int fDualOut = 0;
+    int fPoFedByPi = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Viocdh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'V':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-V\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            OutValue = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( OutValue < 0 )
+                goto usage;
+            break;
+        case 'i':
+            fTrimCis ^= 1;
+            break;
+        case 'o':
+            fTrimCos ^= 1;
+            break;
+        case 'c':
+            fPoFedByPi ^= 1;
+            break;
+        case 'd':
+            fDualOut ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Trim(): There is no AIG.\n" );
+        return 1;
+    }
+    pTemp = Gia_ManDupTrimmed( pAbc->pGia, fTrimCis, fTrimCos, fDualOut, OutValue );
+    if ( fPoFedByPi )
+    {
+        extern Gia_Man_t * Gia_ManDupTrimmed2( Gia_Man_t * p );
+        pTemp = Gia_ManDupTrimmed2( pTemp2 = pTemp );
+        Gia_ManStop( pTemp2 );
+    }
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &trim [-V num] [-iocdh]\n" );
+    Abc_Print( -2, "\t         removes PIs without fanout and PO driven by constants\n" );
+    Abc_Print( -2, "\t-V num : the value (0 or 1) of POs to remove [default = both]\n" );
+    Abc_Print( -2, "\t-i     : toggle removing PIs [default = %s]\n", fTrimCis? "yes": "no" );
+    Abc_Print( -2, "\t-o     : toggle removing POs [default = %s]\n", fTrimCos? "yes": "no" );
+    Abc_Print( -2, "\t-c     : toggle additionally removing POs fed by PIs [default = %s]\n", fPoFedByPi? "yes": "no" );
+    Abc_Print( -2, "\t-d     : toggle using dual-output miter [default = %s]\n", fDualOut? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Dfs( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pTemp;
+    int c;
+    int fNormal  = 0;
+    int fReverse = 0;
+    int fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "nrvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'n':
+            fNormal ^= 1;
+            break;
+        case 'r':
+            fReverse ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Dfs(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( fNormal )
+    {
+        pTemp = Gia_ManDupOrderAiger( pAbc->pGia );
+        if ( fVerbose )
+            Abc_Print( -1, "AIG objects are reordered as follows: CIs, ANDs, COs.\n" );
+    }
+    else if ( fReverse )
+    {
+        pTemp = Gia_ManDupOrderDfsReverse( pAbc->pGia );
+        if ( fVerbose )
+            Abc_Print( -1, "AIG objects are reordered in the reserve DFS order.\n" );
+    }
+    else
+    {
+        pTemp = Gia_ManDupOrderDfs( pAbc->pGia );
+        if ( fVerbose )
+            Abc_Print( -1, "AIG objects are reordered in the DFS order.\n" );
+    }
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &dfs [-nrvh]\n" );
+    Abc_Print( -2, "\t        orders objects in the DFS order\n" );
+    Abc_Print( -2, "\t-n    : toggle using normalized ordering [default = %s]\n", fNormal? "yes": "no" );
+    Abc_Print( -2, "\t-r    : toggle using reverse DFS ordering [default = %s]\n", fReverse? "yes": "no" );
+    Abc_Print( -2, "\t-v    : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Sim( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_ParSim_t Pars, * pPars = &Pars;
+    char * pFileName = NULL;
+    int c;
+    Gia_ManSimSetDefaultParams( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "FWNTImvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nIters = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nIters < 0 )
+                goto usage;
+            break;
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nWords = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nWords < 0 )
+                goto usage;
+            break;
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->RandSeed = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->RandSeed < 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->TimeLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->TimeLimit < 0 )
+                goto usage;
+            break;
+        case 'I':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pFileName = argv[globalUtilOptind];
+            globalUtilOptind++;
+            if ( pFileName == NULL )
+                goto usage;
+            break;
+        case 'm':
+            pPars->fCheckMiter ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Sim(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+    {
+        Abc_Print( -1, "The network is combinational.\n" );
+        return 0;
+    }
+    if ( pFileName != NULL )
+    {
+        extern void Gia_ManSimSimulatePattern( Gia_Man_t * p, char * pFileIn, char * pFileOut );
+        char pFileNameOut[1000];
+        char * pNameGeneric = Extra_FileNameGeneric(pFileName);
+        assert( strlen(pNameGeneric) < 900 );
+        sprintf( pFileNameOut, "%s_out.%s", pNameGeneric, Extra_FileNameExtension(pFileName) );
+        ABC_FREE( pNameGeneric );
+        Gia_ManSimSimulatePattern( pAbc->pGia, pFileName, pFileNameOut );
+        return 1;
+    }
+
+    pAbc->nFrames = -1;
+    if ( Gia_ManSimSimulate( pAbc->pGia, pPars ) )
+        pAbc->Status =  0;
+    else
+        pAbc->Status = -1;
+    Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexSeq );
+//    if ( pLogFileName )
+//        Abc_NtkWriteLogFile( pLogFileName, pAbc->pCex, pAbc->Status, pAbc->nFrames, "&sim" );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &sim [-FWNT num] [-mvh] -I <file>\n" );
+    Abc_Print( -2, "\t         performs random simulation of the sequential miter\n" );
+    Abc_Print( -2, "\t         (if candidate equivalences are defined, performs refinement)\n" );
+    Abc_Print( -2, "\t-F num : the number of frames to simulate [default = %d]\n", pPars->nIters );
+    Abc_Print( -2, "\t-W num : the number of words to simulate [default = %d]\n", pPars->nWords );
+    Abc_Print( -2, "\t-N num : random number seed (1 <= num <= 1000) [default = %d]\n", pPars->RandSeed );
+    Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", pPars->TimeLimit );
+    Abc_Print( -2, "\t-m     : toggle miter vs. any circuit [default = %s]\n", pPars->fCheckMiter? "miter": "circuit" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\t-I file: (optional) file with input patterns (one line per frame, as many as PIs)\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Sim3( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern int Ssw_RarSimulateGia( Gia_Man_t * p, Ssw_RarPars_t * pPars );
+    Ssw_RarPars_t Pars, * pPars = &Pars;
+    int c;
+    Ssw_RarSetDefaultParams( pPars );
+    // parse command line
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "FWBRSNTGgvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nFrames = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nFrames < 0 )
+                goto usage;
+            break;
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nWords = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nWords < 0 )
+                goto usage;
+            break;
+        case 'B':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nBinSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nBinSize < 0 )
+                goto usage;
+            break;
+        case 'R':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nRounds = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nRounds < 0 )
+                goto usage;
+            break;
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nRestart = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nRestart < 0 )
+                goto usage;
+            break;
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nRandSeed = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nRandSeed < 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->TimeOut = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->TimeOut < 0 )
+                goto usage;
+            break;
+        case 'G':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-G\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->TimeOutGap = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->TimeOutGap < 0 )
+                goto usage;
+            break;
+        case 'g':
+            pPars->fUseFfGrouping ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Sim3(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Sim3(): This command works only for sequential AIGs.\n" );
+        return 0;
+    }
+    pAbc->Status = Ssw_RarSimulateGia( pAbc->pGia, pPars );
+    Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexSeq );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &sim3 [-FWBRNT num] [-gvh]\n" );
+    Abc_Print( -2, "\t         performs random simulation of the sequential miter\n" );
+    Abc_Print( -2, "\t-F num : the number of frames to simulate [default = %d]\n",       pPars->nFrames );
+    Abc_Print( -2, "\t-W num : the number of words to simulate [default = %d]\n",        pPars->nWords );
+    Abc_Print( -2, "\t-B num : the number of flops in one bin [default = %d]\n",         pPars->nBinSize );
+    Abc_Print( -2, "\t-R num : the number of simulation rounds [default = %d]\n",        pPars->nRounds );
+    Abc_Print( -2, "\t-S num : the number of rounds before a restart [default = %d]\n",  pPars->nRestart );
+    Abc_Print( -2, "\t-N num : random number seed (1 <= num <= 1000) [default = %d]\n",  pPars->nRandSeed );
+    Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n",   pPars->TimeOut );
+    Abc_Print( -2, "\t-g     : toggle heuristic flop grouping [default = %s]\n",    pPars->fUseFfGrouping? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n",    pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Resim( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Cec_ParSim_t Pars, * pPars = &Pars;
+    int c, RetValue;
+    Cec_ManSimSetDefaultParams( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Fmvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nFrames = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nFrames < 0 )
+                goto usage;
+            break;
+        case 'm':
+            pPars->fCheckMiter ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Resim(): There is no AIG.\n" );
+        return 1;
+    }
+    RetValue = Cec_ManSeqResimulateCounter( pAbc->pGia, pPars, pAbc->pCex );
+    pAbc->Status  = RetValue ? 0 : -1;
+    pAbc->nFrames = pAbc->pCex->iFrame;
+//    Abc_FrameReplaceCex( pAbc, &pAbc->pCex );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &resim [-F num] [-mvh]\n" );
+    Abc_Print( -2, "\t         resimulates equivalence classes using counter-example\n" );
+    Abc_Print( -2, "\t-F num : the number of additinal frames to simulate [default = %d]\n", pPars->nFrames );
+    Abc_Print( -2, "\t-m     : toggle miter vs. any circuit [default = %s]\n", pPars->fCheckMiter? "miter": "circuit" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9SpecI( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern int Gia_CommandSpecI( Gia_Man_t * pGia, int nFrames, int nBTLimit, int fUseStart, int fCheckMiter, int fVerbose );
+    int nFrames     =   100;
+    int nBTLimit    = 25000;
+    int fUseStart   =     1;
+    int fCheckMiter =     1;
+    int fVerbose    =     0;
+    int c;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "FCfmvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFrames = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFrames < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nBTLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nBTLimit < 0 )
+                goto usage;
+            break;
+        case 'f':
+            fUseStart ^= 1;
+            break;
+        case 'm':
+            fCheckMiter ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9SpecI(): There is no AIG.\n" );
+        return 1;
+    }
+    Gia_CommandSpecI( pAbc->pGia, nFrames, nBTLimit, fUseStart, fCheckMiter, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &speci [-FC num] [-fmvh]\n" );
+    Abc_Print( -2, "\t         refines equivalence classes using speculative reduction\n" );
+    Abc_Print( -2, "\t-F num : the max number of time frames [default = %d]\n", nFrames );
+    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", nBTLimit );
+    Abc_Print( -2, "\t-f     : toggle starting BMC from a later frame [default = %s]\n", fUseStart? "yes": "no" );
+    Abc_Print( -2, "\t-m     : toggle miter vs. any circuit [default = %s]\n", fCheckMiter? "miter": "circuit" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Equiv( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Cec_ParSim_t Pars, * pPars = &Pars;
+    int c;
+    Cec_ManSimSetDefaultParams( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "WFRSTsmdvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nWords = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nWords < 0 )
+                goto usage;
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nFrames = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nFrames < 0 )
+                goto usage;
+            break;
+        case 'R':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nRounds = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nRounds < 0 )
+                goto usage;
+            break;
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nNonRefines = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nNonRefines < 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->TimeLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->TimeLimit < 0 )
+                goto usage;
+            break;
+        case 's':
+            pPars->fSeqSimulate ^= 1;
+            break;
+        case 'm':
+            pPars->fCheckMiter ^= 1;
+            break;
+        case 'd':
+            pPars->fDualOut ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Equiv(): There is no AIG.\n" );
+        return 1;
+    }
+    Cec_ManSimulation( pAbc->pGia, pPars );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &equiv [-WFRST num] [-smdvh]\n" );
+    Abc_Print( -2, "\t         computes candidate equivalence classes\n" );
+    Abc_Print( -2, "\t-W num : the number of words to simulate [default = %d]\n", pPars->nWords );
+    Abc_Print( -2, "\t-F num : the number of frames to simulate [default = %d]\n", pPars->nFrames );
+    Abc_Print( -2, "\t-R num : the max number of simulation rounds [default = %d]\n", pPars->nRounds );
+    Abc_Print( -2, "\t-S num : the max number of rounds w/o refinement to stop [default = %d]\n", pPars->nNonRefines );
+    Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", pPars->TimeLimit );
+    Abc_Print( -2, "\t-s     : toggle seq vs. comb simulation [default = %s]\n", pPars->fSeqSimulate? "yes": "no" );
+    Abc_Print( -2, "\t-m     : toggle miter vs. any circuit [default = %s]\n", pPars->fCheckMiter? "miter": "circuit" );
+    Abc_Print( -2, "\t-d     : toggle using two POs intead of XOR [default = %s]\n", pPars->fDualOut? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Equiv2( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern void Ssw_SignalFilterGia( Gia_Man_t * p, int nFramesMax, int nConfMax, int nRounds, int TimeLimit, int TimeLimit2, Abc_Cex_t * pCex, int fLatchOnly, int fVerbose );
+    int nFramesMax =   20;
+    int nConfMax   =  500;
+    int nRounds    =   10;
+    int TimeLimit  =    0;
+    int TimeLimit2 =    0;
+    int fUseCex    =    0;
+    int fLatchOnly =    0;
+    int fVerbose   =    0;
+    int c;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "FCRTSxlvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFramesMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFramesMax < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nConfMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nConfMax < 0 )
+                goto usage;
+            break;
+        case 'R':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nRounds = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nRounds < 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            TimeLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( TimeLimit < 0 )
+                goto usage;
+            break;
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            TimeLimit2 = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( TimeLimit2 < 0 )
+                goto usage;
+            break;
+        case 'x':
+            fUseCex ^= 1;
+            break;
+        case 'l':
+            fLatchOnly ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Equiv2(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+    {
+        Abc_Print( 0, "Abc_CommandAbc9Equiv2(): There is no flops. Nothing is done.\n" );
+        return 0;
+    }
+    if ( fUseCex )
+    {
+        if ( pAbc->pCex == NULL )
+        {
+            Abc_Print( 0, "Abc_CommandAbc9Equiv2(): Counter-example is not available.\n" );
+            return 0;
+        }
+        if ( pAbc->pCex->nPis != Gia_ManPiNum(pAbc->pGia) )
+        {
+            Abc_Print( -1, "Abc_CommandAbc9Equiv2(): The number of PIs differs in cex (%d) and in AIG (%d).\n",
+                pAbc->pCex->nPis, Gia_ManPiNum(pAbc->pGia) );
+            return 1;
+        }
+    }
+    Ssw_SignalFilterGia( pAbc->pGia, nFramesMax, nConfMax, nRounds, TimeLimit, TimeLimit2, fUseCex? pAbc->pCex: NULL, fLatchOnly, fVerbose );
+    pAbc->Status  = -1;
+//    pAbc->nFrames = pAbc->pCex->iFrame;
+//    Abc_FrameReplaceCex( pAbc, &pAbc->pCex );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &equiv2 [-FCRTS num] [-xlvh]\n" );
+    Abc_Print( -2, "\t         computes candidate equivalence classes\n" );
+    Abc_Print( -2, "\t-F num : the max number of frames for BMC [default = %d]\n", nFramesMax );
+    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", nConfMax );
+    Abc_Print( -2, "\t-R num : the max number of BMC rounds [default = %d]\n", nRounds );
+    Abc_Print( -2, "\t-T num : runtime limit in seconds for all rounds [default = %d]\n", TimeLimit );
+    Abc_Print( -2, "\t-S num : runtime limit in seconds for one round [default = %d]\n", TimeLimit2 );
+    Abc_Print( -2, "\t-x     : toggle using the current cex to perform refinement [default = %s]\n", fUseCex? "yes": "no" );
+    Abc_Print( -2, "\t-l     : toggle considering only latch output equivalences [default = %s]\n", fLatchOnly? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Equiv3( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern int Ssw_RarSignalFilterGia( Gia_Man_t * p, Ssw_RarPars_t * pPars );
+    Ssw_RarPars_t Pars, * pPars = &Pars;
+    int c;
+    Ssw_RarSetDefaultParams( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "FWBRSNTmxlvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nFrames = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nFrames < 0 )
+                goto usage;
+            break;
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nWords = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nWords < 0 )
+                goto usage;
+            break;
+        case 'B':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nBinSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nBinSize < 0 )
+                goto usage;
+            break;
+        case 'R':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nRounds = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nRounds < 0 )
+                goto usage;
+            break;
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nRestart = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nRestart < 0 )
+                goto usage;
+            break;
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nRandSeed = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nRandSeed < 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->TimeOut = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->TimeOut < 0 )
+                goto usage;
+            break;
+        case 'm':
+            pPars->fMiter ^= 1;
+            break;
+        case 'x':
+            pPars->fUseCex ^= 1;
+            break;
+        case 'l':
+            pPars->fLatchOnly ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Equiv3(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+    {
+        Abc_Print( 0, "Abc_CommandAbc9Equiv3(): There is no flops. Nothing is done.\n" );
+        return 0;
+    }
+    if ( pPars->fUseCex )
+    {
+        if ( pPars->fMiter )
+        {
+            Abc_Print( 0, "Abc_CommandAbc9Equiv3(): Considering the miter as a circuit because the CEX is given.\n" );
+            pPars->fMiter = 0;
+        }
+        if ( pAbc->pCex == NULL )
+        {
+            Abc_Print( 0, "Abc_CommandAbc9Equiv3(): Counter-example is not available.\n" );
+            return 0;
+        }
+        if ( pAbc->pCex->nPis != Gia_ManPiNum(pAbc->pGia) )
+        {
+            Abc_Print( -1, "Abc_CommandAbc9Equiv3(): The number of PIs differs in cex (%d) and in AIG (%d).\n",
+                pAbc->pCex->nPis, Gia_ManPiNum(pAbc->pGia) );
+            return 1;
+        }
+        pPars->pCex = pAbc->pCex;
+    }
+    pAbc->Status = Ssw_RarSignalFilterGia( pAbc->pGia, pPars );
+//    pAbc->nFrames = pAbc->pGia->pCexSeq->iFrame;
+    Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexSeq );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &equiv3 [-FWRSNT num] [-mxlvh]\n" );
+    Abc_Print( -2, "\t         computes candidate equivalence classes\n" );
+    Abc_Print( -2, "\t-F num : the max number of frames for BMC [default = %d]\n",                   pPars->nFrames );
+    Abc_Print( -2, "\t-W num : the number of words to simulate [default = %d]\n",                    pPars->nWords );
+    Abc_Print( -2, "\t-R num : the max number of simulation rounds [default = %d]\n",                pPars->nRounds );
+    Abc_Print( -2, "\t-S num : the number of rounds before a restart [default = %d]\n",              pPars->nRestart );
+    Abc_Print( -2, "\t-N num : random number seed (1 <= num <= 1000) [default = %d]\n",              pPars->nRandSeed );
+    Abc_Print( -2, "\t-T num : runtime limit in seconds for all rounds [default = %d]\n",            pPars->TimeOut );
+    Abc_Print( -2, "\t-m     : toggle miter vs. any circuit [default = %s]\n",                       pPars->fMiter? "miter": "circuit" );
+    Abc_Print( -2, "\t-x     : toggle using the current CEX to perform refinement [default = %s]\n", pPars->fUseCex? "yes": "no" );
+    Abc_Print( -2, "\t-l     : toggle considering only latch output equivalences [default = %s]\n",  pPars->fLatchOnly? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n",                pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Semi( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Cec_ParSmf_t Pars, * pPars = &Pars;
+    int c;
+    Cec_ManSmfSetDefaultParams( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "WRFSMCTmdvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nWords = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nWords < 0 )
+                goto usage;
+            break;
+        case 'R':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nRounds = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nRounds < 0 )
+                goto usage;
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nFrames = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nFrames < 0 )
+                goto usage;
+            break;
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nNonRefines = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nNonRefines < 0 )
+                goto usage;
+            break;
+        case 'M':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nMinOutputs = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nMinOutputs < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nBTLimit < 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->TimeLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->TimeLimit < 0 )
+                goto usage;
+            break;
+        case 'm':
+            pPars->fCheckMiter ^= 1;
+            break;
+        case 'd':
+            pPars->fDualOut ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Resim(): There is no AIG.\n" );
+        return 1;
+    }
+    Cec_ManSeqSemiformal( pAbc->pGia, pPars );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &semi [-WRFSMCT num] [-mdvh]\n" );
+    Abc_Print( -2, "\t         performs semiformal refinement of equivalence classes\n" );
+    Abc_Print( -2, "\t-W num : the number of words to simulate [default = %d]\n", pPars->nWords );
+    Abc_Print( -2, "\t-R num : the max number of rounds to simulate [default = %d]\n", pPars->nRounds );
+    Abc_Print( -2, "\t-F num : the max number of frames to unroll [default = %d]\n", pPars->nFrames );
+    Abc_Print( -2, "\t-S num : the max number of rounds w/o refinement to stop [default = %d]\n", pPars->nNonRefines );
+    Abc_Print( -2, "\t-M num : the min number of outputs of bounded SRM [default = %d]\n", pPars->nMinOutputs );
+    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
+    Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", pPars->TimeLimit );
+    Abc_Print( -2, "\t-m     : toggle miter vs. any circuit [default = %s]\n", pPars->fCheckMiter? "miter": "circuit" );
+    Abc_Print( -2, "\t-d     : toggle using two POs intead of XOR [default = %s]\n", pPars->fDualOut? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Times( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pTemp;
+    int c, nTimes = 2, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Nvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nTimes = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nTimes < 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Times(): There is no AIG.\n" );
+        return 1;
+    }
+    pTemp = Gia_ManDupTimes( pAbc->pGia, nTimes );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &times [-N <num>] [-vh]\n" );
+    Abc_Print( -2, "\t         creates several \"parallel\" copies of the design\n" );
+    Abc_Print( -2, "\t-N num : number of copies to create [default = %d]\n", nTimes );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Frames( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Gia_Man_t * Gia_ManFrames2( Gia_Man_t * pAig, Gia_ParFra_t * pPars );
+
+    Gia_Man_t * pTemp;
+    Gia_ParFra_t Pars, * pPars = &Pars;
+    int c;
+    int nCofFanLit = 0;
+    int fNewAlgo = 0;
+    int fInitSpecial = 0;
+    Gia_ManFraSetDefaultParams( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "FLsoibavh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nFrames = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nFrames < 0 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nCofFanLit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nCofFanLit < 0 )
+                goto usage;
+            break;
+        case 's':
+            pPars->fDisableSt ^= 1;
+            break;
+        case 'o':
+            pPars->fOrPos ^= 1;
+            break;
+        case 'i':
+            pPars->fInit ^= 1;
+            break;
+        case 'b':
+            fInitSpecial ^= 1;
+            break;
+        case 'a':
+            fNewAlgo ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Frames(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+    {
+        Abc_Print( -1, "The network is combinational.\n" );
+        return 0;
+    }
+    if ( fInitSpecial )
+        pTemp = Gia_ManFramesInitSpecial( pAbc->pGia, pPars->nFrames, pPars->fVerbose );
+    else if ( nCofFanLit )
+        pTemp = Gia_ManUnrollAndCofactor( pAbc->pGia, pPars->nFrames, nCofFanLit, pPars->fVerbose );
+    else if ( fNewAlgo )
+        pTemp = Gia_ManFrames2( pAbc->pGia, pPars );
+    else
+        pTemp = Gia_ManFrames( pAbc->pGia, pPars );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &frames [-FL <num>] [-soibavh]\n" );
+    Abc_Print( -2, "\t         unrolls the design for several timeframes\n" );
+    Abc_Print( -2, "\t-F num : the number of frames to unroll [default = %d]\n", pPars->nFrames );
+    Abc_Print( -2, "\t-L num : the limit on fanout count of resets/enables to cofactor [default = %d]\n", nCofFanLit );
+    Abc_Print( -2, "\t-s     : toggle disabling structural hashing [default = %s]\n", pPars->fDisableSt? "yes": "no" );
+    Abc_Print( -2, "\t-o     : toggle ORing corresponding POs [default = %s]\n", pPars->fOrPos? "yes": "no" );
+    Abc_Print( -2, "\t-i     : toggle initializing registers [default = %s]\n", pPars->fInit? "yes": "no" );
+    Abc_Print( -2, "\t-b     : toggle computing special AIG for BMC [default = %s]\n", fInitSpecial? "yes": "no" );
+    Abc_Print( -2, "\t-a     : toggle using new algorithm [default = %s]\n", fNewAlgo? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Retime( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pTemp;
+    int c;
+    int nMaxIters = 100;
+    int fVerbose  =   0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Nvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nMaxIters = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nMaxIters < 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Retime(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+    {
+        Abc_Print( -1, "The network is combinational.\n" );
+        return 0;
+    }
+    pTemp = Gia_ManRetimeForward( pAbc->pGia, nMaxIters, fVerbose );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &retime [-N <num>] [-vh]\n" );
+    Abc_Print( -2, "\t         performs most-forward retiming\n" );
+    Abc_Print( -2, "\t-N num : the number of incremental iterations [default = %d]\n", nMaxIters );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Enable( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pTemp;
+    int c;
+    int fRemove  = 0;
+    int fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "rvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'r':
+            fRemove ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Enable(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( fRemove )
+        pTemp = Gia_ManRemoveEnables( pAbc->pGia );
+    else
+        pTemp = Gia_ManDupSelf( pAbc->pGia );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &enable [-rvh]\n" );
+    Abc_Print( -2, "\t         adds or removes flop enable signals\n" );
+    Abc_Print( -2, "\t-r     : toggle adding vs. removing enables [default = %s]\n", fRemove? "remove": "add" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Dc2( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pTemp;
+    int c, fVerbose = 0;
+    int fUpdateLevel = 1;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "lvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'l':
+            fUpdateLevel ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Dc2(): There is no AIG.\n" );
+        return 1;
+    }
+    pTemp = Gia_ManCompress2( pAbc->pGia, fUpdateLevel, fVerbose );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &dc2 [-lvh]\n" );
+    Abc_Print( -2, "\t         performs heavy rewriting of the AIG\n" );
+    Abc_Print( -2, "\t-l     : toggle level update during rewriting [default = %s]\n", fUpdateLevel? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Dsd( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Gia_Man_t * Gia_ManCollapseTest( Gia_Man_t * p, int fVerbose );
+    Gia_Man_t * pTemp;
+    int c, fVerbose = 0;
+    int fUpdateLevel = 1;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "lvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'l':
+            fUpdateLevel ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Dsd(): There is no AIG.\n" );
+        return 1;
+    }
+    pTemp = Gia_ManCollapseTest( pAbc->pGia, fVerbose );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &dsd [-vh]\n" );
+    Abc_Print( -2, "\t         performs DSD-based collapsing\n" );
+//    Abc_Print( -2, "\t-l     : toggle level update during rewriting [default = %s]\n", fUpdateLevel? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Bidec( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pTemp;
+    int c, fVerbose = 0;
+    int fUpdateLevel = 1;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "lvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'l':
+            fUpdateLevel ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Bidec(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( !Gia_ManHasMapping(pAbc->pGia) )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Bidec(): Mapping of the AIG is not defined.\n" );
+        return 1;
+    }
+    pTemp = Gia_ManPerformBidec( pAbc->pGia, fVerbose );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &bidec [-vh]\n" );
+    Abc_Print( -2, "\t         performs heavy rewriting of the AIG\n" );
+//    Abc_Print( -2, "\t-l     : toggle level update during rewriting [default = %s]\n", fUpdateLevel? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Shrink( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pTemp = NULL;
+    int nLutSize;
+    int c,fVerbose = 0;
+    int fKeepLevel = 0;
+    int nFanoutMax = 50;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Nlvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by a char string.\n" );
+                goto usage;
+            }
+            nFanoutMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFanoutMax < 0 )
+                goto usage;
+            break;
+        case 'l':
+            fKeepLevel ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Shrink(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( !Gia_ManHasMapping(pAbc->pGia) )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Shrink(): Mapping of the AIG is not defined.\n" );
+        return 1;
+    }
+    nLutSize = Gia_ManLutSizeMax( pAbc->pGia );
+    if ( nLutSize <= 4 )
+        pTemp = Gia_ManMapShrink4( pAbc->pGia, fKeepLevel, fVerbose );
+    else if ( nLutSize <= 6 )
+        pTemp = Gia_ManMapShrink6( pAbc->pGia, nFanoutMax, fKeepLevel, fVerbose );
+    else
+        Abc_Print( -1, "Abc_CommandAbc9Shrink(): Works only for 4-LUTs and 6-LUTs.\n" );
+    if ( pTemp )
+        Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &shrink [-N num] [-lvh]\n" );
+    Abc_Print( -2, "\t         performs fast shrinking using current mapping\n" );
+    Abc_Print( -2, "\t-N num : the max fanout count to skip a divisor [default = %d]\n", nFanoutMax );
+    Abc_Print( -2, "\t-l     : toggle level update during shrinking [default = %s]\n", fKeepLevel? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Fx( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pTemp;
+    int nNewNodesMax = 1000000;
+    int LitCountMax  =       0;
+    int fReverse     =       0;
+    int c, fVerbose  =       0;
+    int fVeryVerbose =       0;
+    // set the defaults
+    Extra_UtilGetoptReset();
+    while ( (c = Extra_UtilGetopt(argc, argv, "NMrvwh")) != EOF )
+    {
+        switch (c)
+        {
+            case 'N':
+                if ( globalUtilOptind >= argc )
+                {
+                    Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                    goto usage;
+                }
+                nNewNodesMax = atoi(argv[globalUtilOptind]);
+                globalUtilOptind++;
+                if ( nNewNodesMax < 0 )
+                    goto usage;
+                break;
+            case 'M':
+                if ( globalUtilOptind >= argc )
+                {
+                    Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
+                    goto usage;
+                }
+                LitCountMax = atoi(argv[globalUtilOptind]);
+                globalUtilOptind++;
+                if ( LitCountMax < 0 )
+                    goto usage;
+                break;
+            case 'r':
+                fReverse ^= 1;
+                break;
+            case 'v':
+                fVerbose ^= 1;
+                break;
+            case 'w':
+                fVeryVerbose ^= 1;
+                break;
+            case 'h':
+                goto usage;
+                break;
+            default:
+                goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Shrink(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( !Gia_ManHasMapping(pAbc->pGia) )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Shrink(): Mapping of the AIG is not defined.\n" );
+        return 1;
+    }
+    pTemp = Gia_ManPerformFx( pAbc->pGia, nNewNodesMax, LitCountMax, fReverse, fVerbose, fVeryVerbose );
+    if ( pTemp != NULL )
+        Abc_FrameUpdateGia( pAbc, pTemp );
+    else
+        Abc_Print( -1, "Abc_CommandAbc9Fx(): Command has failed.\n" );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &fx [-NM <num>] [-vh]\n");
+    Abc_Print( -2, "\t           extract shared logic using the classical \"fast_extract\" algorithm\n");
+    Abc_Print( -2, "\t-N <num> : max number of divisors to extract during this run [default = %d]\n", nNewNodesMax );
+    Abc_Print( -2, "\t-M <num> : upper bound on literal count of divisors to extract [default = %d]\n", LitCountMax );
+    Abc_Print( -2, "\t-r       : reversing variable order during ISOP computation [default = %s]\n", fReverse? "yes": "no" );
+    Abc_Print( -2, "\t-v       : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w       : toggle printing additional information [default = %s]\n", fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Balance( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pTemp = NULL;
+    int nNewNodesMax = ABC_INFINITY;
+    int fDelayOnly   = 0;
+    int fSimpleAnd   = 0;
+    int fKeepLevel   = 0;
+    int c, fVerbose  = 0;
+    int fVeryVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Ndalvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by a char string.\n" );
+                goto usage;
+            }
+            nNewNodesMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nNewNodesMax < 0 )
+                goto usage;
+            break;
+        case 'd':
+            fDelayOnly ^= 1;
+            break;
+        case 'a':
+            fSimpleAnd ^= 1;
+            break;
+        case 'l':
+            fKeepLevel ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'w':
+            fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Balance(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( fDelayOnly )
+        pTemp = Gia_ManBalance( pAbc->pGia, fSimpleAnd, fVerbose );
+    else
+        pTemp = Gia_ManAreaBalance( pAbc->pGia, fSimpleAnd, nNewNodesMax, fVerbose, fVeryVerbose );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &b [-N num] [-davwh]\n" );
+    Abc_Print( -2, "\t         performs AIG balancing to reduce delay and area\n" );
+    Abc_Print( -2, "\t-N num : the max fanout count to skip a divisor [default = %d]\n", nNewNodesMax );
+    Abc_Print( -2, "\t-d     : toggle delay only balancing [default = %s]\n", fDelayOnly? "yes": "no" );
+    Abc_Print( -2, "\t-a     : toggle using AND instead of AND/XOR/MUX [default = %s]\n", fSimpleAnd? "yes": "no" );
+//    Abc_Print( -2, "\t-l     : toggle level update during shrinking [default = %s]\n", fKeepLevel? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w     : toggle printing additional information [default = %s]\n", fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9BalanceLut( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Gia_Man_t * Gia_ManBalanceLut( Gia_Man_t * p, int nLutSize, int nCutNum, int fVerbose );
+    extern Gia_Man_t * Gia_ManLutBalance( Gia_Man_t * p, int nLutSize, int fUseMuxes, int fRecursive, int fOptArea, int fVerbose );
+    Gia_Man_t * pTemp = NULL;
+    int fUseOld      = 0;
+    int nLutSize     = 6;
+    int nCutNum      = 8;
+    int fUseMuxes    = 1;
+    int fRecursive   = 1;
+    int fOptArea     = 1;
+    int c, fVerbose  = 0;
+    int fVeryVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "KCnmravwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by a char string.\n" );
+                goto usage;
+            }
+            nLutSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLutSize < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by a char string.\n" );
+                goto usage;
+            }
+            nCutNum = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nCutNum < 0 )
+                goto usage;
+            break;
+        case 'n':
+            fUseOld ^= 1;
+            break;
+        case 'm':
+            fUseMuxes ^= 1;
+            break;
+        case 'r':
+            fRecursive ^= 1;
+            break;
+        case 'a':
+            fOptArea ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'w':
+            fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9BalanceLut(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( fUseOld )
+        pTemp = Gia_ManBalanceLut( pAbc->pGia, nLutSize, nCutNum, fVerbose );
+    else
+        pTemp = Gia_ManLutBalance( pAbc->pGia, nLutSize, fUseMuxes, fRecursive, fOptArea, fVerbose );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &blut [-KC num] [-mravh]\n" );
+    Abc_Print( -2, "\t           performs AIG balancing for the given LUT size\n" );
+    Abc_Print( -2, "\t-K num   : LUT size for the mapping (2 <= K <= %d) [default = %d]\n", 6, nLutSize );
+    Abc_Print( -2, "\t-C num   : the max number of priority cuts (1 <= C <= %d) [default = %d]\n", 8, nCutNum );
+    Abc_Print( -2, "\t-m       : toggle performing MUX restructuring [default = %s]\n", fUseMuxes? "yes": "no" );
+    Abc_Print( -2, "\t-r       : toggle performing recursive restructuring [default = %s]\n", fRecursive? "yes": "no" );
+    Abc_Print( -2, "\t-a       : toggle performing area-oriented restructuring [default = %s]\n", fOptArea? "yes": "no" );
+    Abc_Print( -2, "\t-v       : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+//    Abc_Print( -2, "\t-w       : toggle printing additional information [default = %s]\n", fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Syn2( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pTemp;
+    int c, fVerbose  =  0;
+    int fOldAlgo     =  0;
+    int fCoarsen     =  1;
+    int fCutMin      =  0;
+    int nRelaxRatio  = 20;
+    int fDelayMin    =  0;
+    int fVeryVerbose =  0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Rakmdvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'R':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( 1, "Command line switch \"-R\" should be followed by a floating point number.\n" );
+                return 0;
+            }
+            nRelaxRatio = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nRelaxRatio < 0 ) 
+                goto usage;
+            break;
+        case 'a':
+            fOldAlgo ^= 1;
+            break;
+        case 'k':
+            fCoarsen ^= 1;
+            break;
+        case 'm':
+            fCutMin ^= 1;
+            break;
+        case 'd':
+            fDelayMin ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'w':
+            fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Syn2(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( fDelayMin )
+    {
+        If_DsdMan_t * p = (If_DsdMan_t *)Abc_FrameReadManDsd();
+        if ( p && If_DsdManVarNum(p) < 6 )
+        {
+            printf( "DSD manager has incompatible number of variables. Delay minimization is not performed.\n" );
+            fDelayMin = 0;
+        }
+    } 
+    pTemp = Gia_ManAigSyn2( pAbc->pGia, fOldAlgo, fCoarsen, fCutMin, nRelaxRatio, fDelayMin, fVerbose, fVeryVerbose );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &syn2 [-R num] [-akmdvh]\n" );
+    Abc_Print( -2, "\t           performs AIG optimization\n" );
+    Abc_Print( -2, "\t-R num   : the delay relaxation ratio (num >= 0) [default = %d]\n",   nRelaxRatio );
+    Abc_Print( -2, "\t-a       : toggles using the old algorithm [default = %s]\n",         fOldAlgo? "yes": "no" );
+    Abc_Print( -2, "\t-k       : toggles coarsening the subject graph [default = %s]\n",    fCoarsen? "yes": "no" );
+    Abc_Print( -2, "\t-m       : toggles cut minimization [default = %s]\n",                fCutMin? "yes": "no" );
+    Abc_Print( -2, "\t-d       : toggles additional delay optimization [default = %s]\n",   fDelayMin? "yes": "no" );
+    Abc_Print( -2, "\t-v       : toggles printing verbose information [default = %s]\n",    fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w       : toggles printing additional information [default = %s]\n", fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Synch2( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Gia_Man_t * Gia_ManAigSynch2( Gia_Man_t * p, void * pPars, int nLutSize, int nRelaxRatio );
+    Gia_Man_t * pTemp;
+    Dch_Pars_t Pars, * pPars = &Pars;
+    int c, nLutSize = 6;
+    int nRelaxRatio = 20;
+    // set defaults
+    Dch_ManSetDefaultParams( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "WCSKRfvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nWords = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nWords < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nBTLimit < 0 )
+                goto usage;
+            break;
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nSatVarMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nSatVarMax < 0 )
+                goto usage;
+            break;
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by a char string.\n" );
+                goto usage;
+            }
+            nLutSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLutSize < 0 )
+                goto usage;
+            break;
+        case 'R':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( 1, "Command line switch \"-R\" should be followed by a floating point number.\n" );
+                return 0;
+            }
+            nRelaxRatio = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nRelaxRatio < 0 ) 
+                goto usage;
+            break;
+        case 'f':
+            pPars->fLightSynth ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Dch(): There is no AIG.\n" );
+        return 1;
+    }
+    pTemp = Gia_ManAigSynch2( pAbc->pGia, pPars, nLutSize, nRelaxRatio );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &synch2 [-WCSKR num] [-fvh]\n" );
+    Abc_Print( -2, "\t         computes structural choices using a new approach\n" );
+    Abc_Print( -2, "\t-W num : the max number of simulation words [default = %d]\n", pPars->nWords );
+    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
+    Abc_Print( -2, "\t-S num : the max number of SAT variables [default = %d]\n", pPars->nSatVarMax );
+    Abc_Print( -2, "\t-K num : the target LUT size for downstream mapping [default = %d]\n", nLutSize );
+    Abc_Print( -2, "\t-R num   : the delay relaxation ratio (num >= 0) [default = %d]\n",   nRelaxRatio );
+    Abc_Print( -2, "\t-f     : toggle using lighter logic synthesis [default = %s]\n", pPars->fLightSynth? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Syn3( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pTemp;
+    int c, fVerbose = 0;
+    int fVeryVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "vwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'w':
+            fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Syn3(): There is no AIG.\n" );
+        return 1;
+    }
+    pTemp = Gia_ManAigSyn3( pAbc->pGia, fVerbose, fVeryVerbose );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &syn3 [-lvh]\n" );
+    Abc_Print( -2, "\t         performs AIG optimization\n" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w     : toggle printing additional information [default = %s]\n", fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Syn4( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pTemp;
+    int c, fVerbose = 0;
+    int fVeryVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "vwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'w':
+            fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Syn4(): There is no AIG.\n" );
+        return 1;
+    }
+    pTemp = Gia_ManAigSyn4( pAbc->pGia, fVerbose, fVeryVerbose );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &syn4 [-lvh]\n" );
+    Abc_Print( -2, "\t         performs AIG optimization\n" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w     : toggle printing additional information [default = %s]\n", fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9False( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Gia_Man_t * Gia_ManCheckFalse( Gia_Man_t * p, int nSlackMax, int nTimeOut, int fVerbose, int fVeryVerbose );
+    Gia_Man_t * pTemp;
+    int nSlackMax = 0;
+    int nTimeOut = 0;
+    int c, fVerbose = 0;
+    int fVeryVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "STvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by a char string.\n" );
+                goto usage;
+            }
+            nSlackMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nSlackMax < 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by a char string.\n" );
+                goto usage;
+            }
+            nTimeOut = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nTimeOut < 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'w':
+            fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9False(): There is no AIG.\n" );
+        return 1;
+    }
+    pTemp = Gia_ManCheckFalse( pAbc->pGia, nSlackMax, nTimeOut, fVerbose, fVeryVerbose );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &false [-ST num] [-vwh]\n" );
+    Abc_Print( -2, "\t         detecting and elimintation false paths\n" );
+    Abc_Print( -2, "\t-S num : maximum slack to identify false paths [default = %d]\n",  nSlackMax );
+    Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n",   nTimeOut );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n",    fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w     : toggle printing additional information [default = %s]\n", fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Miter( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    FILE * pFile;
+    Gia_Man_t * pAux;
+    Gia_Man_t * pSecond;
+    char * FileName, * pTemp;
+    char ** pArgvNew;
+    int nArgcNew;
+    int c;
+    int nInsDup  = 0;
+    int fDualOut = 0;
+    int fSeq     = 0;
+    int fTrans   = 0;
+    int fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Idstvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'I':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-I\" should be followed by a char string.\n" );
+                goto usage;
+            }
+            nInsDup = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nInsDup < 0 )
+                goto usage;
+            break;
+        case 'd':
+            fDualOut ^= 1;
+            break;
+        case 's':
+            fSeq ^= 1;
+            break;
+        case 't':
+            fTrans ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( fTrans )
+    {
+        if ( (Gia_ManPoNum(pAbc->pGia) & 1) == 1 )
+        {
+            Abc_Print( -1, "Abc_CommandAbc9Miter(): The number of outputs should be even.\n" );
+            return 0;
+        }
+        if ( pAbc->pGia == NULL )
+        {
+            Abc_Print( -1, "Abc_CommandAbc9Miter(): There is no AIG.\n" );
+            return 1;
+        }
+        pAux = Gia_ManTransformMiter( pAbc->pGia );
+        Abc_FrameUpdateGia( pAbc, pAux );
+        Abc_Print( 1, "The miter (current AIG) is transformed by XORing POs pair-wise.\n" );
+        return 0;
+    }
+
+    pArgvNew = argv + globalUtilOptind;
+    nArgcNew = argc - globalUtilOptind;
+    if ( nArgcNew != 1 )
+    {
+        Abc_Print( -1, "File name is not given on the command line.\n" );
+        return 1;
+    }
+
+    // get the input file name
+    FileName = pArgvNew[0];
+    // fix the wrong symbol
+    for ( pTemp = FileName; *pTemp; pTemp++ )
+        if ( *pTemp == '>' )
+            *pTemp = '\\';
+    if ( (pFile = fopen( FileName, "r" )) == NULL )
+    {
+        Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
+        if ( (FileName = Extra_FileGetSimilarName( FileName, ".aig", NULL, NULL, NULL, NULL )) )
+            Abc_Print( 1, "Did you mean \"%s\"?", FileName );
+        Abc_Print( 1, "\n" );
+        return 1;
+    }
+    fclose( pFile );
+    pSecond = Gia_AigerRead( FileName, 0, 0 );
+    if ( pSecond == NULL )
+    {
+        Abc_Print( -1, "Reading AIGER has failed.\n" );
+        return 0;
+    }
+    // compute the miter
+    pAux = Gia_ManMiter( pAbc->pGia, pSecond, nInsDup, fDualOut, fSeq, 0, fVerbose );
+    Gia_ManStop( pSecond );
+    Abc_FrameUpdateGia( pAbc, pAux );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &miter [-I num] [-dstvh] <file>\n" );
+    Abc_Print( -2, "\t         creates miter of two designs (current AIG vs. <file>)\n" );
+    Abc_Print( -2, "\t-I num : the number of last PIs to replicate [default = %d]\n", nInsDup );
+    Abc_Print( -2, "\t-d     : toggle creating dual-output miter [default = %s]\n", fDualOut? "yes": "no" );
+    Abc_Print( -2, "\t-s     : toggle creating sequential miter [default = %s]\n", fSeq? "yes": "no" );
+    Abc_Print( -2, "\t-t     : toggle XORing pair-wise POs of the miter [default = %s]\n", fTrans? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\t<file> : AIGER file with the design to miter\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Miter2( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    FILE * pFile;
+    Gia_Man_t * pAux;
+    char * FileName, * pTemp, * pInit;
+    char ** pArgvNew;
+    int nArgcNew;
+    int c, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    pArgvNew = argv + globalUtilOptind;
+    nArgcNew = argc - globalUtilOptind;
+    if ( nArgcNew != 1 )
+    {
+        Abc_Print( -1, "File name is not given on the command line.\n" );
+        return 1;
+    }
+    // get the input file name
+    FileName = pArgvNew[0];
+    // fix the wrong symbol
+    for ( pTemp = FileName; *pTemp; pTemp++ )
+        if ( *pTemp == '>' )
+            *pTemp = '\\';
+    if ( (pFile = fopen( FileName, "r" )) == NULL )
+    {
+        Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
+        if ( (FileName = Extra_FileGetSimilarName( FileName, ".aig", NULL, NULL, NULL, NULL )) )
+            Abc_Print( 1, "Did you mean \"%s\"?", FileName );
+        Abc_Print( 1, "\n" );
+        return 1;
+    }
+    fclose( pFile );
+    // extract string
+    pInit = Extra_FileReadContents( FileName );
+    Extra_StringClean( pInit, "01xX" );
+    if ( (int)strlen(pInit) != Gia_ManCiNum(pAbc->pGia) )
+    {
+        Abc_Print( -1, "Init string length (%d) differs from PI and flop count (%d).\n", strlen(pInit), Gia_ManCiNum(pAbc->pGia) );
+        ABC_FREE( pInit );
+        return 1;
+    }
+    // compute the miter
+    pAux = Gia_ManMiter2( pAbc->pGia, pInit, fVerbose );
+    ABC_FREE( pInit );
+    Abc_FrameUpdateGia( pAbc, pAux );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &miter2 [-vh] <file>\n" );
+    Abc_Print( -2, "\t         creates miter of two copies of the design\n" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\t<file> : file name with flop initial values (0/1/x/X) [default = required]\n" );
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Append( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    FILE * pFile;
+    Gia_Man_t * pSecond;
+    char * FileName, * pTemp;
+    char ** pArgvNew;
+    int nArgcNew;
+    int c;
+    int fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+
+    pArgvNew = argv + globalUtilOptind;
+    nArgcNew = argc - globalUtilOptind;
+    if ( nArgcNew != 1 )
+    {
+        Abc_Print( -1, "File name is not given on the command line.\n" );
+        return 1;
+    }
+
+    // get the input file name
+    FileName = pArgvNew[0];
+    // fix the wrong symbol
+    for ( pTemp = FileName; *pTemp; pTemp++ )
+        if ( *pTemp == '>' )
+            *pTemp = '\\';
+    if ( (pFile = fopen( FileName, "r" )) == NULL )
+    {
+        Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
+        if ( (FileName = Extra_FileGetSimilarName( FileName, ".aig", NULL, NULL, NULL, NULL )) )
+            Abc_Print( 1, "Did you mean \"%s\"?", FileName );
+        Abc_Print( 1, "\n" );
+        return 1;
+    }
+    fclose( pFile );
+    pSecond = Gia_AigerRead( FileName, 0, 0 );
+    if ( pSecond == NULL )
+    {
+        Abc_Print( -1, "Reading AIGER has failed.\n" );
+        return 0;
+    }
+    // compute the miter
+    Gia_ManDupAppend( pAbc->pGia, pSecond );
+    Gia_ManStop( pSecond );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &append [-vh] <file>\n" );
+    Abc_Print( -2, "\t         appends <file> to the current AIG using new PIs and POs\n" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\t<file> : AIGER file with the design to miter\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Scl( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pTemp;
+    int c;
+    int fConst = 1;
+    int fEquiv = 1;
+    int fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "cevh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'c':
+            fConst ^= 1;
+            break;
+        case 'e':
+            fEquiv ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Scl(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( Gia_ManBoxNum(pAbc->pGia) && Gia_ManRegBoxNum(pAbc->pGia) )
+    {
+        if ( pAbc->pGia->pAigExtra == NULL )
+        {
+            printf( "Timing manager is given but there is no GIA of boxes.\n" );
+            return 0;
+        }
+        pTemp = Gia_ManSweepWithBoxes( pAbc->pGia, NULL, NULL, fConst, fEquiv, fVerbose );
+        Abc_FrameUpdateGia( pAbc, pTemp );
+        return 0;
+    }
+    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+    {
+        Abc_Print( -1, "The network is combinational.\n" );
+        return 0;
+    }
+    pTemp = Gia_ManSeqStructSweep( pAbc->pGia, fConst, fEquiv, fVerbose );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &scl [-cevh]\n" );
+    Abc_Print( -2, "\t         performs structural sequential cleanup\n" );
+    Abc_Print( -2, "\t-c     : toggle removing stuck-at constant registers [default = %s]\n", fConst? "yes": "no" );
+    Abc_Print( -2, "\t-e     : toggle removing equivalent-driver registers [default = %s]\n", fEquiv? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Lcorr( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Cec_ParCor_t Pars, * pPars = &Pars;
+    Gia_Man_t * pTemp;
+    int c;
+    Cec_ManCorSetDefaultParams( pPars );
+    pPars->fLatchCorr = 1;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "FCPrcvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nFrames = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nFrames < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nBTLimit < 0 )
+                goto usage;
+            break;
+        case 'P':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nPrefix = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nPrefix < 0 )
+                goto usage;
+            break;
+        case 'r':
+            pPars->fUseRings ^= 1;
+            break;
+        case 'c':
+            pPars->fUseCSat ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Lcorr(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( Gia_ManBoxNum(pAbc->pGia) && Gia_ManRegBoxNum(pAbc->pGia) )
+    {
+        if ( pAbc->pGia->pAigExtra == NULL )
+        {
+            printf( "Timing manager is given but there is no GIA of boxes.\n" );
+            return 0;
+        }
+        pTemp = Gia_ManSweepWithBoxes( pAbc->pGia, NULL, pPars, 0, 0, pPars->fVerbose );
+        Abc_FrameUpdateGia( pAbc, pTemp );
+        return 0;
+    }
+    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+    {
+        Abc_Print( -1, "The network is combinational.\n" );
+        return 0;
+    }
+    pTemp = Cec_ManLSCorrespondence( pAbc->pGia, pPars );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &lcorr [-FCP num] [-rcvh]\n" );
+    Abc_Print( -2, "\t         performs latch correpondence computation\n" );
+    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
+    Abc_Print( -2, "\t-F num : the number of timeframes in inductive case [default = %d]\n", pPars->nFrames );
+    Abc_Print( -2, "\t-P num : the number of timeframes in the prefix [default = %d]\n", pPars->nPrefix );
+    Abc_Print( -2, "\t-r     : toggle using implication rings during refinement [default = %s]\n", pPars->fUseRings? "yes": "no" );
+    Abc_Print( -2, "\t-c     : toggle using circuit-based SAT solver [default = %s]\n", pPars->fUseCSat? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Scorr( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Cec_ParCor_t Pars, * pPars = &Pars;
+    Gia_Man_t * pTemp;
+    int c;
+    Cec_ManCorSetDefaultParams( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "FCPkrecqwvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nFrames = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nFrames < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nBTLimit < 0 )
+                goto usage;
+            break;
+        case 'P':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nPrefix = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nPrefix < 0 )
+                goto usage;
+            break;
+        case 'k':
+            pPars->fConstCorr ^= 1;
+            break;
+        case 'r':
+            pPars->fUseRings ^= 1;
+            break;
+        case 'e':
+            pPars->fMakeChoices ^= 1;
+            break;
+        case 'c':
+            pPars->fUseCSat ^= 1;
+            break;
+        case 'q':
+            pPars->fStopWhenGone ^= 1;
+            break;
+        case 'w':
+            pPars->fVerboseFlops ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Scorr(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( Gia_ManBoxNum(pAbc->pGia) && Gia_ManRegBoxNum(pAbc->pGia) )
+    {
+        if ( pAbc->pGia->pAigExtra == NULL )
+        {
+            printf( "Timing manager is given but there is no GIA of boxes.\n" );
+            return 0;
+        }
+        pTemp = Gia_ManSweepWithBoxes( pAbc->pGia, NULL, pPars, 0, 0, pPars->fVerbose );
+        Abc_FrameUpdateGia( pAbc, pTemp );
+        return 0;
+    }
+    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+    {
+        Abc_Print( -1, "The network is combinational.\n" );
+        return 0;
+    }
+    pTemp = Cec_ManLSCorrespondence( pAbc->pGia, pPars );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &scorr [-FCP num] [-krecqwvh]\n" );
+    Abc_Print( -2, "\t         performs signal correpondence computation\n" );
+    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
+    Abc_Print( -2, "\t-F num : the number of timeframes in inductive case [default = %d]\n", pPars->nFrames );
+    Abc_Print( -2, "\t-P num : the number of timeframes in the prefix [default = %d]\n", pPars->nPrefix );
+    Abc_Print( -2, "\t-k     : toggle using constant correspondence [default = %s]\n", pPars->fConstCorr? "yes": "no" );
+    Abc_Print( -2, "\t-r     : toggle using implication rings during refinement [default = %s]\n", pPars->fUseRings? "yes": "no" );
+    Abc_Print( -2, "\t-e     : toggle using equivalences as choices [default = %s]\n", pPars->fMakeChoices? "yes": "no" );
+    Abc_Print( -2, "\t-c     : toggle using circuit-based SAT solver [default = %s]\n", pPars->fUseCSat? "yes": "no" );
+    Abc_Print( -2, "\t-q     : toggle quitting when PO is not a constant candidate [default = %s]\n", pPars->fStopWhenGone? "yes": "no" );
+    Abc_Print( -2, "\t-w     : toggle printing verbose info about equivalent flops [default = %s]\n", pPars->fVerboseFlops? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Choice( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Cec_ParChc_t Pars, * pPars = &Pars;
+    Gia_Man_t * pTemp;
+    int c;
+    Cec_ManChcSetDefaultParams( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Ccvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nBTLimit < 0 )
+                goto usage;
+            break;
+        case 'c':
+            pPars->fUseCSat ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Choice(): There is no AIG.\n" );
+        return 1;
+    }
+    pTemp = Cec_ManChoiceComputation( pAbc->pGia, pPars );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &choice [-C num] [-cvh]\n" );
+    Abc_Print( -2, "\t         performs computation of structural choices\n" );
+    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
+    Abc_Print( -2, "\t-c     : toggle using circuit-based SAT solver [default = %s]\n", pPars->fUseCSat? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Sat( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Cec_ParSat_t ParsSat, * pPars = &ParsSat;
+    Gia_Man_t * pTemp;
+    int c;
+    int fCSat = 0;
+    Cec_ManSatSetDefaultParams( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "CSNnmtcvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nBTLimit < 0 )
+                goto usage;
+            break;
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nSatVarMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nSatVarMax < 0 )
+                goto usage;
+            break;
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nCallsRecycle = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nCallsRecycle < 0 )
+                goto usage;
+            break;
+        case 'n':
+            pPars->fNonChrono ^= 1;
+            break;
+        case 'm':
+            pPars->fCheckMiter ^= 1;
+            break;
+        case 't':
+            pPars->fLearnCls ^= 1;
+            break;
+        case 'c':
+            fCSat ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Sat(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( fCSat )
+    {
+        Vec_Int_t * vCounters;
+        Vec_Str_t * vStatus;
+        if ( pPars->fLearnCls )
+            vCounters = Tas_ManSolveMiterNc( pAbc->pGia, pPars->nBTLimit, &vStatus, pPars->fVerbose );
+        else if ( pPars->fNonChrono )
+            vCounters = Cbs_ManSolveMiterNc( pAbc->pGia, pPars->nBTLimit, &vStatus, pPars->fVerbose );
+        else
+            vCounters = Cbs_ManSolveMiter( pAbc->pGia, pPars->nBTLimit, &vStatus, pPars->fVerbose );
+        Vec_IntFree( vCounters );
+        Vec_StrFree( vStatus );
+    }
+    else
+    {
+        pTemp = Cec_ManSatSolving( pAbc->pGia, pPars );
+        Abc_FrameUpdateGia( pAbc, pTemp );
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &sat [-CSN <num>] [-nmctvh]\n" );
+    Abc_Print( -2, "\t         performs SAT solving for the combinational outputs\n" );
+    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
+    Abc_Print( -2, "\t-S num : the min number of variables to recycle the solver [default = %d]\n", pPars->nSatVarMax );
+    Abc_Print( -2, "\t-N num : the min number of calls to recycle the solver [default = %d]\n", pPars->nCallsRecycle );
+    Abc_Print( -2, "\t-n     : toggle using non-chronological backtracking [default = %s]\n", pPars->fNonChrono? "yes": "no" );
+    Abc_Print( -2, "\t-m     : toggle miter vs. any circuit [default = %s]\n", pPars->fCheckMiter? "miter": "circuit" );
+    Abc_Print( -2, "\t-c     : toggle using circuit-based SAT solver [default = %s]\n", fCSat? "yes": "no" );
+    Abc_Print( -2, "\t-t     : toggle using learning in curcuit-based solver [default = %s]\n", pPars->fLearnCls? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9SatEnum( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern int Gia_ManSatEnum( Gia_Man_t * p, int nConfLimit, int nTimeOut, int fVerbose );
+    int c, nConfLimit = 0, nTimeOut = 0, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "CTvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nConfLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nConfLimit < 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nTimeOut = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nTimeOut < 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9SatEnum(): There is no AIG.\n" );
+        return 1;
+    }
+    Gia_ManSatEnum( pAbc->pGia, nConfLimit, nTimeOut, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &satenum [-CT <num>] [-vh]\n" );
+    Abc_Print( -2, "\t         enumerates solutions of the combinational miter\n" );
+    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", nConfLimit );
+    Abc_Print( -2, "\t-T num : global timeout [default = %d]\n", nTimeOut );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n",   fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Fraig( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Cec_ParFra_t ParsFra, * pPars = &ParsFra;
+    Gia_Man_t * pTemp;
+    int c;
+    Cec_ManFraSetDefaultParams( pPars );
+    pPars->fSatSweeping = 1;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "WRILDCrmdcwvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nWords = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nWords < 0 )
+                goto usage;
+            break;
+        case 'R':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nRounds = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nRounds < 0 )
+                goto usage;
+            break;
+        case 'I':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nItersMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nItersMax < 0 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nLevelMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nLevelMax < 0 )
+                goto usage;
+            break;
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nDepthMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nDepthMax < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nBTLimit < 0 )
+                goto usage;
+            break;
+        case 'r':
+            pPars->fRewriting ^= 1;
+            break;
+        case 'm':
+            pPars->fCheckMiter ^= 1;
+            break;
+        case 'd':
+            pPars->fDualOut ^= 1;
+            break;
+        case 'c':
+            pPars->fRunCSat ^= 1;
+            break;
+        case 'w':
+            pPars->fVeryVerbose ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Fraig(): There is no AIG.\n" );
+        return 1;
+    }
+    pTemp = Cec_ManSatSweeping( pAbc->pGia, pPars );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &fraig [-WRILDC <num>] [-rmdcwvh]\n" );
+    Abc_Print( -2, "\t         performs combinational SAT sweeping\n" );
+    Abc_Print( -2, "\t-W num : the number of simulation words [default = %d]\n", pPars->nWords );
+    Abc_Print( -2, "\t-R num : the number of simulation rounds [default = %d]\n", pPars->nRounds );
+    Abc_Print( -2, "\t-I num : the number of sweeping iterations [default = %d]\n", pPars->nItersMax );
+    Abc_Print( -2, "\t-L num : the max number of levels of nodes to consider [default = %d]\n", pPars->nLevelMax );
+    Abc_Print( -2, "\t-D num : the max number of steps of speculative reduction [default = %d]\n", pPars->nDepthMax );
+    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
+    Abc_Print( -2, "\t-r     : toggle the use of AIG rewriting [default = %s]\n", pPars->fRewriting? "yes": "no" );
+    Abc_Print( -2, "\t-m     : toggle miter vs. any circuit [default = %s]\n", pPars->fCheckMiter? "miter": "circuit" );
+    Abc_Print( -2, "\t-d     : toggle using double output miters [default = %s]\n", pPars->fDualOut? "yes": "no" );
+    Abc_Print( -2, "\t-c     : toggle using circuit-based solver [default = %s]\n", pPars->fRunCSat? "yes": "no" );
+    Abc_Print( -2, "\t-w     : toggle printing even more verbose information [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9CFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pTemp;
+    int c;
+    Ssc_Pars_t Pars, * pPars = &Pars;
+    Ssc_ManSetDefaultParams( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "WCacvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nWords = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nWords < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nBTLimit < 0 )
+                goto usage;
+            break;
+        case 'a':
+            pPars->fAppend ^= 1;
+            break;
+        case 'c':
+            pPars->fVerify ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9CFraig(): There is no AIG.\n" );
+        return 1;
+    }
+    pTemp = Ssc_PerformSweepingConstr( pAbc->pGia, pPars );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &cfraig [-WC <num>] [-acvh]\n" );
+    Abc_Print( -2, "\t         performs combinational SAT sweeping under constraints\n" );
+    Abc_Print( -2, "\t         which are present in the AIG or set manually using \"constr\"\n" );
+    Abc_Print( -2, "\t         (constraints are listed as last POs and true when they are 0)\n" );
+    Abc_Print( -2, "\t-W num : the number of simulation words [default = %d]\n", pPars->nWords );
+    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
+    Abc_Print( -2, "\t-a     : toggle appending constraints to the result [default = %s]\n", pPars->fAppend? "yes": "no" );
+    Abc_Print( -2, "\t-c     : toggle performing internal verification [default = %s]\n", pPars->fVerify? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Srm( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    char * pFileNameIn = NULL;
+    char pFileName[10] = "gsrm.aig", pFileName2[10] = "gsyn.aig";
+    Gia_Man_t * pTemp, * pAux;
+    int c, fVerbose = 0;
+    int fSynthesis = 0;
+    int fSpeculate = 1;
+    int fSkipSome = 0;
+    int fDualOut = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Adrsfvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'A':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-A\" should be followed by a file name.\n" );
+                goto usage;
+            }
+            pFileNameIn = argv[globalUtilOptind];
+            globalUtilOptind++;
+            break;
+        case 'd':
+            fDualOut ^= 1;
+            break;
+        case 'r':
+            fSynthesis ^= 1;
+            break;
+        case 's':
+            fSpeculate ^= 1;
+            break;
+        case 'f':
+            fSkipSome ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Srm(): There is no AIG.\n" );
+        return 1;
+    }
+    sprintf(pFileName,  "gsrm%s.aig", fSpeculate? "" : "s" );
+    sprintf(pFileName2, "gsyn%s.aig", fSpeculate? "" : "s" );
+    pTemp = Gia_ManSpecReduce( pAbc->pGia, fDualOut, fSynthesis, fSpeculate, fSkipSome, fVerbose );
+    if ( pTemp )
+    {
+        if ( fSpeculate )
+        {
+            pTemp = Gia_ManSeqStructSweep( pAux = pTemp, 1, 1, 0 );
+            Gia_ManStop( pAux );
+        }
+        Gia_AigerWrite( pTemp, pFileNameIn ? pFileNameIn : pFileName, 0, 0 );
+        Abc_Print( 1, "Speculatively reduced model was written into file \"%s\".\n", pFileName );
+        Gia_ManPrintStatsShort( pTemp );
+        Gia_ManStop( pTemp );
+    }
+    if ( fSynthesis )
+    {
+        pTemp = Gia_ManEquivReduce( pAbc->pGia, 1, fDualOut, 0, fVerbose );
+        if ( pTemp )
+        {
+            pTemp = Gia_ManSeqStructSweep( pAux = pTemp, 1, 1, 0 );
+            Gia_ManStop( pAux );
+
+            Gia_AigerWrite( pTemp, pFileName2, 0, 0 );
+            Abc_Print( 1, "Reduced original network was written into file \"%s\".\n", pFileName2 );
+            Gia_ManPrintStatsShort( pTemp );
+            Gia_ManStop( pTemp );
+        }
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &srm [-A file] [-drsfvh]\n" );
+    Abc_Print( -2, "\t          writes speculatively reduced model into file \"%s\"\n", pFileName );
+    Abc_Print( -2, "\t-A file : file name for dumping speculative-reduced model [default = \"gsrm.aig\"]\n" );
+    Abc_Print( -2, "\t-d      : toggle creating dual-output miter [default = %s]\n", fDualOut? "yes": "no" );
+    Abc_Print( -2, "\t-r      : toggle writing reduced network for synthesis [default = %s]\n", fSynthesis? "yes": "no" );
+    Abc_Print( -2, "\t-s      : toggle using speculation at the internal nodes [default = %s]\n", fSpeculate? "yes": "no" );
+    Abc_Print( -2, "\t-f      : toggle filtering to remove redundant equivalences [default = %s]\n", fSkipSome? "yes": "no" );
+    Abc_Print( -2, "\t-v      : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h      : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Srm2( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    char pFileName[10], * pFileName1, * pFileName2;
+    Gia_Man_t * pTemp, * pAux;
+    int fLatchA = 0, fLatchB = 0;
+    int c, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "abvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'a':
+            fLatchA ^= 1;
+            break;
+        case 'b':
+            fLatchB ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Srm2(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( pAbc->pGia->pReprs == NULL || pAbc->pGia->pNexts == NULL )
+    {
+        Abc_Print( -1, "Equivalences are not defined.\n" );
+        return 0;
+    }
+    if ( argc != globalUtilOptind + 2 )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Srm2(): Expecting two file names on the command line.\n" );
+        return 1;
+    }
+    // get the input file name
+    pFileName1 = argv[globalUtilOptind];
+    pFileName2 = argv[globalUtilOptind+1];
+    // create file name
+    sprintf(pFileName,  "gsrm.aig" );
+    pTemp = Gia_ManDup( pAbc->pGia );
+    // copy equivalences
+    pTemp->pReprs = ABC_ALLOC( Gia_Rpr_t, Gia_ManObjNum(pTemp) );
+    memcpy( pTemp->pReprs, pAbc->pGia->pReprs, sizeof(Gia_Rpr_t) * Gia_ManObjNum(pTemp) );
+    pTemp->pNexts = ABC_ALLOC( int, Gia_ManObjNum(pTemp) );
+    memcpy( pTemp->pNexts, pAbc->pGia->pNexts, sizeof(int) * Gia_ManObjNum(pTemp) );
+//Gia_ManPrintStats( pTemp, 0 );
+    // filter the classes
+    if ( !Gia_ManFilterEquivsForSpeculation( pTemp, pFileName1, pFileName2, fLatchA, fLatchB ) )
+    {
+        Gia_ManStop( pTemp );
+        Abc_Print( -1, "Filtering equivalences has failed.\n" );
+        return 1;
+    }
+//Gia_ManPrintStats( pTemp, 0 );
+    pTemp = Gia_ManSpecReduce( pAux = pTemp, 0, 0, 1, 0, 0 );
+    Gia_ManStop( pAux );
+    if ( pTemp )
+    {
+        pTemp = Gia_ManSeqStructSweep( pAux = pTemp, 1, 1, 0 );
+        Gia_ManStop( pAux );
+
+        Gia_AigerWrite( pTemp, pFileName, 0, 0 );
+        Abc_Print( 1, "Speculatively reduced model was written into file \"%s\".\n", pFileName );
+        Gia_ManPrintStatsShort( pTemp );
+        Gia_ManStop( pTemp );
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &srm2 [-abvh] <PartA_FileName> <PartB_FileName>\n" );
+    Abc_Print( -2, "\t         writes speculatively reduced model into file \"%s\"\n", pFileName );
+    Abc_Print( -2, "\t         only preserves equivalences across PartA and PartB\n" );
+    Abc_Print( -2, "\t-a     : toggle using latches only in PartA [default = %s]\n", fLatchA? "yes": "no" );
+    Abc_Print( -2, "\t-b     : toggle using latches only in PartB [default = %s]\n", fLatchB? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Filter( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    char * pFileName1 = NULL, * pFileName2 = NULL;
+    int fFlopsOnly = 0, fFlopsWith = 0, fUseRiDrivers = 0;
+    int c, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "fgivh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'f':
+            fFlopsOnly ^= 1;
+            break;
+        case 'g':
+            fFlopsWith ^= 1;
+            break;
+        case 'i':
+            fUseRiDrivers ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Srm2(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( pAbc->pGia->pReprs == NULL || pAbc->pGia->pNexts == NULL )
+    {
+        Abc_Print( -1, "Equivalences are not defined.\n" );
+        return 0;
+    }
+    if ( argc != globalUtilOptind && argc != globalUtilOptind + 2 )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Srm2(): Expecting two file names on the command line.\n" );
+        return 1;
+    }
+    // filter using one of the choices
+    if ( fFlopsOnly ^ fFlopsWith )
+        Gia_ManFilterEquivsUsingLatches( pAbc->pGia, fFlopsOnly, fFlopsWith, fUseRiDrivers );
+    // get the input file name
+    if ( argc == globalUtilOptind + 2 )
+    {
+        pFileName1 = argv[globalUtilOptind];
+        pFileName2 = argv[globalUtilOptind+1];
+        if ( !Gia_ManFilterEquivsUsingParts( pAbc->pGia, pFileName1, pFileName2 ) )
+        {
+            Abc_Print( -1, "Filtering equivalences using PartA and PartB has failed.\n" );
+            return 1;
+        }
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &filter [-fgivh] <PartA_FileName> <PartB_FileName>\n" );
+    Abc_Print( -2, "\t         performs filtering of equivalence classes\n" );
+    Abc_Print( -2, "\t         (if Parts A/B are given, removes classes composed of one part)\n" );
+    Abc_Print( -2, "\t-f     : toggle removing all elements except flops [default = %s]\n", fFlopsOnly? "yes": "no" );
+    Abc_Print( -2, "\t-g     : toggle removing classes without flops [default = %s]\n", fFlopsWith? "yes": "no" );
+    Abc_Print( -2, "\t-i     : toggle using flop inputs instead of flop outputs [default = %s]\n", fUseRiDrivers? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Reduce( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pTemp, * pTemp2;
+    int c, fVerbose = 0;
+    int fUseAll = 0;
+    int fDualOut = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "advh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'a':
+            fUseAll ^= 1;
+            break;
+        case 'd':
+            fDualOut ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Reduce(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( fUseAll )
+    {
+        pTemp = Gia_ManEquivReduce( pAbc->pGia, fUseAll, fDualOut, 0, fVerbose );
+        pTemp = Gia_ManSeqStructSweep( pTemp2 = pTemp, 1, 1, 0 );
+        Gia_ManStop( pTemp2 );
+    }
+    else
+        pTemp = Gia_ManEquivReduceAndRemap( pAbc->pGia, 1, fDualOut );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &reduce [-advh]\n" );
+    Abc_Print( -2, "\t         reduces the circuit using equivalence classes\n" );
+    Abc_Print( -2, "\t-a     : toggle merging all equivalences [default = %s]\n", fUseAll? "yes": "no" );
+    Abc_Print( -2, "\t-d     : toggle using dual-output merging [default = %s]\n", fDualOut? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9EquivMark( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern void Gia_ManEquivMark( Gia_Man_t * p, char * pFileName, int fSkipSome, int fVerbose );
+    char * pFileName;
+    int c, fVerbose = 0;
+    int fSkipSome = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "fvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'f':
+            fSkipSome ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9EquivMark(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( argc != globalUtilOptind + 1 )
+        goto usage;
+    // get the input file name
+    pFileName = argv[globalUtilOptind];
+    // mark equivalences
+    Gia_ManEquivMark( pAbc->pGia, pFileName, fSkipSome, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &equiv_mark [-fvh] <miter.aig>\n" );
+    Abc_Print( -2, "\t              marks equivalences using an external miter\n" );
+    Abc_Print( -2, "\t-f          : toggle the use of filtered equivalences [default = %s]\n", fSkipSome? "yes": "no" );
+    Abc_Print( -2, "\t-v          : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h          : print the command usage\n");
+    Abc_Print( -2, "\t<miter.aig> : file with the external miter to read\n");
+    Abc_Print( -2, "\t              \n" );
+    Abc_Print( -2, "\t              The external miter should be generated by &srm -s\n" );
+    Abc_Print( -2, "\t              and (partially) solved by any verification engine(s).\n" );
+    Abc_Print( -2, "\t              The external miter should have as many POs as\n" );
+    Abc_Print( -2, "\t              the number of POs in the current AIG plus\n" );
+    Abc_Print( -2, "\t              the number of equivalences in the current AIG.\n" );
+    Abc_Print( -2, "\t              If some POs are proved, the corresponding equivs\n" );
+    Abc_Print( -2, "\t              are marked as proved, to be reduced by &reduce.\n" );
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9EquivFilter( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern void Gia_ManEquivFilter( Gia_Man_t * p, Vec_Int_t * vPoIds, int fVerbose );
+    int c, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9EquivFilter(): There is no AIG.\n" );
+        return 1;
+    }
+    Gia_ManEquivFilter( pAbc->pGia, pAbc->vAbcObjIds, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &equiv_filter [-vh]\n" );
+    Abc_Print( -2, "\t              filters equivalence candidates after disproving some SRM outputs\n" );
+    Abc_Print( -2, "\t              (the array of disproved outputs should be given as pAbc->vAbcObjIds)\n" );
+    Abc_Print( -2, "\t-v          : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h          : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Cec( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Cec_ParCec_t ParsCec, * pPars = &ParsCec;
+    FILE * pFile;
+    Gia_Man_t * pSecond, * pMiter;
+    char * FileName, * pTemp;
+    char ** pArgvNew;
+    int c, nArgcNew, fMiter = 0, fDualOutput = 0, fDumpMiter = 0;
+    Cec_ManCecSetDefaultParams( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "CTnmdavh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nBTLimit < 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->TimeLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->TimeLimit < 0 )
+                goto usage;
+            break;
+        case 'n':
+            pPars->fNaive ^= 1;
+            break;
+        case 'm':
+            fMiter ^= 1;
+            break;
+        case 'd':
+            fDualOutput ^= 1;
+            break;
+        case 'a':
+            fDumpMiter ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( fMiter )
+    {
+        if ( fDualOutput )
+        {
+            if ( Gia_ManPoNum(pAbc->pGia) & 1 )
+            {
+                Abc_Print( -1, "The dual-output miter should have an even number of outputs.\n" );
+                return 1;
+            }
+            Abc_Print( 1, "Assuming the current network is a double-output miter. (Conflict limit = %d.)\n", pPars->nBTLimit );
+            pAbc->Status = Cec_ManVerify( pAbc->pGia, pPars );
+        }
+        else
+        {
+            Gia_Man_t * pTemp;
+            Abc_Print( 1, "Assuming the current network is a single-output miter. (Conflict limit = %d.)\n", pPars->nBTLimit );
+            pTemp = Gia_ManTransformToDual( pAbc->pGia );
+            pAbc->Status = Cec_ManVerify( pTemp, pPars );
+            Gia_ManStop( pTemp );
+        }        
+        Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexComb );
+        return 0;
+    }
+
+    pArgvNew = argv + globalUtilOptind;
+    nArgcNew = argc - globalUtilOptind;
+    if ( nArgcNew != 1 )
+    {
+        if ( pAbc->pGia->pSpec == NULL )
+        {
+            Abc_Print( -1, "File name is not given on the command line.\n" );
+            return 1;
+        }
+        FileName = pAbc->pGia->pSpec;
+    }
+    else
+        FileName = pArgvNew[0];
+    // fix the wrong symbol
+    for ( pTemp = FileName; *pTemp; pTemp++ )
+        if ( *pTemp == '>' )
+            *pTemp = '\\';
+    if ( (pFile = fopen( FileName, "r" )) == NULL )
+    {
+        Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
+        if ( (FileName = Extra_FileGetSimilarName( FileName, ".aig", NULL, NULL, NULL, NULL )) )
+            Abc_Print( 1, "Did you mean \"%s\"?", FileName );
+        Abc_Print( 1, "\n" );
+        return 1;
+    }
+    fclose( pFile );
+    pSecond = Gia_AigerRead( FileName, 0, 0 );
+    if ( pSecond == NULL )
+    {
+        Abc_Print( -1, "Reading AIGER has failed.\n" );
+        return 0;
+    }
+    // compute the miter
+    pMiter = Gia_ManMiter( pAbc->pGia, pSecond, 0, 1, 0, 0, pPars->fVerbose );
+    if ( pMiter )
+    {
+        if ( fDumpMiter )
+        {
+            Abc_Print( 0, "The verification miter is written into file \"%s\".\n", "cec_miter.aig" );
+            Gia_AigerWrite( pMiter, "cec_miter.aig", 0, 0 );
+        }
+        pAbc->Status = Cec_ManVerify( pMiter, pPars );
+        Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexComb );
+        Gia_ManStop( pMiter );
+    }
+    Gia_ManStop( pSecond );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &cec [-CT num] [-nmdavh]\n" );
+    Abc_Print( -2, "\t         new combinational equivalence checker\n" );
+    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
+    Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", pPars->TimeLimit );
+    Abc_Print( -2, "\t-n     : toggle using naive SAT-based checking [default = %s]\n", pPars->fNaive? "yes":"no");
+    Abc_Print( -2, "\t-m     : toggle miter vs. two circuits [default = %s]\n", fMiter? "miter":"two circuits");
+    Abc_Print( -2, "\t-d     : toggle using dual output miter [default = %s]\n", fDualOutput? "yes":"no");
+    Abc_Print( -2, "\t-a     : toggle writing dual-output miter [default = %s]\n", fDumpMiter? "yes":"no");
+    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes":"no");
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Verify( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    char * pFileSpec = NULL;
+    int c, nBTLimit = 1000, nTimeLim = 0, fSeq = 0, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "CTsvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nBTLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nBTLimit < 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nTimeLim = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nTimeLim < 0 )
+                goto usage;
+            break;
+        case 's':
+            fSeq ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( argc == globalUtilOptind + 1 )
+    {
+        pFileSpec = argv[globalUtilOptind];
+        Extra_FileNameCorrectPath( pFileSpec );
+        printf( "Taking spec from file \"%s\".\n", pFileSpec );
+    }
+    Gia_ManVerifyWithBoxes( pAbc->pGia, nBTLimit, nTimeLim, fSeq, fVerbose, pFileSpec );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &verify [-CT num] [-svh] <file>\n" );
+    Abc_Print( -2, "\t         performs verification of combinational design\n" );
+    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", nBTLimit );
+    Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n",  nTimeLim );
+    Abc_Print( -2, "\t-s     : toggle using sequential verification [default = %s]\n",  fSeq? "yes":"no");
+    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n",                 fVerbose? "yes":"no");
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\t<file> : optional file name with the spec [default = not used\n" );
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Sweep( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pTemp;
+    Dch_Pars_t Pars, * pPars = &Pars;
+    int c;
+    Dch_ManSetDefaultParams( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "WCStvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nWords = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nWords < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nBTLimit < 0 )
+                goto usage;
+            break;
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nSatVarMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nSatVarMax < 0 )
+                goto usage;
+            break;
+        case 't':
+            pPars->fSimulateTfo ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Sweep(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( Gia_ManBoxNum(pAbc->pGia) && pAbc->pGia->pAigExtra == NULL )
+    {
+        printf( "Timing manager is given but there is no GIA of boxes.\n" );
+        return 0;
+    }
+    if ( Gia_ManBoxNum(pAbc->pGia) )
+        pTemp = Gia_ManSweepWithBoxes( pAbc->pGia, pPars, NULL, 0, 0, pPars->fVerbose );
+    else
+        pTemp = Gia_ManFraigSweepSimple( pAbc->pGia, pPars );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &sweep [-WCS num] [-tvh]\n" );
+    Abc_Print( -2, "\t         performs SAT sweeping for AIG with boxes\n" );
+    Abc_Print( -2, "\t-W num : the max number of simulation words [default = %d]\n", pPars->nWords );
+    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
+    Abc_Print( -2, "\t-S num : the max number of SAT variables [default = %d]\n", pPars->nSatVarMax );
+    Abc_Print( -2, "\t-t     : toggle simulation of the TFO classes [default = %s]\n", pPars->fSimulateTfo? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Force( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    int nIters     = 20;
+    int fClustered =  1;
+    int fVerbose   =  1;
+    int c;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Icvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'I':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nIters = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nIters < 0 )
+                goto usage;
+            break;
+        case 'c':
+            fClustered ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Force(): There is no AIG.\n" );
+        return 1;
+    }
+    For_ManExperiment( pAbc->pGia, nIters, fClustered, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &force [-I <num>] [-cvh]\n" );
+    Abc_Print( -2, "\t         one-dimensional placement algorithm FORCE introduced by\n" );
+    Abc_Print( -2, "\t         F. A. Aloul, I. L. Markov, and K. A. Sakallah (GLSVLSI�03).\n" );
+    Abc_Print( -2, "\t-I num : the number of refinement iterations [default = %d]\n", nIters );
+    Abc_Print( -2, "\t-c     : toggle clustered representation [default = %s]\n", fClustered? "yes":"no");
+    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes":"no");
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Embed( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Emb_Par_t Pars, * pPars = &Pars;
+    int c;
+    pPars->nDims      = 30;
+    pPars->nIters     = 10;
+    pPars->nSols      =  2;
+    pPars->fRefine    =  0;
+    pPars->fCluster   =  0;
+    pPars->fDump      =  0;
+    pPars->fDumpLarge =  0;
+    pPars->fShowImage =  0;
+    pPars->fVerbose   =  0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "DIrcdlsvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nDims = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nDims < 0 )
+                goto usage;
+            break;
+        case 'I':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nIters = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nIters < 0 )
+                goto usage;
+            break;
+        case 'r':
+            pPars->fRefine ^= 1;
+            break;
+        case 'c':
+            pPars->fCluster ^= 1;
+            break;
+        case 'd':
+            pPars->fDump ^= 1;
+            break;
+        case 'l':
+            pPars->fDumpLarge ^= 1;
+            break;
+        case 's':
+            pPars->fShowImage ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Embed(): There is no AIG.\n" );
+        return 1;
+    }
+    Gia_ManSolveProblem( pAbc->pGia, pPars );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &embed [-DI <num>] [-rdlscvh]\n" );
+    Abc_Print( -2, "\t         fast placement based on high-dimensional embedding from\n" );
+    Abc_Print( -2, "\t         D. Harel and Y. Koren, \"Graph drawing by high-dimensional\n" );
+    Abc_Print( -2, "\t         embedding\", J. Graph Algs & Apps, 2004, Vol 8(2), pp. 195-217\n" );
+    Abc_Print( -2, "\t-D num : the number of dimensions for embedding [default = %d]\n", pPars->nDims );
+    Abc_Print( -2, "\t-I num : the number of refinement iterations [default = %d]\n", pPars->nIters );
+    Abc_Print( -2, "\t-r     : toggle the use of refinement [default = %s]\n", pPars->fRefine? "yes":"no");
+    Abc_Print( -2, "\t-c     : toggle clustered representation [default = %s]\n", pPars->fCluster? "yes":"no");
+    Abc_Print( -2, "\t-d     : toggle dumping placement into a Gnuplot file [default = %s]\n", pPars->fDump? "yes":"no");
+    Abc_Print( -2, "\t-l     : toggle dumping Gnuplot for large placement [default = %s]\n", pPars->fDumpLarge? "yes":"no");
+    Abc_Print( -2, "\t-s     : toggle showing image if Gnuplot is installed [default = %s]\n", pPars->fShowImage? "yes":"no");
+    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes":"no");
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Sopb( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pTemp;
+    int nLevelMax   = 0;
+    int nTimeWindow = 0;
+    int nCutNum     = 8;
+    int nRelaxRatio = 0;
+    int c, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "LWCRvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nLevelMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLevelMax < 0 )
+                goto usage;
+            break;
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nTimeWindow = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nTimeWindow < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nCutNum = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nCutNum < 0 )
+                goto usage;
+            break;
+        case 'R':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nRelaxRatio = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nRelaxRatio < 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Sopb(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( nLevelMax || nTimeWindow )
+        pTemp = Gia_ManPerformSopBalanceWin( pAbc->pGia, nLevelMax, nTimeWindow, nCutNum, nRelaxRatio, fVerbose );
+    else
+        pTemp = Gia_ManPerformSopBalance( pAbc->pGia, nCutNum, nRelaxRatio, fVerbose );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &sopb [-LWCR num] [-vh]\n" );
+    Abc_Print( -2, "\t         performs SOP balancing\n" );
+    Abc_Print( -2, "\t-L num : optimize paths above this level [default = %d]\n", nLevelMax );
+    Abc_Print( -2, "\t-W num : optimize paths falling into this window [default = %d]\n", nTimeWindow );
+    Abc_Print( -2, "\t-C num : the number of cuts at a node [default = %d]\n", nCutNum );
+    Abc_Print( -2, "\t-R num : the delay relaxation ratio (num >= 0) [default = %d]\n", nRelaxRatio );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Dsdb( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pTemp;
+    int nLevelMax   = 0;
+    int nTimeWindow = 0;
+    int nLutSize    = 6;
+    int nCutNum     = 8;
+    int nRelaxRatio = 0;
+    int c, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "LWKCRvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nLevelMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLevelMax < 0 )
+                goto usage;
+            break;
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nTimeWindow = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nTimeWindow < 0 )
+                goto usage;
+            break;
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nLutSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLutSize < 0 )
+                goto usage;
+            break;
+         case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nCutNum = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nCutNum < 0 )
+                goto usage;
+            break;
+        case 'R':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nRelaxRatio = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nRelaxRatio < 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Dsdb(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( nLutSize > DAU_MAX_VAR )
+    {
+        printf( "Abc_CommandAbc9Dsdb(): Size of the required DSD manager (%d) exceeds the precompiled limit (%d) (change parameter DAU_MAX_VAR).\n", nLutSize, DAU_MAX_VAR );
+        return 0;
+    }
+    if ( Abc_FrameReadManDsd2() && nLutSize > If_DsdManVarNum(Abc_FrameReadManDsd2()) )
+    {
+        printf( "Abc_CommandAbc9Dsdb(): Incompatible size of the DSD manager (run \"dsd_free -b\").\n" );
+        return 0;
+    }
+    if ( nLevelMax || nTimeWindow )
+        pTemp = Gia_ManPerformDsdBalanceWin( pAbc->pGia, nLevelMax, nTimeWindow, nLutSize, nCutNum, nRelaxRatio, fVerbose );
+    else
+        pTemp = Gia_ManPerformDsdBalance( pAbc->pGia, nLutSize, nCutNum, nRelaxRatio, fVerbose );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &dsdb [-LWKCR num] [-vh]\n" );
+    Abc_Print( -2, "\t         performs DSD balancing\n" );
+    Abc_Print( -2, "\t-L num : optimize paths above this level [default = %d]\n", nLevelMax );
+    Abc_Print( -2, "\t-W num : optimize paths falling into this window [default = %d]\n", nTimeWindow );
+    Abc_Print( -2, "\t-K num : the number of LUT inputs (LUT size) [default = %d]\n", nLutSize );
+    Abc_Print( -2, "\t-C num : the number of cuts at a node [default = %d]\n", nCutNum );
+    Abc_Print( -2, "\t-R num : the delay relaxation ratio (num >= 0) [default = %d]\n", nRelaxRatio );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Flow( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern void Gia_ManPerformFlow( int fIsMapped, int nAnds, int nLevels, int nLutSize, int nCutNum, int fMinAve, int fUseMfs, int fVerbose );
+    int nLutSize    =  6;
+    int nCutNum     =  8;
+    int fMinAve     =  0;
+    int fUseMfs     =  0;
+    int c, fVerbose =  0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "KCtmvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nLutSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLutSize < 0 )
+                goto usage;
+            break;
+         case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nCutNum = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nCutNum < 0 )
+                goto usage;
+            break;
+        case 't':
+            fMinAve ^= 1;
+            break;
+        case 'm':
+            fUseMfs ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Flow(): There is no AIG.\n" );
+        return 1;
+    }
+    Gia_ManPerformFlow( Gia_ManHasMapping(pAbc->pGia), Gia_ManAndNum(pAbc->pGia), Gia_ManLevelNum(pAbc->pGia), nLutSize, nCutNum, fMinAve, fUseMfs, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &flow [-KC num] [-tmvh]\n" );
+    Abc_Print( -2, "\t         integration optimization and mapping flow\n" );
+    Abc_Print( -2, "\t-K num : the number of LUT inputs (LUT size) [default = %d]\n", nLutSize );
+    Abc_Print( -2, "\t-C num : the number of cuts at a node [default = %d]\n", nCutNum );
+    Abc_Print( -2, "\t-t     : toggle minimizing average rather than max delay [default = %s]\n", fMinAve? "yes": "no" );
+    Abc_Print( -2, "\t-m     : toggle using \"mfs2\" in the script [default = %s]\n", fUseMfs? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Flow2( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern void Gia_ManPerformFlow2( int fIsMapped, int nAnds, int nLevels, int nLutSize, int nCutNum, int fBalance, int fMinAve, int fUseMfs, int fVerbose );
+    int nLutSize    =  6;
+    int nCutNum     =  8;
+    int fBalance    =  0;
+    int fMinAve     =  0;
+    int fUseMfs     =  0;
+    int c, fVerbose =  0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "KCbtmvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nLutSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLutSize < 0 )
+                goto usage;
+            break;
+         case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nCutNum = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nCutNum < 0 )
+                goto usage;
+            break;
+        case 'b':
+            fBalance ^= 1;
+            break;
+        case 't':
+            fMinAve ^= 1;
+            break;
+        case 'm':
+            fUseMfs ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Flow2(): There is no AIG.\n" );
+        return 1;
+    }
+    Gia_ManPerformFlow2( Gia_ManHasMapping(pAbc->pGia), Gia_ManAndNum(pAbc->pGia), Gia_ManLevelNum(pAbc->pGia), nLutSize, nCutNum, fBalance, fMinAve, fUseMfs, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &flow2 [-KC num] [-btmvh]\n" );
+    Abc_Print( -2, "\t         integration optimization and mapping flow\n" );
+    Abc_Print( -2, "\t-K num : the number of LUT inputs (LUT size) [default = %d]\n", nLutSize );
+    Abc_Print( -2, "\t-C num : the number of cuts at a node [default = %d]\n", nCutNum );
+    Abc_Print( -2, "\t-b     : toggle using SOP balancing during synthesis [default = %s]\n", fBalance? "yes": "no" );
+    Abc_Print( -2, "\t-t     : toggle minimizing average (not maximum) level [default = %s]\n", fMinAve? "yes": "no" );
+    Abc_Print( -2, "\t-m     : toggle using \"mfs2\" in the script [default = %s]\n", fUseMfs? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9If( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    char Buffer[200];
+    char LutSize[200];
+    Gia_Man_t * pNew;
+    If_Par_t Pars, * pPars = &Pars;
+    int c;
+    // set defaults
+    Gia_ManSetIfParsDefault( pPars );
+    if ( pAbc->pLibLut == NULL )
+    {
+        Abc_Print( -1, "LUT library is not given. Using default LUT library.\n" );
+        pAbc->pLibLut = If_LibLutSetSimple( 6 );
+    }
+    pPars->pLutLib = (If_LibLut_t *)pAbc->pLibLut;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "KCFAGRDEWSTqalepmrsdbgxyofuijkztncvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nLutSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nLutSize < 0 )
+                goto usage;
+            // if the LUT size is specified, disable library
+            pPars->pLutLib = NULL;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nCutsMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nCutsMax < 0 )
+                goto usage;
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nFlowIters = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nFlowIters < 0 )
+                goto usage;
+            break;
+        case 'A':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-A\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nAreaIters = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nAreaIters < 0 )
+                goto usage;
+            break;
+        case 'G':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-G\" should be followed by a positive integer no less than 3.\n" );
+                goto usage;
+            }
+            pPars->nGateSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nGateSize < 2 )
+                goto usage;
+            break;
+        case 'R':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( 1, "Command line switch \"-R\" should be followed by a floating point number.\n" );
+                return 0;
+            }
+            pPars->nRelaxRatio = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nRelaxRatio < 0 ) 
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by a positive integer 0,1,or 2.\n" );
+                goto usage;
+            }
+            pPars->nStructType = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nStructType < 0 || pPars->nStructType > 2 )
+                goto usage;
+            break;
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            pPars->DelayTarget = (float)atof(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->DelayTarget <= 0.0 )
+                goto usage;
+            break;
+        case 'E':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-E\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            pPars->Epsilon = (float)atof(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->Epsilon < 0.0 || pPars->Epsilon > 1.0 )
+                goto usage;
+            break;
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            pPars->WireDelay = (float)atof(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->WireDelay < 0.0 )
+                goto usage;
+            break;
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by string.\n" );
+                goto usage;
+            }
+            pPars->pLutStruct = argv[globalUtilOptind];
+            globalUtilOptind++;
+            if ( strlen(pPars->pLutStruct) != 2 && strlen(pPars->pLutStruct) != 3 )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by a 2- or 3-char string (e.g. \"44\" or \"555\").\n" );
+                goto usage;
+            }
+            break;
+        case 'q':
+            pPars->fPreprocess ^= 1;
+            break;
+        case 'a':
+            pPars->fArea ^= 1;
+            break;
+        case 'r':
+            pPars->fExpRed ^= 1;
+            break;
+        case 'l':
+            pPars->fLatchPaths ^= 1;
+            break;
+        case 'e':
+            pPars->fEdge ^= 1;
+            break;
+        case 'p':
+            pPars->fPower ^= 1;
+            break;
+        case 'm':
+            pPars->fCutMin ^= 1;
+            break;
+        case 's':
+            pPars->fDelayOptLut ^= 1;
+            break;
+        case 'd':
+            pPars->fBidec ^= 1;
+            break;
+        case 'b':
+            pPars->fUseBat ^= 1;
+            break;
+        case 'g':
+            pPars->fDelayOpt ^= 1;
+            break;
+        case 'x':
+            pPars->fDsdBalance ^= 1;
+            break;
+        case 'y':
+            pPars->fUserRecLib ^= 1;
+            break;
+        case 'o':
+            pPars->fUseBuffs ^= 1;
+            break;
+        case 'f':
+            pPars->fEnableCheck75 ^= 1;
+            break;
+        case 'u':
+            pPars->fEnableCheck75u ^= 1;
+            break;
+        case 'i':
+            pPars->fUseCofVars ^= 1;
+            break;
+//        case 'j':
+//            pPars->fEnableCheck07 ^= 1;
+//            break;
+        case 'j':
+            pPars->fUseAndVars ^= 1;
+            break;
+        case 'k':
+            pPars->fUseDsdTune ^= 1;
+            break;
+        case 'z':
+            pPars->fDeriveLuts ^= 1;
+            break;
+        case 't':
+            pPars->fDoAverage ^= 1;
+            break;
+        case 'n':
+            pPars->fUseDsd ^= 1;
+            break;
+        case 'c':
+            pPars->fUseTtPerm ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'h':
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Empty GIA network.\n" );
+        return 1;
+    }
+    if ( Gia_ManBufNum(pAbc->pGia) )
+    {
+        Abc_Print( -1, "This command does not work with barrier buffers.\n" );
+        return 1;
+    }
+    if ( Gia_ManHasMapping(pAbc->pGia) )
+    {
+        Abc_Print( -1, "Current AIG has mapping. Run \"&st\".\n" );
+        return 1;
+    }
+
+    if ( pPars->nLutSize == -1 )
+    {
+        if ( pPars->pLutLib == NULL )
+        {
+            Abc_Print( -1, "The LUT library is not given.\n" );
+            return 1;
+        }
+        // get LUT size from the library
+        pPars->nLutSize = pPars->pLutLib->LutMax;
+        // if variable pin delay, force truth table computation
+//        if ( pPars->pLutLib->fVarPinDelays )
+//            pPars->fTruth = 1;
+    }
+
+    if ( pPars->nLutSize < 2 || pPars->nLutSize > IF_MAX_LUTSIZE )
+    {
+        Abc_Print( -1, "Incorrect LUT size (%d).\n", pPars->nLutSize );
+        return 1;
+    }
+
+    if ( pPars->nCutsMax < 1 || pPars->nCutsMax >= (1<<12) )
+    {
+        Abc_Print( -1, "Incorrect number of cuts.\n" );
+        return 1;
+    }
+
+    // enable truth table computation if choices are selected
+    if ( Gia_ManHasChoices(pAbc->pGia) )
+    {
+//        if ( !Abc_FrameReadFlag("silentmode") )
+//            Abc_Print( 0, "Performing LUT mapping with choices.\n" );
+        pPars->fExpRed = 0;
+    }
+
+    if ( pPars->fUseBat )
+    {
+        if ( pPars->nLutSize < 4 || pPars->nLutSize > 6 )
+        {
+            Abc_Print( -1, "This feature only works for {4,5,6}-LUTs.\n" );
+            return 1;
+        }
+        pPars->fCutMin = 1;
+    }
+
+    if ( pPars->fEnableCheck07 + pPars->fUseCofVars + pPars->fUseDsdTune + pPars->fEnableCheck75 + pPars->fEnableCheck75u + (pPars->pLutStruct != NULL) > 1 )
+    {
+        Abc_Print( -1, "Only one additional check can be performed at the same time.\n" );
+        return 1;
+    }
+    if ( pPars->fEnableCheck07 )
+    {
+        if ( pPars->nLutSize < 6 || pPars->nLutSize > 7 )
+        {
+            Abc_Print( -1, "This feature only works for {6,7}-LUTs.\n" );
+            return 1;
+        }
+        pPars->pFuncCell = If_CutPerformCheck07;
+        pPars->fCutMin = 1;
+    }
+    if ( pPars->fUseCofVars )
+    {
+        if ( !(pPars->nLutSize & 1) )
+        {
+            Abc_Print( -1, "This feature only works for odd-sized LUTs.\n" );
+            return 1;
+        }
+        pPars->fCutMin = 1;
+    }
+    if ( pPars->fUseAndVars )
+        pPars->fCutMin = 1;
+    if ( pPars->fUseDsdTune )
+    {
+        If_DsdMan_t * pDsdMan = (If_DsdMan_t *)Abc_FrameReadManDsd();
+        if ( pDsdMan == NULL )
+        {
+            Abc_Print( -1, "DSD manager is not available.\n" );
+            return 1;
+        }
+        if ( pPars->nLutSize > If_DsdManVarNum(pDsdMan) )
+        {
+            Abc_Print( -1, "LUT size (%d) is more than the number of variables in the DSD manager (%d).\n", pPars->nLutSize, If_DsdManVarNum(pDsdMan) );
+            return 1;
+        }
+        if ( pPars->fDeriveLuts && If_DsdManGetCellStr(pDsdMan) == NULL )
+        {
+            Abc_Print( -1, "DSD manager is not matched with any particular cell.\n" );
+            return 1;
+        }
+        pPars->fCutMin = 1;
+        pPars->fUseDsd = 1;
+        If_DsdManSetNewAsUseless( pDsdMan );
+    }
+    if ( pPars->fEnableCheck75 || pPars->fEnableCheck75u )
+    {
+        if ( pPars->fEnableCheck75 && pPars->fEnableCheck75u )
+        {
+            Abc_Print( -1, "Switches -f and -u are not compatible.\n" );
+            return 1;
+        }
+        if ( pPars->nLutSize < 5 || pPars->nLutSize > 8 )
+        {
+            Abc_Print( -1, "This feature only works for {6,7,8}-LUTs.\n" );
+            return 1;
+        }
+        pPars->pFuncCell = If_CutPerformCheck75;
+        pPars->fCutMin = 1;
+    }
+    if ( pPars->pLutStruct )
+    {
+        if ( pPars->fDsdBalance )
+        {
+            Abc_Print( -1, "Incompatible options (-S and -x).\n" );
+            return 1;
+        }
+        if ( pPars->nLutSize < 6 || pPars->nLutSize > 16 )
+        {
+            Abc_Print( -1, "This feature only works for [6;16]-LUTs.\n" );
+            return 1;
+        }
+        pPars->pFuncCell = pPars->fDelayOptLut ? NULL : If_CutPerformCheck16;
+        pPars->fCutMin = 1;
+    }
+
+    // enable truth table computation if cut minimization is selected
+    if ( pPars->fCutMin || pPars->fDeriveLuts )
+    {
+        pPars->fTruth = 1;
+        pPars->fExpRed = 0;
+        if ( pPars->pLutStruct == NULL && !pPars->fUseDsdTune )
+            pPars->fDeriveLuts = 1;
+    }
+    // modify the subgraph recording
+    if ( pPars->fUserRecLib )
+    {
+        pPars->fTruth      =  1;
+        pPars->fCutMin     =  1;
+        pPars->fExpRed     =  0;
+        pPars->fUsePerm    =  1;
+        pPars->pLutLib     =  NULL;
+    }
+    // modify for delay optimization
+    if ( pPars->fDelayOpt || pPars->fDsdBalance || pPars->fDelayOptLut )
+    {
+        pPars->fTruth      =  1;
+        pPars->fCutMin     =  1;
+        pPars->fExpRed     =  0;
+        pPars->fUseDsd     =  pPars->fDsdBalance || pPars->fDelayOptLut;
+        pPars->pLutLib     =  NULL;
+    }
+    // modify for delay optimization
+    if ( pPars->nGateSize > 0 )
+    {
+        pPars->fTruth      =  1;
+        pPars->fCutMin     =  1;
+        pPars->fExpRed     =  0;
+        pPars->fUsePerm    =  1;
+        pPars->pLutLib     =  NULL;
+        pPars->nLutSize    =  pPars->nGateSize;
+    }
+
+    if ( pPars->fUseDsd || pPars->fUseTtPerm )
+    {
+        pPars->fTruth      =  1;
+        pPars->fCutMin     =  1;
+        pPars->fExpRed     =  0;
+    }
+
+    if ( pPars->fUseDsd )
+    {
+        int LutSize = (pPars->pLutStruct && pPars->pLutStruct[2] == 0)? pPars->pLutStruct[0] - '0' : 0;
+        If_DsdMan_t * p = (If_DsdMan_t *)Abc_FrameReadManDsd();
+        if ( pPars->pLutStruct && pPars->pLutStruct[2] != 0 )
+        {
+            printf( "DSD only works for LUT structures XY.\n" );
+            return 0;
+        }
+        if ( p && pPars->nLutSize > If_DsdManVarNum(p) )
+        {
+            printf( "DSD manager has incompatible number of variables.\n" );
+            return 0;
+        }
+        if ( p && LutSize != If_DsdManLutSize(p) && !pPars->fDsdBalance )
+        {
+            printf( "DSD manager has different LUT size.\n" );
+            return 0;
+        }
+        if ( p == NULL )
+        {
+            if ( LutSize > DAU_MAX_VAR || pPars->nLutSize > DAU_MAX_VAR )
+            {
+                printf( "Size of required DSD manager (%d) exceeds the precompiled limit (%d) (change parameter DAU_MAX_VAR).\n", LutSize, DAU_MAX_VAR );
+                return 0;
+            }
+            Abc_FrameSetManDsd( If_DsdManAlloc(pPars->nLutSize, LutSize) );
+        }
+    }
+
+    if ( pPars->fUserRecLib )
+    {
+        if ( !Abc_NtkRecIsRunning3() )
+        {
+            printf( "LMS manager is not running (use \"rec_start3\").\n" );
+            return 0;
+        }
+        if ( Abc_NtkRecInputNum3() != pPars->nLutSize )
+        {
+            printf( "The number of library inputs (%d) different from the K parameters (%d).\n", Abc_NtkRecInputNum3(), pPars->nLutSize );
+            return 0;
+        }
+    }
+
+    // complain if truth tables are requested but the cut size is too large
+    if ( pPars->fTruth && pPars->nLutSize > IF_MAX_FUNC_LUTSIZE )
+    {
+        Abc_Print( -1, "Truth tables cannot be computed for LUT larger than %d inputs.\n", IF_MAX_FUNC_LUTSIZE );
+        return 1;
+    }
+    if ( pAbc->pGia->pManTime && pAbc->pLibBox == NULL )
+    {
+        Abc_Print( -1, "Design has boxes but box library is not entered.\n" );
+        return 1;
+    }
+
+    // perform mapping
+    pNew = Gia_ManPerformMapping( pAbc->pGia, pPars );
+    if ( pNew == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9If(): Mapping of GIA has failed.\n" );
+        return 1;
+    }
+    Abc_FrameUpdateGia( pAbc, pNew );
+    return 0;
+
+usage:
+    if ( pPars->DelayTarget == -1 )
+        sprintf(Buffer, "best possible" );
+    else
+        sprintf(Buffer, "%.2f", pPars->DelayTarget );
+    if ( pPars->nLutSize == -1 )
+        sprintf(LutSize, "library" );
+    else
+        sprintf(LutSize, "%d", pPars->nLutSize );
+    Abc_Print( -2, "usage: &if [-KCFAGRT num] [-DEW float] [-S str] [-qarlepmsdbgxyofuijkztncvh]\n" );
+    Abc_Print( -2, "\t           performs FPGA technology mapping of the network\n" );
+    Abc_Print( -2, "\t-K num   : the number of LUT inputs (2 < num < %d) [default = %s]\n", IF_MAX_LUTSIZE+1, LutSize );
+    Abc_Print( -2, "\t-C num   : the max number of priority cuts (0 < num < 2^12) [default = %d]\n", pPars->nCutsMax );
+    Abc_Print( -2, "\t-F num   : the number of area flow recovery iterations (num >= 0) [default = %d]\n", pPars->nFlowIters );
+    Abc_Print( -2, "\t-A num   : the number of exact area recovery iterations (num >= 0) [default = %d]\n", pPars->nAreaIters );
+    Abc_Print( -2, "\t-G num   : the max AND/OR gate size for mapping (0 = unused) [default = %d]\n", pPars->nGateSize );
+    Abc_Print( -2, "\t-R num   : the delay relaxation ratio (num >= 0) [default = %d]\n", pPars->nRelaxRatio );
+    Abc_Print( -2, "\t-T num   : the type of LUT structures [default = any]\n", pPars->nStructType );
+    Abc_Print( -2, "\t-D float : sets the delay constraint for the mapping [default = %s]\n", Buffer );
+    Abc_Print( -2, "\t-E float : sets epsilon used for tie-breaking [default = %f]\n", pPars->Epsilon );
+    Abc_Print( -2, "\t-W float : sets wire delay between adjects LUTs [default = %f]\n", pPars->WireDelay );
+    Abc_Print( -2, "\t-S str   : string representing the LUT structure [default = %s]\n", pPars->pLutStruct ? pPars->pLutStruct : "not used" );
+    Abc_Print( -2, "\t-q       : toggles preprocessing using several starting points [default = %s]\n", pPars->fPreprocess? "yes": "no" );
+    Abc_Print( -2, "\t-a       : toggles area-oriented mapping [default = %s]\n", pPars->fArea? "yes": "no" );
+    Abc_Print( -2, "\t-r       : enables expansion/reduction of the best cuts [default = %s]\n", pPars->fExpRed? "yes": "no" );
+    Abc_Print( -2, "\t-l       : optimizes latch paths for delay, other paths for area [default = %s]\n", pPars->fLatchPaths? "yes": "no" );
+    Abc_Print( -2, "\t-e       : uses edge-based cut selection heuristics [default = %s]\n", pPars->fEdge? "yes": "no" );
+    Abc_Print( -2, "\t-p       : uses power-aware cut selection heuristics [default = %s]\n", pPars->fPower? "yes": "no" );
+    Abc_Print( -2, "\t-m       : enables cut minimization by removing vacuous variables [default = %s]\n", pPars->fCutMin? "yes": "no" );
+    Abc_Print( -2, "\t-s       : toggles delay-oriented mapping used with -S <NN> [default = %s]\n", pPars->fDelayOptLut? "yes": "no" );
+    Abc_Print( -2, "\t-d       : toggles deriving local AIGs using bi-decomposition [default = %s]\n", pPars->fBidec? "yes": "no" );
+    Abc_Print( -2, "\t-b       : toggles the use of one special feature [default = %s]\n", pPars->fUseBat? "yes": "no" );
+    Abc_Print( -2, "\t-g       : toggles delay optimization by SOP balancing [default = %s]\n", pPars->fDelayOpt? "yes": "no" );
+    Abc_Print( -2, "\t-x       : toggles delay optimization by DSD balancing [default = %s]\n", pPars->fDsdBalance? "yes": "no" );
+    Abc_Print( -2, "\t-y       : toggles delay optimization with recorded library [default = %s]\n", pPars->fUserRecLib? "yes": "no" );
+    Abc_Print( -2, "\t-o       : toggles using buffers to decouple combinational outputs [default = %s]\n", pPars->fUseBuffs? "yes": "no" );
+    Abc_Print( -2, "\t-f       : toggles enabling additional check [default = %s]\n", pPars->fEnableCheck75? "yes": "no" );
+    Abc_Print( -2, "\t-u       : toggles enabling additional check [default = %s]\n", pPars->fEnableCheck75u? "yes": "no" );
+    Abc_Print( -2, "\t-i       : toggles using cofactoring variables [default = %s]\n", pPars->fUseCofVars? "yes": "no" );
+//    Abc_Print( -2, "\t-j       : toggles enabling additional check [default = %s]\n", pPars->fEnableCheck07? "yes": "no" );
+    Abc_Print( -2, "\t-j       : toggles using AND bi-decomposition [default = %s]\n", pPars->fUseAndVars? "yes": "no" );
+    Abc_Print( -2, "\t-k       : toggles matching based on precomputed DSD manager [default = %s]\n", pPars->fUseDsdTune? "yes": "no" );
+    Abc_Print( -2, "\t-z       : toggles deriving LUTs when mapping into LUT structures [default = %s]\n", pPars->fDeriveLuts? "yes": "no" );
+    Abc_Print( -2, "\t-t       : toggles optimizing average rather than maximum level [default = %s]\n", pPars->fDoAverage? "yes": "no" );
+    Abc_Print( -2, "\t-n       : toggles computing DSDs of the cut functions [default = %s]\n", pPars->fUseDsd? "yes": "no" );
+    Abc_Print( -2, "\t-c       : toggles computing truth tables in a new way [default = %s]\n", pPars->fUseTtPerm? "yes": "no" );
+    Abc_Print( -2, "\t-v       : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : prints the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Iff( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern void Gia_ManIffTest( Gia_Man_t * pGia, If_LibLut_t * pLib, int fVerbose );
+    int c, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Iff(): There is no AIG to map.\n" );
+        return 1;
+    }
+    if ( !Gia_ManHasMapping(pAbc->pGia) )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Iff(): Mapping of the AIG is not defined.\n" );
+        return 1;
+    }
+    if ( pAbc->pLibLut == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Iff(): LUT library is not defined.\n" );
+        return 1;
+    }
+    Gia_ManIffTest( pAbc->pGia, (If_LibLut_t *)pAbc->pLibLut, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &iff [-vh]\n" );
+    Abc_Print( -2, "\t           performs structural mapping into LUT structures\n" );
+    Abc_Print( -2, "\t-v       : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9If2( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Abc_Ntk_t * Mpm_ManCellMapping( Gia_Man_t * p, Mpm_Par_t * pPars, void * pMio );
+    extern Gia_Man_t * Mpm_ManLutMapping( Gia_Man_t * p, Mpm_Par_t * pPars );
+    char Buffer[200];
+    Abc_Ntk_t * pTemp;
+    Gia_Man_t * pNew;
+    Mpm_Par_t Pars, * pPars = &Pars;
+    int c, nLutSize = 6;
+    // set defaults
+    Mpm_ManSetParsDefault( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "KCDtmzrcuxvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            nLutSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLutSize < 2 || nLutSize > 16 )
+            {
+                Abc_Print( -1, "LUT size %d is not supported.\n", nLutSize );
+                goto usage;
+            }
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nNumCuts = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nNumCuts < 0 )
+                goto usage;
+            break;
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            pPars->DelayTarget = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->DelayTarget <= 0.0 )
+                goto usage;
+            break;
+        case 't':
+            pPars->fUseGates ^= 1;
+            break;
+        case 'm':
+            pPars->fCutMin ^= 1;
+            break;
+        case 'z':
+            pPars->fDeriveLuts ^= 1;
+            break;
+        case 'r':
+            pPars->fOneRound ^= 1;
+            break;
+        case 'c':
+            pPars->fMap4Cnf ^= 1;
+            break;
+        case 'u':
+            pPars->fMap4Aig ^= 1;
+            break;
+        case 'x':
+            pPars->fMap4Gates ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'w':
+            pPars->fVeryVerbose ^= 1;
+            break;
+        case 'h':
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Empty GIA network.\n" );
+        return 1;
+    }
+
+    if ( pPars->fMap4Cnf )
+        pPars->fUseDsd = 1;
+    if ( pPars->fCutMin )
+        pPars->fUseDsd = 1;
+//        pPars->fUseTruth = 1;
+    if ( pPars->fMap4Gates )
+    {
+        pPars->fUseDsd = 1;
+        if ( pAbc->pLibScl == NULL )
+        {
+            Abc_Print( -1, "There is no SCL library available.\n" );
+            return 1;
+        }
+        pPars->pScl = pAbc->pLibScl;
+    }
+    if ( pPars->fUseDsd || pPars->fUseTruth )
+        pPars->fDeriveLuts = 1;
+    if ( pPars->fUseDsd && nLutSize != 6 )
+    {
+        Abc_Print( -1, "Currently DSD can only be used with 6-input cuts.\n" );
+        return 1;
+    }
+    // perform mapping
+    assert( pPars->pLib == NULL );
+    if ( pPars->fMap4Gates )
+    {
+        if ( Abc_FrameReadLibGen() == NULL )
+        {
+            Abc_Print( -1, "There is no GENLIB library available.\n" );
+            return 1;
+        }
+        pPars->pLib = Mpm_LibLutSetSimple( nLutSize );
+        pTemp = Mpm_ManCellMapping( pAbc->pGia, pPars, Abc_FrameReadLibGen() );
+        Mpm_LibLutFree( pPars->pLib );
+        if ( pTemp == NULL )
+        {
+            Abc_Print( -1, "Abc_CommandAbc9If2(): Mapping into standard cells has failed.\n" );
+            return 1;
+        }
+        Abc_FrameReplaceCurrentNetwork( pAbc, pTemp );
+    }
+    else
+    {
+        pPars->pLib = Mpm_LibLutSetSimple( nLutSize );
+        pNew = Mpm_ManLutMapping( pAbc->pGia, pPars );
+        Mpm_LibLutFree( pPars->pLib );
+        if ( pNew == NULL )
+        {
+            Abc_Print( -1, "Abc_CommandAbc9If2(): Mapping into LUTs has failed.\n" );
+            return 1;
+        }
+        Abc_FrameUpdateGia( pAbc, pNew );
+    }
+    return 0;
+
+usage:
+    if ( pPars->DelayTarget == -1 )
+        sprintf(Buffer, "best possible" );
+    else
+        sprintf(Buffer, "%d", pPars->DelayTarget );
+    Abc_Print( -2, "usage: &if2 [-KCD num] [-tmzrcuxvwh]\n" );
+    Abc_Print( -2, "\t           performs technology mapping of the network\n" );
+    Abc_Print( -2, "\t-K num   : sets the LUT size for the mapping [default = %d]\n", nLutSize );
+    Abc_Print( -2, "\t-C num   : the max number of priority cuts (0 < num < 2^12) [default = %d]\n", pPars->nNumCuts );
+    Abc_Print( -2, "\t-D num   : sets the delay constraint for the mapping [default = %s]\n", Buffer );
+    Abc_Print( -2, "\t-t       : enables using AND/XOR/MUX nodes instead of simple AIG [default = %s]\n", pPars->fUseGates? "yes": "no" );
+    Abc_Print( -2, "\t-m       : enables cut minimization by removing vacuous variables [default = %s]\n", pPars->fCutMin? "yes": "no" );
+    Abc_Print( -2, "\t-z       : toggles deriving LUTs when mapping into LUT structures [default = %s]\n", pPars->fDeriveLuts? "yes": "no" );
+    Abc_Print( -2, "\t-r       : toggles using one round of mapping [default = %s]\n", pPars->fOneRound? "yes": "no" );
+    Abc_Print( -2, "\t-c       : toggles mapping for CNF computation [default = %s]\n", pPars->fMap4Cnf? "yes": "no" );
+    Abc_Print( -2, "\t-u       : toggles mapping for AIG computation [default = %s]\n", pPars->fMap4Aig? "yes": "no" );
+    Abc_Print( -2, "\t-x       : toggles mapping for standard cells [default = %s]\n", pPars->fMap4Gates? "yes": "no" );
+    Abc_Print( -2, "\t-v       : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w       : toggles very verbose output [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : prints the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Jf( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    char Buffer[200];
+    Jf_Par_t Pars, * pPars = &Pars;
+    Gia_Man_t * pNew; int c;
+    Jf_ManSetDefaultPars( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "KCDWaekmdcgvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nLutSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nLutSize < 2 || pPars->nLutSize > pPars->nLutSizeMax )
+            {
+                Abc_Print( -1, "LUT size %d is not supported.\n", pPars->nLutSize );
+                goto usage;
+            }
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nCutNum = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nCutNum < 1 || pPars->nCutNum > pPars->nCutNumMax )
+            {
+                Abc_Print( -1, "This number of cuts (%d) is not supported.\n", pPars->nCutNum );
+                goto usage;
+            }
+            break;
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            pPars->DelayTarget = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->DelayTarget <= 0.0 )
+                goto usage;
+            break;
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nVerbLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nVerbLimit < 0 )
+                goto usage;
+            break;
+        case 'a':
+            pPars->fAreaOnly ^= 1;
+            break;
+        case 'e':
+            pPars->fOptEdge ^= 1;
+            break;
+        case 'k':
+            pPars->fCoarsen ^= 1;
+            break;
+        case 'm':
+            pPars->fCutMin ^= 1;
+            break;
+        case 'd':
+            pPars->fFuncDsd ^= 1;
+            break;
+        case 'c':
+            pPars->fGenCnf ^= 1;
+            break;
+        case 'g':
+            pPars->fPureAig ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'w':
+            pPars->fVeryVerbose ^= 1;
+            break;
+        case 'h':
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Empty GIA network.\n" );
+        return 1;
+    }
+    if ( Gia_ManBufNum(pAbc->pGia) )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Jf(): This command does not work with barrier buffers.\n" );
+        return 1;
+    }
+    if ( (pPars->fFuncDsd || pPars->fGenCnf) && pPars->nLutSize > 6 )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Jf(): DSD computation works for LUT6 or less.\n" );
+        return 1;
+    }
+
+    if ( (pPars->fFuncDsd || pPars->fGenCnf) && !Sdm_ManCanRead() )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Jf(): Cannot input DSD data from file.\n" );
+        return 1;
+    }
+
+    pNew = Jf_ManPerformMapping( pAbc->pGia, pPars );
+    if ( pNew == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Jf(): Mapping into LUTs has failed.\n" );
+        return 1;
+    }
+    Abc_FrameUpdateGia( pAbc, pNew );
+    return 0;
+
+usage:
+    if ( pPars->DelayTarget == -1 )
+        sprintf(Buffer, "best possible" );
+    else
+        sprintf(Buffer, "%d", pPars->DelayTarget );
+    Abc_Print( -2, "usage: &jf [-KCDW num] [-akmdcgvwh]\n" );
+    Abc_Print( -2, "\t           performs technology mapping of the network\n" );
+    Abc_Print( -2, "\t-K num   : LUT size for the mapping (2 <= K <= %d) [default = %d]\n", pPars->nLutSizeMax, pPars->nLutSize );
+    Abc_Print( -2, "\t-C num   : the max number of priority cuts (1 <= C <= %d) [default = %d]\n", pPars->nCutNumMax, pPars->nCutNum );
+    Abc_Print( -2, "\t-D num   : sets the delay constraint for the mapping [default = %s]\n", Buffer );
+    Abc_Print( -2, "\t-W num   : min frequency when printing functions with \"-w\" [default = %d]\n", pPars->nVerbLimit );
+    Abc_Print( -2, "\t-a       : toggles area-oriented mapping [default = %s]\n", pPars->fAreaOnly? "yes": "no" );
+    Abc_Print( -2, "\t-e       : toggles edge vs node minimization [default = %s]\n", pPars->fOptEdge? "yes": "no" );
+    Abc_Print( -2, "\t-k       : toggles coarsening the subject graph [default = %s]\n", pPars->fCoarsen? "yes": "no" );
+    Abc_Print( -2, "\t-m       : toggles cut minimization [default = %s]\n", pPars->fCutMin? "yes": "no" );
+    Abc_Print( -2, "\t-d       : toggles using DSD to represent cut functions [default = %s]\n", pPars->fFuncDsd? "yes": "no" );
+    Abc_Print( -2, "\t-c       : toggles mapping for CNF generation [default = %s]\n", pPars->fGenCnf? "yes": "no" );
+    Abc_Print( -2, "\t-g       : toggles generating AIG without mapping [default = %s]\n", pPars->fPureAig? "yes": "no" );
+    Abc_Print( -2, "\t-v       : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w       : toggles very verbose output [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : prints the command usage\n");
+    return 1;
+}
+
+#ifdef ABC_USE_PTHREADS
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Kf( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern void Kf_ManSetDefaultPars( Jf_Par_t * pPars );
+    extern Gia_Man_t * Kf_ManPerformMapping( Gia_Man_t * pGia, Jf_Par_t * pPars );
+    char Buffer[200];
+    Jf_Par_t Pars, * pPars = &Pars;
+    Gia_Man_t * pNew; int c;
+    Kf_ManSetDefaultPars( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "KCPDWaekmdcgtsvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nLutSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nLutSize < 2 || pPars->nLutSize > pPars->nLutSizeMax )
+            {
+                Abc_Print( -1, "LUT size %d is not supported.\n", pPars->nLutSize );
+                goto usage;
+            }
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nCutNum = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nCutNum < 1 || pPars->nCutNum > pPars->nCutNumMax )
+            {
+                Abc_Print( -1, "This number of cuts (%d) is not supported.\n", pPars->nCutNum );
+                goto usage;
+            }
+            break;
+        case 'P':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-P\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nProcNum = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nProcNum < 0 )
+                goto usage;
+            break;
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            pPars->DelayTarget = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->DelayTarget <= 0.0 )
+                goto usage;
+            break;
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nVerbLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nVerbLimit < 0 )
+                goto usage;
+            break;
+        case 'a':
+            pPars->fAreaOnly ^= 1;
+            break;
+        case 'e':
+            pPars->fOptEdge ^= 1;
+            break;
+        case 'k':
+            pPars->fCoarsen ^= 1;
+            break;
+        case 'm':
+            pPars->fCutMin ^= 1;
+            break;
+        case 'd':
+            pPars->fFuncDsd ^= 1;
+            break;
+        case 'c':
+            pPars->fGenCnf ^= 1;
+            break;
+        case 'g':
+            pPars->fPureAig ^= 1;
+            break;
+        case 't':
+            pPars->fCutHashing ^= 1;
+            break;
+        case 's':
+            pPars->fCutSimple ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'w':
+            pPars->fVeryVerbose ^= 1;
+            break;
+        case 'h':
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Empty GIA network.\n" );
+        return 1;
+    }
+
+    pNew = Kf_ManPerformMapping( pAbc->pGia, pPars );
+    if ( pNew == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Kf(): Mapping into LUTs has failed.\n" );
+        return 1;
+    }
+    Abc_FrameUpdateGia( pAbc, pNew );
+    return 0;
+
+usage:
+    if ( pPars->DelayTarget == -1 )
+        sprintf(Buffer, "best possible" );
+    else
+        sprintf(Buffer, "%d", pPars->DelayTarget );
+    Abc_Print( -2, "usage: &kf [-KCPDW num] [-akmdcgtsvwh]\n" );
+    Abc_Print( -2, "\t           performs technology mapping of the network\n" );
+    Abc_Print( -2, "\t-K num   : LUT size for the mapping (2 <= K <= %d) [default = %d]\n", pPars->nLutSizeMax, pPars->nLutSize );
+    Abc_Print( -2, "\t-C num   : the max number of priority cuts (1 <= C <= %d) [default = %d]\n", pPars->nCutNumMax, pPars->nCutNum );
+    Abc_Print( -2, "\t-P num   : the number of cut computation processes (0 <= P <= %d) [default = %d]\n", pPars->nProcNumMax, pPars->nProcNum );
+    Abc_Print( -2, "\t-D num   : sets the delay constraint for the mapping [default = %s]\n", Buffer );
+    Abc_Print( -2, "\t-W num   : min frequency when printing functions with \"-w\" [default = %d]\n", pPars->nVerbLimit );
+    Abc_Print( -2, "\t-a       : toggles area-oriented mapping [default = %s]\n", pPars->fAreaOnly? "yes": "no" );
+    Abc_Print( -2, "\t-e       : toggles edge vs node minimization [default = %s]\n", pPars->fOptEdge? "yes": "no" );
+    Abc_Print( -2, "\t-k       : toggles coarsening the subject graph [default = %s]\n", pPars->fCoarsen? "yes": "no" );
+    Abc_Print( -2, "\t-m       : toggles cut minimization [default = %s]\n", pPars->fCutMin? "yes": "no" );
+    Abc_Print( -2, "\t-d       : toggles using DSD to represent cut functions [default = %s]\n", pPars->fFuncDsd? "yes": "no" );
+    Abc_Print( -2, "\t-c       : toggles mapping for CNF generation [default = %s]\n", pPars->fGenCnf? "yes": "no" );
+    Abc_Print( -2, "\t-g       : toggles generating AIG without mapping [default = %s]\n", pPars->fPureAig? "yes": "no" );
+    Abc_Print( -2, "\t-t       : toggles cut computation using hash table [default = %s]\n", pPars->fCutHashing? "yes": "no" );
+    Abc_Print( -2, "\t-s       : toggles cut computation using a simple method [default = %s]\n", pPars->fCutSimple? "yes": "no" );
+    Abc_Print( -2, "\t-v       : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w       : toggles very verbose output [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : prints the command usage\n");
+    return 1;
+}
+#endif
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Lf( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    char Buffer[200];
+    Jf_Par_t Pars, * pPars = &Pars;
+    Gia_Man_t * pNew; int c;
+    Lf_ManSetDefaultPars( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "KCFARLEDWMaekmupgtvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nLutSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nLutSize < 2 || pPars->nLutSize > pPars->nLutSizeMax )
+            {
+                Abc_Print( -1, "LUT size %d is not supported.\n", pPars->nLutSize );
+                goto usage;
+            }
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nCutNum = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nCutNum < 1 || pPars->nCutNum > pPars->nCutNumMax )
+            {
+                Abc_Print( -1, "This number of cuts (%d) is not supported.\n", pPars->nCutNum );
+                goto usage;
+            }
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nRounds = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nRounds < 0 )
+                goto usage;
+            break;
+        case 'A':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-A\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nRoundsEla = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nRoundsEla < 0 )
+                goto usage;
+            break;
+        case 'R':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( 1, "Command line switch \"-R\" should be followed by a floating point number.\n" );
+                return 0;
+            }
+            pPars->nRelaxRatio = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nRelaxRatio < 0 ) 
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( 1, "Command line switch \"-R\" should be followed by a floating point number.\n" );
+                return 0;
+            }
+            pPars->nCoarseLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nCoarseLimit < 0 ) 
+                goto usage;
+            break;
+        case 'E':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( 1, "Command line switch \"-E\" should be followed by a floating point number.\n" );
+                return 0;
+            }
+            pPars->nAreaTuner = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nAreaTuner < 0 ) 
+                goto usage;
+            break;
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            pPars->DelayTarget = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->DelayTarget <= 0.0 )
+                goto usage;
+            break;
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nVerbLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nVerbLimit < 0 )
+                goto usage;
+            break;
+        case 'M':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-M\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nLutSizeMux = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nLutSizeMux < 2 || pPars->nLutSizeMux > pPars->nLutSizeMax )
+            {
+                Abc_Print( -1, "LUT size %d is not supported.\n", pPars->nLutSizeMux );
+                goto usage;
+            }
+            break;
+        case 'a':
+            pPars->fAreaOnly ^= 1;
+            break;
+        case 'e':
+            pPars->fOptEdge ^= 1;
+            break;
+        case 'k':
+            pPars->fCoarsen ^= 1;
+            break;
+        case 'm':
+            pPars->fCutMin ^= 1;
+            break;
+        case 'u':
+            pPars->fUseMux7 ^= 1;
+            break;
+        case 'p':
+            pPars->fPower ^= 1;
+            break;
+        case 'g':
+            pPars->fPureAig ^= 1;
+            break;
+        case 't':
+            pPars->fDoAverage ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'w':
+            pPars->fVeryVerbose ^= 1;
+            break;
+        case 'h':
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Empty GIA network.\n" );
+        return 1;
+    }
+    if ( Gia_ManHasMapping(pAbc->pGia) )
+    {
+        Abc_Print( -1, "Current AIG has mapping. Run \"&st\".\n" );
+        return 1;
+    }
+    if ( pPars->nLutSizeMux && pPars->fUseMux7 )
+    {
+        Abc_Print( -1, "Flags \"-M\" and \"-u\" are incompatible.\n" );
+        return 1;
+    }
+
+    pNew = Lf_ManPerformMapping( pAbc->pGia, pPars );
+    if ( pNew == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Lf(): Mapping into LUTs has failed.\n" );
+        return 1;
+    }
+    Abc_FrameUpdateGia( pAbc, pNew );
+    return 0;
+
+usage:
+    if ( pPars->DelayTarget == -1 )
+        sprintf(Buffer, "best possible" );
+    else
+        sprintf(Buffer, "%d", pPars->DelayTarget );
+    Abc_Print( -2, "usage: &lf [-KCFARLEDM num] [-kmupgtvwh]\n" );
+    Abc_Print( -2, "\t           performs technology mapping of the network\n" );
+    Abc_Print( -2, "\t-K num   : LUT size for the mapping (2 <= K <= %d) [default = %d]\n", pPars->nLutSizeMax, pPars->nLutSize );
+    Abc_Print( -2, "\t-C num   : the max number of priority cuts (1 <= C <= %d) [default = %d]\n", pPars->nCutNumMax, pPars->nCutNum );
+    Abc_Print( -2, "\t-F num   : the number of area flow rounds [default = %d]\n", pPars->nRounds );
+    Abc_Print( -2, "\t-A num   : the number of exact area rounds [default = %d]\n", pPars->nRoundsEla );
+    Abc_Print( -2, "\t-R num   : the delay relaxation ratio (num >= 0) [default = %d]\n", pPars->nRelaxRatio );
+    Abc_Print( -2, "\t-L num   : the fanout limit for coarsening XOR/MUX (num >= 2) [default = %d]\n", pPars->nCoarseLimit );
+    Abc_Print( -2, "\t-E num   : the area/edge tradeoff parameter (0 <= num <= 100) [default = %d]\n", pPars->nAreaTuner );
+    Abc_Print( -2, "\t-D num   : sets the delay constraint for the mapping [default = %s]\n", Buffer );
+    Abc_Print( -2, "\t-M num   : LUT size when cofactoring is performed (0 <= num <= 100) [default = %d]\n", pPars->nLutSizeMux );
+//    Abc_Print( -2, "\t-a       : toggles area-oriented mapping [default = %s]\n", pPars->fAreaOnly? "yes": "no" );
+    Abc_Print( -2, "\t-e       : toggles edge vs node minimization [default = %s]\n", pPars->fOptEdge? "yes": "no" );
+    Abc_Print( -2, "\t-k       : toggles coarsening the subject graph [default = %s]\n", pPars->fCoarsen? "yes": "no" );
+    Abc_Print( -2, "\t-m       : toggles cut minimization [default = %s]\n", pPars->fCutMin? "yes": "no" );
+    Abc_Print( -2, "\t-u       : toggles using additional MUXes [default = %s]\n", pPars->fUseMux7? "yes": "no" );
+    Abc_Print( -2, "\t-p       : toggles power-aware cut selection heuristics [default = %s]\n", pPars->fPower? "yes": "no" );
+    Abc_Print( -2, "\t-g       : toggles generating AIG without mapping [default = %s]\n", pPars->fPureAig? "yes": "no" );
+    Abc_Print( -2, "\t-t       : toggles optimizing average rather than maximum level [default = %s]\n", pPars->fDoAverage? "yes": "no" );
+    Abc_Print( -2, "\t-v       : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w       : toggles very verbose output [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : prints the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Mf( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    char Buffer[200];
+    Jf_Par_t Pars, * pPars = &Pars;
+    Gia_Man_t * pNew; int c;
+    Mf_ManSetDefaultPars( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "KCFARLEDWaekmcgvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nLutSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nLutSize < 2 || pPars->nLutSize > pPars->nLutSizeMax )
+            {
+                Abc_Print( -1, "LUT size %d is not supported.\n", pPars->nLutSize );
+                goto usage;
+            }
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nCutNum = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nCutNum < 1 || pPars->nCutNum > pPars->nCutNumMax )
+            {
+                Abc_Print( -1, "This number of cuts (%d) is not supported.\n", pPars->nCutNum );
+                goto usage;
+            }
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nRounds = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nRounds < 0 )
+                goto usage;
+            break;
+        case 'A':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-A\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nRoundsEla = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nRoundsEla < 0 )
+                goto usage;
+            break;
+        case 'R':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( 1, "Command line switch \"-R\" should be followed by a floating point number.\n" );
+                return 0;
+            }
+            pPars->nRelaxRatio = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nRelaxRatio < 0 ) 
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( 1, "Command line switch \"-R\" should be followed by a floating point number.\n" );
+                return 0;
+            }
+            pPars->nCoarseLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nCoarseLimit < 0 ) 
+                goto usage;
+            break;
+        case 'E':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( 1, "Command line switch \"-E\" should be followed by a floating point number.\n" );
+                return 0;
+            }
+            pPars->nAreaTuner = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nAreaTuner < 0 ) 
+                goto usage;
+            break;
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            pPars->DelayTarget = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->DelayTarget <= 0.0 )
+                goto usage;
+            break;
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nVerbLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nVerbLimit < 0 )
+                goto usage;
+            break;
+        case 'a':
+            pPars->fAreaOnly ^= 1;
+            break;
+        case 'e':
+            pPars->fOptEdge ^= 1;
+            break;
+        case 'k':
+            pPars->fCoarsen ^= 1;
+            break;
+        case 'm':
+            pPars->fCutMin ^= 1;
+            break;
+        case 'c':
+            pPars->fGenCnf ^= 1;
+            break;
+        case 'g':
+            pPars->fPureAig ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'w':
+            pPars->fVeryVerbose ^= 1;
+            break;
+        case 'h':
+        default:
+            goto usage;
+        }
+    }
+
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Empty GIA network.\n" );
+        return 1;
+    }
+
+    pNew = Mf_ManPerformMapping( pAbc->pGia, pPars );
+    if ( pNew == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Lf(): Mapping into LUTs has failed.\n" );
+        return 1;
+    }
+    if ( pPars->fGenCnf )
+        Cnf_DataFree( pAbc->pGia->pData ), pAbc->pGia->pData = NULL;
+    Abc_FrameUpdateGia( pAbc, pNew );
+    return 0;
+
+usage:
+    if ( pPars->DelayTarget == -1 )
+        sprintf(Buffer, "best possible" );
+    else
+        sprintf(Buffer, "%d", pPars->DelayTarget );
+    Abc_Print( -2, "usage: &mf [-KCFARLED num] [-akmcgvwh]\n" );
+    Abc_Print( -2, "\t           performs technology mapping of the network\n" );
+    Abc_Print( -2, "\t-K num   : LUT size for the mapping (2 <= K <= %d) [default = %d]\n", pPars->nLutSizeMax, pPars->nLutSize );
+    Abc_Print( -2, "\t-C num   : the max number of priority cuts (1 <= C <= %d) [default = %d]\n", pPars->nCutNumMax, pPars->nCutNum );
+    Abc_Print( -2, "\t-F num   : the number of area flow rounds [default = %d]\n", pPars->nRounds );
+    Abc_Print( -2, "\t-A num   : the number of exact area rounds [default = %d]\n", pPars->nRoundsEla );
+    Abc_Print( -2, "\t-R num   : the delay relaxation ratio (num >= 0) [default = %d]\n", pPars->nRelaxRatio );
+    Abc_Print( -2, "\t-L num   : the fanout limit for coarsening XOR/MUX (num >= 2) [default = %d]\n", pPars->nCoarseLimit );
+    Abc_Print( -2, "\t-E num   : the area/edge tradeoff parameter (0 <= num <= 100) [default = %d]\n", pPars->nAreaTuner );
+    Abc_Print( -2, "\t-D num   : sets the delay constraint for the mapping [default = %s]\n", Buffer );
+    Abc_Print( -2, "\t-a       : toggles area-oriented mapping [default = %s]\n", pPars->fAreaOnly? "yes": "no" );
+    Abc_Print( -2, "\t-e       : toggles edge vs node minimization [default = %s]\n", pPars->fOptEdge? "yes": "no" );
+    Abc_Print( -2, "\t-k       : toggles coarsening the subject graph [default = %s]\n", pPars->fCoarsen? "yes": "no" );
+    Abc_Print( -2, "\t-m       : toggles cut minimization [default = %s]\n", pPars->fCutMin? "yes": "no" );
+    Abc_Print( -2, "\t-c       : toggles mapping for CNF generation [default = %s]\n", pPars->fGenCnf? "yes": "no" );
+    Abc_Print( -2, "\t-g       : toggles generating AIG without mapping [default = %s]\n", pPars->fPureAig? "yes": "no" );
+    Abc_Print( -2, "\t-v       : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w       : toggles very verbose output [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : prints the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Nf( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern void Nf_ManSetDefaultPars( Jf_Par_t * pPars );
+    extern Gia_Man_t * Nf_ManPerformMapping( Gia_Man_t * pGia, Jf_Par_t * pPars );
+    extern Gia_Man_t * Pf_ManPerformMapping( Gia_Man_t * pGia, Jf_Par_t * pPars );
+    char Buffer[200];
+    Jf_Par_t Pars, * pPars = &Pars;
+    Gia_Man_t * pNew; int c;
+    Nf_ManSetDefaultPars( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "KCFARLEDWapkvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'K':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nLutSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nLutSize < 2 || pPars->nLutSize > pPars->nLutSizeMax )
+            {
+                Abc_Print( -1, "LUT size %d is not supported.\n", pPars->nLutSize );
+                goto usage;
+            }
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nCutNum = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nCutNum < 1 || pPars->nCutNum > pPars->nCutNumMax )
+            {
+                Abc_Print( -1, "This number of cuts (%d) is not supported.\n", pPars->nCutNum );
+                goto usage;
+            }
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nRounds = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nRounds < 0 )
+                goto usage;
+            break;
+        case 'A':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-A\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nRoundsEla = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nRoundsEla < 0 )
+                goto usage;
+            break;
+        case 'R':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( 1, "Command line switch \"-R\" should be followed by a floating point number.\n" );
+                return 0;
+            }
+            pPars->nRelaxRatio = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nRelaxRatio < 0 ) 
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( 1, "Command line switch \"-R\" should be followed by a floating point number.\n" );
+                return 0;
+            }
+            pPars->nCoarseLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nCoarseLimit < 0 ) 
+                goto usage;
+            break;
+        case 'E':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( 1, "Command line switch \"-E\" should be followed by a floating point number.\n" );
+                return 0;
+            }
+            pPars->nAreaTuner = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nAreaTuner < 0 ) 
+                goto usage;
+            break;
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            pPars->DelayTarget = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->DelayTarget <= 0.0 )
+                goto usage;
+            break;
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            pPars->nVerbLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nVerbLimit < 0 )
+                goto usage;
+            break;
+        case 'a':
+            pPars->fAreaOnly ^= 1;
+            break;
+        case 'p':
+            pPars->fPinPerm ^= 1;
+            break;
+        case 'k':
+            pPars->fCoarsen ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'w':
+            pPars->fVeryVerbose ^= 1;
+            break;
+        case 'h':
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Empty GIA network.\n" );
+        return 1;
+    }
+    if ( Abc_FrameReadLibGen() == NULL )
+    {
+        Abc_Print( -1, "Current library is not available.\n" );
+        return 1;
+    }
+//    if ( pPars->fAreaOnly )
+//        pNew = Pf_ManPerformMapping( pAbc->pGia, pPars );
+//    else
+        pNew = Nf_ManPerformMapping( pAbc->pGia, pPars );
+    if ( pNew == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Nf(): Mapping into LUTs has failed.\n" );
+        return 1;
+    }
+    Abc_FrameUpdateGia( pAbc, pNew );
+    return 0;
+
+usage:
+    if ( pPars->DelayTarget == -1 )
+        sprintf(Buffer, "best possible" );
+    else
+        sprintf(Buffer, "%d", pPars->DelayTarget );
+    Abc_Print( -2, "usage: &nf [-KCFARLED num] [-akpvwh]\n" );
+    Abc_Print( -2, "\t           performs technology mapping of the network\n" );
+    Abc_Print( -2, "\t-K num   : LUT size for the mapping (2 <= K <= %d) [default = %d]\n", pPars->nLutSizeMax, pPars->nLutSize );
+    Abc_Print( -2, "\t-C num   : the max number of priority cuts (1 <= C <= %d) [default = %d]\n", pPars->nCutNumMax, pPars->nCutNum );
+    Abc_Print( -2, "\t-F num   : the number of area flow rounds [default = %d]\n", pPars->nRounds );
+    Abc_Print( -2, "\t-A num   : the number of exact area rounds (when \'-a\' is used) [default = %d]\n", pPars->nRoundsEla );
+    Abc_Print( -2, "\t-R num   : the delay relaxation ratio (num >= 0) [default = %d]\n", pPars->nRelaxRatio );
+    Abc_Print( -2, "\t-L num   : the fanout limit for coarsening XOR/MUX (num >= 2) [default = %d]\n", pPars->nCoarseLimit );
+    Abc_Print( -2, "\t-E num   : the area/edge tradeoff parameter (0 <= num <= 100) [default = %d]\n", pPars->nAreaTuner );
+    Abc_Print( -2, "\t-D num   : sets the delay constraint for the mapping [default = %s]\n", Buffer );
+    Abc_Print( -2, "\t-a       : toggles area-oriented mapping [default = %s]\n", pPars->fAreaOnly? "yes": "no" );
+    Abc_Print( -2, "\t-k       : toggles coarsening the subject graph [default = %s]\n", pPars->fCoarsen? "yes": "no" );
+    Abc_Print( -2, "\t-p       : toggles pin-permutation (useful when pin-delays differ) [default = %s]\n", pPars->fPinPerm? "yes": "no" );
+    Abc_Print( -2, "\t-v       : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w       : toggles very verbose output [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : prints the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Unmap( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern void Gia_ManTestStruct( Gia_Man_t * p );
+    int c, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Struct(): There is no AIG to map.\n" );
+        return 1;
+    }
+    Vec_IntFreeP( &pAbc->pGia->vMapping );
+    Vec_IntFreeP( &pAbc->pGia->vPacking );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &unmap [-vh]\n" );
+    Abc_Print( -2, "\t           removes mapping from the current network\n" );
+    Abc_Print( -2, "\t-v       : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Struct( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern void Gia_ManTestStruct( Gia_Man_t * p );
+    int c, fVerbose;
+    // set defaults
+    fVerbose   = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Struct(): There is no AIG to map.\n" );
+        return 1;
+    }
+    if ( !Gia_ManHasMapping(pAbc->pGia) )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Struct(): Mapping of the AIG is not defined.\n" );
+        return 1;
+    }
+    if ( Gia_ManLutSizeMax(pAbc->pGia) >= 8 )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Struct(): Can only handle nodes with less than 8 inputs.\n" );
+        return 1;
+    }
+    Gia_ManTestStruct( pAbc->pGia );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &struct [-vh]\n" );
+    Abc_Print( -2, "\t           checks decomposition structures of the current mapping\n" );
+    Abc_Print( -2, "\t-v       : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Trace( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    int c;
+    int fUseLutLib;
+    int fVerbose;
+    // set defaults
+    fUseLutLib = 0;
+    fVerbose   = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "lvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'l':
+            fUseLutLib ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Speedup(): There is no AIG to map.\n" );
+        return 1;
+    }
+    if ( !Gia_ManHasMapping(pAbc->pGia) )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Speedup(): Mapping of the AIG is not defined.\n" );
+        return 1;
+    }
+    pAbc->pGia->pLutLib = fUseLutLib ? pAbc->pLibLut : NULL;
+    Gia_ManDelayTraceLutPrint( pAbc->pGia, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &trace [-lvh]\n" );
+    Abc_Print( -2, "\t           performs delay trace of LUT-mapped network\n" );
+    Abc_Print( -2, "\t-l       : toggle using unit- or LUT-library-delay model [default = %s]\n", fUseLutLib? "lib": "unit" );
+    Abc_Print( -2, "\t-v       : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Speedup( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pTemp;
+    int fUseLutLib;
+    int Percentage;
+    int Degree;
+    int fVerbose;
+    int c, fVeryVerbose;
+
+    // set defaults
+    fUseLutLib   = 0;
+    Percentage   = 5;
+    Degree       = 2;
+    fVerbose     = 0;
+    fVeryVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "PNlvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'P':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            Percentage = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( Percentage < 1 || Percentage > 100 )
+                goto usage;
+            break;
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            Degree = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( Degree < 1 || Degree > 5 )
+                goto usage;
+            break;
+        case 'l':
+            fUseLutLib ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'w':
+            fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Speedup(): There is no AIG to map.\n" );
+        return 1;
+    }
+    if ( !Gia_ManHasMapping(pAbc->pGia) )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Speedup(): Mapping of the AIG is not defined.\n" );
+        return 1;
+    }
+    pAbc->pGia->pLutLib = fUseLutLib ? pAbc->pLibLut : NULL;
+    pTemp = Gia_ManSpeedup( pAbc->pGia, Percentage, Degree, fVerbose, fVeryVerbose );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &speedup [-P num] [-N num] [-lvwh]\n" );
+    Abc_Print( -2, "\t           transforms LUT-mapped network into an AIG with choices;\n" );
+    Abc_Print( -2, "\t           the choices are added to speedup the next round of mapping\n" );
+    Abc_Print( -2, "\t-P <num> : delay delta defining critical path for library model [default = %d%%]\n", Percentage );
+    Abc_Print( -2, "\t-N <num> : the max critical path degree for resynthesis (0 < num < 6) [default = %d]\n", Degree );
+    Abc_Print( -2, "\t-l       : toggle using unit- or LUT-library-delay model [default = %s]\n", fUseLutLib? "lib" : "unit" );
+    Abc_Print( -2, "\t-v       : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w       : toggle printing detailed stats for each node [default = %s]\n", fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Era( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+//    Gia_Man_t * pTemp = NULL;
+    int c, fVerbose = 0;
+    int fUseCubes = 1;
+    int fDumpFile = 0;
+    int fMiter = 0;
+    int nStatesMax = 1000000000;
+    extern int Gia_ManCollectReachable( Gia_Man_t * pAig, int nStatesMax, int fMiter, int fDumpFile, int fVerbose );
+    extern int Gia_ManArePerform( Gia_Man_t * pAig, int nStatesMax, int fMiter, int fVerbose );
+
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Smcdvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            nStatesMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nStatesMax < 0 )
+                goto usage;
+            break;
+        case 'm':
+            fMiter ^= 1;
+            break;
+        case 'c':
+            fUseCubes ^= 1;
+            break;
+        case 'd':
+            fDumpFile ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Era(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Era(): The network is combinational.\n" );
+        return 1;
+    }
+    if ( !fUseCubes && Gia_ManPiNum(pAbc->pGia) > 12 )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Era(): The number of PIs (%d) should be no more than 12 when cubes are not used.\n", Gia_ManPiNum(pAbc->pGia) );
+        return 1;
+    }
+    if ( fUseCubes && !fDumpFile )
+        pAbc->Status = Gia_ManArePerform( pAbc->pGia, nStatesMax, fMiter, fVerbose );
+    else
+        pAbc->Status = Gia_ManCollectReachable( pAbc->pGia, nStatesMax, fMiter, fDumpFile, fVerbose );
+    Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexSeq );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &era [-S num] [-mcdvh]\n" );
+    Abc_Print( -2, "\t          explicit reachability analysis for small sequential AIGs\n" );
+    Abc_Print( -2, "\t-S num  : the max number of states (num > 0) [default = %d]\n", nStatesMax );
+    Abc_Print( -2, "\t-m      : stop when the miter output is 1 [default = %s]\n", fMiter? "yes": "no" );
+    Abc_Print( -2, "\t-c      : use state cubes instead of state minterms [default = %s]\n", fUseCubes? "yes": "no" );
+    Abc_Print( -2, "\t-d      : toggle dumping STG into a file [default = %s]\n", fDumpFile? "yes": "no" );
+    Abc_Print( -2, "\t-v      : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h      : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Dch( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pTemp;
+    Dch_Pars_t Pars, * pPars = &Pars;
+    int c;
+    // set defaults
+    Dch_ManSetDefaultParams( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "WCSsptfvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nWords = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nWords < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nBTLimit < 0 )
+                goto usage;
+            break;
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nSatVarMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nSatVarMax < 0 )
+                goto usage;
+            break;
+        case 's':
+            pPars->fSynthesis ^= 1;
+            break;
+        case 'p':
+            pPars->fPower ^= 1;
+            break;
+        case 't':
+            pPars->fSimulateTfo ^= 1;
+            break;
+        case 'f':
+            pPars->fLightSynth ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Dch(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( Gia_ManBufNum(pAbc->pGia) )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Dch(): This command does not work with barrier buffers.\n" );
+        return 1;
+    }
+    pTemp = Gia_ManPerformDch( pAbc->pGia, pPars );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &dch [-WCS num] [-sptfvh]\n" );
+    Abc_Print( -2, "\t         computes structural choices using a new approach\n" );
+    Abc_Print( -2, "\t-W num : the max number of simulation words [default = %d]\n", pPars->nWords );
+    Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
+    Abc_Print( -2, "\t-S num : the max number of SAT variables [default = %d]\n", pPars->nSatVarMax );
+    Abc_Print( -2, "\t-s     : toggle synthesizing three snapshots [default = %s]\n", pPars->fSynthesis? "yes": "no" );
+    Abc_Print( -2, "\t-p     : toggle power-aware rewriting [default = %s]\n", pPars->fPower? "yes": "no" );
+    Abc_Print( -2, "\t-t     : toggle simulation of the TFO classes [default = %s]\n", pPars->fSimulateTfo? "yes": "no" );
+    Abc_Print( -2, "\t-f     : toggle using lighter logic synthesis [default = %s]\n", pPars->fLightSynth? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Rpm( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pTemp;
+    int c, nCutMax   = 16;
+    int fUseOldAlgo  =  0;
+    int fVerbose     =  0;
+    int fVeryVerbose =  0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Cavwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nCutMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nCutMax < 0 )
+                goto usage;
+            break;
+        case 'a':
+            fUseOldAlgo ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'w':
+            fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Rpm(): There is no AIG.\n" );
+        return 0;
+    }
+    if ( fUseOldAlgo )
+        pTemp = Abs_RpmPerformOld( pAbc->pGia, fVerbose );
+    else
+        pTemp = Abs_RpmPerform( pAbc->pGia, nCutMax, fVerbose, fVeryVerbose );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &rpm [-C num] [-avwh]\n" );
+    Abc_Print( -2, "\t         performs structural reparametrization\n" );
+    Abc_Print( -2, "\t-C num : max cut size for testing range equivalence [default = %d]\n", nCutMax );
+    Abc_Print( -2, "\t-a     : toggle using old algorithm [default = %s]\n", fUseOldAlgo? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w     : toggle printing more verbose information [default = %s]\n", fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9BackReach( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Gia_Man_t * Gia_ManCofTest( Gia_Man_t * pGia, int nFrameMax, int nConfMax, int nTimeMax, int fVerbose );
+
+    Gia_Man_t * pTemp = NULL;
+    int c, fVerbose = 0;
+    int nFrameMax = 1000000;
+    int nConfMax  = 1000000;
+    int nTimeMax  =      10;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "FCTvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFrameMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFrameMax < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nConfMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nConfMax < 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nTimeMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nTimeMax < 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9BackReach(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( Gia_ManPoNum(pAbc->pGia) != 1 )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9BackReach(): The number of POs is different from 1.\n" );
+        return 1;
+    }
+    pTemp = Gia_ManCofTest( pAbc->pGia, nFrameMax, nConfMax, nTimeMax, fVerbose );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &back_reach [-FCT <num>] [-vh]\n" );
+    Abc_Print( -2, "\t         performs backward reachability by circuit cofactoring\n" );
+    Abc_Print( -2, "\t-F num : the limit on the depth of induction [default = %d]\n", nFrameMax );
+    Abc_Print( -2, "\t-C num : the conflict limit at a node during induction [default = %d]\n", nConfMax );
+    Abc_Print( -2, "\t-T num : the timeout for property directed reachability [default = %d]\n", nTimeMax );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Posplit( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Aig_Man_t * Aig_ManSplit( Aig_Man_t * p, int nVars, int fVerbose );
+    Aig_Man_t * pMan, * pAux;
+    Gia_Man_t * pTemp = NULL;
+    int c, nVars = 5, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Nvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nVars = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nVars < 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Posplit(): There is no AIG.\n" );
+        return 1;
+    }
+    pMan = Gia_ManToAigSimple( pAbc->pGia );
+    pMan = Aig_ManSplit( pAux = pMan, nVars, fVerbose );
+    Aig_ManStop( pAux );
+    if ( pMan != NULL )
+    {
+        pTemp = Gia_ManFromAigSimple( pMan );
+        Aig_ManStop( pMan );
+        Abc_FrameUpdateGia( pAbc, pTemp );
+    }
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &posplit [-N num] [-vh]\n" );
+    Abc_Print( -2, "\t         cofactors the property output w.r.t. a support subset\n" );
+    Abc_Print( -2, "\t         (the OR of new PO functions is equal to the original property)\n" );
+    Abc_Print( -2, "\t-N num : the number of random cofactoring variables [default = %d]\n", nVars );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9ReachM( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+//    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    Gia_ParLlb_t Pars, * pPars = &Pars;
+    char * pLogFileName = NULL;
+    int c;
+    extern int Llb_ManModelCheckGia( Gia_Man_t * pGia, Gia_ParLlb_t * pPars );
+
+    // set defaults
+    Llb_ManSetDefaultParams( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "TBFCHSLripcsyzvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->TimeLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->TimeLimit < 0 )
+                goto usage;
+            break;
+        case 'B':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nBddMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nBddMax < 0 )
+                goto usage;
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nIterMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nIterMax < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nClusterMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nClusterMax < 0 )
+                goto usage;
+            break;
+        case 'H':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-H\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nHintDepth = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nHintDepth < 0 )
+                goto usage;
+            break;
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->HintFirst = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->HintFirst < 0 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by a file name.\n" );
+                goto usage;
+            }
+            pLogFileName = argv[globalUtilOptind];
+            globalUtilOptind++;
+            break;
+        case 'r':
+            pPars->fReorder ^= 1;
+            break;
+        case 'i':
+            pPars->fIndConstr ^= 1;
+            break;
+        case 'p':
+            pPars->fUsePivots ^= 1;
+            break;
+        case 'c':
+            pPars->fCluster ^= 1;
+            break;
+        case 's':
+            pPars->fSchedule ^= 1;
+            break;
+        case 'y':
+            pPars->fSkipOutCheck ^= 1;
+            break;
+        case 'z':
+            pPars->fSkipReach ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'w':
+            pPars->fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9ReachM(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9ReachM(): The current AIG has no latches.\n" );
+        return 0;
+    }
+    if ( Gia_ManObjNum(pAbc->pGia) >= (1<<16) )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9ReachM(): Currently cannot handle AIGs with more than %d objects.\n", (1<<16) );
+        return 0;
+    }
+    pAbc->Status  = Llb_ManModelCheckGia( pAbc->pGia, pPars );
+    pAbc->nFrames = pPars->iFrame;
+    Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexSeq );
+    if ( pLogFileName )
+        Abc_NtkWriteLogFile( pLogFileName, pAbc->pCex, pAbc->Status, pAbc->nFrames, "&reachm" );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &reachm [-TBFCHS num] [-L file] [-ripcsyzvwh]\n" );
+    Abc_Print( -2, "\t         model checking via BDD-based reachability (dependence-matrix-based)\n" );
+    Abc_Print( -2, "\t-T num : approximate time limit in seconds (0=infinite) [default = %d]\n", pPars->TimeLimit );
+    Abc_Print( -2, "\t-B num : max number of nodes in the intermediate BDDs [default = %d]\n", pPars->nBddMax );
+    Abc_Print( -2, "\t-F num : max number of reachability iterations [default = %d]\n", pPars->nIterMax );
+    Abc_Print( -2, "\t-C num : max number of variables in a cluster [default = %d]\n", pPars->nClusterMax );
+    Abc_Print( -2, "\t-H num : max number of hints to use [default = %d]\n", pPars->nHintDepth );
+    Abc_Print( -2, "\t-S num : the number of the starting hint [default = %d]\n", pPars->HintFirst );
+    Abc_Print( -2, "\t-L file: the log file name [default = %s]\n", pLogFileName ? pLogFileName : "no logging" );
+    Abc_Print( -2, "\t-r     : enable dynamic BDD variable reordering [default = %s]\n", pPars->fReorder? "yes": "no" );
+    Abc_Print( -2, "\t-i     : enable extraction of inductive constraints [default = %s]\n", pPars->fIndConstr? "yes": "no" );
+    Abc_Print( -2, "\t-p     : enable partitions for internal cut-points [default = %s]\n", pPars->fUsePivots? "yes": "no" );
+    Abc_Print( -2, "\t-c     : enable clustering of partitions [default = %s]\n", pPars->fCluster? "yes": "no" );
+    Abc_Print( -2, "\t-s     : enable scheduling of clusters [default = %s]\n", pPars->fSchedule? "yes": "no" );
+    Abc_Print( -2, "\t-y     : skip checking property outputs [default = %s]\n", pPars->fSkipOutCheck? "yes": "no" );
+    Abc_Print( -2, "\t-z     : skip reachability (run preparation phase only) [default = %s]\n", pPars->fSkipReach? "yes": "no" );
+    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w     : prints dependency matrix [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9ReachP( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+//    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    Gia_ParLlb_t Pars, * pPars = &Pars;
+    Aig_Man_t * pMan;
+    char * pLogFileName = NULL;
+    int c;
+    extern int Llb_ManReachMinCut( Aig_Man_t * pAig, Gia_ParLlb_t * pPars );
+
+    // set defaults
+    Llb_ManSetDefaultParams( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "NBFTLrbyzdvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nPartValue = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nPartValue < 0 )
+                goto usage;
+            break;
+        case 'B':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nBddMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nBddMax < 0 )
+                goto usage;
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nIterMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nIterMax < 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->TimeLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->TimeLimit < 0 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by a file name.\n" );
+                goto usage;
+            }
+            pLogFileName = argv[globalUtilOptind];
+            globalUtilOptind++;
+            break;
+        case 'r':
+            pPars->fReorder ^= 1;
+            break;
+        case 'b':
+            pPars->fBackward ^= 1;
+            break;
+        case 'y':
+            pPars->fSkipOutCheck ^= 1;
+            break;
+        case 'z':
+            pPars->fSkipReach ^= 1;
+            break;
+        case 'd':
+            pPars->fDumpReached ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'w':
+            pPars->fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9ReachP(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9ReachP(): The current AIG has no latches.\n" );
+        return 0;
+    }
+    if ( Gia_ManObjNum(pAbc->pGia) >= (1<<16) )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9ReachP(): Currently cannot handle AIGs with more than %d objects.\n", (1<<16) );
+        return 0;
+    }
+    pMan          = Gia_ManToAigSimple( pAbc->pGia );
+    pAbc->Status  = Llb_ManReachMinCut( pMan, pPars );
+    pAbc->nFrames = pPars->iFrame;
+    Abc_FrameReplaceCex( pAbc, &pMan->pSeqModel );
+    if ( pLogFileName )
+        Abc_NtkWriteLogFile( pLogFileName, pAbc->pCex, pAbc->Status, pAbc->nFrames, "&reachp" );
+    Aig_ManStop( pMan );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &reachp [-NFT num] [-L file] [-rbyzdvwh]\n" );
+    Abc_Print( -2, "\t         model checking via BDD-based reachability (partitioning-based)\n" );
+    Abc_Print( -2, "\t-N num : partitioning value (MinVol=nANDs/N/2; MaxVol=nANDs/N) [default = %d]\n", pPars->nPartValue );
+//    Abc_Print( -2, "\t-B num : the BDD node increase when hints kick in [default = %d]\n", pPars->nBddMax );
+    Abc_Print( -2, "\t-F num : max number of reachability iterations [default = %d]\n", pPars->nIterMax );
+    Abc_Print( -2, "\t-T num : approximate time limit in seconds (0=infinite) [default = %d]\n", pPars->TimeLimit );
+    Abc_Print( -2, "\t-L file: the log file name [default = %s]\n", pLogFileName ? pLogFileName : "no logging" );
+    Abc_Print( -2, "\t-r     : enable additional BDD var reordering before image [default = %s]\n", pPars->fReorder? "yes": "no" );
+    Abc_Print( -2, "\t-b     : perform backward reachability analysis [default = %s]\n", pPars->fBackward? "yes": "no" );
+    Abc_Print( -2, "\t-y     : skip checking property outputs [default = %s]\n", pPars->fSkipOutCheck? "yes": "no" );
+    Abc_Print( -2, "\t-z     : skip reachability (run preparation phase only) [default = %s]\n", pPars->fSkipReach? "yes": "no" );
+    Abc_Print( -2, "\t-d     : dump BDD of reached states into file \"reached.blif\" [default = %s]\n", pPars->fDumpReached? "yes": "no" );
+    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w     : prints additional information [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9ReachN( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+//    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    Gia_ParLlb_t Pars, * pPars = &Pars;
+    Aig_Man_t * pMan;
+    char * pLogFileName = NULL;
+    int c;
+    extern int Llb_NonlinCoreReach( Aig_Man_t * pAig, Gia_ParLlb_t * pPars );
+
+    // set defaults
+    Llb_ManSetDefaultParams( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "BFTLryzvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'B':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nBddMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nBddMax < 0 )
+                goto usage;
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nIterMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nIterMax < 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->TimeLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->TimeLimit < 0 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by a file name.\n" );
+                goto usage;
+            }
+            pLogFileName = argv[globalUtilOptind];
+            globalUtilOptind++;
+            break;
+        case 'r':
+            pPars->fReorder ^= 1;
+            break;
+        case 'y':
+            pPars->fSkipOutCheck ^= 1;
+            break;
+        case 'z':
+            pPars->fSkipReach ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'w':
+            pPars->fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9ReachN(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9ReachN(): The current AIG has no latches.\n" );
+        return 0;
+    }
+    if ( Gia_ManObjNum(pAbc->pGia) >= (1<<16) )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9ReachN(): Currently cannot handle AIGs with more than %d objects.\n", (1<<16) );
+        return 0;
+    }
+    pMan          = Gia_ManToAigSimple( pAbc->pGia );
+    pAbc->Status  = Llb_NonlinCoreReach( pMan, pPars );
+    pAbc->nFrames = pPars->iFrame;
+    Abc_FrameReplaceCex( pAbc, &pMan->pSeqModel );
+    if ( pLogFileName )
+        Abc_NtkWriteLogFile( pLogFileName, pAbc->pCex, pAbc->Status, pAbc->nFrames, "&reachn" );
+    Aig_ManStop( pMan );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &reachn [-BFT num] [-L file] [-ryzvh]\n" );
+    Abc_Print( -2, "\t         model checking via BDD-based reachability (non-linear-QS-based)\n" );
+    Abc_Print( -2, "\t-B num : the BDD node increase when hints kick in [default = %d]\n", pPars->nBddMax );
+    Abc_Print( -2, "\t-F num : max number of reachability iterations [default = %d]\n", pPars->nIterMax );
+    Abc_Print( -2, "\t-T num : approximate time limit in seconds (0=infinite) [default = %d]\n", pPars->TimeLimit );
+    Abc_Print( -2, "\t-L file: the log file name [default = %s]\n", pLogFileName ? pLogFileName : "no logging" );
+    Abc_Print( -2, "\t-r     : enable additional BDD var reordering before image [default = %s]\n", pPars->fReorder? "yes": "no" );
+    Abc_Print( -2, "\t-y     : skip checking property outputs [default = %s]\n", pPars->fSkipOutCheck? "yes": "no" );
+    Abc_Print( -2, "\t-z     : skip reachability (run preparation phase only) [default = %s]\n", pPars->fSkipReach? "yes": "no" );
+    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+//    Abc_Print( -2, "\t-w     : prints additional information [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9ReachY( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+//    Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+    Gia_ParLlb_t Pars, * pPars = &Pars;
+    Aig_Man_t * pMan;
+    char * pLogFileName = NULL;
+    int c;
+
+    // set defaults
+    Llb_ManSetDefaultParams( pPars );
+    pPars->fCluster = 0;
+    pPars->fReorder = 0;
+    pPars->nBddMax     = 100;
+    pPars->nClusterMax = 500;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "BCFTLbcryzvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'B':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nBddMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nBddMax < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nClusterMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nClusterMax < 0 )
+                goto usage;
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nIterMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nIterMax < 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->TimeLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->TimeLimit < 0 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by a file name.\n" );
+                goto usage;
+            }
+            pLogFileName = argv[globalUtilOptind];
+            globalUtilOptind++;
+            break;
+        case 'b':
+            pPars->fBackward ^= 1;
+            break;
+        case 'c':
+            pPars->fCluster ^= 1;
+            break;
+        case 'r':
+            pPars->fReorder ^= 1;
+            break;
+        case 'y':
+            pPars->fSkipOutCheck ^= 1;
+            break;
+        case 'z':
+            pPars->fSkipReach ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'w':
+            pPars->fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9ReachN(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9ReachN(): The current AIG has no latches.\n" );
+        return 0;
+    }
+/*
+    if ( Gia_ManObjNum(pAbc->pGia) >= (1<<16) )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9ReachN(): Currently cannot handle AIGs with more than %d objects.\n", (1<<16) );
+        return 0;
+    }
+*/
+    pMan          = Gia_ManToAigSimple( pAbc->pGia );
+    pAbc->Status  = Llb_Nonlin4CoreReach( pMan, pPars );
+    pAbc->nFrames = pPars->iFrame;
+    Abc_FrameReplaceCex( pAbc, &pMan->pSeqModel );
+    if ( pLogFileName )
+        Abc_NtkWriteLogFile( pLogFileName, pAbc->pCex, pAbc->Status, pAbc->nFrames, "&reachy" );
+    Aig_ManStop( pMan );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &reachy [-BCFT num] [-L file] [-bcryzvh]\n" );
+    Abc_Print( -2, "\t         model checking via BDD-based reachability (non-linear-QS-based)\n" );
+    Abc_Print( -2, "\t-B num : the max BDD size to introduce cut points [default = %d]\n", pPars->nBddMax );
+    Abc_Print( -2, "\t-C num : the max BDD size to reparameterize/cluster [default = %d]\n", pPars->nClusterMax );
+    Abc_Print( -2, "\t-F num : max number of reachability iterations [default = %d]\n", pPars->nIterMax );
+    Abc_Print( -2, "\t-T num : approximate time limit in seconds (0=infinite) [default = %d]\n", pPars->TimeLimit );
+    Abc_Print( -2, "\t-L file: the log file name [default = %s]\n", pLogFileName ? pLogFileName : "no logging" );
+    Abc_Print( -2, "\t-b     : enable using backward enumeration [default = %s]\n", pPars->fBackward? "yes": "no" );
+    Abc_Print( -2, "\t-c     : enable reparametrization clustering [default = %s]\n", pPars->fCluster? "yes": "no" );
+    Abc_Print( -2, "\t-r     : enable additional BDD var reordering before image [default = %s]\n", pPars->fReorder? "yes": "no" );
+    Abc_Print( -2, "\t-y     : skip checking property outputs [default = %s]\n", pPars->fSkipOutCheck? "yes": "no" );
+    Abc_Print( -2, "\t-z     : skip reachability (run preparation phase only) [default = %s]\n", pPars->fSkipReach? "yes": "no" );
+    Abc_Print( -2, "\t-v     : prints verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+//    Abc_Print( -2, "\t-w     : prints additional information [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Undo( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    int c;
+    // set defaults
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Undo(): There is no design.\n" );
+        return 1;
+    }
+    if ( pAbc->pGia2 == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Undo(): There is no previously saved network.\n" );
+        return 1;
+    }
+    Gia_ManStop( pAbc->pGia );
+    pAbc->pGia = pAbc->pGia2;
+    pAbc->pGia2 = NULL;
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &undo [-h]\n" );
+    Abc_Print( -2, "\t        reverses the previous AIG transformation\n" );
+    Abc_Print( -2, "\t-h    : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Iso( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pAig;
+    Vec_Ptr_t * vPosEquivs;
+//    Vec_Ptr_t * vPiPerms;
+    int c, fNewAlgo = 1, fEstimate = 0, fBetterQual = 0, fDualOut = 0, fVerbose = 0, fVeryVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "neqdvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'n':
+            fNewAlgo ^= 1;
+            break;
+        case 'e':
+            fEstimate ^= 1;
+            break;
+        case 'q':
+            fBetterQual ^= 1;
+            break;
+        case 'd':
+            fDualOut ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'w':
+            fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Iso(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( Gia_ManPoNum(pAbc->pGia) == 1 )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Iso(): The AIG has only one PO. Isomorphism detection is not performed.\n" );
+        return 1;
+    }
+    if ( fNewAlgo )
+        pAig = Gia_ManIsoReduce2( pAbc->pGia, &vPosEquivs, NULL, fEstimate, fBetterQual, fDualOut, fVerbose, fVeryVerbose );
+    else
+        pAig = Gia_ManIsoReduce( pAbc->pGia, &vPosEquivs, NULL, fEstimate, fDualOut, fVerbose, fVeryVerbose );
+//    pAig = Gia_ManIsoReduce( pAbc->pGia, &vPosEquivs, &vPiPerms, 0, fDualOut, fVerbose, fVeryVerbose );
+//    Vec_VecFree( (Vec_Vec_t *)vPiPerms );
+    if ( pAig == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Iso(): Transformation has failed.\n" );
+        return 1;
+    }
+    // update the internal storage of PO equivalences
+    Abc_FrameReplacePoEquivs( pAbc, &vPosEquivs );
+    // update the AIG
+    Abc_FrameUpdateGia( pAbc, pAig );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &iso [-neqdvwh]\n" );
+    Abc_Print( -2, "\t         removes POs with isomorphic sequential COI\n" );
+    Abc_Print( -2, "\t-n     : toggle using new fast algorithm [default = %s]\n", fNewAlgo? "yes": "no" );
+    Abc_Print( -2, "\t-e     : toggle computing lower bound on equivalence classes [default = %s]\n", fEstimate? "yes": "no" );
+    Abc_Print( -2, "\t-q     : toggle improving quality at the expense of runtime [default = %s]\n", fBetterQual? "yes": "no" );
+    Abc_Print( -2, "\t-d     : toggle treating the current AIG as a dual-output miter [default = %s]\n", fDualOut? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w     : toggle printing very verbose information [default = %s]\n", fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9CexInfo( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern void Bmc_CexTest( Gia_Man_t * p, Abc_Cex_t * pCex, int fVerbose );
+    int c, fDualOut = 0, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "dvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'd':
+            fDualOut ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9CexInfo(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( pAbc->pCex == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9CexInfo(): There is no CEX.\n" );
+        return 1;
+    }
+    Bmc_CexTest( pAbc->pGia, pAbc->pCex, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &cexinfo [-vh]\n" );
+    Abc_Print( -2, "\t         prints information about the current counter-example\n" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Cycle( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pTemp;
+    int c, nFrames = 10, fUseCex = 0, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Fcvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFrames = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFrames < 0 )
+                goto usage;
+            break;
+        case 'c':
+            fUseCex ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Cycle(): There is no AIG.\n" );
+        return 1;
+    }
+    pTemp = Gia_ManDupCycled( pAbc->pGia, fUseCex ? pAbc->pCex : NULL, nFrames );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &cycle [-F num] [-cvh]\n" );
+    Abc_Print( -2, "\t         cycles sequential circuit for the given number of timeframes\n" );
+    Abc_Print( -2, "\t         to derive a new initial state (which may be on the envelope)\n" );
+    Abc_Print( -2, "\t-F num : the number of frames to simulate [default = %d]\n", nFrames );
+    Abc_Print( -2, "\t-c     : toggle using PI values from the current CEX [default = %s]\n", fUseCex? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Cone( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pTemp;
+    Vec_Int_t * vPos;
+    int c, iOutNum = -1, nOutRange = 1, iPartNum = -1, nLevelMax = 0, nTimeWindow = 0, fUseAllCis = 0, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "ORPLWavh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'O':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-O\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            iOutNum = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( iOutNum < 0 )
+                goto usage;
+            break;
+        case 'R':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nOutRange = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nOutRange < 0 )
+                goto usage;
+            break;
+        case 'P':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            iPartNum = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( iPartNum < 0 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nLevelMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nLevelMax < 0 )
+                goto usage;
+            break;
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nTimeWindow = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nTimeWindow < 0 )
+                goto usage;
+            break;
+        case 'a':
+            fUseAllCis ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Cone(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( nLevelMax || nTimeWindow )
+    {
+        if ( nLevelMax && nTimeWindow )
+        {
+            Abc_Print( -1, "Abc_CommandAbc9Cone(): Parameters -L (max level) and -W (timing window) cannot be specified at the same time.\n" );
+            return 1;
+        }
+        else
+        {
+            pTemp = Gia_ManExtractWindow( pAbc->pGia, nLevelMax, nTimeWindow, fVerbose );
+            Abc_FrameUpdateGia( pAbc, pTemp );
+            return 0;
+        }
+    }
+    if ( iPartNum >= 0 )
+    {
+        Vec_Int_t * vClass;
+        Vec_Vec_t * vClasses = (Vec_Vec_t *)pAbc->vPoEquivs;
+        if ( vClasses == NULL )
+        {
+            Abc_Print( -1, "Abc_CommandAbc9Cone(): Partitions are not defined.\n" );
+            return 1;
+        }
+        if ( iPartNum >= Vec_VecSize(vClasses) )
+        {
+            Abc_Print( -1, "Abc_CommandAbc9Cone(): Partition index exceed the array size.\n" );
+            return 1;
+        }
+        vClass = Vec_VecEntryInt( vClasses, iPartNum );
+        pTemp = Gia_ManDupCones( pAbc->pGia, Vec_IntArray(vClass), Vec_IntSize(vClass), !fUseAllCis );
+        if ( pTemp )
+            Abc_FrameUpdateGia( pAbc, pTemp );
+        return 0;
+    }
+    if ( iOutNum < 0 || iOutNum + nOutRange > Gia_ManPoNum(pAbc->pGia) )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Cone(): Range of outputs to extract is incorrect.\n" );
+        return 1;
+    }
+    vPos = Vec_IntStartRange( iOutNum, nOutRange );
+    pTemp = Gia_ManDupCones( pAbc->pGia, Vec_IntArray(vPos), nOutRange, !fUseAllCis );
+    Vec_IntFree( vPos );
+    if ( pTemp )
+        Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &cone [-ORPLW num] [-avh]\n" );
+    Abc_Print( -2, "\t         extracting multi-output sequential logic cones\n" );
+    Abc_Print( -2, "\t-O num : the index of first PO to extract [default = %d]\n", iOutNum );
+    Abc_Print( -2, "\t-R num : (optional) the number of outputs to extract [default = %d]\n", nOutRange );
+    Abc_Print( -2, "\t-P num : (optional) the partition number to extract [default = %d]\n", iPartNum );
+    Abc_Print( -2, "\t-L num : (optional) extract cones with higher level [default = %d]\n", nLevelMax );
+    Abc_Print( -2, "\t-W num : (optional) extract cones falling into this window [default = %d]\n", nTimeWindow );
+    Abc_Print( -2, "\t-a     : toggle keeping all CIs or structral support only [default = %s]\n", fUseAllCis? "all": "structural" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Slice( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Gia_Man_t * pTemp;
+    int c, nSuppSize = 6, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Svh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nSuppSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nSuppSize < 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Slice(): There is no AIG.\n" );
+        return 1;
+    }
+    pTemp = Gia_ManDupSliced( pAbc->pGia, nSuppSize );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &slice [-S num] [-vh]\n" );
+    Abc_Print( -2, "\t         cuts the lower part of the AIG with nodes using their support\n" );
+    Abc_Print( -2, "\t-S num : the largest support size to keep in the slide [default = %d]\n", nSuppSize );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9PoPart( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Gia_Man_t * Gia_ManFindPoPartition( Gia_Man_t * p, int SelectShift, int fOnlyCis, int fSetLargest, int fVerbose, Vec_Ptr_t ** pvPosEquivs );
+    Gia_Man_t * pTemp;
+    Vec_Ptr_t * vPosEquivs = NULL;
+    int c, SelectShift = 0, fOnlyCis = 0, fSetLargest = 0, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Simvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            SelectShift = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( SelectShift < 0 )
+                goto usage;
+            break;
+        case 'i':
+            fOnlyCis ^= 1;
+            break;
+        case 'm':
+            fSetLargest ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9PoPart(): There is no AIG.\n" );
+        return 1;
+    }
+    pTemp = Gia_ManFindPoPartition( pAbc->pGia, SelectShift, fOnlyCis, fSetLargest, fVerbose, &vPosEquivs );
+    if ( pTemp )
+        Abc_FrameUpdateGia( pAbc, pTemp );
+    Abc_FrameReplacePoEquivs( pAbc, &vPosEquivs );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &popart [-S num] [-imvh]\n" );
+    Abc_Print( -2, "\t         partitioning of POs into equivalence classes\n" );
+    Abc_Print( -2, "\t-S num : random seed to select the set of pivot nodes [default = %d]\n", SelectShift );
+    Abc_Print( -2, "\t       : (if the seed is 0, the nodes with max fanout counts are used)\n" );
+    Abc_Print( -2, "\t-i     : toggle allowing only CIs to be the pivots [default = %s]\n", fOnlyCis? "yes": "no" );
+    Abc_Print( -2, "\t-m     : toggle using the largest part as the current network [default = %s]\n", fSetLargest? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9PoPart2( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Gia_Man_t * Gia_ManFindPoPartition2( Gia_Man_t * p, int iStartNum, int nDelta, int nOutsMin, int nOutsMax, int fSetLargest, int fVerbose, Vec_Ptr_t ** pvPosEquivs );
+    Gia_Man_t * pTemp = NULL;
+    Vec_Ptr_t * vPosEquivs = NULL;
+    int c, iStartNum = 0, nDelta = 10, nOutsMin = 100, nOutsMax = 1000, fSetLargest = 0, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "SDLUmvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            iStartNum = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( iStartNum < 0 )
+                goto usage;
+            break;
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nDelta = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nDelta < 0 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nOutsMin = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nOutsMin < 0 )
+                goto usage;
+            break;
+        case 'U':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-U\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nOutsMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nOutsMax < 0 )
+                goto usage;
+            break;
+        case 'm':
+            fSetLargest ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9PoPart(): There is no AIG.\n" );
+        return 1;
+    }
+    pTemp = Gia_ManFindPoPartition2( pAbc->pGia, iStartNum, nDelta, nOutsMin, nOutsMax, fSetLargest, fVerbose, &vPosEquivs );
+    if ( pTemp )
+        Abc_FrameUpdateGia( pAbc, pTemp );
+    Abc_FrameReplacePoEquivs( pAbc, &vPosEquivs );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &popart2 [-SDLU num] [-mvh]\n" );
+    Abc_Print( -2, "\t         extracting multi-output sequential logic cones\n" );
+    Abc_Print( -2, "\t-S num : the index of the PO to start the cluster [default = %d]\n", iStartNum );
+    Abc_Print( -2, "\t-D num : the max increase in flop count after adding one PO [default = %d]\n", nDelta );
+    Abc_Print( -2, "\t-L num : the minimum number of POs in a cluster [default = %d]\n", nOutsMin );
+    Abc_Print( -2, "\t-U num : the maximum number of POs in a cluster [default = %d]\n", nOutsMax );
+    Abc_Print( -2, "\t-m     : toggle selecting the largest cluster [default = %s]\n", fSetLargest? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9GroupProve( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Vec_Int_t * Gia_ManGroupProve( Gia_Man_t * p, char * pCommLine, int nGroupSize, int fVerbose );
+    Vec_Int_t * vStatus;
+    char * pCommLine = NULL;
+    int c, nGroupSize = 1, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "GSvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'G':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-G\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nGroupSize = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nGroupSize <= 0 )
+                goto usage;
+            break;
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by a file name.\n" );
+                goto usage;
+            }
+            pCommLine = argv[globalUtilOptind];
+            globalUtilOptind++;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9GroupProve(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( pCommLine == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9GroupProve(): Command line is not given.\n" );
+        return 1;
+    }
+    vStatus = Gia_ManGroupProve( pAbc->pGia, pCommLine, nGroupSize, fVerbose );
+    Vec_IntFree( vStatus );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &gprove [-GS num] [-vh]\n" );
+    Abc_Print( -2, "\t         proves multi-output testcase by splitting outputs into groups\n" );
+    Abc_Print( -2, "\t         (currently, group size more than one works only for \"bmc3\" and \"pdr\")\n" );
+    Abc_Print( -2, "\t-G num : the size of one group [default = %d]\n", nGroupSize );
+    Abc_Print( -2, "\t-S str : the command line to be executed for each group [default = %s]\n", pCommLine ? pCommLine : "none" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9MultiProve( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern int Gia_ManMultiProve( Gia_Man_t * p, Bmc_MulPar_t * pPars );
+    Vec_Int_t * vStatuses; int c;
+    Bmc_MulPar_t Pars, * pPars = &Pars;
+    memset( pPars, 0, sizeof(Bmc_MulPar_t) );
+    pPars->TimeOutGlo =  30;
+    pPars->TimeOutLoc =   2;
+    pPars->TimeOutInc = 100;
+    pPars->TimeOutGap =   0;
+    pPars->TimePerOut =   0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "TLMGHsdvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->TimeOutGlo = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->TimeOutGlo < 0 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->TimeOutLoc = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->TimeOutLoc <= 0 )
+                goto usage;
+            break;
+        case 'M':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->TimeOutInc = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->TimeOutInc <= 0 )
+                goto usage;
+            break;
+        case 'G':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-G\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->TimeOutGap = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->TimeOutGap <= 0 )
+                goto usage;
+            break;
+        case 'H':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-H\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->TimePerOut = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->TimePerOut <= 0 )
+                goto usage;
+            break;
+        case 's':
+            pPars->fUseSyn ^= 1;
+            break;
+        case 'd':
+            pPars->fDumpFinal ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'w':
+            pPars->fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9MultiProve(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9MultiProve(): The problem is combinational.\n" );
+        return 1;
+    }
+    pAbc->Status = Gia_ManMultiProve( pAbc->pGia, pPars );
+    vStatuses = Abc_FrameDeriveStatusArray( pAbc->pGia->vSeqModelVec );
+    Abc_FrameReplacePoStatuses( pAbc, &vStatuses );        
+    Abc_FrameReplaceCexVec( pAbc, &pAbc->pGia->vSeqModelVec );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &mprove [-TLMGH num] [-sdvwh]\n" );
+    Abc_Print( -2, "\t         proves multi-output testcase by applying several engines\n" );
+    Abc_Print( -2, "\t-T num : approximate global runtime limit in seconds [default = %d]\n",     pPars->TimeOutGlo );
+    Abc_Print( -2, "\t-L num : approximate local runtime limit in seconds [default = %d]\n",      pPars->TimeOutLoc );
+    Abc_Print( -2, "\t-M num : percentage of local runtime limit increase [default = %d]\n",      pPars->TimeOutInc );
+    Abc_Print( -2, "\t-G num : approximate gap runtime limit in seconds [default = %d]\n",        pPars->TimeOutGap );
+    Abc_Print( -2, "\t-H num : timeout per output in miliseconds [default = %d]\n",               pPars->TimePerOut );
+    Abc_Print( -2, "\t-s     : toggle using combinational synthesis [default = %s]\n",            pPars->fUseSyn?      "yes": "no" );
+    Abc_Print( -2, "\t-d     : toggle dumping invariant into a file [default = %s]\n",            pPars->fDumpFinal?   "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n",             pPars->fVerbose?     "yes": "no" );
+    Abc_Print( -2, "\t-w     : toggle printing additional verbose information [default = %s]\n",  pPars->fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+#ifdef ABC_USE_PTHREADS
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9SplitProve( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern int Cec_GiaSplitTest( Gia_Man_t * p, int nProcs, int nTimeOut, int nIterMax, int LookAhead, int fVerbose, int fVeryVerbose );
+    int c, nProcs = 1, nTimeOut = 10, nIterMax = 0, LookAhead = 1, fVerbose = 0, fVeryVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "PTILvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'P':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-P\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            nProcs = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nProcs <= 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by a positive integer.\n" );
+                goto usage;
+            }
+            nTimeOut = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nTimeOut <= 0 )
+                goto usage;
+            break;
+        case 'I':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nIterMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nIterMax < 0 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            LookAhead = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( LookAhead <= 0 || LookAhead > 100 )
+            {
+                Abc_Print( -1, "Look-ahead value (\"-L <num>\") should be between 1 and 100.\n", LookAhead );
+                goto usage;
+            }
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'w':
+            fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9SplitProve(): There is no AIG.\n" );
+        return 1;
+    }
+    if ( Gia_ManRegNum(pAbc->pGia) > 0 )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9SplitProve(): The problem is sequential.\n" );
+        return 1;
+    }
+    pAbc->Status = Cec_GiaSplitTest( pAbc->pGia, nProcs, nTimeOut, nIterMax, LookAhead, fVerbose, fVeryVerbose );
+    pAbc->pCex = pAbc->pGia->pCexComb;  pAbc->pGia->pCexComb = NULL;
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &splitprove [-PTIL num] [-vwh]\n" );
+    Abc_Print( -2, "\t         proves CEC problem by case-splitting\n" );
+    Abc_Print( -2, "\t-P num : the number of concurrent processes [default = %d]\n",          nProcs );
+    Abc_Print( -2, "\t-T num : runtime limit in seconds per subproblem [default = %d]\n",     nTimeOut );
+    Abc_Print( -2, "\t-I num : the max number of iterations (0 = infinity) [default = %d]\n", nIterMax );
+    Abc_Print( -2, "\t-L num : maximum look-ahead during cofactoring [default = %d]\n",       LookAhead );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n",         fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w     : toggle printing more verbose information [default = %s]\n",    fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+#endif
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Bmc( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    int c;
+    Bmc_AndPar_t Pars, * pPars = &Pars;
+    memset( pPars, 0, sizeof(Bmc_AndPar_t) );
+    pPars->nStart        =    0;  // starting timeframe
+    pPars->nFramesMax    =    0;  // maximum number of timeframes 
+    pPars->nFramesAdd    =   50;  // the number of additional frames
+    pPars->nConfLimit    =    0;  // maximum number of conflicts at a node
+    pPars->nTimeOut      =    0;  // timeout in seconds
+    pPars->fLoadCnf      =    0;  // dynamic CNF loading
+    pPars->fDumpFrames   =    0;  // dump unrolled timeframes
+    pPars->fUseSynth     =    0;  // use synthesis
+    pPars->fUseOldCnf    =    1;  // use old CNF construction
+    pPars->fVerbose      =    0;  // verbose 
+    pPars->fVeryVerbose  =    0;  // very verbose 
+    pPars->fNotVerbose   =    0;  // skip line-by-line print-out 
+    pPars->iFrame        =    0;  // explored up to this frame
+    pPars->nFailOuts     =    0;  // the number of failed outputs
+    pPars->nDropOuts     =    0;  // the number of dropped outputs
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "SFATdscvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nStart = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nStart < 0 )
+                goto usage;
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nFramesMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nFramesMax < 0 )
+                goto usage;
+            break;
+        case 'A':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-A\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nFramesAdd = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nFramesAdd < 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nTimeOut = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nTimeOut < 0 )
+                goto usage;
+            break;
+        case 'd':
+            pPars->fDumpFrames ^= 1;
+            break;
+        case 's':
+            pPars->fUseSynth ^= 1;
+            break;
+        case 'c':
+            pPars->fUseOldCnf ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'w':
+            pPars->fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Bmc(): There is no AIG.\n" );
+        return 0;
+    }
+    if ( !pPars->fUseOldCnf && !Sdm_ManCanRead() )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Bmc(): Cannot input precomputed DSD information.\n" );
+        return 0;
+    }
+    pAbc->Status  = Gia_ManBmcPerform( pAbc->pGia, pPars );
+    pAbc->nFrames = pPars->iFrame;
+    Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexSeq );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &bmc [-SFAT num] [-dscvwh]\n" );
+    Abc_Print( -2, "\t         performs bounded model checking\n" );
+    Abc_Print( -2, "\t-S num : the starting timeframe [default = %d]\n",                      pPars->nStart );
+    Abc_Print( -2, "\t-F num : the maximum number of timeframes [default = %d]\n",            pPars->nFramesMax );
+    Abc_Print( -2, "\t-A num : the number of additional frames to unroll [default = %d]\n",   pPars->nFramesAdd );
+    Abc_Print( -2, "\t-T num : approximate timeout in seconds [default = %d]\n",              pPars->nTimeOut );
+    Abc_Print( -2, "\t-d     : toggle dumping unfolded timeframes [default = %s]\n",          pPars->fDumpFrames?  "yes": "no" );
+    Abc_Print( -2, "\t-s     : toggle synthesizing unrolled timeframes [default = %s]\n",     pPars->fUseSynth?    "yes": "no" );
+    Abc_Print( -2, "\t-c     : toggle using old CNF computation [default = %s]\n",            pPars->fUseOldCnf?   "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n",         pPars->fVerbose?     "yes": "no" );
+    Abc_Print( -2, "\t-w     : toggle printing information about unfolding [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9ChainBmc( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern int Bmc_ChainTest( Gia_Man_t * p, int nFrameMax, int nConfMax, int fVerbose, int fVeryVerbose, Vec_Ptr_t ** pvCexes );
+    Vec_Ptr_t * vCexes = NULL;
+    int nFrameMax    =  200;
+    int nConfMax     =    0;
+    int fVerbose     =    0;
+    int fVeryVerbose =    0;
+    int c;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "FCvwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFrameMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFrameMax < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nConfMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nConfMax < 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'w':
+            fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9ChainBmc(): There is no AIG.\n" );
+        return 0;
+    }
+    if ( !Gia_ManRegNum(pAbc->pGia) )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9ChainBmc(): The AIG is combinational.\n" );
+        return 0;
+    }
+    Bmc_ChainTest( pAbc->pGia, nFrameMax, nConfMax, fVerbose, fVeryVerbose, &vCexes );
+    if ( vCexes ) Vec_PtrFreeFree( vCexes );
+    //pAbc->Status  = ...;
+    //pAbc->nFrames = pPars->iFrame;
+    //Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexSeq );
+    return 0;
+usage:
+    Abc_Print( -2, "usage: &chainbmc [-FC <num>] [-vwh]\n" );
+    Abc_Print( -2, "\t           runs a specialized flavor of BMC\n" );
+    Abc_Print( -2, "\t-F <num> : the max number of timeframes (0 = unused) [default = %d]\n", nFrameMax );
+    Abc_Print( -2, "\t-C <num> : the max number of conflicts (0 = unused) [default = %d]\n", nConfMax );
+    Abc_Print( -2, "\t-v       : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w       : toggle printing even more information [default = %s]\n", fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9BCore( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    int c;
+    Bmc_BCorePar_t Pars, * pPars = &Pars;
+    memset( pPars, 0, sizeof(Bmc_BCorePar_t) );
+    pPars->iFrame        =   10;  // timeframe
+    pPars->iOutput       =    0;  // property output
+    pPars->nTimeOut      =    0;  // timeout in seconds
+    pPars->pFilePivots   = NULL;  // file name with AIG IDs of pivot objects
+    pPars->pFileProof    = NULL;  // file name to write the resulting proof
+    pPars->fVerbose      =    0;  // verbose output
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "FOTVvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->iFrame = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->iFrame < 0 )
+                goto usage;
+            break;
+        case 'O':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-O\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->iOutput = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->iOutput < 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nTimeOut = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nTimeOut < 0 )
+                goto usage;
+            break;
+        case 'V':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-V\" should be followed by a file name.\n" );
+                goto usage;
+            }
+            pPars->pFilePivots = argv[globalUtilOptind];
+            globalUtilOptind++;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9BCore(): There is no AIG.\n" );
+        return 0;
+    }
+    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9BCore(): AIG has no registers.\n" );
+        return 0;
+    }
+    // get the file name
+    if ( pPars->pFilePivots != NULL )
+    {
+        FILE * pFile;
+        pFile = fopen( pPars->pFilePivots, "r" );
+        if ( pFile == NULL )
+        {
+            Abc_Print( -1, "Abc_CommandAbc9BCore(): Cannot open file \"%s\" with pivot node IDs.\n", pPars->pFilePivots );
+            return 0;
+        }
+        fclose( pFile );
+    }
+    // get the file name
+    if ( argc == globalUtilOptind + 1 )
+    {
+        FILE * pFile;
+        pPars->pFileProof = argv[globalUtilOptind];
+        pFile = fopen( pPars->pFileProof, "wb" );
+        if ( pFile == NULL )
+        {
+            Abc_Print( -1, "Abc_CommandAbc9BCore(): Cannot open file \"%s\" for writing the proof.\n", pPars->pFileProof );
+            return 0;
+        }
+        fclose( pFile );
+    }
+    Bmc_ManBCorePerform( pAbc->pGia, pPars );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &bcore [-FOTV num] [-vh] <file>\n" );
+    Abc_Print( -2, "\t         records UNSAT core of the BMC instance\n" );
+    Abc_Print( -2, "\t-F num : the zero-based index of a timeframe [default = %d]\n",         pPars->iFrame );
+    Abc_Print( -2, "\t-O num : the zero-based index of a primary output [default = %d]\n",    pPars->iOutput );
+    Abc_Print( -2, "\t-T num : approximate timeout in seconds [default = %d]\n",              pPars->nTimeOut );
+    Abc_Print( -2, "\t-V file: file name with AIG IDs of pivot variables [default = no pivots]\n" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n",         pPars->fVerbose?     "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    Abc_Print( -2, "\t<file> : file name to write the resulting proof [default = stdout]\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9ICheck( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    int c, nFramesMax = 1, nTimeOut = 0, fEmpty = 0, fSearch = 1, fReverse = 0, fDump = 0, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "MTesrdvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'M':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFramesMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFramesMax <= 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nTimeOut = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nTimeOut < 0 )
+                goto usage;
+            break;
+        case 'e':
+            fEmpty ^= 1;
+            break;
+        case 's':
+            fSearch ^= 1;
+            break;
+        case 'r':
+            fReverse ^= 1;
+            break;
+        case 'd':
+            fDump ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9ICheck(): There is no AIG.\n" );
+        return 0;
+    }
+    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9ICheck(): The AIG is combinational.\n" );
+        return 0;
+    }
+    Vec_IntFreeP( &pAbc->vIndFlops );
+    if ( fSearch )
+        pAbc->vIndFlops = Bmc_PerformISearch( pAbc->pGia, nFramesMax, nTimeOut, fReverse, fDump, fVerbose );
+    else
+        Bmc_PerformICheck( pAbc->pGia, nFramesMax, nTimeOut, fEmpty, fVerbose );
+    pAbc->nIndFrames = pAbc->vIndFlops ? nFramesMax : 0;
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &icheck [-MT num] [-esrdvh]\n" );
+    Abc_Print( -2, "\t         performs specialized induction check\n" );
+    Abc_Print( -2, "\t-M num : the number of timeframes used for induction [default = %d]\n",    nFramesMax );
+    Abc_Print( -2, "\t-T num : approximate global runtime limit in seconds [default = %d]\n",    nTimeOut );
+    Abc_Print( -2, "\t-e     : toggle using empty set of next-state functions [default = %s]\n", fEmpty? "yes": "no" );
+    Abc_Print( -2, "\t-s     : toggle searching for a minimal subset [default = %s]\n",          fSearch? "yes": "no" );
+    Abc_Print( -2, "\t-r     : toggle searching in the reverse order [default = %s]\n",          fReverse? "yes": "no" );
+    Abc_Print( -2, "\t-d     : toggle printing out the resulting set [default = %s]\n",          fDump? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n",            fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9SatTest( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern void Bmc_LoadTest( Gia_Man_t * pGia, int fLoadCnf, int fVerbose );
+    int c, fLoadCnf = 0, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "cvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'c':
+            fLoadCnf ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9SatTest(): There is no AIG.\n" );
+        return 0;
+    }
+    Bmc_LoadTest( pAbc->pGia, fLoadCnf, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &sattest [-cvh]\n" );
+    Abc_Print( -2, "\t         performs testing of dynamic CNF loading\n" );
+    Abc_Print( -2, "\t-c     : toggle dynamic CNF loading [default = %s]\n",          fLoadCnf? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9FFTest( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern void Gia_ParFfSetDefault( Bmc_ParFf_t * p );
+    extern void Gia_ManFaultTest( Gia_Man_t * p, Gia_Man_t * pG, Bmc_ParFf_t * pPars );
+    Bmc_ParFf_t Pars, * pPars = &Pars;
+    char * pFileName = NULL;
+    Gia_Man_t * pGold = NULL;
+    int c;
+    Gia_ParFfSetDefault( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "ATNSGsbduvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'A':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-A\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->Algo = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->Algo < 0 || pPars->Algo > 4 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nTimeOut = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nTimeOut < 0 )
+                goto usage;
+            break;
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nIterCheck = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nIterCheck < 0 )
+                goto usage;
+            break;
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by string.\n" );
+                goto usage;
+            }
+            pPars->pFormStr = argv[globalUtilOptind];
+            globalUtilOptind++;
+            break;
+        case 'G':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-G\" should be followed by string.\n" );
+                goto usage;
+            }
+            pFileName = argv[globalUtilOptind];
+            globalUtilOptind++;
+            break;
+        case 's':
+            pPars->fStartPats ^= 1;
+            break;
+        case 'b':
+            pPars->fBasic ^= 1;
+            break;
+        case 'd':
+            pPars->fDump ^= 1;
+            break;
+        case 'u':
+            pPars->fDumpUntest ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pPars->Algo == 0 && pPars->pFormStr == NULL )
+    {
+        Abc_Print( -1, "Formula string (-S <str>) should be selected when algorithm is 0 (-A 0).\n" );
+        return 0;
+    }
+    if ( pPars->Algo != 0 && pPars->pFormStr != NULL )
+    {
+        Abc_Print( -1, "Algorithm should be 0 (-A 0) when formula string is selected (-S <str>).\n" );
+        return 0;
+    }
+    // get the file name
+    if ( argc == globalUtilOptind + 1 )
+    {
+        FILE * pFile;
+        pPars->pFileName = argv[globalUtilOptind];
+        pFile = fopen( pPars->pFileName, "r" );
+        if ( pFile == NULL )
+        {
+            Abc_Print( -1, "Cannot open file \"%s\" with the input test patterns.\n", pPars->pFileName );
+            return 0;
+        }
+        fclose( pFile );
+    }
+    // check other conditions
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9FFTest(): There is no AIG.\n" );
+        return 0;
+    }
+    if ( Gia_ManRegNum(pAbc->pGia) == 0 && pPars->Algo == 1 )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9FFTest(): For delay testing, AIG should be sequential.\n" );
+        return 0;
+    }
+    // check if the file is valid
+    if ( pFileName )
+    {
+        FILE * pFile = fopen( pFileName, "r" );
+        if ( pFile == NULL )
+        {
+            Abc_Print( -1, "Abc_CommandAbc9FFTest(): File name \"%s\" with golden model is invalid.\n", pFileName );
+            return 0;
+        }
+        fclose( pFile );
+        pGold = Gia_AigerRead( pFileName, 0, 0 );
+        if ( pGold == NULL )
+        {
+            Abc_Print( -1, "Abc_CommandAbc9FFTest(): Cannot read file \"%s\" with golden model.\n", pFileName );
+            return 0;
+        }
+        if ( Gia_ManPiNum(pAbc->pGia) != Gia_ManPiNum(pGold) )
+        {
+            Gia_ManStop( pGold );
+            Abc_Print( -1, "Abc_CommandAbc9FFTest(): Old model and gold model have different number of PIs.\n" );
+            return 0;
+        }
+        if ( Gia_ManPoNum(pAbc->pGia) != Gia_ManPoNum(pGold) )
+        {
+            Gia_ManStop( pGold );
+            Abc_Print( -1, "Abc_CommandAbc9FFTest(): Old model and gold model have different number of POs.\n" );
+            return 0;
+        }
+        printf( "Entered spec AIG from file \"%s\".\n", pFileName );
+    }
+    Gia_ManFaultTest( pAbc->pGia, pGold ? pGold : pAbc->pGia, pPars );
+    Gia_ManStopP( &pGold );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &fftest [-ATN num] [-sbduvh] <file> [-G file] [-S str]\n" );
+    Abc_Print( -2, "\t          performs functional fault test generation\n" );
+    Abc_Print( -2, "\t-A num  : selects fault model for all gates [default = %d]\n", pPars->Algo );
+    Abc_Print( -2, "\t                0: fault model is not selected (use -S str)\n" );
+    Abc_Print( -2, "\t                1: delay fault testing for sequential circuits\n" );
+    Abc_Print( -2, "\t                2: traditional stuck-at fault: -S (((a&b)&~p)|q)\n" );
+    Abc_Print( -2, "\t                3: complement fault: -S ((a&b)^p)\n" );
+    Abc_Print( -2, "\t                4: functionally observable fault\n" );
+    Abc_Print( -2, "\t-T num  : specifies approximate runtime limit in seconds [default = %d]\n",        pPars->nTimeOut );
+    Abc_Print( -2, "\t-N num  : specifies iteration to check for fixed parameters [default = %d]\n",     pPars->nIterCheck );
+    Abc_Print( -2, "\t-s      : toggles starting with the all-0 and all-1 patterns [default = %s]\n",    pPars->fStartPats?  "yes": "no" );
+    Abc_Print( -2, "\t-b      : toggles testing for single faults only [default = %s]\n",                pPars->fBasic?      "yes": "no" );
+    Abc_Print( -2, "\t-d      : toggles dumping test patterns into file \"tests.txt\" [default = %s]\n", pPars->fDump?       "yes": "no" );
+    Abc_Print( -2, "\t-u      : toggles dumping untestable faults into \"untest.txt\" [default = %s]\n", pPars->fDumpUntest? "yes": "no" );
+    Abc_Print( -2, "\t-v      : toggles printing verbose information [default = %s]\n",                  pPars->fVerbose?    "yes": "no" );
+    Abc_Print( -2, "\t-h      : print the command usage\n");
+    Abc_Print( -2, "\t<file>  : (optional) file name with input test patterns\n\n");
+    Abc_Print( -2, "\t-G file : (optional) file name with the golden model\n\n");
+    Abc_Print( -2, "\t-S str  : (optional) string representing the fault model\n");
+    Abc_Print( -2, "\t          The following notations are used:\n");
+    Abc_Print( -2, "\t            Functional variables: {a,b} (both a and b are always present)\n");
+    Abc_Print( -2, "\t            Parameter variables: {p,q,r,s,t,u,v,w} (any number from 1 to 8)\n");
+    Abc_Print( -2, "\t            Boolean operators: AND(&), OR(|), XOR(^), MUX(?:), NOT(~)\n");
+    Abc_Print( -2, "\t            Parentheses should be used around each operator. Spaces not allowed.\n");
+    Abc_Print( -2, "\t            Complement (~) is only allowed before variables (use DeMorgan law).\n");
+    Abc_Print( -2, "\t            Examples:\n");
+    Abc_Print( -2, "\t              (((a&b)&~p)|q)        stuck-at-0/1 at the output\n");
+    Abc_Print( -2, "\t              (((a&~p)|q)&b)        stuck-at-0/1 at input a\n");
+    Abc_Print( -2, "\t              (((a|p)&(b|q))&~r)    stuck-at-1 at the inputs and stuck-at-0 at the output\n");
+    Abc_Print( -2, "\t              (((a&~p)&(b&~q))|r)   stuck-at-0 at the inputs and stuck-at-1 at the output\n");
+    Abc_Print( -2, "\t              ((a&b)^p)             complement at the output\n");
+    Abc_Print( -2, "\t              (((a^p)&(b^q))^r)     complement at the inputs and at the output\n");
+    Abc_Print( -2, "\t              (a?(b?~s:r):(b?q:p))  functionally observable fault at the output\n");
+    Abc_Print( -2, "\t              (p?(a|b):(a&b))       replace AND by OR\n");    
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Qbf( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Gia_Man_t * Gia_QbfQuantify( Gia_Man_t * p, int nPars );
+    extern void Gia_QbfDumpFile( Gia_Man_t * pGia, int nPars );
+    extern int Gia_QbfSolve( Gia_Man_t * pGia, int nPars, int nIterLimit, int nConfLimit, int nTimeOut, int fVerbose );
+    int c, nPars   = -1;
+    int nIterLimit =  0;
+    int nConfLimit =  0;
+    int nTimeOut   =  0;
+    int fDumpCnf   =  0;
+    int fQuantX    =  0;
+    int fVerbose   =  0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "PICTdqvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'P':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nPars = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nPars < 0 )
+                goto usage;
+            break;
+        case 'I':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nIterLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nIterLimit < 0 )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nConfLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nConfLimit < 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nTimeOut = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nTimeOut < 0 )
+                goto usage;
+            break;
+        case 'd':
+            fDumpCnf ^= 1;
+            break;
+        case 'q':
+            fQuantX ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "There is no current GIA.\n" );
+        return 1;
+    }
+    if ( Gia_ManRegNum(pAbc->pGia) )
+    {
+        Abc_Print( -1, "Works only for combinational networks.\n" );
+        return 1;
+    }
+    if ( Gia_ManPoNum(pAbc->pGia) != 1 )
+    {
+        Abc_Print( -1, "The miter should have one primary output.\n" );
+        return 1;
+    }
+    if ( !(nPars > 0 && nPars < Gia_ManPiNum(pAbc->pGia)) )
+    {
+        Abc_Print( -1, "The number of parameter variables is invalid (should be > 0 and < PI num).\n" );
+        return 1;
+    }
+    if ( fQuantX )
+    {
+        Gia_Man_t * pTemp;
+        if ( Gia_ManPiNum(pAbc->pGia) - nPars > 16 )
+        {
+            Abc_Print( -1, "Cannot quantify more than 16 variables.\n" );
+            return 1;
+        }
+        pTemp = Gia_QbfQuantify( pAbc->pGia, nPars );
+        Abc_FrameUpdateGia( pAbc, pTemp );
+        return 0;
+    }
+    if ( fDumpCnf )
+        Gia_QbfDumpFile( pAbc->pGia, nPars );
+    else
+        Gia_QbfSolve( pAbc->pGia, nPars, nIterLimit, nConfLimit, nTimeOut, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &qbf [-PICT num] [-dqvh]\n" );
+    Abc_Print( -2, "\t         solves QBF problem EpVxM(p,x)\n" );
+    Abc_Print( -2, "\t-P num : number of parameters p (should be the first PIs) [default = %d]\n", nPars );
+    Abc_Print( -2, "\t-I num : quit after the given iteration even if unsolved [default = %d]\n", nIterLimit );
+    Abc_Print( -2, "\t-C num : conflict limit per problem [default = %d]\n", nConfLimit );
+    Abc_Print( -2, "\t-T num : global timeout [default = %d]\n", nTimeOut );
+    Abc_Print( -2, "\t-d     : toggle dumping QDIMACS file instead of solving [default = %s]\n", fDumpCnf? "yes": "no" );
+    Abc_Print( -2, "\t-q     : toggle quantifying functions variables [default = %s]\n", fQuantX? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Inse( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Vec_Int_t * Gia_ManInseTest( Gia_Man_t * p, Vec_Int_t * vInit, int nFrames, int nWords, int nTimeOut, int fSim, int fVerbose );
+    int c, nFrames = 10, nWords = 1000, nTimeOut = 0, fSim = 0, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "FWTsvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFrames = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFrames < 0 )
+                goto usage;
+            break;
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nWords = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nWords < 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nTimeOut = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nTimeOut < 0 )
+                goto usage;
+            break;
+        case 's':
+            fSim ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Inse(): There is no AIG.\n" );
+        return 0;
+    }
+    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Inse(): AIG is combinational.\n" );
+        return 0;
+    }
+    if ( pAbc->pGia->vInitClasses != NULL )
+    {
+        Abc_Print( 1, "Abc_CommandAbc9Inse(): All-0 initial state is assumed.\n" );
+        Vec_IntFreeP( &pAbc->pGia->vInitClasses );
+    }
+    pAbc->pGia->vInitClasses = Gia_ManInseTest( pAbc->pGia, NULL, nFrames, nWords, nTimeOut, fSim, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &inse [-FWT num] [-svh]\n" );
+    Abc_Print( -2, "\t         experimental procedure\n" );
+    Abc_Print( -2, "\t-F num : the number of timeframes [default = %d]\n",                    nFrames );
+    Abc_Print( -2, "\t-W num : the number of machine words [default = %d]\n",                 nWords );
+    Abc_Print( -2, "\t-T num : approximate global runtime limit in seconds [default = %d]\n", nTimeOut );
+    Abc_Print( -2, "\t-s     : toggles using ternary simulation [default = %s]\n",            fSim?     "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggles printing verbose information [default = %s]\n",        fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Maxi( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Vec_Int_t * Gia_ManMaxiTest( Gia_Man_t * p, Vec_Int_t * vInit, int nFrames, int nWords, int nTimeOut, int fSim, int fVerbose );
+    Vec_Int_t * vTemp;
+    int c, nFrames = 5, nWords = 1000, nTimeOut = 0, fSim = 0, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "FWTsvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFrames = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFrames < 0 )
+                goto usage;
+            break;
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nWords = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nWords < 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nTimeOut = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nTimeOut < 0 )
+                goto usage;
+            break;
+        case 's':
+            fSim ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Maxi(): There is no AIG.\n" );
+        return 0;
+    }
+    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Maxi(): AIG is combinational.\n" );
+        return 0;
+    }
+    pAbc->pGia->vInitClasses = Gia_ManMaxiTest( pAbc->pGia, vTemp = pAbc->pGia->vInitClasses, nFrames, nWords, nTimeOut, fSim, fVerbose );
+    Vec_IntFreeP( &vTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &maxi [-FWT num] [-svh]\n" );
+    Abc_Print( -2, "\t         experimental procedure\n" );
+    Abc_Print( -2, "\t-F num : the number of timeframes [default = %d]\n",                    nFrames );
+    Abc_Print( -2, "\t-W num : the number of machine words [default = %d]\n",                 nWords );
+    Abc_Print( -2, "\t-T num : approximate global runtime limit in seconds [default = %d]\n", nTimeOut );
+    Abc_Print( -2, "\t-s     : toggles using ternary simulation [default = %s]\n",            fSim?     "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggles printing verbose information [default = %s]\n",        fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Bmci( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern int Gia_ManBmciTest( Gia_Man_t * p, Vec_Int_t * vInit, int nFrames, int nWords, int nTimeOut, int fSim, int fVerbose );
+    int c, nFrames = 1000, nWords = 1000, nTimeOut = 0, fSim = 0, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "FWTsvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFrames = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFrames < 0 )
+                goto usage;
+            break;
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nWords = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nWords < 0 )
+                goto usage;
+            break;
+        case 'T':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nTimeOut = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nTimeOut < 0 )
+                goto usage;
+            break;
+        case 's':
+            fSim ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Bmci(): There is no AIG.\n" );
+        return 0;
+    }
+    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Bmci(): AIG is combinational.\n" );
+        return 0;
+    }
+    if ( pAbc->pGia->vInitClasses == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Bmci(): Init array is not given.\n" );
+        return 0;
+    }
+    Gia_ManBmciTest( pAbc->pGia, pAbc->pGia->vInitClasses, nFrames, nWords, nTimeOut, fSim, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &bmci [-FWT num] [-svh]\n" );
+    Abc_Print( -2, "\t         experimental procedure\n" );
+    Abc_Print( -2, "\t-F num : the number of timeframes [default = %d]\n",                    nFrames );
+    Abc_Print( -2, "\t-W num : the number of machine words [default = %d]\n",                 nWords );
+    Abc_Print( -2, "\t-T num : approximate global runtime limit in seconds [default = %d]\n", nTimeOut );
+    Abc_Print( -2, "\t-s     : toggles using ternary simulation [default = %s]\n",            fSim?     "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggles printing verbose information [default = %s]\n",        fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9PoXsim( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Vec_Int_t * Gia_ManPoXSim( Gia_Man_t * p, int nFrames, int fVerbose );
+    int c, nFrames = 1000, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Fvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFrames = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFrames < 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Bmci(): There is no AIG.\n" );
+        return 0;
+    }
+    if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Bmci(): AIG is combinational.\n" );
+        return 0;
+    }
+    Vec_IntFreeP( &pAbc->vAbcObjIds );
+    pAbc->vAbcObjIds = Gia_ManPoXSim( pAbc->pGia, nFrames, fVerbose );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &poxsim [-F num] [-vh]\n" );
+    Abc_Print( -2, "\t         X-valued simulation of the multi-output sequential miter\n" );
+    Abc_Print( -2, "\t-F num : the number of timeframes [default = %d]\n",                    nFrames );
+    Abc_Print( -2, "\t-v     : toggles printing verbose information [default = %s]\n",        fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Demiter( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Gia_Man_t * Gia_ManDupDemiter( Gia_Man_t * p, int fVerbose );
+    Gia_Man_t * pTemp;
+    int c, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Demiter(): There is no AIG.\n" );
+        return 0;
+    }
+    if ( Gia_ManPoNum(pAbc->pGia) != 1 )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Demiter(): Miter should have one output.\n" );
+        return 0;
+    }
+    pTemp = Gia_ManDupDemiter( pAbc->pGia, fVerbose );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    if ( fVerbose )
+        Gia_ManPrintStatsMiter( pTemp, 0 );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &demiter [-vh]\n" );
+    Abc_Print( -2, "\t         decomposes a single-output miter\n" );
+    Abc_Print( -2, "\t-v     : toggles printing verbose information [default = %s]\n",  fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Fadds( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Gia_Man_t * Gia_ManDupWithNaturalBoxes( Gia_Man_t * p, int nFaddMin, int fVerbose );
+    extern Gia_Man_t * Gia_ManDupWithArtificialBoxes( Gia_Man_t * p, int DelayC, int nPathMin, int nPathMax, int nPathLimit, int fUseFanout, int fIgnoreBoxDelays, int fVerbose );
+    Gia_Man_t * pTemp, * pTemp2;
+    int c, nFaddMin = 3, fUseNat = 0, fUseArt = 0, fVerbose = 0;
+    int DelayC = 0, nPathMin = 3, nPathMax = 32, nPathLimit = 50, fUseFanout = 0, fIgnoreBoxDelays = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "NBSLPnafbvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nFaddMin = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nFaddMin < 0 )
+                goto usage;
+            break;
+        case 'B':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            DelayC = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( DelayC < 0 )
+                goto usage;
+            break;
+        case 'S':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nPathMin = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nPathMin < 0 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nPathMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nPathMax < 0 )
+                goto usage;
+            break;
+        case 'P':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nPathLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nPathLimit < 0 )
+                goto usage;
+            break;
+        case 'n':
+            fUseNat ^= 1;
+            break;
+        case 'a':
+            fUseArt ^= 1;
+            break;
+        case 'f':
+            fUseFanout ^= 1;
+            break;
+        case 'b':
+            fIgnoreBoxDelays ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Fadds(): There is no AIG.\n" );
+        return 0;
+    }
+    if ( fUseNat )
+        pTemp = Gia_ManDupWithNaturalBoxes( pAbc->pGia, nFaddMin, fVerbose );
+    else
+    {
+        pTemp = Gia_ManDup( pAbc->pGia );
+        Gia_ManTransferTiming( pTemp, pAbc->pGia );
+    }
+    if ( fUseArt )
+        pTemp2 = Gia_ManDupWithArtificialBoxes( pTemp, DelayC, nPathMin, nPathMax, nPathLimit, fUseFanout, fIgnoreBoxDelays, fVerbose );
+    else
+    {
+        pTemp2 = Gia_ManDup( pTemp );
+        Gia_ManTransferTiming( pTemp2, pTemp );
+    }
+    Gia_ManStop( pTemp );
+    Abc_FrameUpdateGia( pAbc, pTemp2 );
+    return 0;
+usage:
+    Abc_Print( -2, "usage: &fadds [-NBSLP num] [-nafvh]\n" );
+    Abc_Print( -2, "\t         detects full-adder chains and puts them into white boxes\n" );
+    Abc_Print( -2, "\t-n     : toggles detecting natural full-adder chains [default = %s]\n",              fUseNat? "yes": "no" );
+    Abc_Print( -2, "\t-N num : minimum length of a natural full-adder chain to detect [default = %d]\n",   nFaddMin );
+    Abc_Print( -2, "\t-a     : toggles detecting artificial full-adder chains [default = %s]\n",           fUseArt? "yes": "no" );
+    Abc_Print( -2, "\t-B num : full-adder box delay (percentage of AND-gate delay) [default = %d]\n",      DelayC );
+    Abc_Print( -2, "\t-S num : minimum length of an artificial full-adder chain [default = %d]\n",         nPathMin );
+    Abc_Print( -2, "\t-L num : maximum length of an artificial full-adder chain [default = %d]\n",         nPathMax );
+    Abc_Print( -2, "\t-P num : maximum number of artificial full-adder chains to detect [default = %d]\n", nPathLimit );
+    Abc_Print( -2, "\t-f     : toggles allowing external fanouts in artificial chains [default = %s]\n",   fUseFanout? "yes": "no" );
+    Abc_Print( -2, "\t-b     : toggles ignoring boxes when computing delays [default = %s]\n",             fIgnoreBoxDelays? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggles printing verbose information [default = %s]\n",                     fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CommandAbc9Mfs( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern Gia_Man_t * Gia_ManPerformMfs( Gia_Man_t * p, Sfm_Par_t * pPars );
+    Gia_Man_t * pTemp; int c;
+    Sfm_Par_t Pars, * pPars = &Pars;
+    Sfm_ParSetDefault( pPars );
+    pPars->nTfoLevMax  =    5;
+    pPars->nDepthMax   =  100;
+    pPars->nWinSizeMax = 2000; 
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "WFDMLCNdaevwh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'W':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nTfoLevMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nTfoLevMax < 0 )
+                goto usage;
+            break;
+        case 'F':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nFanoutMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nFanoutMax < 0 )
+                goto usage;
+            break;
+        case 'D':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nDepthMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nDepthMax < 0 )
+                goto usage;
+            break;
+        case 'M':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nWinSizeMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nWinSizeMax < 0 )
+                goto usage;
+            break;
+        case 'L':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nGrowthLevel = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nGrowthLevel < 0 || pPars->nGrowthLevel > ABC_INFINITY )
+                goto usage;
+            break;
+        case 'C':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nBTLimit = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nBTLimit < 0 )
+                goto usage;
+            break;
+        case 'N':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            pPars->nNodesMax = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( pPars->nNodesMax < 0 )
+                goto usage;
+            break;
+        case 'd':
+            pPars->fRrOnly ^= 1;
+            break;
+        case 'a':
+            pPars->fArea ^= 1;
+            break;
+        case 'e':
+            pPars->fMoreEffort ^= 1;
+            break;
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'w':
+            pPars->fVeryVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pGia == NULL )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Mfs(): There is no AIG.\n" );
+        return 0;
+    }
+    if ( Gia_ManBufNum(pAbc->pGia) )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Mfs(): This command does not work with barrier buffers.\n" );
+        return 1;
+    }
+    if ( !Gia_ManHasMapping(pAbc->pGia) )
+    {
+        Abc_Print( -1, "Abc_CommandAbc9Mfs(): The current AIG has no mapping.\n" );
+        return 0;
+    }
+    pTemp = Gia_ManPerformMfs( pAbc->pGia, pPars );
+    Abc_FrameUpdateGia( pAbc, pTemp );
+    return 0;
+
+usage:
+    Abc_Print( -2, "usage: &mfs [-WFDMLCN <num>] [-daevwh]\n" );
+    Abc_Print( -2, "\t           performs don't-care-based optimization of logic networks\n" );
+    Abc_Print( -2, "\t-W <num> : the number of levels in the TFO cone (0 <= num) [default = %d]\n",             pPars->nTfoLevMax );
+    Abc_Print( -2, "\t-F <num> : the max number of fanouts to skip (1 <= num) [default = %d]\n",                pPars->nFanoutMax );
+    Abc_Print( -2, "\t-D <num> : the max depth nodes to try (0 = no limit) [default = %d]\n",                   pPars->nDepthMax );
+    Abc_Print( -2, "\t-M <num> : the max node count of windows to consider (0 = no limit) [default = %d]\n",    pPars->nWinSizeMax );
+    Abc_Print( -2, "\t-L <num> : the max increase in node level after resynthesis (0 <= num) [default = %d]\n", pPars->nGrowthLevel );
+    Abc_Print( -2, "\t-C <num> : the max number of conflicts in one SAT run (0 = no limit) [default = %d]\n",   pPars->nBTLimit );
+    Abc_Print( -2, "\t-N <num> : the max number of nodes to try (0 = all) [default = %d]\n",                    pPars->nNodesMax );
+    Abc_Print( -2, "\t-d       : toggle performing redundancy removal [default = %s]\n",                        pPars->fRrOnly? "yes": "no" );
+    Abc_Print( -2, "\t-a       : toggle minimizing area or area+edges [default = %s]\n",                        pPars->fArea? "area": "area+edges" );
+    Abc_Print( -2, "\t-e       : toggle high-effort resubstitution [default = %s]\n",                           pPars->fMoreEffort? "yes": "no" );
+    Abc_Print( -2, "\t-v       : toggle printing optimization summary [default = %s]\n",                        pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-w       : toggle printing detailed stats for each node [default = %s]\n",                pPars->fVeryVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h       : print the command usage\n");
     return 1;
 }
 
diff --git a/abc-build/src/base/abci/abcBm.c b/abc-build/src/base/abci/abcBm.c
--- a/abc-build/src/base/abci/abcBm.c
+++ b/abc-build/src/base/abci/abcBm.c
@@ -1909,15 +1909,14 @@
 			}				
 
 			if( iLastItem2 < Abc_NtkPiNum(pNtk2) )
-			{				
 				iNumOfItemsAdded = iSplitByDep(pNtk2, iDep2, iMatch2, iGroup2, &iLastItem2, oGroup2);
-				if( oLastItem2 < Abc_NtkPoNum(pNtk2) )		
-					oNumOfItemsAdded = oSplitByDep(pNtk2, oDep2, oMatch2, oGroup2, &oLastItem2, iGroup2);
-				else
-					oNumOfItemsAdded = 0;
-			}
 			else
-				iNumOfItemsAdded = 0;							
+				iNumOfItemsAdded = 0;	
+				
+			if( oLastItem2 < Abc_NtkPoNum(pNtk2) )		
+				oNumOfItemsAdded = oSplitByDep(pNtk2, oDep2, oMatch2, oGroup2, &oLastItem2, iGroup2);
+			else
+				oNumOfItemsAdded = 0;
 			
 			if(!checkListConsistency(iMatch1, oMatch1, iMatch2, oMatch2, iLastItem1, oLastItem1, iLastItem2, oLastItem2))
 			{
diff --git a/abc-build/src/base/abci/abcDar.c b/abc-build/src/base/abci/abcDar.c
--- a/abc-build/src/base/abci/abcDar.c
+++ b/abc-build/src/base/abci/abcDar.c
@@ -720,8 +720,8 @@
     Gia_Obj_t * pObj, * pObjLi, * pObjLo;
     Vec_Ptr_t * vReflect;
     int i, k, iFan, nDupGates; 
-    assert( Gia_ManHasMapping(p) );
-    pNtkNew = Abc_NtkAlloc( ABC_NTK_LOGIC, ABC_FUNC_AIG, 1 );
+    assert( Gia_ManHasMapping(p) || p->pMuxes );
+    pNtkNew = Abc_NtkAlloc( ABC_NTK_LOGIC, Gia_ManHasMapping(p) ? ABC_FUNC_AIG : ABC_FUNC_SOP, 1 );
     // duplicate the name and the spec
     pNtkNew->pName = Extra_UtilStrsav(p->pName);
     pNtkNew->pSpec = Extra_UtilStrsav(p->pSpec);
@@ -748,23 +748,60 @@
         Abc_LatchSetInit0( pObjNew );
     }
     // rebuild the AIG
-    vReflect = Vec_PtrStart( Gia_ManObjNum(p) );
-    Gia_ManForEachLut( p, i )
-    {
-        pObj = Gia_ManObj(p, i);
-        assert( pObj->Value == ~0 );
-        if ( Gia_ObjLutSize(p, i) == 0 )
+    if ( p->pMuxes )
+    {
+        Gia_ManForEachAnd( p, pObj, i )
+        {
+            pObjNew = Abc_NtkCreateNode( pNtkNew );
+            if ( Gia_ObjIsMuxId(p, i) )
+            {
+                Abc_ObjAddFanin( pObjNew, Abc_NtkObj(pNtkNew, Gia_ObjValue(Gia_ObjFanin2(p, pObj))) );
+                Abc_ObjAddFanin( pObjNew, Abc_NtkObj(pNtkNew, Gia_ObjValue(Gia_ObjFanin1(pObj))) );
+                Abc_ObjAddFanin( pObjNew, Abc_NtkObj(pNtkNew, Gia_ObjValue(Gia_ObjFanin0(pObj))) );
+                pObjNew->pData = Abc_SopCreateMux( (Mem_Flex_t *)pNtkNew->pManFunc );
+                if ( Gia_ObjFaninC2(p, pObj) )  Abc_SopComplementVar( (char *)pObjNew->pData, 0 );
+                if ( Gia_ObjFaninC1(pObj) )     Abc_SopComplementVar( (char *)pObjNew->pData, 1 );
+                if ( Gia_ObjFaninC0(pObj) )     Abc_SopComplementVar( (char *)pObjNew->pData, 2 );
+            }
+            else if ( Gia_ObjIsXor(pObj) )
+            {
+                Abc_ObjAddFanin( pObjNew, Abc_NtkObj(pNtkNew, Gia_ObjValue(Gia_ObjFanin0(pObj))) );
+                Abc_ObjAddFanin( pObjNew, Abc_NtkObj(pNtkNew, Gia_ObjValue(Gia_ObjFanin1(pObj))) );
+                pObjNew->pData = Abc_SopCreateXor( (Mem_Flex_t *)pNtkNew->pManFunc, 2 );
+                if ( Gia_ObjFaninC0(pObj) )  Abc_SopComplementVar( (char *)pObjNew->pData, 0 );
+                if ( Gia_ObjFaninC1(pObj) )  Abc_SopComplementVar( (char *)pObjNew->pData, 1 );
+            }
+            else 
+            {
+                Abc_ObjAddFanin( pObjNew, Abc_NtkObj(pNtkNew, Gia_ObjValue(Gia_ObjFanin0(pObj))) );
+                Abc_ObjAddFanin( pObjNew, Abc_NtkObj(pNtkNew, Gia_ObjValue(Gia_ObjFanin1(pObj))) );
+                pObjNew->pData = Abc_SopCreateAnd( (Mem_Flex_t *)pNtkNew->pManFunc, 2, NULL );
+                if ( Gia_ObjFaninC0(pObj) )  Abc_SopComplementVar( (char *)pObjNew->pData, 0 );
+                if ( Gia_ObjFaninC1(pObj) )  Abc_SopComplementVar( (char *)pObjNew->pData, 1 );
+            }
+            pObj->Value = Abc_ObjId( pObjNew );
+        }
+    }
+    else
+    {
+        vReflect = Vec_PtrStart( Gia_ManObjNum(p) );
+        Gia_ManForEachLut( p, i )
         {
-            pObj->Value = Abc_ObjId(pConst0);
-            continue;
-        }
-        pObjNew = Abc_NtkCreateNode( pNtkNew );
-        Gia_LutForEachFanin( p, i, iFan, k )
-            Abc_ObjAddFanin( pObjNew, Abc_NtkObj(pNtkNew, Gia_ObjValue(Gia_ManObj(p, iFan))) );
-        pObjNew->pData = Abc_ObjHopFromGia( (Hop_Man_t *)pNtkNew->pManFunc, p, i, vReflect );
-        pObj->Value = Abc_ObjId( pObjNew );
+            pObj = Gia_ManObj(p, i);
+            assert( pObj->Value == ~0 );
+            if ( Gia_ObjLutSize(p, i) == 0 )
+            {
+                pObj->Value = Abc_ObjId(pConst0);
+                continue;
+            }
+            pObjNew = Abc_NtkCreateNode( pNtkNew );
+            Gia_LutForEachFanin( p, i, iFan, k )
+                Abc_ObjAddFanin( pObjNew, Abc_NtkObj(pNtkNew, Gia_ObjValue(Gia_ManObj(p, iFan))) );
+            pObjNew->pData = Abc_ObjHopFromGia( (Hop_Man_t *)pNtkNew->pManFunc, p, i, vReflect );
+            pObj->Value = Abc_ObjId( pObjNew );
+        }
+        Vec_PtrFree( vReflect );
     }
-    Vec_PtrFree( vReflect );
     // connect the PO nodes
     Gia_ManForEachCo( p, pObj, i )
     {
@@ -820,6 +857,8 @@
     int iObjNew = Vec_IntEntry( vCopyLits, Abc_Var2Lit(i, c) );
     if ( iObjNew >= 0 )
         return Abc_NtkObj(p, iObjNew);
+    // opposite phase should be already constructed
+    assert( 0 );
     if ( i == 0 )
         pObjNew = c ? Abc_NtkCreateNodeConst1(p) : Abc_NtkCreateNodeConst0(p);
     else
@@ -832,13 +871,14 @@
 }
 Abc_Ntk_t * Abc_NtkFromCellMappedGia( Gia_Man_t * p )
 {
-    int fVerbose = 1;
+    int fFixDrivers = 1;
     int fDuplicate = 1;
+    int fVerbose = 1;
     Abc_Ntk_t * pNtkNew;
     Vec_Int_t * vCopyLits;
     Abc_Obj_t * pObjNew, * pObjNewLi, * pObjNewLo;
     Gia_Obj_t * pObj, * pObjLi, * pObjLo;
-    int i, k, iLit, iFanLit, nDupGates, nCells; 
+    int i, k, iLit, iFanLit, nCells, fNeedConst[2] = {0}; 
     Mio_Cell_t * pCells = Mio_CollectRootsNewDefault( 6, &nCells, 0 );
     assert( Gia_ManHasCellMapping(p) );
     // start network
@@ -867,16 +907,73 @@
         Abc_NtkFromCellWrite( vCopyLits, Gia_ObjId(p, pObjLo), 0, Abc_ObjId( pObjNewLo ) );
         Abc_LatchSetInit0( pObjNew );
     }
+
+    // create constants
+    Gia_ManForEachCo( p, pObj, i )
+        if ( Gia_ObjFaninId0p(p, pObj) == 0 )
+            fNeedConst[Gia_ObjFaninC0(pObj)] = 1;
+    Gia_ManForEachBuf( p, pObj, i )
+        if ( Gia_ObjFaninId0p(p, pObj) == 0 )
+            fNeedConst[Gia_ObjFaninC0(pObj)] = 1;
+    if ( fNeedConst[0] )
+        Abc_NtkFromCellWrite( vCopyLits, 0, 0, Abc_ObjId(Abc_NtkCreateNodeConst0(pNtkNew)) );
+    if ( fNeedConst[1] )
+        Abc_NtkFromCellWrite( vCopyLits, 0, 1, Abc_ObjId(Abc_NtkCreateNodeConst1(pNtkNew)) );
+
     // rebuild the AIG
     Gia_ManForEachCell( p, iLit )
     {
-        assert( Vec_IntEntry(vCopyLits, iLit) == -1 );
-        pObjNew = Abc_NtkCreateNode( pNtkNew );
-        Gia_CellForEachFanin( p, iLit, iFanLit, k )
+        int fSkip = 0;
+        if ( Gia_ObjIsCellBuf(p, iLit) )
+        {
+            assert( !Abc_LitIsCompl(iLit) );
+            // build buffer
+            pObjNew = Abc_NtkCreateNode( pNtkNew );
+            iFanLit = Gia_ObjFaninLit0p( p, Gia_ManObj(p, Abc_Lit2Var(iLit)) );
             Abc_ObjAddFanin( pObjNew, Abc_NtkFromCellRead(pNtkNew, vCopyLits, Abc_Lit2Var(iFanLit), Abc_LitIsCompl(iFanLit)) );
-        pObjNew->pData = Mio_LibraryReadGateByName( (Mio_Library_t *)pNtkNew->pManFunc, pCells[Gia_ObjCellId(p, iLit)].pName, NULL );
+            pObjNew->pData = NULL; // barrier buffer
+            assert( Abc_ObjIsBarBuf(pObjNew) );
+            pNtkNew->nBarBufs2++;
+        }
+        else if ( Gia_ObjIsCellInv(p, iLit) )
+        {
+            int iLitNot = Abc_LitNot(iLit);
+            if ( !Abc_LitIsCompl(iLit) ) // positive phase
+            {
+                // build negative phase
+                assert( Vec_IntEntry(vCopyLits, iLitNot) == -1 );
+                assert( Gia_ObjCellId(p, iLitNot) > 0 );
+                pObjNew = Abc_NtkCreateNode( pNtkNew );
+                Gia_CellForEachFanin( p, iLitNot, iFanLit, k )
+                    Abc_ObjAddFanin( pObjNew, Abc_NtkFromCellRead(pNtkNew, vCopyLits, Abc_Lit2Var(iFanLit), Abc_LitIsCompl(iFanLit)) );
+                pObjNew->pData = Mio_LibraryReadGateByName( (Mio_Library_t *)pNtkNew->pManFunc, pCells[Gia_ObjCellId(p, iLitNot)].pName, NULL );
+                Abc_NtkFromCellWrite( vCopyLits, Abc_Lit2Var(iLitNot), Abc_LitIsCompl(iLitNot), Abc_ObjId(pObjNew) );
+                fSkip = 1;
+            }
+            else // negative phase
+            {
+                // positive phase is available
+                assert( Vec_IntEntry(vCopyLits, iLitNot) != -1 );
+            }
+            // build inverter
+            pObjNew = Abc_NtkCreateNode( pNtkNew );
+            Abc_ObjAddFanin( pObjNew, Abc_NtkFromCellRead(pNtkNew, vCopyLits, Abc_Lit2Var(iLit), Abc_LitIsCompl(iLitNot)) );
+            pObjNew->pData = Mio_LibraryReadGateByName( (Mio_Library_t *)pNtkNew->pManFunc, pCells[3].pName, NULL );
+        }
+        else
+        {
+            assert( Gia_ObjCellId(p, iLit) > 0 );
+            pObjNew = Abc_NtkCreateNode( pNtkNew );
+            Gia_CellForEachFanin( p, iLit, iFanLit, k )
+                Abc_ObjAddFanin( pObjNew, Abc_NtkFromCellRead(pNtkNew, vCopyLits, Abc_Lit2Var(iFanLit), Abc_LitIsCompl(iFanLit)) );
+            pObjNew->pData = Mio_LibraryReadGateByName( (Mio_Library_t *)pNtkNew->pManFunc, pCells[Gia_ObjCellId(p, iLit)].pName, NULL );
+        }
+        assert( Vec_IntEntry(vCopyLits, iLit) == -1 );
         Abc_NtkFromCellWrite( vCopyLits, Abc_Lit2Var(iLit), Abc_LitIsCompl(iLit), Abc_ObjId(pObjNew) );
+        // skip next
+        iLit += fSkip;
     }
+
     // connect the PO nodes
     Gia_ManForEachCo( p, pObj, i )
     {
@@ -889,14 +986,18 @@
     Abc_NtkAddDummyBoxNames( pNtkNew );
 
     // decouple the PO driver nodes to reduce the number of levels
-    nDupGates = Abc_NtkLogicMakeSimpleCos( pNtkNew, fDuplicate );
-    if ( fVerbose && nDupGates && !Abc_FrameReadFlag("silentmode") )
+    if ( fFixDrivers )
     {
-        if ( !fDuplicate )
-            printf( "Added %d buffers/inverters to decouple the CO drivers.\n", nDupGates );
-        else
-            printf( "Duplicated %d gates to decouple the CO drivers.\n", nDupGates );
+        int nDupGates = Abc_NtkLogicMakeSimpleCos( pNtkNew, fDuplicate );
+        if ( fVerbose && nDupGates && !Abc_FrameReadFlag("silentmode") )
+        {
+            if ( !fDuplicate )
+                printf( "Added %d buffers/inverters to decouple the CO drivers.\n", nDupGates );
+            else
+                printf( "Duplicated %d gates to decouple the CO drivers.\n", nDupGates );
+        }
     }
+
     assert( Gia_ManPiNum(p) == Abc_NtkPiNum(pNtkNew) );
     assert( Gia_ManPoNum(p) == Abc_NtkPoNum(pNtkNew) );
     assert( Gia_ManRegNum(p) == Abc_NtkLatchNum(pNtkNew) );
@@ -2307,7 +2408,7 @@
                     if ( pPars->nDropOuts )
                         Abc_Print( 1, " while others timed out (%d out of %d)", pPars->nDropOuts, nOutputs );
                 }
-                Abc_Print( 1, " after %d frames", pPars->iFrame );
+                Abc_Print( 1, " after %d frames", pPars->iFrame+2 );
                 Abc_Print( 1, ".   " );
             }
         }
diff --git a/abc-build/src/base/abci/abcDec.c b/abc-build/src/base/abci/abcDec.c
--- a/abc-build/src/base/abci/abcDec.c
+++ b/abc-build/src/base/abci/abcDec.c
@@ -502,6 +502,10 @@
         vCover = Vec_IntAlloc( 1 << 16 );
         for ( i = 0; i < p->nFuncs; i++ )
         {
+//            extern int Abc_IsopTest( word * pFunc, int nVars, Vec_Int_t * vCover );
+//            if ( i == 0 ) printf( "\n" );
+//            Abc_IsopTest( p->pFuncs[i], p->nVars, vCover );
+//            continue;
             if ( fVerbose )
                 printf( "%7d : ", i );
             pSopStr = Kit_PlaFromTruthNew( (unsigned *)p->pFuncs[i], p->nVars, vCover, vStr );
@@ -597,6 +601,7 @@
 
     // allocate data-structure
     p = Abc_TtStoreLoad( pFileName, nVarNum );
+    if ( p == NULL ) return;
 
     // consider functions from the file
     Abc_TruthDecPerform( p, DecType, fVerbose );
diff --git a/abc-build/src/base/abci/abcFx.c b/abc-build/src/base/abci/abcFx.c
--- a/abc-build/src/base/abci/abcFx.c
+++ b/abc-build/src/base/abci/abcFx.c
@@ -635,7 +635,7 @@
   SeeAlso     []
 
 ***********************************************************************/
-int Fx_ManDivFindCubeFree( Vec_Int_t * vArr1, Vec_Int_t * vArr2, Vec_Int_t * vCubeFree )
+int Fx_ManDivFindCubeFree( Vec_Int_t * vArr1, Vec_Int_t * vArr2, Vec_Int_t * vCubeFree, int * fWarning )
 {
     int * pBeg1 = vArr1->pArray + 1;  // skip variable ID
     int * pBeg2 = vArr2->pArray + 1;  // skip variable ID
@@ -664,8 +664,8 @@
         printf( "The SOP has duplicated cubes.\n" );
     else if ( Vec_IntSize(vCubeFree) == 1 )
         printf( "The SOP has contained cubes.\n" );
-    else if ( Vec_IntSize(vCubeFree) == 2 && Abc_Lit2Var(Abc_Lit2Var(Vec_IntEntry(vCubeFree, 0))) == Abc_Lit2Var(Abc_Lit2Var(Vec_IntEntry(vCubeFree, 1))) )
-        printf( "The SOP has distance-1 cubes or it is not a prime cover.  Please make sure the result verifies.\n" );
+    else if ( Vec_IntSize(vCubeFree) == 2 && Abc_Lit2Var(Abc_Lit2Var(Vec_IntEntry(vCubeFree, 0))) == Abc_Lit2Var(Abc_Lit2Var(Vec_IntEntry(vCubeFree, 1))) && !*fWarning )
+        printf( "The SOP has distance-1 cubes or it is not a prime cover.  Please make sure the result verifies.\n" ), *fWarning = 1;
     assert( !Abc_LitIsCompl(Vec_IntEntry(vCubeFree, 0)) );
     return Counter;
 }
@@ -819,7 +819,7 @@
     }
     return Vec_IntSize(vPivot) * (Vec_IntSize(vPivot) - 1) / 2;
 }
-void Fx_ManCubeDoubleCubeDivisors( Fx_Man_t * p, int iFirst, Vec_Int_t * vPivot, int fRemove, int fUpdate )
+void Fx_ManCubeDoubleCubeDivisors( Fx_Man_t * p, int iFirst, Vec_Int_t * vPivot, int fRemove, int fUpdate, int * fWarning )
 {
     Vec_Int_t * vCube;
     int i, iDiv, Base;
@@ -831,7 +831,7 @@
             continue;
         if ( Vec_IntEntry(vCube, 0) != Vec_IntEntry(vPivot, 0) )
             break;
-        Base = Fx_ManDivFindCubeFree( vCube, vPivot, p->vCubeFree );
+        Base = Fx_ManDivFindCubeFree( vCube, vPivot, p->vCubeFree, fWarning );
         if ( Vec_IntSize(p->vCubeFree) == 4 )
         { 
             int Value = Fx_ManDivNormalize( p->vCubeFree );
@@ -872,7 +872,7 @@
 {
     Vec_Int_t * vCube;
     float Weight;
-    int i;
+    int i, fWarning = 0;
     // alloc hash table
     assert( p->pHash == NULL );
     p->pHash = Hsh_VecManStart( 1000 );
@@ -883,7 +883,7 @@
     assert( p->nDivsS == Vec_FltSize(p->vWeights) );
     // create two-cube divisors
     Vec_WecForEachLevel( p->vCubes, vCube, i )
-        Fx_ManCubeDoubleCubeDivisors( p, i+1, vCube, 0, 0 ); // add - no update
+        Fx_ManCubeDoubleCubeDivisors( p, i+1, vCube, 0, 0, &fWarning ); // add - no update
     // create queue with all divisors
     p->vPrio = Vec_QueAlloc( Vec_FltSize(p->vWeights) );
     Vec_QueSetPriority( p->vPrio, Vec_FltArrayP(p->vWeights) );
@@ -926,7 +926,7 @@
 
 ***********************************************************************/
 static inline int Fx_ManGetCubeVar( Vec_Wec_t * vCubes, int iCube )  { return Vec_IntEntry( Vec_WecEntry(vCubes, iCube), 0 );      }
-void Fx_ManFindCommonPairs( Vec_Wec_t * vCubes, Vec_Int_t * vPart0, Vec_Int_t * vPart1, Vec_Int_t * vPairs, Vec_Int_t * vCompls, Vec_Int_t * vDiv, Vec_Int_t * vCubeFree )
+void Fx_ManFindCommonPairs( Vec_Wec_t * vCubes, Vec_Int_t * vPart0, Vec_Int_t * vPart1, Vec_Int_t * vPairs, Vec_Int_t * vCompls, Vec_Int_t * vDiv, Vec_Int_t * vCubeFree, int * fWarning )
 {
     int * pBeg1 = vPart0->pArray;
     int * pBeg2 = vPart1->pArray;
@@ -952,7 +952,7 @@
             {
                 if ( pBeg1[i_] == pBeg2[k_] )
                     continue;
-                Fx_ManDivFindCubeFree( Vec_WecEntry(vCubes, pBeg1[i_]), Vec_WecEntry(vCubes, pBeg2[k_]), vCubeFree );
+                Fx_ManDivFindCubeFree( Vec_WecEntry(vCubes, pBeg1[i_]), Vec_WecEntry(vCubes, pBeg2[k_]), vCubeFree, fWarning );
                 fCompl = (Vec_IntSize(vCubeFree) == 4 && Fx_ManDivNormalize(vCubeFree) == 1);
                 if ( !Vec_IntEqual( vDiv, vCubeFree ) )
                     continue;
@@ -981,7 +981,7 @@
   SeeAlso     []
 
 ***********************************************************************/
-void Fx_ManUpdate( Fx_Man_t * p, int iDiv )
+void Fx_ManUpdate( Fx_Man_t * p, int iDiv, int * fWarning )
 {
     Vec_Int_t * vCube, * vCube2, * vLitP, * vLitN;
     Vec_Int_t * vDiv = p->vDiv;
@@ -1014,7 +1014,7 @@
     // collect double-cube-divisor cube pairs
     Fx_ManCompressCubes( p->vCubes, Vec_WecEntry(p->vLits, Lit0) );
     Fx_ManCompressCubes( p->vCubes, Vec_WecEntry(p->vLits, Lit1) );
-    Fx_ManFindCommonPairs( p->vCubes, Vec_WecEntry(p->vLits, Lit0), Vec_WecEntry(p->vLits, Lit1), p->vCubesD, p->vCompls, vDiv, p->vCubeFree );
+    Fx_ManFindCommonPairs( p->vCubes, Vec_WecEntry(p->vLits, Lit0), Vec_WecEntry(p->vLits, Lit1), p->vCubesD, p->vCompls, vDiv, p->vCubeFree, fWarning );
 
     // subtract cost of single-cube divisors
     Fx_ManForEachCubeVec( p->vCubesS, p->vCubes, vCube, i )
@@ -1028,9 +1028,9 @@
 
     // subtract cost of double-cube divisors
     Fx_ManForEachCubeVec( p->vCubesS, p->vCubes, vCube, i )
-        Fx_ManCubeDoubleCubeDivisors( p, Fx_ManGetFirstVarCube(p, vCube), vCube, 1, 1 );  // remove - update
+        Fx_ManCubeDoubleCubeDivisors( p, Fx_ManGetFirstVarCube(p, vCube), vCube, 1, 1, fWarning );  // remove - update
     Fx_ManForEachCubeVec( p->vCubesD, p->vCubes, vCube, i )
-        Fx_ManCubeDoubleCubeDivisors( p, Fx_ManGetFirstVarCube(p, vCube), vCube, 1, 1 );  // remove - update
+        Fx_ManCubeDoubleCubeDivisors( p, Fx_ManGetFirstVarCube(p, vCube), vCube, 1, 1, fWarning );  // remove - update
 
     // unmark the cubes to be removed
     Vec_WecUnmarkLevels( p->vCubes, p->vCubesS );
@@ -1119,9 +1119,9 @@
 
     // add cost of double-cube divisors
     Fx_ManForEachCubeVec( p->vCubesS, p->vCubes, vCube, i )
-        Fx_ManCubeDoubleCubeDivisors( p, Fx_ManGetFirstVarCube(p, vCube), vCube, 0, 1 );  // add - update
+        Fx_ManCubeDoubleCubeDivisors( p, Fx_ManGetFirstVarCube(p, vCube), vCube, 0, 1, fWarning );  // add - update
     Fx_ManForEachCubeVec( p->vCubesD, p->vCubes, vCube, i )
-        Fx_ManCubeDoubleCubeDivisors( p, Fx_ManGetFirstVarCube(p, vCube), vCube, 0, 1 );  // add - update
+        Fx_ManCubeDoubleCubeDivisors( p, Fx_ManGetFirstVarCube(p, vCube), vCube, 0, 1, fWarning );  // add - update
 
     // unmark the cubes to be removed
     Vec_WecUnmarkLevels( p->vCubes, p->vCubesS );
@@ -1168,7 +1168,7 @@
 int Fx_FastExtract( Vec_Wec_t * vCubes, int ObjIdMax, int nNewNodesMax, int LitCountMax, int fVerbose, int fVeryVerbose )
 {
     int fVeryVeryVerbose = 0;
-    int i, iDiv;
+    int i, iDiv, fWarning = 0;
     Fx_Man_t * p;
     abctime clk = Abc_Clock();
     // initialize the data-structure
@@ -1188,7 +1188,7 @@
         iDiv = Vec_QuePop(p->vPrio);
         if ( fVeryVerbose )
             Fx_PrintDiv( p, iDiv );
-        Fx_ManUpdate( p, iDiv );
+        Fx_ManUpdate( p, iDiv, &fWarning );
         if ( fVeryVeryVerbose )
             Fx_PrintMatrix( p );
     }
diff --git a/abc-build/src/base/abci/abcMfs.c b/abc-build/src/base/abci/abcMfs.c
--- a/abc-build/src/base/abci/abcMfs.c
+++ b/abc-build/src/base/abci/abcMfs.c
@@ -270,7 +270,6 @@
     p = Abc_NtkExtractMfs( pNtk, pPars->nFirstFixed );
     // perform optimization
     nNodes = Sfm_NtkPerform( p, pPars );
-    // call the fast extract procedure
     if ( nNodes == 0 )
     {
 //        Abc_Print( 1, "The network is not changed by \"mfs\".\n" );
@@ -451,7 +450,6 @@
     pp = Abc_NtkExtractMfs2( pNtk, iPivot );
     // perform optimization
     nNodes = Sfm_NtkPerform( pp, pPars );
-    // call the fast extract procedure
     if ( nNodes == 0 )
     {
 //        Abc_Print( 1, "The network is not changed by \"mfs\".\n" );
diff --git a/abc-build/src/base/abci/abcNpnSave.c b/abc-build/src/base/abci/abcNpnSave.c
--- a/abc-build/src/base/abci/abcNpnSave.c
+++ b/abc-build/src/base/abci/abcNpnSave.c
@@ -34,7 +34,7 @@
 struct Npn_Obj_t_
 {
     word         uTruth;      // truth table
-    int          Count;       // occurances
+    int          Count;       // occurrences
     int          iNext;       // next entry
 };
 struct Npn_Man_t_
diff --git a/abc-build/src/base/abci/abcPrint.c b/abc-build/src/base/abci/abcPrint.c
--- a/abc-build/src/base/abci/abcPrint.c
+++ b/abc-build/src/base/abci/abcPrint.c
@@ -221,7 +221,8 @@
         return;
     }
     if ( fSaveBest )
-        Abc_NtkCompareAndSaveBest( pNtk );
+        Abc_NtkCompareAndSaveBest( pNtk );
+/*
     if ( fDumpResult )
     {
         char Buffer[1000] = {0};
@@ -229,7 +230,8 @@
         sprintf( Buffer, "%s_dump.blif", pNameGen );
         Io_Write( pNtk, Buffer, IO_FILE_BLIF );
         if ( pNtk->pSpec ) ABC_FREE( pNameGen );
-    }
+    }
+*/
 
 //    if ( Abc_NtkIsStrash(pNtk) )
 //        Abc_AigCountNext( pNtk->pManFunc );
@@ -304,7 +306,9 @@
 //        Abc_Print( 1,"  var = %5d", Abc_NtkCiNum(pNtk) + Abc_NtkCoNum(pNtk)+Abc_NtkGetMultiRefNum(pNtk) );
     }
     else
-        Abc_Print( 1,"  lev =%3d", Abc_NtkLevel(pNtk) );
+        Abc_Print( 1,"  lev = %d", Abc_NtkLevel(pNtk) );
+    if ( pNtk->nBarBufs2 )
+        Abc_Print( 1,"  buf = %d", pNtk->nBarBufs2 );
     if ( fUseLutLib && Abc_FrameReadLibLut() )
         Abc_Print( 1,"  delay =%5.2f", Abc_NtkDelayTraceLut(pNtk, 1) );
     if ( fUseLutLib && Abc_FrameReadLibLut() )
@@ -321,7 +325,19 @@
     }
     Abc_Print( 1,"\n" );
 
-    // print the statistic into a file
+    // print the statistic into a file
+    if ( fDumpResult )
+    {
+        FILE * pTable = fopen( "abcstats.txt", "a+" );
+        fprintf( pTable, "%s ",  pNtk->pName );
+        fprintf( pTable, "%d ", Abc_NtkPiNum(pNtk) );
+        fprintf( pTable, "%d ", Abc_NtkPoNum(pNtk) );
+        fprintf( pTable, "%d ", Abc_NtkNodeNum(pNtk) );
+        fprintf( pTable, "%d ", Abc_NtkGetTotalFanins(pNtk) );
+        fprintf( pTable, "%d ", Abc_NtkLevel(pNtk) );
+        fprintf( pTable, "\n" );
+        fclose( pTable );
+    }
 /*
     {
         FILE * pTable;
@@ -1057,7 +1073,7 @@
 
         // count the gates by name
         CounterTotal = 0;
-        Abc_NtkForEachNode( pNtk, pObj, i )
+        Abc_NtkForEachNodeNotBarBuf( pNtk, pObj, i )
         {
             if ( i == 0 ) continue;
             Mio_GateSetValue( (Mio_Gate_t *)pObj->pData, 1 + Mio_GateReadValue((Mio_Gate_t *)pObj->pData) );
@@ -1112,7 +1128,7 @@
 
     // get hold of the SOP of the node
     CountConst = CountBuf = CountInv = CountAnd = CountOr = CountOther = CounterTotal = 0;
-    Abc_NtkForEachNode( pNtk, pObj, i )
+    Abc_NtkForEachNodeNotBarBuf( pNtk, pObj, i )
     {
         if ( i == 0 ) continue;
         if ( Abc_NtkHasMapping(pNtk) )
diff --git a/abc-build/src/base/abci/abcRec3.c b/abc-build/src/base/abci/abcRec3.c
--- a/abc-build/src/base/abci/abcRec3.c
+++ b/abc-build/src/base/abci/abcRec3.c
@@ -1430,4 +1430,4 @@
 ////////////////////////////////////////////////////////////////////////
 
 
-ABC_NAMESPACE_IMPL_END
+ABC_NAMESPACE_IMPL_END
diff --git a/abc-build/src/base/abci/abcStrash.c b/abc-build/src/base/abci/abcStrash.c
--- a/abc-build/src/base/abci/abcStrash.c
+++ b/abc-build/src/base/abci/abcStrash.c
@@ -412,7 +412,6 @@
 ***********************************************************************/
 void Abc_NtkStrashPerform( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkNew, int fAllNodes, int fRecord )
 {
-//    ProgressBar * pProgress;
     Vec_Ptr_t * vNodes;
     Abc_Obj_t * pNodeOld;
     int i; //, clk = Abc_Clock();
@@ -422,13 +421,13 @@
     vNodes = Abc_NtkDfsIter( pNtkOld, fAllNodes );
 //printf( "Nodes = %d. ", Vec_PtrSize(vNodes) );
 //ABC_PRT( "Time", Abc_Clock() - clk );
-//    pProgress = Extra_ProgressBarStart( stdout, vNodes->nSize );
     Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNodeOld, i )
-    {
-//        Extra_ProgressBarUpdate( pProgress, i, NULL );
-        pNodeOld->pCopy = Abc_NodeStrash( pNtkNew, pNodeOld, fRecord );
+    {
+        if ( Abc_ObjIsBarBuf(pNodeOld) )
+            pNodeOld->pCopy = Abc_ObjChild0Copy(pNodeOld);
+        else
+            pNodeOld->pCopy = Abc_NodeStrash( pNtkNew, pNodeOld, fRecord );
     }
-//    Extra_ProgressBarStop( pProgress );
     Vec_PtrFree( vNodes );
 }
 
diff --git a/abc-build/src/base/abci/abcTiming.c b/abc-build/src/base/abci/abcTiming.c
--- a/abc-build/src/base/abci/abcTiming.c
+++ b/abc-build/src/base/abci/abcTiming.c
@@ -827,7 +827,14 @@
 
     // start the arrival time of the node
     pTimeOut = Abc_NodeArrival(pNode);
-    pTimeOut->Rise = pTimeOut->Fall = -ABC_INFINITY; 
+    pTimeOut->Rise = pTimeOut->Fall = -ABC_INFINITY; 
+    // consider the buffer
+    if ( Abc_ObjIsBarBuf(pNode) )
+    {
+        pTimeIn = Abc_NodeArrival(Abc_ObjFanin0(pNode));
+        *pTimeOut = *pTimeIn;
+        return;
+    }
     // go through the pins of the gate
     pPin = Mio_GateReadPins((Mio_Gate_t *)pNode->pData);
     Abc_ObjForEachFanin( pNode, pFanin, i )
diff --git a/abc-build/src/base/abci/module.make b/abc-build/src/base/abci/module.make
--- a/abc-build/src/base/abci/module.make
+++ b/abc-build/src/base/abci/module.make
@@ -17,14 +17,14 @@
 	src/base/abci/abcDsd.c \
 	src/base/abci/abcExtract.c \
 	src/base/abci/abcFraig.c \
-        src/base/abci/abcFx.c \
-        src/base/abci/abcFxu.c \
-        src/base/abci/abcGen.c \
+	src/base/abci/abcFx.c \
+	src/base/abci/abcFxu.c \
+	src/base/abci/abcGen.c \
 	src/base/abci/abcHaig.c \
 	src/base/abci/abcIf.c \
 	src/base/abci/abcIfif.c \
 	src/base/abci/abcIfMux.c \
-        src/base/abci/abcIvy.c \
+	src/base/abci/abcIvy.c \
 	src/base/abci/abcLog.c \
 	src/base/abci/abcLut.c \
 	src/base/abci/abcLutmin.c \
diff --git a/abc-build/src/base/cba/cba.c b/abc-build/src/base/cba/cba.c
new file mode 100644
--- /dev/null
+++ b/abc-build/src/base/cba/cba.c
@@ -0,0 +1,52 @@
+/**CFile****************************************************************
+
+  FileName    [cba.c]
+
+  SystemName  [ABC: Logic synthesis and verification system.]
+
+  PackageName [Verilog parser.]
+
+  Synopsis    [Parses several flavors of word-level Verilog.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - November 29, 2014.]
+
+  Revision    [$Id: cba.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "cba.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/abc-build/src/base/cba/cba.h b/abc-build/src/base/cba/cba.h
new file mode 100644
--- /dev/null
+++ b/abc-build/src/base/cba/cba.h
@@ -0,0 +1,801 @@
+/**CFile****************************************************************
+
+  FileName    [cba.h]
+
+  SystemName  [ABC: Logic synthesis and verification system.]
+
+  PackageName [Hierarchical word-level netlist.]
+
+  Synopsis    [External declarations.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - November 29, 2014.]
+
+  Revision    [$Id: cba.h,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#ifndef ABC__base__cba__cba_h
+#define ABC__base__cba__cba_h
+
+////////////////////////////////////////////////////////////////////////
+///                          INCLUDES                                ///
+////////////////////////////////////////////////////////////////////////
+
+#include "aig/gia/gia.h"
+#include "misc/extra/extra.h"
+#include "misc/util/utilNam.h"
+
+////////////////////////////////////////////////////////////////////////
+///                         PARAMETERS                               ///
+////////////////////////////////////////////////////////////////////////
+
+ABC_NAMESPACE_HEADER_START 
+
+////////////////////////////////////////////////////////////////////////
+///                         BASIC TYPES                              ///
+////////////////////////////////////////////////////////////////////////
+
+// network objects
+typedef enum { 
+    CBA_OBJ_NONE = 0,  // 0:  unused
+    CBA_OBJ_PI,        // 1:  input
+    CBA_OBJ_PO,        // 2:  output
+    CBA_OBJ_BI,        // 3:  box input
+    CBA_OBJ_BO,        // 4:  box output
+    CBA_OBJ_BOX,       // 5:  box
+
+    CBA_BOX_C0,   
+    CBA_BOX_C1,   
+    CBA_BOX_CX,   
+    CBA_BOX_CZ,   
+    CBA_BOX_BUF,  
+    CBA_BOX_INV,  
+    CBA_BOX_AND,  
+    CBA_BOX_NAND, 
+    CBA_BOX_OR,   
+    CBA_BOX_NOR,  
+    CBA_BOX_XOR,  
+    CBA_BOX_XNOR, 
+    CBA_BOX_SHARP,
+    CBA_BOX_MUX,  
+    CBA_BOX_MAJ,  
+
+    CBA_BOX_RAND,
+    CBA_BOX_RNAND,
+    CBA_BOX_ROR,
+    CBA_BOX_RNOR,
+    CBA_BOX_RXOR,
+    CBA_BOX_RXNOR,
+
+    CBA_BOX_N1MUX,  
+    CBA_BOX_SEL,
+    CBA_BOX_PSEL,
+    CBA_BOX_ENC,
+    CBA_BOX_PENC,
+    CBA_BOX_DEC,
+    CBA_BOX_EDEC,
+
+    CBA_BOX_ADD,
+    CBA_BOX_SUB,
+    CBA_BOX_MUL,
+    CBA_BOX_DIV,
+    CBA_BOX_MOD,
+    CBA_BOX_REM,
+    CBA_BOX_POW,
+    CBA_BOX_MIN,
+    CBA_BOX_ABS,
+
+    CBA_BOX_LTHAN,
+    CBA_BOX_LETHAN,
+    CBA_BOX_METHAN,
+    CBA_BOX_MTHAN,
+    CBA_BOX_EQU,
+    CBA_BOX_NEQU,
+
+    CBA_BOX_SHIL,
+    CBA_BOX_SHIR,
+    CBA_BOX_ROTL,
+    CBA_BOX_ROTR,
+
+    CBA_BOX_GATE,  
+    CBA_BOX_LUT,  
+    CBA_BOX_ASSIGN,  
+
+    CBA_BOX_TRI,
+    CBA_BOX_RAM,
+    CBA_BOX_RAMR,
+    CBA_BOX_RAMW,
+    CBA_BOX_RAMWC,
+
+    CBA_BOX_LATCH,
+    CBA_BOX_LATCHRS,
+    CBA_BOX_DFF,
+    CBA_BOX_DFFRS,
+
+    CBA_BOX_UNKNOWN   // 67
+} Cba_ObjType_t; 
+
+
+typedef struct Cba_Ntk_t_ Cba_Ntk_t;
+typedef struct Cba_Man_t_ Cba_Man_t;
+
+// network
+struct Cba_Ntk_t_
+{
+    Cba_Man_t *  pDesign;  // design
+    int          NameId;   // name ID
+    int          iCopy;    // copy module
+    int          iBoxNtk;  // instance network ID
+    int          iBoxObj;  // instance object ID
+    int          Count;    // object counter
+    int          Mark;     // visit mark 
+    // interface
+    Vec_Int_t    vInputs;  // inputs 
+    Vec_Int_t    vOutputs; // outputs
+    // object attributes
+    Vec_Str_t    vType;    // types     
+    Vec_Int_t    vFanin;   // fanin
+    Vec_Int_t    vIndex;   // index
+    Vec_Int_t    vName;    // original NameId or InstId
+    Vec_Int_t    vRange;   // range
+    Vec_Int_t    vCopy;    // copy
+    // other
+    Vec_Int_t    vArray;
+};
+
+// design
+struct Cba_Man_t_
+{
+    // design names
+    char *       pName;    // design name
+    char *       pSpec;    // spec file name
+    Abc_Nam_t *  pStrs;    // string manager
+    Abc_Nam_t *  pMods;    // module name manager
+    // internal data
+    int          iRoot;    // root network
+    int          nNtks;    // number of current networks
+    Cba_Ntk_t *  pNtks;    // networks
+    Vec_Int_t    vInfo;    // box info
+    // user data
+    Vec_Int_t    vBuf2RootNtk;
+    Vec_Int_t    vBuf2RootObj;
+    Vec_Int_t    vBuf2LeafNtk;
+    Vec_Int_t    vBuf2LeafObj;
+    void *       pMioLib;
+    void **      ppGraphs;
+    int          ElemGates[4];
+};
+
+static inline char *         Cba_ManName( Cba_Man_t * p )                    { return p->pName;                                                                            }
+static inline char *         Cba_ManSpec( Cba_Man_t * p )                    { return p->pSpec;                                                                            }
+static inline int            Cba_ManNtkNum( Cba_Man_t * p )                  { return p->nNtks;                                                                            }
+static inline int            Cba_ManNtkIsOk( Cba_Man_t * p, int i )          { return i >= 0 && i < Cba_ManNtkNum(p);                                                      }
+static inline Cba_Ntk_t *    Cba_ManNtk( Cba_Man_t * p, int i )              { return Cba_ManNtkIsOk(p, i) ? p->pNtks + i : NULL;                                          }
+static inline int            Cba_ManNtkFindId( Cba_Man_t * p, char * pName ) { return Abc_NamStrFind(p->pMods, pName) - 1;                                                 }
+static inline Cba_Ntk_t *    Cba_ManNtkFind( Cba_Man_t * p, char * pName )   { return Cba_ManNtk( p, Cba_ManNtkFindId(p, pName) );                                         }
+static inline Cba_Ntk_t *    Cba_ManRoot( Cba_Man_t * p )                    { return Cba_ManNtk(p, p->iRoot);                                                             }
+static inline char *         Cba_ManStr( Cba_Man_t * p, int i )              { return Abc_NamStr(p->pStrs, i);                                                             }
+static inline int            Cba_ManStrId( Cba_Man_t * p, char * pStr )      { return Abc_NamStrFind(p->pStrs, pStr);                                                      }
+static inline int            Cba_ManInfoNum( Cba_Man_t * p )                 { return Vec_IntSize(&p->vInfo) >> 2;                                                         }
+
+static inline int            Cba_NtkId( Cba_Ntk_t * p )                      { int i = p - p->pDesign->pNtks; assert(Cba_ManNtkIsOk(p->pDesign, i)); return i;             }
+static inline Cba_Man_t *    Cba_NtkMan( Cba_Ntk_t * p )                     { return p->pDesign;                                                                          }
+static inline int            Cba_NtkNameId( Cba_Ntk_t * p )                  { return p->NameId;                                                                           }
+static inline char *         Cba_NtkName( Cba_Ntk_t * p )                    { return Cba_ManStr(p->pDesign, Cba_NtkNameId(p));                                            }
+static inline int            Cba_NtkCopy( Cba_Ntk_t * p )                    { return p->iCopy;                                                                            }
+static inline Cba_Ntk_t *    Cba_NtkCopyNtk(Cba_Man_t * pNew, Cba_Ntk_t * p) { return Cba_ManNtk(pNew, Cba_NtkCopy(p));                                                    }
+static inline void           Cba_NtkSetCopy( Cba_Ntk_t * p, int i )          { assert(p->iCopy == -1); p->iCopy = i;                                                       }
+
+static inline int            Cba_NtkObjNum( Cba_Ntk_t * p )                  { return Vec_StrSize(&p->vType);                                                              }
+static inline int            Cba_NtkObjNumAlloc( Cba_Ntk_t * p )             { return Vec_StrCap(&p->vType);                                                               }
+static inline int            Cba_NtkPiNum( Cba_Ntk_t * p )                   { return Vec_IntSize(&p->vInputs);                                                            }
+static inline int            Cba_NtkPoNum( Cba_Ntk_t * p )                   { return Vec_IntSize(&p->vOutputs);                                                           }
+static inline int            Cba_NtkPioNum( Cba_Ntk_t * p )                  { return Cba_NtkPiNum(p) + Cba_NtkPoNum(p);                                                   }
+static inline int            Cba_NtkPiNumAlloc( Cba_Ntk_t * p )              { return Vec_IntCap(&p->vInputs);                                                             }
+static inline int            Cba_NtkPoNumAlloc( Cba_Ntk_t * p )              { return Vec_IntCap(&p->vOutputs);                                                            }
+static inline int            Cba_NtkBiNum( Cba_Ntk_t * p )                   { return Vec_StrCountEntry(&p->vType, (char)CBA_OBJ_BI);                                      }
+static inline int            Cba_NtkBoNum( Cba_Ntk_t * p )                   { return Vec_StrCountEntry(&p->vType, (char)CBA_OBJ_BO);                                      }
+static inline int            Cba_NtkCiNum( Cba_Ntk_t * p )                   { return Cba_NtkPiNum(p) + Cba_NtkBoNum(p);                                                   }
+static inline int            Cba_NtkCoNum( Cba_Ntk_t * p )                   { return Cba_NtkPoNum(p) + Cba_NtkBiNum(p);                                                   }
+static inline int            Cba_NtkBoxNum( Cba_Ntk_t * p )                  { return Cba_NtkObjNum(p) - Vec_StrCountSmaller(&p->vType, (char)CBA_OBJ_BOX);                }
+static inline int            Cba_NtkPrimNum( Cba_Ntk_t * p )                 { return Vec_StrCountLarger(&p->vType, (char)CBA_OBJ_BOX);                                    }
+static inline int            Cba_NtkUserNum( Cba_Ntk_t * p )                 { return Vec_StrCountEntry(&p->vType, (char)CBA_OBJ_BOX);                                     }
+ 
+static inline int            Cba_NtkPi( Cba_Ntk_t * p, int i )               { return Vec_IntEntry(&p->vInputs, i);                                                        }
+static inline int            Cba_NtkPo( Cba_Ntk_t * p, int i )               { return Vec_IntEntry(&p->vOutputs, i);                                                       }
+static inline char *         Cba_NtkStr( Cba_Ntk_t * p, int i )              { return Cba_ManStr(p->pDesign, i);                                                           }
+static inline Cba_Ntk_t *    Cba_NtkHostNtk( Cba_Ntk_t * p )                 { return p->iBoxNtk >= 0 ? Cba_ManNtk(p->pDesign, p->iBoxNtk) : NULL;                         }
+static inline int            Cba_NtkHostObj( Cba_Ntk_t * p )                 { return p->iBoxObj;                                                                          }
+static inline void           Cba_NtkSetHost( Cba_Ntk_t * p, int n, int i )   { assert(p->iBoxNtk == -1); p->iBoxNtk = n; p->iBoxObj = i;                                   }
+
+static inline void           Cba_NtkStartNames( Cba_Ntk_t * p )              { assert(Cba_NtkObjNumAlloc(p)); Vec_IntFill(&p->vName,  Cba_NtkObjNumAlloc(p),  0);          }
+static inline void           Cba_NtkStartRanges( Cba_Ntk_t * p )             { assert(Cba_NtkObjNumAlloc(p)); Vec_IntFill(&p->vRange, Cba_NtkObjNumAlloc(p),  0);          }
+static inline void           Cba_NtkStartCopies( Cba_Ntk_t * p )             { assert(Cba_NtkObjNumAlloc(p)); Vec_IntFill(&p->vCopy,  Cba_NtkObjNumAlloc(p), -1);          }
+static inline void           Cba_NtkFreeNames( Cba_Ntk_t * p )               { Vec_IntErase(&p->vName);                                                                    }
+static inline void           Cba_NtkFreeRanges( Cba_Ntk_t * p )              { Vec_IntErase(&p->vRange);                                                                   }
+static inline void           Cba_NtkFreeCopies( Cba_Ntk_t * p )              { Vec_IntErase(&p->vCopy);                                                                    }
+static inline int            Cba_NtkHasNames( Cba_Ntk_t * p )                { return p->vName.pArray != NULL;                                                             }
+static inline int            Cba_NtkHasRanges( Cba_Ntk_t * p )               { return p->vRange.pArray != NULL;                                                            }
+static inline int            Cba_NtkHasCopies( Cba_Ntk_t * p )               { return p->vCopy.pArray != NULL;                                                             }
+
+static inline int            Cba_TypeIsBox( Cba_ObjType_t Type )             { return Type >= CBA_OBJ_BOX && Type < CBA_BOX_UNKNOWN;                                       }
+
+static inline Cba_ObjType_t  Cba_ObjType( Cba_Ntk_t * p, int i )             { return (Cba_ObjType_t)Vec_StrEntry(&p->vType, i);                                           }
+static inline int            Cba_ObjIsPi( Cba_Ntk_t * p, int i )             { return Cba_ObjType(p, i) == CBA_OBJ_PI;                                                     }
+static inline int            Cba_ObjIsPo( Cba_Ntk_t * p, int i )             { return Cba_ObjType(p, i) == CBA_OBJ_PO;                                                     }
+static inline int            Cba_ObjIsPio( Cba_Ntk_t * p, int i )            { return Cba_ObjIsPi(p, i) || Cba_ObjIsPo(p, i);                                              }
+static inline int            Cba_ObjIsBi( Cba_Ntk_t * p, int i )             { return Cba_ObjType(p, i) == CBA_OBJ_BI;                                                     }
+static inline int            Cba_ObjIsBo( Cba_Ntk_t * p, int i )             { return Cba_ObjType(p, i) == CBA_OBJ_BO;                                                     }
+static inline int            Cba_ObjIsBio( Cba_Ntk_t * p, int i )            { return Cba_ObjIsBi(p, i) || Cba_ObjIsBo(p, i);                                              }
+static inline int            Cba_ObjIsBox( Cba_Ntk_t * p, int i )            { return Cba_TypeIsBox(Cba_ObjType(p, i));                                                    }
+static inline int            Cba_ObjIsBoxUser( Cba_Ntk_t * p, int i )        { return Cba_ObjType(p, i) == CBA_OBJ_BOX;                                                    }
+static inline int            Cba_ObjIsBoxPrim( Cba_Ntk_t * p, int i )        { return Cba_ObjIsBox(p, i) && !Cba_ObjIsBoxUser(p, i);                                       }
+static inline int            Cba_ObjIsGate( Cba_Ntk_t * p, int i )           { return Cba_ObjType(p, i) == CBA_BOX_GATE;                                                   }
+static inline int            Cba_ObjIsCi( Cba_Ntk_t * p, int i )             { return Cba_ObjIsPi(p, i) || Cba_ObjIsBo(p, i);                                              }
+static inline int            Cba_ObjIsCo( Cba_Ntk_t * p, int i )             { return Cba_ObjIsPo(p, i) || Cba_ObjIsBi(p, i);                                              }
+static inline int            Cba_ObjIsCio( Cba_Ntk_t * p, int i )            { return Cba_ObjType(p, i) < CBA_OBJ_BOX;                                                     }
+
+static inline int            Cba_ObjFanin( Cba_Ntk_t * p, int i )            { assert(Cba_ObjIsCo(p, i)); return Vec_IntEntry(&p->vFanin, i);                              }
+static inline int            Cba_ObjIndex( Cba_Ntk_t * p, int i )            { assert(Cba_ObjIsCio(p, i)); return Vec_IntEntry(&p->vIndex, i);                             }
+static inline int            Cba_ObjFaninTwo( Cba_Ntk_t * p, int i )         { return Cba_ObjFanin(p, Cba_ObjFanin(p, i));                                                 }
+static inline int            Cba_ObjName( Cba_Ntk_t * p, int i )             { return Vec_IntEntry(&p->vName, i);                                                          }
+static inline int            Cba_ObjRange( Cba_Ntk_t * p, int i )            { return Vec_IntEntry(&p->vRange, i);                                                         }
+static inline int            Cba_ObjCopy( Cba_Ntk_t * p, int i )             { return Vec_IntEntry(&p->vCopy, i);                                                          }
+static inline char *         Cba_ObjNameStr( Cba_Ntk_t * p, int i )          { return Cba_NtkStr(p, Cba_ObjName(p, i));                                                    }
+static inline char *         Cba_ObjRangeStr( Cba_Ntk_t * p, int i )         { return Cba_NtkStr(p, Cba_ObjRange(p, i));                                                   }
+static inline void           Cba_ObjSetFanin( Cba_Ntk_t * p, int i, int x )  { assert(Cba_ObjFanin(p, i) == -1); Vec_IntWriteEntry( &p->vFanin, i, x );                    }
+static inline void           Cba_ObjSetIndex( Cba_Ntk_t * p, int i, int x )  { assert(Cba_ObjIndex(p, i) == -1); Vec_IntWriteEntry( &p->vIndex, i, x );                    }
+static inline void           Cba_ObjSetName( Cba_Ntk_t * p, int i, int x )   { assert(Cba_ObjName(p, i) == 0);   Vec_IntWriteEntry( &p->vName,  i, x );                    }
+static inline void           Cba_ObjSetRange( Cba_Ntk_t * p, int i, int x )  { assert(Cba_ObjRange(p, i) == 0);  Vec_IntWriteEntry( &p->vRange, i, x );                    }
+static inline void           Cba_ObjSetCopy( Cba_Ntk_t * p, int i, int x )   { assert(Cba_ObjCopy(p, i) == -1);  Vec_IntWriteEntry( &p->vCopy,  i, x );                    }
+
+static inline int            Cba_BoxBiNum( Cba_Ntk_t * p, int i )            { int s = i-1; assert(Cba_ObjIsBox(p, i)); while (--i >= 0               && Cba_ObjIsBi(p, i)); return s - i;  }
+static inline int            Cba_BoxBoNum( Cba_Ntk_t * p, int i )            { int s = i+1; assert(Cba_ObjIsBox(p, i)); while (++i < Cba_NtkObjNum(p) && Cba_ObjIsBo(p, i)); return i - s;  }
+static inline int            Cba_BoxSize( Cba_Ntk_t * p, int i )             { return 1 + Cba_BoxBiNum(p, i) + Cba_BoxBoNum(p, i);                                         }
+static inline int            Cba_BoxBi( Cba_Ntk_t * p, int b, int i )        { assert(Cba_ObjIsBox(p, b)); return b - 1 - i;                                               }
+static inline int            Cba_BoxBo( Cba_Ntk_t * p, int b, int i )        { assert(Cba_ObjIsBox(p, b)); return b + 1 + i;                                               }
+static inline int            Cba_BoxBiBox( Cba_Ntk_t * p, int i )            { assert(Cba_ObjIsBi(p, i)); return i + 1 + Cba_ObjIndex(p, i);                               }
+static inline int            Cba_BoxBoBox( Cba_Ntk_t * p, int i )            { assert(Cba_ObjIsBo(p, i)); return i - 1 - Cba_ObjIndex(p, i);                               }
+static inline int            Cba_BoxFanin( Cba_Ntk_t * p, int b, int i )     { return Cba_ObjFanin(p, Cba_BoxBi(p, b, i));                                                 }
+
+static inline int            Cba_BoxNtkId( Cba_Ntk_t * p, int i )            { assert(Cba_ObjIsBox(p, i)); return Vec_IntEntry(&p->vFanin, i);                             }
+static inline void           Cba_BoxSetNtkId( Cba_Ntk_t * p, int i, int x )  { assert(Cba_ObjIsBox(p, i) && Cba_ManNtkIsOk(p->pDesign, x)); Vec_IntWriteEntry(&p->vFanin, i, x);            }
+static inline int            Cba_BoxBiNtkId( Cba_Ntk_t * p, int i )          { assert(Cba_ObjIsBi(p, i)); return Cba_BoxNtkId(p, Cba_BoxBiBox(p, i));                      }
+static inline int            Cba_BoxBoNtkId( Cba_Ntk_t * p, int i )          { assert(Cba_ObjIsBo(p, i)); return Cba_BoxNtkId(p, Cba_BoxBoBox(p, i));                      }
+static inline Cba_Ntk_t *    Cba_BoxNtk( Cba_Ntk_t * p, int i )              { return Cba_ManNtk( p->pDesign, Cba_BoxNtkId(p, i) );                                        }
+static inline Cba_Ntk_t *    Cba_BoxBiNtk( Cba_Ntk_t * p, int i )            { return Cba_ManNtk( p->pDesign, Cba_BoxBiNtkId(p, i) );                                      }
+static inline Cba_Ntk_t *    Cba_BoxBoNtk( Cba_Ntk_t * p, int i )            { return Cba_ManNtk( p->pDesign, Cba_BoxBoNtkId(p, i) );                                      }
+static inline char *         Cba_BoxNtkName( Cba_Ntk_t * p, int i )          { return Abc_NamStr( p->pDesign->pMods, Cba_BoxNtkId(p, i) );                                 }
+
+
+////////////////////////////////////////////////////////////////////////
+///                      MACRO DEFINITIONS                           ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+///                             ITERATORS                            ///
+////////////////////////////////////////////////////////////////////////
+
+#define Cba_ManForEachNtk( p, pNtk, i )                                   \
+    for ( i = 0; (i < Cba_ManNtkNum(p)) && (((pNtk) = Cba_ManNtk(p, i)), 1); i++ ) 
+
+#define Cba_NtkForEachPi( p, iObj, i )                                    \
+    for ( i = 0; (i < Cba_NtkPiNum(p))  && (((iObj) = Vec_IntEntry(&p->vInputs, i)), 1); i++ ) 
+#define Cba_NtkForEachPo( p, iObj, i )                                    \
+    for ( i = 0; (i < Cba_NtkPoNum(p))  && (((iObj) = Vec_IntEntry(&p->vOutputs, i)), 1); i++ ) 
+
+#define Cba_NtkForEachObj( p, i )                                         \
+    for ( i = 0; (i < Cba_NtkObjNum(p)); i++ ) 
+#define Cba_NtkForEachObjType( p, Type, i )                               \
+    for ( i = 0; (i < Cba_NtkObjNum(p))  && (((Type) = Cba_ObjType(p, i)), 1); i++ ) 
+
+#define Cba_NtkForEachBox( p, i )                                         \
+    for ( i = 0; (i < Cba_NtkObjNum(p)); i++ ) if ( !Cba_ObjIsBox(p, i) ) {} else
+#define Cba_NtkForEachBoxUser( p, i )                                     \
+    for ( i = 0; (i < Cba_NtkObjNum(p)); i++ ) if ( !Cba_ObjIsBoxUser(p, i) ) {} else
+#define Cba_NtkForEachBoxPrim( p, i )                                     \
+    for ( i = 0; (i < Cba_NtkObjNum(p)); i++ ) if ( !Cba_ObjIsBoxPrim(p, i) ) {} else
+
+#define Cba_NtkForEachCi( p, i )                                          \
+    for ( i = 0; (i < Cba_NtkObjNum(p)); i++ ) if ( !Cba_ObjIsCi(p, i) ) {} else
+#define Cba_NtkForEachCo( p, i )                                          \
+    for ( i = 0; (i < Cba_NtkObjNum(p)); i++ ) if ( !Cba_ObjIsCo(p, i) ) {} else
+#define Cba_NtkForEachCio( p, i )                                         \
+    for ( i = 0; (i < Cba_NtkObjNum(p)); i++ ) if ( !Cba_ObjIsCio(p, i) ){} else
+
+#define Cba_NtkForEachBi( p, i )                                          \
+    for ( i = 0; (i < Cba_NtkObjNum(p)); i++ ) if ( !Cba_ObjIsBi(p, i) ){} else
+#define Cba_NtkForEachBo( p, i )                                          \
+    for ( i = 0; (i < Cba_NtkObjNum(p)); i++ ) if ( !Cba_ObjIsBo(p, i) ){} else
+#define Cba_NtkForEachBio( p, i )                                         \
+    for ( i = 0; (i < Cba_NtkObjNum(p)); i++ ) if ( !Cba_ObjIsBio(p, i) ){} else
+
+#define Cba_BoxForEachBi( p, iBox, iTerm, i )                             \
+    for ( iTerm = iBox - 1, i = 0; iTerm >= 0 && Cba_ObjIsBi(p, iTerm); iTerm--, i++ )
+#define Cba_BoxForEachBo( p, iBox, iTerm, i )                             \
+    for ( iTerm = iBox + 1, i = 0; iTerm < Cba_NtkObjNum(p) && Cba_ObjIsBo(p, iTerm); iTerm++, i++ )
+#define Cba_BoxForEachBiReverse( p, iBox, iTerm, i )                      \
+    for ( i = Cba_BoxBiNum(p, iBox), iTerm = iBox - i--; Cba_ObjIsBi(p, iTerm); iTerm++, i-- )
+
+#define Cba_BoxForEachFanin( p, iBox, iFanin, i )                         \
+    for ( i = 0; iBox - 1 - i >= 0 && Cba_ObjIsBi(p, iBox - 1 - i) && (((iFanin) = Cba_BoxFanin(p, iBox, i)), 1); i++ )
+
+////////////////////////////////////////////////////////////////////////
+///                    FUNCTION DECLARATIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    [Object APIs.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Cba_ObjAlloc( Cba_Ntk_t * p, Cba_ObjType_t Type, int Fanin )
+{
+    int iObj = Cba_NtkObjNum(p);
+    assert( iObj == Vec_IntSize(&p->vFanin) );
+    if ( Type == CBA_OBJ_PI )
+        Vec_IntPush( &p->vInputs, iObj );
+    else if ( Type == CBA_OBJ_PO )
+        Vec_IntPush( &p->vOutputs, iObj );
+    Vec_StrPush( &p->vType, (char)Type );
+    Vec_IntPush( &p->vFanin, Fanin );
+    return iObj;
+}
+static inline int Cba_ObjDup( Cba_Ntk_t * pNew, Cba_Ntk_t * p, int i )
+{
+    int iObj = Cba_ObjAlloc( pNew, Cba_ObjType(p, i), Cba_ObjIsBox(p, i) ? Cba_BoxNtkId(p, i) : -1 );
+    if ( Cba_NtkHasNames(p) && Cba_NtkHasNames(pNew) ) 
+        Cba_ObjSetName( pNew, iObj, Cba_ObjName(p, i) );
+    if ( Cba_NtkHasRanges(p) && Cba_NtkHasRanges(pNew) ) 
+        Cba_ObjSetRange( pNew, iObj, Cba_ObjRange(p, i) );
+    Cba_ObjSetCopy( p, i, iObj );
+    return iObj;
+}
+static inline int Cba_BoxAlloc( Cba_Ntk_t * p, Cba_ObjType_t Type, int nIns, int nOuts, int iNtk )
+{
+    int i, iObj;
+    for ( i = nIns - 1; i >= 0; i-- )
+        Cba_ObjAlloc( p, CBA_OBJ_BI, -1 );
+    iObj = Cba_ObjAlloc( p, Type, iNtk );
+    for ( i = 0; i < nOuts; i++ )
+        Cba_ObjAlloc( p, CBA_OBJ_BO, -1 );
+    return iObj;
+}
+static inline int Cba_BoxDup( Cba_Ntk_t * pNew, Cba_Ntk_t * p, int iBox )
+{
+    int i, iTerm, iBoxNew;
+    Cba_BoxForEachBiReverse( p, iBox, iTerm, i )
+        Cba_ObjDup( pNew, p, iTerm );
+    iBoxNew = Cba_ObjDup( pNew, p, iBox );
+    if ( Cba_BoxNtk(p, iBox) )
+        Cba_BoxSetNtkId( pNew, iBoxNew, Cba_NtkCopy(Cba_BoxNtk(p, iBox)) );
+    Cba_BoxForEachBo( p, iBox, iTerm, i )
+        Cba_ObjDup( pNew, p, iTerm );
+    return iBoxNew;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    [Network APIs.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline void Cba_NtkAlloc( Cba_Ntk_t * pNew, int NameId, int nIns, int nOuts, int nObjs )
+{
+    int NtkId, fFound;
+    assert( pNew->pDesign != NULL );
+    assert( Cba_NtkPiNum(pNew) == 0 );
+    assert( Cba_NtkPoNum(pNew) == 0 );
+    pNew->NameId  = NameId;
+    pNew->iCopy   = -1;
+    pNew->iBoxNtk = -1;
+    pNew->iBoxObj = -1;
+    Vec_IntGrow( &pNew->vInputs,  nIns );
+    Vec_IntGrow( &pNew->vOutputs, nOuts );
+    Vec_StrGrow( &pNew->vType,    nObjs );
+    Vec_IntGrow( &pNew->vFanin,   nObjs );
+    // check if the network is unique
+    NtkId = Abc_NamStrFindOrAdd( pNew->pDesign->pMods, Cba_NtkStr(pNew, NameId), &fFound );
+    if ( fFound )
+        printf( "Network with name %s already exists.\n", Cba_NtkStr(pNew, NameId) );
+    else
+        assert( NtkId == Cba_NtkId(pNew) + 1 );
+}
+static inline void Cba_NtkDup( Cba_Ntk_t * pNew, Cba_Ntk_t * p )
+{
+    int i, iObj;
+    assert( pNew != p );
+    Cba_NtkAlloc( pNew, Cba_NtkNameId(p), Cba_NtkPiNum(p), Cba_NtkPoNum(p), Cba_NtkObjNum(p) );
+    Cba_NtkStartCopies( p );
+    if ( Cba_NtkHasNames(p) )
+        Cba_NtkStartNames( pNew );
+    Cba_NtkForEachPi( p, iObj, i )
+        Cba_ObjDup( pNew, p, iObj );
+    Cba_NtkForEachBox( p, iObj )
+        Cba_BoxDup( pNew, p, iObj );
+    Cba_NtkForEachPo( p, iObj, i )
+        Cba_ObjDup( pNew, p, iObj );
+    Cba_NtkForEachCo( p, iObj )
+        Cba_ObjSetFanin( pNew, Cba_ObjCopy(p, iObj), Cba_ObjCopy(p, Cba_ObjFanin(p, iObj)) );
+    //Cba_NtkFreeCopies( p ); // needed for host ntk
+    assert( Cba_NtkObjNum(pNew) == Cba_NtkObjNumAlloc(pNew) );
+}
+static inline void Cba_NtkDupUserBoxes( Cba_Ntk_t * pNew, Cba_Ntk_t * p )
+{
+    int i, iObj;
+    assert( pNew != p );
+    Cba_NtkAlloc( pNew, Cba_NtkNameId(p), Cba_NtkPiNum(p), Cba_NtkPoNum(p), Cba_NtkObjNum(p) + 3*Cba_NtkCoNum(p) );
+    Cba_NtkStartCopies( p );
+    if ( Cba_NtkHasNames(p) )
+        Cba_NtkStartNames( pNew );
+    Cba_NtkForEachPi( p, iObj, i )
+        Cba_ObjDup( pNew, p, iObj );
+    Cba_NtkForEachPo( p, iObj, i )
+        Cba_ObjDup( pNew, p, iObj );
+    Cba_NtkForEachBoxUser( p, iObj )
+        Cba_BoxDup( pNew, p, iObj );
+    // connect feed-throughs
+    Cba_NtkForEachCo( p, iObj )
+        if ( Cba_ObjCopy(p, iObj) >= 0 && 
+             Cba_ObjCopy(p, Cba_ObjFanin(p, iObj)) >= 0 && 
+             Cba_ObjName(p, iObj) == Cba_ObjName(p, Cba_ObjFanin(p, iObj)) )
+            Cba_ObjSetFanin( pNew, Cba_ObjCopy(p, iObj), Cba_ObjCopy(p, Cba_ObjFanin(p, iObj)) );
+}
+static inline void Cba_NtkFree( Cba_Ntk_t * p )
+{
+    Vec_IntErase( &p->vInputs );
+    Vec_IntErase( &p->vOutputs );
+    Vec_StrErase( &p->vType );
+    Vec_IntErase( &p->vFanin );    
+    Vec_IntErase( &p->vIndex );
+    Vec_IntErase( &p->vName );    
+    Vec_IntErase( &p->vRange );    
+    Vec_IntErase( &p->vCopy );    
+    Vec_IntErase( &p->vArray );    
+}
+static inline int Cba_NtkMemory( Cba_Ntk_t * p )
+{
+    int nMem = sizeof(Cba_Ntk_t);
+    nMem += Vec_IntMemory(&p->vInputs);
+    nMem += Vec_IntMemory(&p->vOutputs);
+    nMem += Vec_StrMemory(&p->vType);
+    nMem += Vec_IntMemory(&p->vFanin);
+    nMem += Vec_IntMemory(&p->vIndex);
+    nMem += Vec_IntMemory(&p->vName);
+    nMem += Vec_IntMemory(&p->vRange);
+    nMem += Vec_IntMemory(&p->vCopy);
+    return nMem;
+}
+static inline void Cba_NtkPrintStats( Cba_Ntk_t * p )
+{
+    printf( "pi =%5d  ",   Cba_NtkPiNum(p) );
+    printf( "pi =%5d  ",   Cba_NtkPoNum(p) );
+    printf( "box =%6d  ",  Cba_NtkBoxNum(p) );
+    printf( "clp =%7d  ",  p->Count );
+    printf( "obj =%7d  ",  Cba_NtkObjNum(p) );
+    printf( "%s ",         Cba_NtkName(p) );
+    if ( Cba_NtkHostNtk(p) )
+        printf( "-> %s",   Cba_NtkName(Cba_NtkHostNtk(p)) );
+    printf( "\n" );
+}
+static inline void Cba_NtkDeriveIndex( Cba_Ntk_t * p )
+{
+    int i, iObj, iTerm;
+    Vec_IntFill( &p->vIndex, Cba_NtkObjNum(p), -1 );
+    Cba_NtkForEachPi( p, iObj, i )
+        Cba_ObjSetIndex( p, iObj, i );
+    Cba_NtkForEachPo( p, iObj, i )
+        Cba_ObjSetIndex( p, iObj, i );
+    Cba_NtkForEachBox( p, iObj )
+    {
+        Cba_BoxForEachBi( p, iObj, iTerm, i )
+            Cba_ObjSetIndex( p, iTerm, i );
+        Cba_BoxForEachBo( p, iObj, iTerm, i )
+            Cba_ObjSetIndex( p, iTerm, i );
+    }
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    [Manager APIs.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline Cba_Man_t * Cba_ManAlloc( char * pFileName, int nNtks )
+{
+    Cba_Ntk_t * pNtk; int i;
+    Cba_Man_t * pNew = ABC_CALLOC( Cba_Man_t, 1 );
+    pNew->pName = Extra_FileDesignName( pFileName );
+    pNew->pSpec = Abc_UtilStrsav( pFileName );
+    pNew->pStrs = Abc_NamStart( 1000, 24 );
+    pNew->pMods = Abc_NamStart( 1000, 24 );
+    pNew->iRoot = 0;
+    pNew->nNtks = nNtks;
+    pNew->pNtks = ABC_CALLOC( Cba_Ntk_t, pNew->nNtks );
+    Cba_ManForEachNtk( pNew, pNtk, i )
+        pNtk->pDesign = pNew;
+    return pNew;
+}
+static inline Cba_Man_t * Cba_ManStart( Cba_Man_t * p, int nNtks )
+{
+    Cba_Ntk_t * pNtk; int i;
+    Cba_Man_t * pNew = ABC_CALLOC( Cba_Man_t, 1 );
+    pNew->pName = Abc_UtilStrsav( Cba_ManName(p) );
+    pNew->pSpec = Abc_UtilStrsav( Cba_ManSpec(p) );
+    pNew->pStrs = Abc_NamRef( p->pStrs );  
+    pNew->pMods = Abc_NamStart( 1000, 24 );
+    pNew->iRoot = 0;
+    pNew->nNtks = nNtks;
+    pNew->pNtks = ABC_CALLOC( Cba_Ntk_t, nNtks );
+    Cba_ManForEachNtk( pNew, pNtk, i )
+        pNtk->pDesign = pNew;
+    return pNew;
+}
+static inline Cba_Man_t * Cba_ManDup( Cba_Man_t * p )
+{
+    Cba_Ntk_t * pNtk, * pHost; int i;
+    Cba_Man_t * pNew = Cba_ManStart( p, Cba_ManNtkNum(p) );
+    Cba_ManForEachNtk( p, pNtk, i )
+        Cba_NtkSetCopy( pNtk, i );
+    Cba_ManForEachNtk( p, pNtk, i )
+        Cba_NtkDup( Cba_NtkCopyNtk(pNew, pNtk), pNtk );
+    Cba_ManForEachNtk( p, pNtk, i )
+        if ( (pHost = Cba_NtkHostNtk(pNtk)) )
+            Cba_NtkSetHost( Cba_NtkCopyNtk(pNew, pNtk), Cba_NtkCopy(pHost), Cba_ObjCopy(pHost, Cba_NtkHostObj(pNtk)) );
+    return pNew;
+}
+static inline Cba_Man_t * Cba_ManDupUserBoxes( Cba_Man_t * p )
+{
+    Cba_Ntk_t * pNtk, * pHost; int i;
+    Cba_Man_t * pNew = Cba_ManStart( p, Cba_ManNtkNum(p) );
+    Cba_ManForEachNtk( p, pNtk, i )
+        Cba_NtkSetCopy( pNtk, i );
+    Cba_ManForEachNtk( p, pNtk, i )
+        Cba_NtkDupUserBoxes( Cba_NtkCopyNtk(pNew, pNtk), pNtk );
+    Cba_ManForEachNtk( p, pNtk, i )
+        if ( (pHost = Cba_NtkHostNtk(pNtk)) )
+            Cba_NtkSetHost( Cba_NtkCopyNtk(pNew, pNtk), Cba_NtkCopy(pHost), Cba_ObjCopy(pHost, Cba_NtkHostObj(pNtk)) );
+    return pNew;
+}
+
+
+static inline void Cba_ManFree( Cba_Man_t * p )
+{
+    Cba_Ntk_t * pNtk; int i;
+    Cba_ManForEachNtk( p, pNtk, i )
+        Cba_NtkFree( pNtk );
+    Vec_IntErase( &p->vBuf2LeafNtk );
+    Vec_IntErase( &p->vBuf2LeafObj );
+    Vec_IntErase( &p->vBuf2RootNtk );
+    Vec_IntErase( &p->vBuf2RootObj );
+    Vec_IntErase( &p->vInfo );
+    Abc_NamDeref( p->pStrs );
+    Abc_NamDeref( p->pMods );
+    ABC_FREE( p->pName );
+    ABC_FREE( p->pSpec );
+    ABC_FREE( p->pNtks );
+    ABC_FREE( p );
+}
+static inline int Cba_ManMemory( Cba_Man_t * p )
+{
+    Cba_Ntk_t * pNtk; int i;
+    int nMem = sizeof(Cba_Man_t);
+    if ( p->pName )
+    nMem += (int)strlen(p->pName);
+    if ( p->pSpec )
+    nMem += (int)strlen(p->pSpec);
+    nMem += Abc_NamMemUsed(p->pStrs);
+    nMem += Abc_NamMemUsed(p->pMods);
+    Cba_ManForEachNtk( p, pNtk, i )
+        nMem += Cba_NtkMemory( pNtk );
+    return nMem;
+}
+static inline int Cba_ManObjNum( Cba_Man_t * p )
+{
+    Cba_Ntk_t * pNtk; int i, Count = 0;
+    Cba_ManForEachNtk( p, pNtk, i )
+        Count += Cba_NtkObjNum(pNtk);
+    return Count;
+}
+static inline int Cba_ManNodeNum( Cba_Man_t * p )
+{
+    Cba_Ntk_t * pNtk; int i, Count = 0;
+    Cba_ManForEachNtk( p, pNtk, i )
+        Count += Cba_NtkBoxNum( pNtk );
+    return Count;
+}
+static inline int Cba_ManBoxNum_rec( Cba_Ntk_t * p )
+{
+    int iObj, Counter = 0;
+    if ( p->Count >= 0 )
+        return p->Count;
+    Cba_NtkForEachBox( p, iObj )
+        Counter += Cba_ObjIsBoxUser(p, iObj) ? Cba_ManBoxNum_rec( Cba_BoxNtk(p, iObj) ) : 1;
+    return (p->Count = Counter);
+}
+static inline int Cba_ManBoxNum( Cba_Man_t * p )
+{
+    Cba_Ntk_t * pNtk; int i;
+    Cba_ManForEachNtk( p, pNtk, i )
+        pNtk->Count = -1;
+    return Cba_ManBoxNum_rec( Cba_ManRoot(p) );
+}
+static inline void Cba_ManPrintStats( Cba_Man_t * p, int nModules, int fVerbose )
+{
+    Cba_Ntk_t * pNtk; int i;
+    Cba_Ntk_t * pRoot = Cba_ManRoot( p );
+    printf( "%-12s : ",   Cba_ManName(p) );
+    printf( "pi =%5d  ",  Cba_NtkPiNum(pRoot) );
+    printf( "po =%5d  ",  Cba_NtkPoNum(pRoot) );
+    printf( "mod =%6d  ", Cba_ManNtkNum(p) );
+    printf( "box =%7d  ", Cba_ManNodeNum(p) );
+    printf( "obj =%7d  ", Cba_ManObjNum(p) );
+    printf( "mem =%6.3f MB", 1.0*Cba_ManMemory(p)/(1<<20) );
+    printf( "\n" );
+    Cba_ManBoxNum( p );
+    Cba_ManForEachNtk( p, pNtk, i )
+    {
+        if ( i == nModules )
+            break;
+        printf( "Module %5d : ", i );
+        Cba_NtkPrintStats( pNtk );
+    }
+}
+
+
+
+/**Function*************************************************************
+
+  Synopsis    [Other APIs.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline Cba_ObjType_t Ptr_SopToType( char * pSop )
+{
+    if ( !strcmp(pSop, " 0\n") )         return CBA_BOX_C0;
+    if ( !strcmp(pSop, " 1\n") )         return CBA_BOX_C1;
+    if ( !strcmp(pSop, "1 1\n") )        return CBA_BOX_BUF;
+    if ( !strcmp(pSop, "0 1\n") )        return CBA_BOX_INV;
+    if ( !strcmp(pSop, "11 1\n") )       return CBA_BOX_AND;
+    if ( !strcmp(pSop, "00 1\n") )       return CBA_BOX_NOR;
+    if ( !strcmp(pSop, "00 0\n") )       return CBA_BOX_OR;
+    if ( !strcmp(pSop, "-1 1\n1- 1\n") ) return CBA_BOX_OR;
+    if ( !strcmp(pSop, "1- 1\n-1 1\n") ) return CBA_BOX_OR;
+    if ( !strcmp(pSop, "01 1\n10 1\n") ) return CBA_BOX_XOR;
+    if ( !strcmp(pSop, "10 1\n01 1\n") ) return CBA_BOX_XOR;
+    if ( !strcmp(pSop, "11 1\n00 1\n") ) return CBA_BOX_XNOR;
+    if ( !strcmp(pSop, "00 1\n11 1\n") ) return CBA_BOX_XNOR;
+    if ( !strcmp(pSop, "10 1\n") )       return CBA_BOX_SHARP;
+    assert( 0 );
+    return CBA_OBJ_NONE;
+}
+static inline char * Ptr_SopToTypeName( char * pSop )
+{
+    if ( !strcmp(pSop, " 0\n") )         return "CBA_BOX_C0";
+    if ( !strcmp(pSop, " 1\n") )         return "CBA_BOX_C1";
+    if ( !strcmp(pSop, "1 1\n") )        return "CBA_BOX_BUF";
+    if ( !strcmp(pSop, "0 1\n") )        return "CBA_BOX_INV";
+    if ( !strcmp(pSop, "11 1\n") )       return "CBA_BOX_AND";
+    if ( !strcmp(pSop, "00 1\n") )       return "CBA_BOX_NOR";
+    if ( !strcmp(pSop, "00 0\n") )       return "CBA_BOX_OR";
+    if ( !strcmp(pSop, "-1 1\n1- 1\n") ) return "CBA_BOX_OR";
+    if ( !strcmp(pSop, "1- 1\n-1 1\n") ) return "CBA_BOX_OR";
+    if ( !strcmp(pSop, "01 1\n10 1\n") ) return "CBA_BOX_XOR";
+    if ( !strcmp(pSop, "10 1\n01 1\n") ) return "CBA_BOX_XOR";
+    if ( !strcmp(pSop, "11 1\n00 1\n") ) return "CBA_BOX_XNOR";
+    if ( !strcmp(pSop, "00 1\n11 1\n") ) return "CBA_BOX_XNOR";
+    if ( !strcmp(pSop, "10 1\n") )       return "CBA_BOX_SHARP";
+    assert( 0 );
+    return NULL;
+}
+static inline char * Ptr_TypeToName( Cba_ObjType_t Type )
+{
+    if ( Type == CBA_BOX_C0 )    return "const0";
+    if ( Type == CBA_BOX_C1 )    return "const1";
+    if ( Type == CBA_BOX_BUF )   return "buf";
+    if ( Type == CBA_BOX_INV )   return "not";
+    if ( Type == CBA_BOX_AND )   return "and";
+    if ( Type == CBA_BOX_NAND )  return "nand";
+    if ( Type == CBA_BOX_OR )    return "or";
+    if ( Type == CBA_BOX_NOR )   return "nor";
+    if ( Type == CBA_BOX_XOR )   return "xor";
+    if ( Type == CBA_BOX_XNOR )  return "xnor";
+    if ( Type == CBA_BOX_MUX )   return "mux";
+    if ( Type == CBA_BOX_MAJ )   return "maj";
+    if ( Type == CBA_BOX_SHARP ) return "sharp";
+    assert( 0 );
+    return "???";
+}
+static inline char * Ptr_TypeToSop( Cba_ObjType_t Type )
+{
+    if ( Type == CBA_BOX_C0 )    return " 0\n";
+    if ( Type == CBA_BOX_C1 )    return " 1\n";
+    if ( Type == CBA_BOX_BUF )   return "1 1\n";
+    if ( Type == CBA_BOX_INV )   return "0 1\n";
+    if ( Type == CBA_BOX_AND )   return "11 1\n";
+    if ( Type == CBA_BOX_NAND )  return "11 0\n";
+    if ( Type == CBA_BOX_OR )    return "00 0\n";
+    if ( Type == CBA_BOX_NOR )   return "00 1\n";
+    if ( Type == CBA_BOX_XOR )   return "01 1\n10 1\n";
+    if ( Type == CBA_BOX_XNOR )  return "00 1\n11 1\n";
+    if ( Type == CBA_BOX_SHARP ) return "10 1\n";
+    if ( Type == CBA_BOX_MUX )   return "11- 1\n0-1 1\n";
+    if ( Type == CBA_BOX_MAJ )   return "11- 1\n1-1 1\n-11 1\n";
+    assert( 0 );
+    return "???";
+}
+
+/*=== cbaCom.c ===============================================================*/
+extern void        Abc_FrameImportPtr( Vec_Ptr_t * vPtr );
+extern Vec_Ptr_t * Abc_FrameExportPtr();
+
+/*=== cbaBlast.c =============================================================*/
+extern int         Cba_NtkBuildLibrary( Cba_Man_t * p );
+extern Gia_Man_t * Cba_ManExtract( Cba_Man_t * p, int fBuffers, int fVerbose );
+extern Cba_Man_t * Cba_ManInsertGia( Cba_Man_t * p, Gia_Man_t * pGia );
+extern void *      Cba_ManInsertAbc( Cba_Man_t * p, void * pAbc );
+/*=== cbaCba.c ===============================================================*/
+extern Cba_Man_t * Cba_ManReadCba( char * pFileName );
+extern void        Cba_ManWriteCba( char * pFileName, Cba_Man_t * p );
+/*=== cbaNtk.c ===============================================================*/
+extern void        Cba_ManAssignInternNames( Cba_Man_t * p );
+extern Cba_Man_t * Cba_ManCollapse( Cba_Man_t * p );
+/*=== cbaPtr.c ===============================================================*/
+extern void        Cba_PtrFree( Vec_Ptr_t * vDes );
+extern int         Cba_PtrMemory( Vec_Ptr_t * vDes );
+extern void        Cba_PtrDumpBlif( char * pFileName, Vec_Ptr_t * vDes );
+extern Vec_Ptr_t * Cba_PtrTransformTest( Vec_Ptr_t * vDes );
+/*=== cbaPtrAbc.c ============================================================*/
+extern Cba_Man_t * Cba_PtrTransformToCba( Vec_Ptr_t * vDes );
+extern Vec_Ptr_t * Cba_PtrDeriveFromCba( Cba_Man_t * p );
+/*=== cbaPrsBuild.c ==========================================================*/
+extern void        Prs_ManVecFree( Vec_Ptr_t * vPrs );
+extern Cba_Man_t * Prs_ManBuildCba( char * pFileName, Vec_Ptr_t * vDes );
+/*=== cbaReadBlif.c ==========================================================*/
+extern Vec_Ptr_t * Prs_ManReadBlif( char * pFileName );
+/*=== cbaReadSmt.c ===========================================================*/
+extern Vec_Ptr_t * Prs_ManReadSmt( char * pFileName );
+/*=== cbaReadVer.c ===========================================================*/
+extern Vec_Ptr_t * Prs_ManReadVerilog( char * pFileName );
+/*=== cbaWriteBlif.c =========================================================*/
+extern void        Prs_ManWriteBlif( char * pFileName, Vec_Ptr_t * p );
+extern void        Cba_ManWriteBlif( char * pFileName, Cba_Man_t * p );
+/*=== cbaWriteVer.c ==========================================================*/
+extern void        Prs_ManWriteVerilog( char * pFileName, Vec_Ptr_t * p );
+extern void        Cba_ManWriteVerilog( char * pFileName, Cba_Man_t * p );
+
+ABC_NAMESPACE_HEADER_END
+
+#endif
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
diff --git a/abc-build/src/base/cba/cbaBlast.c b/abc-build/src/base/cba/cbaBlast.c
new file mode 100644
--- /dev/null
+++ b/abc-build/src/base/cba/cbaBlast.c
@@ -0,0 +1,573 @@
+/**CFile****************************************************************
+
+  FileName    [cbaBlast.c]
+
+  SystemName  [ABC: Logic synthesis and verification system.]
+
+  PackageName [Hierarchical word-level netlist.]
+
+  Synopsis    [Bit-blasting of the netlist.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - November 29, 2014.]
+
+  Revision    [$Id: cbaBlast.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "cba.h"
+#include "base/abc/abc.h"
+#include "map/mio/mio.h"
+#include "bool/dec/dec.h"
+#include "base/main/mainInt.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Cba_ManPrepareGates( Cba_Man_t * p )
+{
+    Dec_Graph_t ** ppGraphs; int i;
+    if ( p->pMioLib == NULL )
+        return;
+    ppGraphs = ABC_CALLOC( Dec_Graph_t *, Abc_NamObjNumMax(p->pMods) );
+    for ( i = 1; i < Abc_NamObjNumMax(p->pMods); i++ )
+    {
+        char * pGateName = Abc_NamStr( p->pMods, i );
+        Mio_Gate_t * pGate = Mio_LibraryReadGateByName( (Mio_Library_t *)p->pMioLib, pGateName, NULL );
+        if ( pGate != NULL )
+            ppGraphs[i] = Dec_Factor( Mio_GateReadSop(pGate) );
+    }
+    assert( p->ppGraphs == NULL );
+    p->ppGraphs = (void **)ppGraphs;
+}
+void Cba_ManUndoGates( Cba_Man_t * p )
+{
+    int i;
+    if ( p->pMioLib == NULL )
+        return;
+    for ( i = 1; i < Abc_NamObjNumMax(p->pMods); i++ )
+        if ( p->ppGraphs[i] )
+            Dec_GraphFree( (Dec_Graph_t *)p->ppGraphs[i] );
+    ABC_FREE( p->ppGraphs );
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Cba_ManAddBarbuf( Gia_Man_t * pNew, int iRes, Cba_Man_t * p, int iLNtk, int iLObj, int iRNtk, int iRObj, Vec_Int_t * vMap )
+{
+    int iBufLit, iIdLit;
+    if ( iRes == 0 || iRes == 1 )
+        return iRes;
+    assert( iRes > 0 );
+    if ( vMap && Abc_Lit2Var(iRes) < Vec_IntSize(vMap) && (iIdLit = Vec_IntEntry(vMap, Abc_Lit2Var(iRes))) >= 0 && 
+        Vec_IntEntry(&p->vBuf2LeafNtk, Abc_Lit2Var(iIdLit)) == iLNtk && Vec_IntEntry(&p->vBuf2RootNtk, Abc_Lit2Var(iIdLit)) == iRNtk )
+        return Abc_LitNotCond( Vec_IntEntry(pNew->vBarBufs, Abc_Lit2Var(iIdLit)), Abc_LitIsCompl(iRes) ^ Abc_LitIsCompl(iIdLit) );
+    Vec_IntPush( &p->vBuf2LeafNtk, iLNtk );
+    Vec_IntPush( &p->vBuf2LeafObj, iLObj );
+    Vec_IntPush( &p->vBuf2RootNtk, iRNtk );
+    Vec_IntPush( &p->vBuf2RootObj, iRObj );
+    iBufLit = Gia_ManAppendBuf( pNew, iRes );
+    if ( vMap )
+    {
+        Vec_IntSetEntryFull( vMap, Abc_Lit2Var(iRes), Abc_Var2Lit(Vec_IntSize(pNew->vBarBufs), Abc_LitIsCompl(iRes)) );
+        Vec_IntPush( pNew->vBarBufs, iBufLit );
+    }
+    return iBufLit;
+}
+int Cba_ManExtract_rec( Gia_Man_t * pNew, Cba_Ntk_t * p, int i, int fBuffers, Vec_Int_t * vMap )
+{
+    int iRes = Cba_ObjCopy( p, i );
+    if ( iRes >= 0 )
+        return iRes;
+    if ( Cba_ObjIsCo(p, i) )
+        iRes = Cba_ManExtract_rec( pNew, p, Cba_ObjFanin(p, i), fBuffers, vMap );
+    else if ( Cba_ObjIsPi(p, i) )
+    {
+        Cba_Ntk_t * pHost = Cba_NtkHostNtk( p );
+        int iObj = Cba_BoxBi( pHost, Cba_NtkHostObj(p), Cba_ObjIndex(p, i) );
+        iRes = Cba_ManExtract_rec( pNew, pHost, iObj, fBuffers, vMap );
+        if ( fBuffers )
+            iRes = Cba_ManAddBarbuf( pNew, iRes, p->pDesign, Cba_NtkId(p), i, Cba_NtkId(pHost), iObj, vMap );
+    }
+    else if ( Cba_ObjIsBo(p, i) )
+    {
+        int iBox = Cba_BoxBoBox(p, i);
+        if ( Cba_ObjIsBoxUser(p, iBox) ) // user box
+        {
+            Cba_Ntk_t * pBox = Cba_BoxBoNtk( p, i );
+            int iObj = Cba_NtkPo( pBox, Cba_ObjIndex(p, i) );
+            iRes = Cba_ManExtract_rec( pNew, pBox, iObj, fBuffers, vMap );
+            if ( fBuffers )
+                iRes = Cba_ManAddBarbuf( pNew, iRes, p->pDesign, Cba_NtkId(p), i, Cba_NtkId(pBox), iObj, vMap );
+        }
+        else // primitive
+        {
+            int iFanin, nLits, pLits[16];
+            assert( Cba_ObjIsBoxPrim(p, iBox) );
+            Cba_BoxForEachFanin( p, iBox, iFanin, nLits )
+                pLits[nLits] = Cba_ManExtract_rec( pNew, p, iFanin, fBuffers, vMap );
+            assert( nLits <= 16 );
+            if ( p->pDesign->ppGraphs ) // mapped gate
+            {
+                extern int Gia_ManFactorGraph( Gia_Man_t * p, Dec_Graph_t * pFForm, Vec_Int_t * vLeaves );
+                Dec_Graph_t * pGraph = (Dec_Graph_t *)p->pDesign->ppGraphs[Cba_BoxNtkId(p, iBox)];
+                Vec_Int_t Leaves = { nLits, nLits, pLits };
+                assert( pGraph != NULL );
+                return Gia_ManFactorGraph( pNew, pGraph, &Leaves );
+            }
+            else
+            {
+                Cba_ObjType_t Type = Cba_ObjType(p, iBox);
+                if ( nLits == 0 )
+                {
+                    if ( Type == CBA_BOX_C0 )
+                        iRes = 0;
+                    else if ( Type == CBA_BOX_C1 )
+                        iRes = 1;
+                    else assert( 0 );
+                }
+                else if ( nLits == 1 )
+                {
+                    if ( Type == CBA_BOX_BUF )
+                        iRes = pLits[0];
+                    else if ( Type == CBA_BOX_INV )
+                        iRes = Abc_LitNot( pLits[0] );
+                    else assert( 0 );
+                }
+                else
+                {
+                    assert( nLits == 2 );
+                    if ( Type == CBA_BOX_AND )
+                        iRes = Gia_ManHashAnd( pNew, pLits[0], pLits[1] );
+                    else if ( Type == CBA_BOX_OR )
+                        iRes = Gia_ManHashOr( pNew, pLits[0], pLits[1] );
+                    else if ( Type == CBA_BOX_NOR )
+                        iRes = Abc_LitNot( Gia_ManHashOr( pNew, pLits[0], pLits[1] ) );
+                    else if ( Type == CBA_BOX_XOR )
+                        iRes = Gia_ManHashXor( pNew, pLits[0], pLits[1] );
+                    else if ( Type == CBA_BOX_XNOR )
+                        iRes = Abc_LitNot( Gia_ManHashXor( pNew, pLits[0], pLits[1] ) );
+                    else if ( Type == CBA_BOX_SHARP )
+                        iRes = Gia_ManHashAnd( pNew, pLits[0], Abc_LitNot(pLits[1]) );
+                    else assert( 0 );
+                }
+                //printf("%d input\n", nLits );
+            }
+        }
+    }
+    else assert( 0 );
+    Cba_ObjSetCopy( p, i, iRes );
+    return iRes;
+}
+Gia_Man_t * Cba_ManExtract( Cba_Man_t * p, int fBuffers, int fVerbose )
+{
+    Cba_Ntk_t * pNtk, * pRoot = Cba_ManRoot(p);
+    Gia_Man_t * pNew, * pTemp; 
+    Vec_Int_t * vMap = NULL;
+    int i, iObj;
+
+    Vec_IntClear( &p->vBuf2LeafNtk );
+    Vec_IntClear( &p->vBuf2LeafObj );
+    Vec_IntClear( &p->vBuf2RootNtk );
+    Vec_IntClear( &p->vBuf2RootObj );
+
+    Cba_ManForEachNtk( p, pNtk, i )
+    {
+        Cba_NtkDeriveIndex( pNtk );
+        Cba_NtkStartCopies( pNtk );
+    }
+
+    // start the manager
+    pNew = Gia_ManStart( Cba_ManNodeNum(p) );
+    pNew->pName = Abc_UtilStrsav(p->pName);
+    pNew->pSpec = Abc_UtilStrsav(p->pSpec);
+
+    // primary inputs
+    Cba_NtkForEachPi( pRoot, iObj, i )
+        Cba_ObjSetCopy( pRoot, iObj, Gia_ManAppendCi(pNew) );
+
+    // internal nodes
+    Gia_ManHashAlloc( pNew );
+    pNew->vBarBufs = Vec_IntAlloc( 10000 );
+    vMap = Vec_IntStartFull( 10000 );
+    Cba_ManPrepareGates( p );
+    Cba_NtkForEachPo( pRoot, iObj, i )
+        Cba_ManExtract_rec( pNew, pRoot, iObj, fBuffers, vMap );
+    Cba_ManUndoGates( p );
+    Vec_IntFreeP( &vMap );
+    Gia_ManHashStop( pNew );
+
+    // primary outputs
+    Cba_NtkForEachPo( pRoot, iObj, i )
+        Gia_ManAppendCo( pNew, Cba_ObjCopy(pRoot, iObj) );
+    assert( Vec_IntSize(&p->vBuf2LeafNtk) == pNew->nBufs );
+
+    // cleanup
+    pNew = Gia_ManCleanup( pTemp = pNew );
+    Gia_ManStop( pTemp );
+    //Gia_ManPrintStats( pNew, NULL );
+    return pNew;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Mark each GIA node with the network it belongs to.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Cba_ManMarkNodesGia( Cba_Man_t * p, Gia_Man_t * pGia )
+{
+    Gia_Obj_t * pObj; int i, Count = 0;
+    assert( Vec_IntSize(&p->vBuf2LeafNtk) == Gia_ManBufNum(pGia) );
+    Gia_ManConst0(pGia)->Value = 0;
+    Gia_ManForEachPi( pGia, pObj, i )
+        pObj->Value = 0;
+    Gia_ManForEachAnd( pGia, pObj, i )
+    {
+        if ( Gia_ObjIsBuf(pObj) )
+            pObj->Value = Vec_IntEntry( &p->vBuf2LeafNtk, Count++ );
+        else
+        {
+            pObj->Value = Gia_ObjFanin0(pObj)->Value;
+            assert( pObj->Value == Gia_ObjFanin1(pObj)->Value );
+        }
+    }
+    assert( Count == Gia_ManBufNum(pGia) );
+    Gia_ManForEachPo( pGia, pObj, i )
+    {
+        assert( Gia_ObjFanin0(pObj)->Value == 0 );
+        pObj->Value = 0;
+    }
+}
+void Cba_ManRemapBarbufs( Cba_Man_t * pNew, Cba_Man_t * p )
+{
+    Cba_Ntk_t * pNtk;  int Entry, i;
+    assert( Vec_IntSize(&p->vBuf2RootNtk) );
+    assert( !Vec_IntSize(&pNew->vBuf2RootNtk) );
+    Vec_IntAppend( &pNew->vBuf2RootNtk, &p->vBuf2RootNtk );
+    Vec_IntAppend( &pNew->vBuf2RootObj, &p->vBuf2RootObj );
+    Vec_IntAppend( &pNew->vBuf2LeafNtk, &p->vBuf2LeafNtk );
+    Vec_IntAppend( &pNew->vBuf2LeafObj, &p->vBuf2LeafObj );
+    Vec_IntForEachEntry( &p->vBuf2LeafObj, Entry, i )
+    {
+        pNtk = Cba_ManNtk( p, Vec_IntEntry(&p->vBuf2LeafNtk, i) );
+        Vec_IntWriteEntry( &pNew->vBuf2LeafObj, i, Cba_ObjCopy(pNtk, Entry) );
+    }
+    Vec_IntForEachEntry( &p->vBuf2RootObj, Entry, i )
+    {
+        pNtk = Cba_ManNtk( p, Vec_IntEntry(&p->vBuf2RootNtk, i) );
+        Vec_IntWriteEntry( &pNew->vBuf2RootObj, i, Cba_ObjCopy(pNtk, Entry) );
+    }
+}
+void Cba_NtkCreateAndConnectBuffer( Gia_Man_t * pGia, Gia_Obj_t * pObj, Cba_Ntk_t * p, int iTerm )
+{
+    int iObj;
+    if ( pGia && Gia_ObjFaninId0p(pGia, pObj) > 0 )
+    {
+        assert( Cba_ObjName(p, Gia_ObjFanin0(pObj)->Value) != Cba_ObjName(p, iTerm) ); // not a feedthrough
+        iObj = Cba_ObjAlloc( p, CBA_OBJ_BI, Gia_ObjFanin0(pObj)->Value );
+        Cba_ObjSetName( p, iObj, Cba_ObjName(p, Gia_ObjFanin0(pObj)->Value) );
+        Cba_ObjAlloc( p, Gia_ObjFaninC0(pObj) ? CBA_BOX_INV : CBA_BOX_BUF, -1 );
+    }
+    else
+    {
+        Cba_ObjAlloc( p, pGia && Gia_ObjFaninC0(pObj) ? CBA_BOX_C1 : CBA_BOX_C0, -1 );
+    }
+    iObj = Cba_ObjAlloc( p, CBA_OBJ_BO, -1 );
+    Cba_ObjSetName( p, iObj, Cba_ObjName(p, iTerm) );
+    Cba_ObjSetFanin( p, iTerm, iObj );
+}
+void Cba_NtkInsertGia( Cba_Man_t * p, Gia_Man_t * pGia )
+{
+    Cba_Ntk_t * pNtk, * pRoot = Cba_ManRoot( p );
+    int i, j, k, iBox, iTerm, Count = 0;
+    Gia_Obj_t * pObj;
+
+    Gia_ManConst0(pGia)->Value = ~0;
+    Gia_ManForEachPi( pGia, pObj, i )
+        pObj->Value = Cba_NtkPi( pRoot, i );
+    Gia_ManForEachAnd( pGia, pObj, i )
+    {
+        if ( Gia_ObjIsBuf(pObj) )
+        {
+            pNtk = Cba_ManNtk( p, Vec_IntEntry(&p->vBuf2RootNtk, Count) );
+            iTerm = Vec_IntEntry( &p->vBuf2RootObj, Count );
+            assert( Cba_ObjIsCo(pNtk, iTerm) );
+            if ( Cba_ObjFanin(pNtk, iTerm) == -1 ) // not a feedthrough
+                Cba_NtkCreateAndConnectBuffer( pGia, pObj, pNtk, iTerm );
+            // prepare leaf
+            pObj->Value = Vec_IntEntry( &p->vBuf2LeafObj, Count++ );
+        }
+        else
+        {
+            int iLit0 = Gia_ObjFanin0(pObj)->Value;
+            int iLit1 = Gia_ObjFanin1(pObj)->Value;
+            Cba_ObjType_t Type;
+            pNtk = Cba_ManNtk( p, pObj->Value );
+            if ( Gia_ObjFaninC0(pObj) && Gia_ObjFaninC1(pObj) )
+                Type = CBA_BOX_NOR;
+            else if ( Gia_ObjFaninC1(pObj) )
+                Type = CBA_BOX_SHARP;
+            else if ( Gia_ObjFaninC0(pObj) )
+            {
+                Type = CBA_BOX_SHARP;
+                ABC_SWAP( int, iLit0, iLit1 );
+            }
+            else 
+                Type = CBA_BOX_AND;
+            // create box
+            iTerm = Cba_ObjAlloc( pNtk, CBA_OBJ_BI, iLit1 );
+            Cba_ObjSetName( pNtk, iTerm, Cba_ObjName(pNtk, iLit1) );
+            iTerm = Cba_ObjAlloc( pNtk, CBA_OBJ_BI, iLit0 );
+            Cba_ObjSetName( pNtk, iTerm, Cba_ObjName(pNtk, iLit0) );
+            Cba_ObjAlloc( pNtk, Type, -1 );
+            pObj->Value = Cba_ObjAlloc( pNtk, CBA_OBJ_BO, -1 );
+        }
+    }
+    assert( Count == Gia_ManBufNum(pGia) );
+
+    // create constant 0 drivers for COs without barbufs
+    Cba_ManForEachNtk( p, pNtk, i )
+    {
+        Cba_NtkForEachBox( pNtk, iBox )
+            Cba_BoxForEachBi( pNtk, iBox, iTerm, j )
+                if ( Cba_ObjFanin(pNtk, iTerm) == -1 )
+                    Cba_NtkCreateAndConnectBuffer( NULL, NULL, pNtk, iTerm );
+        Cba_NtkForEachPo( pNtk, iTerm, k )
+            if ( pNtk != pRoot && Cba_ObjFanin(pNtk, iTerm) == -1 )
+                Cba_NtkCreateAndConnectBuffer( NULL, NULL, pNtk, iTerm );
+    }
+    // create node and connect POs
+    Gia_ManForEachPo( pGia, pObj, i )
+        if ( Cba_ObjFanin(pRoot, Cba_NtkPo(pRoot, i)) == -1 ) // not a feedthrough
+            Cba_NtkCreateAndConnectBuffer( pGia, pObj, pRoot, Cba_NtkPo(pRoot, i) );
+}
+Cba_Man_t * Cba_ManInsertGia( Cba_Man_t * p, Gia_Man_t * pGia )
+{
+    Cba_Man_t * pNew = Cba_ManDupUserBoxes( p );
+    Cba_ManMarkNodesGia( p, pGia );
+    Cba_ManRemapBarbufs( pNew, p );
+    Cba_NtkInsertGia( pNew, pGia );
+    return pNew;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Cba_Man_t * Cba_ManBlastTest( Cba_Man_t * p )
+{
+    Gia_Man_t * pGia = Cba_ManExtract( p, 1, 0 );
+    Cba_Man_t * pNew = Cba_ManInsertGia( p, pGia );
+    Gia_ManStop( pGia );
+    return pNew;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Mark each GIA node with the network it belongs to.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Abc_NodeIsSeriousGate( Abc_Obj_t * p )
+{
+    return Abc_ObjIsNode(p) && Abc_ObjFaninNum(p) > 0 && !Abc_ObjIsBarBuf(p);
+}
+void Cba_ManMarkNodesAbc( Cba_Man_t * p, Abc_Ntk_t * pNtk )
+{
+    Abc_Obj_t * pObj, * pFanin; int i, k, Count = 0;
+    assert( Vec_IntSize(&p->vBuf2LeafNtk) == pNtk->nBarBufs2 );
+    Abc_NtkForEachPi( pNtk, pObj, i )
+        pObj->iTemp = 0;
+    Abc_NtkForEachNode( pNtk, pObj, i )
+    {
+        if ( Abc_ObjIsBarBuf(pObj) )
+            pObj->iTemp = Vec_IntEntry( &p->vBuf2LeafNtk, Count++ );
+        else if ( Abc_NodeIsSeriousGate(pObj) )
+        {
+            pObj->iTemp = Abc_ObjFanin0(pObj)->iTemp;
+            Abc_ObjForEachFanin( pObj, pFanin, k )
+                assert( pObj->iTemp == pFanin->iTemp );
+        }
+    }
+    Abc_NtkForEachPo( pNtk, pObj, i )
+    {
+        if ( !Abc_NodeIsSeriousGate(Abc_ObjFanin0(pObj)) )
+            continue;
+        assert( Abc_ObjFanin0(pObj)->iTemp == 0 );
+        pObj->iTemp = Abc_ObjFanin0(pObj)->iTemp;
+    }
+    assert( Count == pNtk->nBarBufs2 );
+}
+void Cba_NtkCreateOrConnectFanin( Abc_Obj_t * pFanin, Cba_Ntk_t * p, int iTerm )
+{
+    int iObj;
+    if ( pFanin && Abc_NodeIsSeriousGate(pFanin) && Cba_ObjName(p, pFanin->iTemp) == -1 ) // gate without name
+    {
+        iObj = pFanin->iTemp;
+    }
+    else if ( pFanin && (Abc_ObjIsPi(pFanin) || Abc_ObjIsBarBuf(pFanin) || Abc_NodeIsSeriousGate(pFanin)) ) // PI/BO or gate with name
+    {
+        assert( Cba_ObjName(p, pFanin->iTemp) != Cba_ObjName(p, iTerm) ); // not a feedthrough
+        iObj = Cba_ObjAlloc( p, CBA_OBJ_BI, pFanin->iTemp );
+        Cba_ObjSetName( p, iObj, Cba_ObjName(p, pFanin->iTemp) );
+        Cba_ObjAlloc( p, CBA_BOX_GATE, p->pDesign->ElemGates[2] ); // buffer
+        iObj = Cba_ObjAlloc( p, CBA_OBJ_BO, -1 );
+    }
+    else
+    {
+        assert( !pFanin || Abc_NodeIsConst0(pFanin) || Abc_NodeIsConst1(pFanin) );
+        Cba_ObjAlloc( p, CBA_BOX_GATE, p->pDesign->ElemGates[(pFanin && Abc_NodeIsConst1(pFanin))] ); // const 0/1
+        iObj = Cba_ObjAlloc( p, CBA_OBJ_BO, -1 );
+    }
+    Cba_ObjSetName( p, iObj, Cba_ObjName(p, iTerm) );
+    Cba_ObjSetFanin( p, iTerm, iObj );
+}
+void Cba_NtkPrepareLibrary( Cba_Man_t * p, Mio_Library_t * pLib )
+{
+    Mio_Gate_t * pGate;
+    Mio_Gate_t * pGate0 = Mio_LibraryReadConst0( pLib );
+    Mio_Gate_t * pGate1 = Mio_LibraryReadConst1( pLib );
+    Mio_Gate_t * pGate2 = Mio_LibraryReadBuf( pLib );
+    if ( !pGate0 || !pGate1 || !pGate2 )
+    {
+        printf( "The library does not have one of the elementary gates.\n" );
+        return;
+    }
+    p->ElemGates[0] = Abc_NamStrFindOrAdd( p->pMods, Mio_GateReadName(pGate0), NULL );
+    p->ElemGates[1] = Abc_NamStrFindOrAdd( p->pMods, Mio_GateReadName(pGate1), NULL );
+    p->ElemGates[2] = Abc_NamStrFindOrAdd( p->pMods, Mio_GateReadName(pGate2), NULL );
+    Mio_LibraryForEachGate( pLib, pGate )
+        if ( pGate != pGate0 && pGate != pGate1 && pGate != pGate2 )
+            Abc_NamStrFindOrAdd( p->pMods, Mio_GateReadName(pGate), NULL );
+    assert( Abc_NamObjNumMax(p->pMods) > 1 );
+}
+int Cba_NtkBuildLibrary( Cba_Man_t * p )
+{
+    int RetValue = 1;
+    Mio_Library_t * pLib = (Mio_Library_t *)Abc_FrameReadLibGen( Abc_FrameGetGlobalFrame() );
+    if ( pLib == NULL )
+        printf( "The standard cell library is not available.\n" ), RetValue = 0;
+    else
+        Cba_NtkPrepareLibrary( p, pLib );
+    p->pMioLib = pLib;
+    return RetValue;
+}
+void Cba_NtkInsertNtk( Cba_Man_t * p, Abc_Ntk_t * pNtk )
+{
+    Cba_Ntk_t * pCbaNtk, * pRoot = Cba_ManRoot( p );
+    int i, j, k, iBox, iTerm, Count = 0;
+    Abc_Obj_t * pObj;
+    assert( Abc_NtkHasMapping(pNtk) );
+    Cba_NtkPrepareLibrary( p, (Mio_Library_t *)pNtk->pManFunc );
+    p->pMioLib = pNtk->pManFunc;
+
+    Abc_NtkForEachPi( pNtk, pObj, i )
+        pObj->iTemp = Cba_NtkPi( pRoot, i );
+    Abc_NtkForEachNode( pNtk, pObj, i )
+    {
+        if ( Abc_ObjIsBarBuf(pObj) )
+        {
+            pCbaNtk = Cba_ManNtk( p, Vec_IntEntry(&p->vBuf2RootNtk, Count) );
+            iTerm = Vec_IntEntry( &p->vBuf2RootObj, Count );
+            assert( Cba_ObjIsCo(pCbaNtk, iTerm) );
+            if ( Cba_ObjFanin(pCbaNtk, iTerm) == -1 ) // not a feedthrough
+                Cba_NtkCreateOrConnectFanin( Abc_ObjFanin0(pObj), pCbaNtk, iTerm );
+            // prepare leaf
+            pObj->iTemp = Vec_IntEntry( &p->vBuf2LeafObj, Count++ );
+        }
+        else if ( Abc_NodeIsSeriousGate(pObj) )
+        {
+            pCbaNtk = Cba_ManNtk( p, pObj->iTemp );
+            for ( k = Abc_ObjFaninNum(pObj)-1; k >= 0; k-- )
+            {
+                iTerm = Cba_ObjAlloc( pCbaNtk, CBA_OBJ_BI, Abc_ObjFanin(pObj, k)->iTemp );
+                Cba_ObjSetName( pCbaNtk, iTerm, Cba_ObjName(pCbaNtk, Abc_ObjFanin(pObj, k)->iTemp) );
+            }
+            Cba_ObjAlloc( pCbaNtk, CBA_BOX_GATE, Abc_NamStrFind(p->pMods, Mio_GateReadName((Mio_Gate_t *)pObj->pData)) );
+            pObj->iTemp = Cba_ObjAlloc( pCbaNtk, CBA_OBJ_BO, -1 );
+        }
+    }
+    assert( Count == pNtk->nBarBufs2 );
+
+    // create constant 0 drivers for COs without barbufs
+    Cba_ManForEachNtk( p, pCbaNtk, i )
+    {
+        Cba_NtkForEachBox( pCbaNtk, iBox )
+            Cba_BoxForEachBi( pCbaNtk, iBox, iTerm, j )
+                if ( Cba_ObjFanin(pCbaNtk, iTerm) == -1 )
+                    Cba_NtkCreateOrConnectFanin( NULL, pCbaNtk, iTerm );
+        Cba_NtkForEachPo( pCbaNtk, iTerm, k )
+            if ( pCbaNtk != pRoot && Cba_ObjFanin(pCbaNtk, iTerm) == -1 )
+                Cba_NtkCreateOrConnectFanin( NULL, pCbaNtk, iTerm );
+    }
+    // create node and connect POs
+    Abc_NtkForEachPo( pNtk, pObj, i )
+        if ( Cba_ObjFanin(pRoot, Cba_NtkPo(pRoot, i)) == -1 ) // not a feedthrough
+            Cba_NtkCreateOrConnectFanin( Abc_ObjFanin0(pObj), pRoot, Cba_NtkPo(pRoot, i) );
+}
+void * Cba_ManInsertAbc( Cba_Man_t * p, void * pAbc )
+{
+    Abc_Ntk_t * pNtk = (Abc_Ntk_t *)pAbc;
+    Cba_Man_t * pNew = Cba_ManDupUserBoxes( p );
+    Cba_ManMarkNodesAbc( p, pNtk );
+    Cba_ManRemapBarbufs( pNew, p );
+    Cba_NtkInsertNtk( pNew, pNtk );
+    return pNew;
+}
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/abc-build/src/base/cba/cbaCba.c b/abc-build/src/base/cba/cbaCba.c
new file mode 100644
--- /dev/null
+++ b/abc-build/src/base/cba/cbaCba.c
@@ -0,0 +1,244 @@
+/**CFile****************************************************************
+
+  FileName    [cbaCba.c]
+
+  SystemName  [ABC: Logic synthesis and verification system.]
+
+  PackageName [Hierarchical word-level netlist.]
+
+  Synopsis    [Verilog parser.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - November 29, 2014.]
+
+  Revision    [$Id: cbaCba.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "cba.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+
+/**Function*************************************************************
+
+  Synopsis    [Read CBA.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int CbaManReadCbaLine( Vec_Str_t * vOut, int * pPos, char * pBuffer, char * pLimit )
+{
+    char c;
+    while ( (c = Vec_StrEntry(vOut, (*pPos)++)) != '\n' && pBuffer < pLimit )
+        *pBuffer++ = c;
+    *pBuffer = 0;
+    return pBuffer < pLimit;
+}
+int CbaManReadCbaNameAndNums( char * pBuffer, int * Num1, int * Num2, int * Num3 )
+{
+    *Num1 = *Num2 = *Num3 = -1;
+    // read name
+    while ( *pBuffer && *pBuffer != ' ' )
+        pBuffer++;
+    if ( !*pBuffer )
+        return 0;
+    assert( *pBuffer == ' ' );
+    *pBuffer = 0;
+    // read Num1
+    *Num1 = atoi(++pBuffer);
+    while ( *pBuffer && *pBuffer != ' ' )
+        pBuffer++;
+    if ( !*pBuffer )
+        return 0;
+    // read Num2
+    assert( *pBuffer == ' ' );
+    *Num2 = atoi(++pBuffer);
+    while ( *pBuffer && *pBuffer != ' ' )
+        pBuffer++;
+    if ( !*pBuffer )
+        return 1;
+    // read Num3
+    assert( *pBuffer == ' ' );
+    *Num3 = atoi(++pBuffer);
+    return 1;
+}
+void Cba_ManReadCbaVecStr( Vec_Str_t * vOut, int * pPos, Vec_Str_t * p, int nSize )
+{
+    memcpy( Vec_StrArray(p), Vec_StrArray(vOut) + *pPos, nSize );
+    *pPos += nSize;
+    p->nSize = nSize;
+    assert( Vec_StrSize(p) == Vec_StrCap(p) );
+}
+void Cba_ManReadCbaVecInt( Vec_Str_t * vOut, int * pPos, Vec_Int_t * p, int nSize )
+{
+    memcpy( Vec_IntArray(p), Vec_StrArray(vOut) + *pPos, nSize );
+    *pPos += nSize;
+    p->nSize = nSize / 4;
+    assert( Vec_IntSize(p) == Vec_IntCap(p) );
+}
+void Cba_ManReadCbaNtk( Vec_Str_t * vOut, int * pPos, Cba_Ntk_t * pNtk )
+{
+    int i, Type;
+    Cba_ManReadCbaVecStr( vOut, pPos, &pNtk->vType,      Cba_NtkObjNumAlloc(pNtk) );
+    Cba_ManReadCbaVecInt( vOut, pPos, &pNtk->vFanin, 4 * Cba_NtkObjNumAlloc(pNtk) );
+    Cba_NtkForEachObjType( pNtk, Type, i )
+    {
+        if ( Type == CBA_OBJ_PI )
+            Vec_IntPush( &pNtk->vInputs, i );
+        if ( Type == CBA_OBJ_PO )
+            Vec_IntPush( &pNtk->vOutputs, i );
+    }
+    assert( Cba_NtkPiNum(pNtk)  == Cba_NtkPiNumAlloc(pNtk) );
+    assert( Cba_NtkPoNum(pNtk)  == Cba_NtkPoNumAlloc(pNtk) );
+    assert( Cba_NtkObjNum(pNtk) == Cba_NtkObjNumAlloc(pNtk) );
+}
+Cba_Man_t * Cba_ManReadCbaInt( Vec_Str_t * vOut )
+{
+    Cba_Man_t * p;
+    Cba_Ntk_t * pNtk;
+    char Buffer[1000] = "#"; 
+    int i, NameId, Pos = 0, Num1, Num2, Num3;
+    while ( Buffer[0] == '#' )
+        if ( !CbaManReadCbaLine(vOut, &Pos, Buffer, Buffer+1000) )
+            return NULL;
+    if ( !CbaManReadCbaNameAndNums(Buffer, &Num1, &Num2, &Num3) )
+        return NULL;
+    // start manager
+    assert( Num1 > 0 && Num2 >= 0 );
+    p = Cba_ManAlloc( Buffer, Num1 );
+    Vec_IntGrow( &p->vInfo, 4 * Num2 );
+    // start networks
+    Cba_ManForEachNtk( p, pNtk, i )
+    {
+        if ( !CbaManReadCbaLine(vOut, &Pos, Buffer, Buffer+1000) )
+        {
+            Cba_ManFree( p );
+            return NULL;
+        }
+        if ( !CbaManReadCbaNameAndNums(Buffer, &Num1, &Num2, &Num3) )
+        {
+            Cba_ManFree( p );
+            return NULL;
+        }
+        assert( Num1 > 0 && Num2 > 0 && Num3 > 0 );
+        NameId = Abc_NamStrFindOrAdd( p->pStrs, Buffer, NULL );
+        Cba_NtkAlloc( pNtk, NameId, Num1, Num2, Num3 );
+    }
+    // read networks
+    Cba_ManForEachNtk( p, pNtk, i )
+        Cba_ManReadCbaNtk( vOut, &Pos, pNtk );
+    Cba_ManReadCbaVecInt( vOut, &Pos, &p->vInfo,  4 * Vec_IntSize(&p->vInfo) );
+    assert( Pos == Vec_StrSize(vOut) );
+    return p;
+}
+Cba_Man_t * Cba_ManReadCba( char * pFileName )
+{
+    Cba_Man_t * p;
+    FILE * pFile;
+    Vec_Str_t * vOut;
+    int nFileSize;
+    pFile = fopen( pFileName, "rb" );
+    if ( pFile == NULL )
+    {
+        printf( "Cannot open file \"%s\" for reading.\n", pFileName );
+        return NULL;
+    }
+    // get the file size, in bytes
+    fseek( pFile, 0, SEEK_END );  
+    nFileSize = ftell( pFile );  
+    rewind( pFile ); 
+    // load the contents
+    vOut = Vec_StrAlloc( nFileSize );
+    vOut->nSize = vOut->nCap;
+    assert( nFileSize == Vec_StrSize(vOut) );
+    nFileSize = fread( Vec_StrArray(vOut), 1, Vec_StrSize(vOut), pFile );
+    assert( nFileSize == Vec_StrSize(vOut) );
+    fclose( pFile );
+    // read the library
+    p = Cba_ManReadCbaInt( vOut );
+    if ( p != NULL )
+    {
+        ABC_FREE( p->pSpec );
+        p->pSpec = Abc_UtilStrsav( pFileName );
+    }
+    Vec_StrFree( vOut );
+    return p;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Write CBA.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Cba_ManWriteCbaNtk( Vec_Str_t * vOut, Cba_Ntk_t * pNtk )
+{
+    Vec_StrPushBuffer( vOut, (char *)Vec_StrArray(&pNtk->vType),      Cba_NtkObjNum(pNtk) );
+    Vec_StrPushBuffer( vOut, (char *)Vec_IntArray(&pNtk->vFanin), 4 * Cba_NtkObjNum(pNtk) );
+}
+void Cba_ManWriteCbaInt( Vec_Str_t * vOut, Cba_Man_t * p )
+{
+    char Buffer[1000];
+    Cba_Ntk_t * pNtk; int i;
+    sprintf( Buffer, "# Design \"%s\" written by ABC on %s\n", Cba_ManName(p), Extra_TimeStamp() );
+    Vec_StrPrintStr( vOut, Buffer );
+    // write short info
+    sprintf( Buffer, "%s %d %d \n", Cba_ManName(p), Cba_ManNtkNum(p), Cba_ManInfoNum(p) );
+    Vec_StrPrintStr( vOut, Buffer );
+    Cba_ManForEachNtk( p, pNtk, i )
+    {
+        sprintf( Buffer, "%s %d %d %d \n", Cba_NtkName(pNtk), Cba_NtkPiNum(pNtk), Cba_NtkPoNum(pNtk), Cba_NtkObjNum(pNtk) );
+        Vec_StrPrintStr( vOut, Buffer );
+    }
+    Cba_ManForEachNtk( p, pNtk, i )
+        Cba_ManWriteCbaNtk( vOut, pNtk );
+    Vec_StrPushBuffer( vOut, (char *)Vec_IntArray(&p->vInfo), 16 * Cba_ManInfoNum(p) );
+}
+void Cba_ManWriteCba( char * pFileName, Cba_Man_t * p )
+{
+    Vec_Str_t * vOut;
+    assert( p->pMioLib == NULL );
+    vOut = Vec_StrAlloc( 10000 );
+    Cba_ManWriteCbaInt( vOut, p );
+    if ( Vec_StrSize(vOut) > 0 )
+    {
+        FILE * pFile = fopen( pFileName, "wb" );
+        if ( pFile == NULL )
+            printf( "Cannot open file \"%s\" for writing.\n", pFileName );
+        else
+        {
+            fwrite( Vec_StrArray(vOut), 1, Vec_StrSize(vOut), pFile );
+            fclose( pFile );
+        }
+    }
+    Vec_StrFree( vOut );    
+}
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/abc-build/src/base/cba/cbaCom.c b/abc-build/src/base/cba/cbaCom.c
new file mode 100644
--- /dev/null
+++ b/abc-build/src/base/cba/cbaCom.c
@@ -0,0 +1,692 @@
+/**CFile****************************************************************
+
+  FileName    [cbaCom.c]
+
+  SystemName  [ABC: Logic synthesis and verification system.]
+
+  PackageName [Hierarchical word-level netlist.]
+
+  Synopsis    [Command handlers.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - November 29, 2014.]
+
+  Revision    [$Id: cbaCom.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "cba.h"
+#include "proof/cec/cec.h"
+#include "base/main/mainInt.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+static int  Cba_CommandRead     ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int  Cba_CommandWrite    ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int  Cba_CommandPs       ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int  Cba_CommandPut      ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int  Cba_CommandGet      ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int  Cba_CommandClp      ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int  Cba_CommandCec      ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int  Cba_CommandTest     ( Abc_Frame_t * pAbc, int argc, char ** argv );
+
+static inline Cba_Man_t * Cba_AbcGetMan( Abc_Frame_t * pAbc )                       { return (Cba_Man_t *)pAbc->pAbcCba;                        }
+static inline void        Cba_AbcFreeMan( Abc_Frame_t * pAbc )                      { if ( pAbc->pAbcCba ) Cba_ManFree(Cba_AbcGetMan(pAbc));    }
+static inline void        Cba_AbcUpdateMan( Abc_Frame_t * pAbc, Cba_Man_t * p )     { Cba_AbcFreeMan(pAbc); pAbc->pAbcCba = p;                  }
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function********************************************************************
+
+  Synopsis    [Accessing current Cba_Ntk_t.]
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+******************************************************************************/
+void Abc_FrameImportPtr( Vec_Ptr_t * vPtr )
+{
+    Cba_Man_t * p;
+    if ( Abc_FrameGetGlobalFrame() == NULL )
+    {
+        printf( "ABC framework is not started.\n" );
+        return;
+    }
+    p = Cba_PtrTransformToCba( vPtr );
+    if ( p == NULL )
+        printf( "Converting from Ptr failed.\n" );
+    Cba_AbcUpdateMan( Abc_FrameGetGlobalFrame(), p );
+}
+Vec_Ptr_t * Abc_FrameExportPtr()
+{
+    Vec_Ptr_t * vPtr;
+    Cba_Man_t * p;
+    if ( Abc_FrameGetGlobalFrame() == NULL )
+    {
+        printf( "ABC framework is not started.\n" );
+        return NULL;
+    }
+    p = Cba_AbcGetMan( Abc_FrameGetGlobalFrame() );
+    if ( p == NULL )
+        printf( "There is no CBA design present.\n" );
+    vPtr = Cba_PtrDeriveFromCba( p );
+    if ( vPtr == NULL )
+        printf( "Converting to Ptr has failed.\n" );
+    return vPtr;
+}
+
+/**Function********************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+******************************************************************************/
+void Cba_Init( Abc_Frame_t * pAbc )
+{
+    Cmd_CommandAdd( pAbc, "New word level", "@read",       Cba_CommandRead,      0 );
+    Cmd_CommandAdd( pAbc, "New word level", "@write",      Cba_CommandWrite,     0 );
+    Cmd_CommandAdd( pAbc, "New word level", "@ps",         Cba_CommandPs,        0 );
+    Cmd_CommandAdd( pAbc, "New word level", "@put",        Cba_CommandPut,       0 );
+    Cmd_CommandAdd( pAbc, "New word level", "@get",        Cba_CommandGet,       0 );
+    Cmd_CommandAdd( pAbc, "New word level", "@clp",        Cba_CommandClp,       0 );
+    Cmd_CommandAdd( pAbc, "New word level", "@cec",        Cba_CommandCec,       0 );
+    Cmd_CommandAdd( pAbc, "New word level", "@test",       Cba_CommandTest,      0 );
+}
+
+/**Function********************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+******************************************************************************/
+void Cba_End( Abc_Frame_t * pAbc )
+{
+    Cba_AbcFreeMan( pAbc );
+}
+
+
+/**Function********************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+******************************************************************************/
+int Cba_CommandRead( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    FILE * pFile;
+    Cba_Man_t * p = NULL;
+    Vec_Ptr_t * vDes = NULL;
+    char * pFileName = NULL;
+    int c, fUseAbc = 0, fVerbose  =    0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "avh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'a':
+            fUseAbc ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( argc != globalUtilOptind + 1 )
+    {
+        printf( "Cba_CommandRead(): Input file name should be given on the command line.\n" );
+        return 0;
+    }
+    // get the file name
+    pFileName = argv[globalUtilOptind];
+    if ( (pFile = fopen( pFileName, "r" )) == NULL )
+    {
+        Abc_Print( 1, "Cannot open input file \"%s\". ", pFileName );
+        if ( (pFileName = Extra_FileGetSimilarName( pFileName, ".v", ".blif", ".smt", ".cba", NULL )) )
+            Abc_Print( 1, "Did you mean \"%s\"?", pFileName );
+        Abc_Print( 1, "\n" );
+        return 0;
+    }
+    fclose( pFile );
+    // perform reading
+    if ( fUseAbc )
+    {
+        extern Vec_Ptr_t * Ptr_AbcDeriveDes( Abc_Ntk_t * pNtk );
+        Abc_Ntk_t * pAbcNtk = Io_ReadNetlist( pFileName, Io_ReadFileType(pFileName), 0 );
+        Vec_Ptr_t * vDes = Ptr_AbcDeriveDes( pAbcNtk );
+        p = Cba_PtrTransformToCba( vDes );
+        Cba_PtrFree( vDes ); // points to names in pAbcNtk
+        if ( p )
+        {
+            ABC_FREE( p->pSpec );
+            p->pSpec = Abc_UtilStrsav( pAbcNtk->pSpec );
+        }
+        Abc_NtkDelete( pAbcNtk );
+    }
+    else if ( !strcmp( Extra_FileNameExtension(pFileName), "blif" )  )
+    {
+        vDes = Prs_ManReadBlif( pFileName );
+        if ( vDes && Vec_PtrSize(vDes) )
+            p = Prs_ManBuildCba( pFileName, vDes );
+        Prs_ManVecFree( vDes );
+    }
+    else if ( !strcmp( Extra_FileNameExtension(pFileName), "v" )  )
+    {
+        vDes = Prs_ManReadVerilog( pFileName );
+        if ( vDes && Vec_PtrSize(vDes) )
+            p = Prs_ManBuildCba( pFileName, vDes );
+        Prs_ManVecFree( vDes );
+    }
+    else if ( !strcmp( Extra_FileNameExtension(pFileName), "smt" )  )
+    {
+        vDes = NULL;//Prs_ManReadSmt( pFileName );
+        if ( vDes && Vec_PtrSize(vDes) )
+            p = Prs_ManBuildCba( pFileName, vDes );
+        Prs_ManVecFree( vDes );
+    }
+    else if ( !strcmp( Extra_FileNameExtension(pFileName), "cba" )  )
+    {
+        p = Cba_ManReadCba( pFileName );
+    }
+    else assert( 0 );
+    Cba_AbcUpdateMan( pAbc, p );
+    return 0;
+usage:
+    Abc_Print( -2, "usage: @read [-avh] <file_name>\n" );
+    Abc_Print( -2, "\t         reads hierarchical design in BLIF or Verilog\n" );
+    Abc_Print( -2, "\t-a     : toggle using old ABC parser [default = %s]\n", fUseAbc? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function********************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+******************************************************************************/
+int Cba_CommandWrite( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Cba_Man_t * p = Cba_AbcGetMan(pAbc);
+    char * pFileName = NULL;
+    int c, fVerbose  =    0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( p == NULL )
+    {
+        Abc_Print( 1, "Cba_CommandWrite(): There is no current design.\n" );
+        return 0;
+    }
+    if ( argc == globalUtilOptind + 1 )
+        pFileName = argv[globalUtilOptind];
+    else if ( argc == globalUtilOptind && p )
+        pFileName = Extra_FileNameGenericAppend( Cba_ManName(p), "_out.v" );
+    else 
+    {
+        printf( "Output file name should be given on the command line.\n" );
+        return 0;
+    }
+    // perform writing
+    if ( !strcmp( Extra_FileNameExtension(pFileName), "blif" )  )
+        Cba_ManWriteBlif( pFileName, p );
+    else if ( !strcmp( Extra_FileNameExtension(pFileName), "v" )  )
+        Cba_ManWriteVerilog( pFileName, p );
+    else if ( !strcmp( Extra_FileNameExtension(pFileName), "cba" )  )
+        Cba_ManWriteCba( pFileName, p );
+    else 
+    {
+        printf( "Unrecognized output file extension.\n" );
+        return 0;
+    }
+    return 0;
+usage:
+    Abc_Print( -2, "usage: @write [-vh]\n" );
+    Abc_Print( -2, "\t         writes the design into a file in BLIF or Verilog\n" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n",  fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+
+/**Function********************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+******************************************************************************/
+int Cba_CommandPs( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Cba_Man_t * p = Cba_AbcGetMan(pAbc);
+    int c, nModules = 0, fVerbose  = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Mvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'M':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
+                goto usage;
+            }
+            nModules = atoi(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( nModules < 0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( p == NULL )
+    {
+        Abc_Print( 1, "Cba_CommandPs(): There is no current design.\n" );
+        return 0;
+    }
+    Cba_ManPrintStats( p, nModules, fVerbose );
+    return 0;
+usage:
+    Abc_Print( -2, "usage: @ps [-M num] [-vh]\n" );
+    Abc_Print( -2, "\t         prints statistics\n" );
+    Abc_Print( -2, "\t-M num : the number of first modules to report [default = %d]\n", nModules );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function********************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+******************************************************************************/
+int Cba_CommandPut( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Cba_Man_t * p = Cba_AbcGetMan(pAbc);
+    Gia_Man_t * pGia = NULL;
+    int c, fBarBufs = 1, fVerbose  = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "bvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'b':
+            fBarBufs ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( p == NULL )
+    {
+        Abc_Print( 1, "Cba_CommandPut(): There is no current design.\n" );
+        return 0;
+    }
+    pGia = Cba_ManExtract( p, fBarBufs, fVerbose );
+    if ( pGia == NULL )
+    {
+        Abc_Print( 1, "Cba_CommandPut(): Conversion to AIG has failed.\n" );
+        return 0;
+    }
+    Abc_FrameUpdateGia( pAbc, pGia );
+    return 0;
+usage:
+    Abc_Print( -2, "usage: @put [-bvh]\n" );
+    Abc_Print( -2, "\t         extracts AIG from the hierarchical design\n" );
+    Abc_Print( -2, "\t-b     : toggle using barrier buffers [default = %s]\n", fBarBufs? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function********************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+******************************************************************************/
+int Cba_CommandGet( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Cba_Man_t * pNew = NULL, * p = Cba_AbcGetMan(pAbc);
+    int c, fMapped = 0, fVerbose  = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "mvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'm':
+            fMapped ^= 1;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( p == NULL )
+    {
+        Abc_Print( 1, "Cba_CommandGet(): There is no current design.\n" );
+        return 0;
+    }
+    if ( fMapped )
+    {
+        if ( pAbc->pNtkCur == NULL )
+        {
+            Abc_Print( 1, "Cba_CommandGet(): There is no current mapped design.\n" );
+            return 0;
+        }
+        pNew = Cba_ManInsertAbc( p, pAbc->pNtkCur );
+    }
+    else
+    {
+        if ( pAbc->pGia == NULL )
+        {
+            Abc_Print( 1, "Cba_CommandGet(): There is no current AIG.\n" );
+            return 0;
+        }
+        pNew = Cba_ManInsertGia( p, pAbc->pGia );
+    }
+    Cba_AbcUpdateMan( pAbc, pNew );
+    return 0;
+usage:
+    Abc_Print( -2, "usage: @get [-mvh]\n" );
+    Abc_Print( -2, "\t         extracts AIG or mapped network into the hierarchical design\n" );
+    Abc_Print( -2, "\t-m     : toggle using mapped network from main-space [default = %s]\n", fMapped? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function********************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+******************************************************************************/
+int Cba_CommandClp( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Cba_Man_t * pNew = NULL, * p = Cba_AbcGetMan(pAbc);
+    int c, fVerbose  = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( p == NULL )
+    {
+        Abc_Print( 1, "Cba_CommandGet(): There is no current design.\n" );
+        return 0;
+    }
+    pNew = Cba_ManCollapse( p );
+    Cba_AbcUpdateMan( pAbc, pNew );
+    return 0;
+usage:
+    Abc_Print( -2, "usage: @clp [-vh]\n" );
+    Abc_Print( -2, "\t         collapses the current hierarchical design\n" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function********************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+******************************************************************************/
+int Cba_CommandCec( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Cba_Man_t * p = Cba_AbcGetMan(pAbc);
+    Gia_Man_t * pFirst, * pSecond, * pMiter;
+    Cec_ParCec_t ParsCec, * pPars = &ParsCec;
+    Vec_Ptr_t * vDes;
+    char * FileName, * pStr, ** pArgvNew;
+    int c, nArgcNew, fDumpMiter = 0;
+    FILE * pFile;
+    Cec_ManCecSetDefaultParams( pPars );
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'v':
+            pPars->fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( p == NULL )
+    {
+        Abc_Print( 1, "Cba_CommandCec(): There is no current design.\n" );
+        return 0;
+    }
+    pArgvNew = argv + globalUtilOptind;
+    nArgcNew = argc - globalUtilOptind;
+    if ( nArgcNew != 1 )
+    {
+        if ( p->pSpec == NULL )
+        {
+            Abc_Print( -1, "File name is not given on the command line.\n" );
+            return 1;
+        }
+        FileName = p->pSpec;
+    }
+    else
+        FileName = pArgvNew[0];
+    // fix the wrong symbol
+    for ( pStr = FileName; *pStr; pStr++ )
+        if ( *pStr == '>' )
+            *pStr = '\\';
+    if ( (pFile = fopen( FileName, "r" )) == NULL )
+    {
+        Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
+        if ( (FileName = Extra_FileGetSimilarName( FileName, ".v", ".blif", NULL, NULL, NULL )) )
+            Abc_Print( 1, "Did you mean \"%s\"?", FileName );
+        Abc_Print( 1, "\n" );
+        return 1;
+    }
+    fclose( pFile );
+
+    // extract AIG from the current design
+    pFirst = Cba_ManExtract( p, 0, 0 );
+    if ( pFirst == NULL )
+    {
+        Abc_Print( -1, "Extracting AIG from the current design has failed.\n" );
+        return 0;
+    }
+    // extract AIG from the second design
+    if ( !strcmp( Extra_FileNameExtension(FileName), "blif" )  )
+        vDes = Prs_ManReadBlif( FileName );
+    else if ( !strcmp( Extra_FileNameExtension(FileName), "v" )  )
+        vDes = Prs_ManReadVerilog( FileName );
+    else assert( 0 );
+    p = Prs_ManBuildCba( FileName, vDes );
+    Prs_ManVecFree( vDes );
+    pSecond = Cba_ManExtract( p, 0, 0 );
+    Cba_ManFree( p );
+    if ( pSecond == NULL )
+    {
+        Gia_ManStop( pFirst );
+        Abc_Print( -1, "Extracting AIG from the original design has failed.\n" );
+        return 0;
+    }
+    // compute the miter
+    pMiter = Gia_ManMiter( pFirst, pSecond, 0, 1, 0, 0, pPars->fVerbose );
+    if ( pMiter )
+    {
+        if ( fDumpMiter )
+        {
+            Abc_Print( 0, "The verification miter is written into file \"%s\".\n", "cec_miter.aig" );
+            Gia_AigerWrite( pMiter, "cec_miter.aig", 0, 0 );
+        }
+        pAbc->Status = Cec_ManVerify( pMiter, pPars );
+        //Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexComb );
+        Gia_ManStop( pMiter );
+    }
+    Gia_ManStop( pFirst );
+    Gia_ManStop( pSecond );
+    return 0;
+usage:
+    Abc_Print( -2, "usage: @cec [-vh]\n" );
+    Abc_Print( -2, "\t         combinational equivalence checking\n" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function********************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+******************************************************************************/
+int Cba_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    extern void Prs_ManReadBlifTest();
+    extern void Prs_ManReadVerilogTest();
+    extern void Prs_SmtReadSmtTest();
+    //Cba_Man_t * p = Cba_AbcGetMan(pAbc);
+    int c, fVerbose  = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+/*
+    if ( p == NULL )
+    {
+        Abc_Print( 1, "Cba_CommandTest(): There is no current design.\n" );
+        return 0;
+    }
+*/
+    //Cba_PtrTransformTestTest();
+    //Prs_ManReadVerilogTest();
+    //Prs_SmtReadSmtTest();
+    return 0;
+usage:
+    Abc_Print( -2, "usage: @test [-vh]\n" );
+    Abc_Print( -2, "\t         experiments with word-level networks\n" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/abc-build/src/base/cba/cbaLib.c b/abc-build/src/base/cba/cbaLib.c
new file mode 100644
--- /dev/null
+++ b/abc-build/src/base/cba/cbaLib.c
@@ -0,0 +1,52 @@
+/**CFile****************************************************************
+
+  FileName    [cbaLib.c]
+
+  SystemName  [ABC: Logic synthesis and verification system.]
+
+  PackageName [Hierarchical word-level netlist.]
+
+  Synopsis    [Library procedures.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - November 29, 2014.]
+
+  Revision    [$Id: cbaLib.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "cba.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/abc-build/src/base/cba/cbaNtk.c b/abc-build/src/base/cba/cbaNtk.c
new file mode 100644
--- /dev/null
+++ b/abc-build/src/base/cba/cbaNtk.c
@@ -0,0 +1,299 @@
+/**CFile****************************************************************
+
+  FileName    [cbaNtk.c]
+
+  SystemName  [ABC: Logic synthesis and verification system.]
+
+  PackageName [Hierarchical word-level netlist.]
+
+  Synopsis    [Netlist manipulation.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - November 29, 2014.]
+
+  Revision    [$Id: cbaNtk.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "cba.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Cba_ManAssignInternNamesNtk( Cba_Ntk_t * p )
+{
+    char Buffer[100];
+    int i, iObj, iTerm, NameId, fFound, nNameLess = 0;
+    int nDigits = Abc_Base10Log( Cba_NtkObjNum(p) );
+    // PI/PO should have NameId
+    Cba_NtkForEachPi( p, iObj, i )
+        assert( Cba_ObjName(p, iObj) );
+    Cba_NtkForEachPo( p, iObj, i )
+        assert( Cba_ObjName(p, iObj) );
+    // user BI/BO should have NameId
+    Cba_NtkForEachBoxUser( p, iObj )
+    {
+        Cba_BoxForEachBi( p, iObj, iTerm, i )
+            assert( Cba_ObjName(p, iTerm) );
+        Cba_BoxForEachBo( p, iObj, iTerm, i )
+            assert( Cba_ObjName(p, iTerm) );
+    }
+    // check missing IDs
+    Cba_NtkForEachBoxPrim( p, iObj )
+    {
+        Cba_BoxForEachBi( p, iObj, iTerm, i )
+            nNameLess += !Cba_ObjName(p, iTerm);
+        Cba_BoxForEachBo( p, iObj, iTerm, i )
+            nNameLess += !Cba_ObjName(p, iTerm);
+    }
+    if ( !nNameLess )
+        return;
+    // create names for prim BO
+    Cba_NtkForEachBoxPrim( p, iObj )
+        Cba_BoxForEachBo( p, iObj, iTerm, i )
+        {
+            if ( Cba_ObjName(p, iTerm) )
+                continue;
+            sprintf( Buffer, "%s%0*d", "_n_", nDigits, iTerm );
+            NameId = Abc_NamStrFindOrAdd( p->pDesign->pStrs, Buffer, &fFound );
+            //assert( !fFound );
+            Cba_ObjSetName( p, iTerm, NameId );
+        }
+    // transfer names for prim BI
+    Cba_NtkForEachBoxPrim( p, iObj )
+        Cba_BoxForEachBi( p, iObj, iTerm, i )
+        {
+            if ( Cba_ObjName(p, iTerm) )
+                continue;
+            assert( Cba_ObjName(p, Cba_ObjFanin(p, iTerm)) );
+            Cba_ObjSetName( p, iTerm, Cba_ObjName(p, Cba_ObjFanin(p, iTerm)) );
+        }
+}
+void Cba_ManAssignInternNames( Cba_Man_t * p )
+{
+    Cba_Ntk_t * pNtk; int i;
+    Cba_ManForEachNtk( p, pNtk, i )
+        Cba_ManAssignInternNamesNtk( pNtk );
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    [Count number of objects after collapsing.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Cba_ManClpObjNum_rec( Cba_Ntk_t * p )
+{
+    int i, Counter = 0;
+    if ( p->Count >= 0 )
+        return p->Count;
+    Cba_NtkForEachBox( p, i )
+        Counter += Cba_ObjIsBoxUser(p, i) ? Cba_ManClpObjNum_rec( Cba_BoxNtk(p, i) ) + 3*Cba_BoxBoNum(p, i) : Cba_BoxSize(p, i);
+    return (p->Count = Counter);
+}
+int Cba_ManClpObjNum( Cba_Man_t * p )
+{
+    Cba_Ntk_t * pNtk; int i;
+    Cba_ManForEachNtk( p, pNtk, i )
+        pNtk->Count = -1;
+    return Cba_NtkPioNum( Cba_ManRoot(p) ) + Cba_ManClpObjNum_rec( Cba_ManRoot(p) );
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Collects boxes in the DFS order.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Cba_NtkDfs_rec( Cba_Ntk_t * p, int iObj, Vec_Int_t * vBoxes )
+{
+    int k, iFanin;
+    if ( Cba_ObjIsBo(p, iObj) == 1 )
+    {
+        Cba_NtkDfs_rec( p, Cba_ObjFanin(p, iObj), vBoxes );
+        return;
+    }
+    assert( Cba_ObjIsPi(p, iObj) || Cba_ObjIsBox(p, iObj) );
+    if ( Cba_ObjCopy(p, iObj) > 0 ) // visited
+        return;
+    Cba_ObjSetCopy( p, iObj, 1 );
+    Cba_BoxForEachFanin( p, iObj, iFanin, k )
+        Cba_NtkDfs_rec( p, iFanin, vBoxes );
+    Vec_IntPush( vBoxes, iObj );
+}
+Vec_Int_t * Cba_NtkDfs( Cba_Ntk_t * p )
+{
+    int i, iObj;
+    Vec_Int_t * vBoxes = Vec_IntAlloc( Cba_NtkBoxNum(p) );
+    Cba_NtkStartCopies( p ); // -1 = not visited; 1 = finished
+    Cba_NtkForEachPi( p, iObj, i )
+        Cba_ObjSetCopy( p, iObj, 1 );
+    Cba_NtkForEachPo( p, iObj, i )
+        Cba_NtkDfs_rec( p, Cba_ObjFanin(p, iObj), vBoxes );
+    return vBoxes;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Collects user boxes in the DFS order.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Cba_NtkDfsUserBoxes_rec( Cba_Ntk_t * p, int iObj, Vec_Int_t * vBoxes )
+{
+    int k, iFanin;
+    assert( Cba_ObjIsBoxUser(p, iObj) );
+    if ( Cba_ObjCopy(p, iObj) == 1 ) // visited
+        return 1;
+    if ( Cba_ObjCopy(p, iObj) == 0 ) // loop
+        return 0;
+    Cba_ObjSetCopy( p, iObj, 0 );
+    Cba_BoxForEachFanin( p, iObj, iFanin, k )
+        if ( Cba_ObjIsBo(p, iFanin) && Cba_ObjIsBoxUser(p, Cba_ObjFanin(p, iFanin)) )
+            if ( !Cba_NtkDfsUserBoxes_rec( p, Cba_ObjFanin(p, iFanin), vBoxes ) )
+                return 0;
+    Vec_IntPush( vBoxes, iObj );
+    Cba_ObjSetCopy( p, iObj, 1 );
+    return 1;
+}
+int Cba_NtkDfsUserBoxes( Cba_Ntk_t * p )
+{
+    int iObj;
+    Cba_NtkStartCopies( p ); // -1 = not visited; 0 = on the path; 1 = finished
+    Vec_IntClear( &p->vArray );
+    Cba_NtkForEachBoxUser( p, iObj )
+        if ( !Cba_NtkDfsUserBoxes_rec( p, iObj, &p->vArray ) )
+        {
+            printf( "Cyclic dependency of user boxes is detected.\n" );
+            return 0;
+        }
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Cba_NtkCollapse_rec( Cba_Ntk_t * pNew, Cba_Ntk_t * p, Vec_Int_t * vSigs )
+{
+    int i, iObj, iObjNew, iTerm;
+    Cba_NtkStartCopies( p );
+    // set PI copies
+    assert( Vec_IntSize(vSigs) == Cba_NtkPiNum(p) );
+    Cba_NtkForEachPi( p, iObj, i )
+        Cba_ObjSetCopy( p, iObj, Vec_IntEntry(vSigs, i) );
+    // duplicate internal objects and create buffers for hierarchy instances
+    Cba_NtkForEachBox( p, iObj )
+        if ( Cba_ObjIsBoxPrim( p, iObj ) )
+            Cba_BoxDup( pNew, p, iObj );
+        else
+        {
+            Cba_BoxForEachBo( p, iObj, iTerm, i )
+            {
+                iObjNew = Cba_ObjAlloc( pNew, CBA_OBJ_BI,  -1 );
+                iObjNew = Cba_ObjAlloc( pNew, CBA_BOX_BUF, -1 ); // buffer
+                iObjNew = Cba_ObjAlloc( pNew, CBA_OBJ_BO,  -1 );
+                Cba_ObjSetCopy( p, iTerm, iObjNew );
+            }
+        }
+    // duplicate user modules and connect objects
+    Cba_NtkForEachBox( p, iObj )
+        if ( Cba_ObjIsBoxPrim( p, iObj ) )
+        {
+            Cba_BoxForEachBi( p, iObj, iTerm, i )
+                Cba_ObjSetFanin( pNew, Cba_ObjCopy(p, iTerm), Cba_ObjCopy(p, Cba_ObjFanin(p, iTerm)) );
+        }
+        else
+        {
+            Vec_IntClear( vSigs );
+            Cba_BoxForEachBi( p, iObj, iTerm, i )
+                Vec_IntPush( vSigs, Cba_ObjCopy(p, Cba_ObjFanin(p, iTerm)) );
+            Cba_NtkCollapse_rec( pNew, Cba_BoxNtk(p, iObj), vSigs );
+            assert( Vec_IntSize(vSigs) == Cba_BoxBoNum(p, iObj) );
+            Cba_BoxForEachBo( p, iObj, iTerm, i )
+                Cba_ObjSetFanin( pNew, Cba_ObjCopy(p, iTerm)-2, Vec_IntEntry(vSigs, i) );
+        }
+    // collect POs
+    Vec_IntClear( vSigs );
+    Cba_NtkForEachPo( p, iObj, i )
+        Vec_IntPush( vSigs, Cba_ObjCopy(p, Cba_ObjFanin(p, iObj)) );
+}
+Cba_Man_t * Cba_ManCollapse( Cba_Man_t * p )
+{
+    int i, iObj;
+    Vec_Int_t * vSigs = Vec_IntAlloc( 1000 );
+    Cba_Man_t * pNew = Cba_ManStart( p, 1 );
+    Cba_Ntk_t * pRoot = Cba_ManRoot( p );
+    Cba_Ntk_t * pRootNew = Cba_ManRoot( pNew );
+    Cba_NtkAlloc( pRootNew, Cba_NtkNameId(pRoot), Cba_NtkPiNum(pRoot), Cba_NtkPoNum(pRoot), Cba_ManClpObjNum(p) );
+    Cba_NtkForEachPi( pRoot, iObj, i )
+        Vec_IntPush( vSigs, Cba_ObjAlloc(pRootNew, CBA_OBJ_PI, -1) );
+    Cba_NtkCollapse_rec( pRootNew, pRoot, vSigs );
+    assert( Vec_IntSize(vSigs) == Cba_NtkPoNum(pRoot) );
+    Cba_NtkForEachPo( pRoot, iObj, i )
+        Cba_ObjAlloc( pRootNew, CBA_OBJ_PO, Vec_IntEntry(vSigs, i) );
+    assert( Cba_NtkObjNum(pRootNew) == Cba_NtkObjNumAlloc(pRootNew) );
+    Vec_IntFree( vSigs );
+    // transfer PI/PO names
+    if ( Cba_NtkHasNames(pRoot) )
+    {
+        Cba_NtkStartNames( pRootNew );
+        Cba_NtkForEachPi( pRoot, iObj, i )
+            Cba_ObjSetName( pRootNew, Cba_NtkPi(pRootNew, i), Cba_ObjName(pRoot, iObj) );
+        Cba_NtkForEachPo( pRoot, iObj, i )
+            Cba_ObjSetName( pRootNew, Cba_NtkPo(pRootNew, i), Cba_ObjName(pRoot, iObj) );
+    }
+    return pNew;
+}
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/abc-build/src/base/cba/cbaPrs.h b/abc-build/src/base/cba/cbaPrs.h
new file mode 100644
--- /dev/null
+++ b/abc-build/src/base/cba/cbaPrs.h
@@ -0,0 +1,350 @@
+/**CFile****************************************************************
+
+  FileName    [cbaPrs.h]
+
+  SystemName  [ABC: Logic synthesis and verification system.]
+
+  PackageName [Hierarchical word-level netlist.]
+
+  Synopsis    [Parser declarations.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - November 29, 2014.]
+
+  Revision    [$Id: cbaPrs.h,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#ifndef ABC__base__prs__prs_h
+#define ABC__base__prs__prs_h
+
+
+////////////////////////////////////////////////////////////////////////
+///                          INCLUDES                                ///
+////////////////////////////////////////////////////////////////////////
+
+#include "aig/gia/gia.h"
+#include "misc/util/utilNam.h"
+
+////////////////////////////////////////////////////////////////////////
+///                         PARAMETERS                               ///
+////////////////////////////////////////////////////////////////////////
+
+ABC_NAMESPACE_HEADER_START 
+
+// parser name types
+typedef enum { 
+    CBA_PRS_NAME = 0,        // 0:  name/variable
+    CBA_PRS_SLICE,           // 1:  slice
+    CBA_PRS_CONST,           // 2:  constant
+    CBA_PRS_CONCAT,          // 3:  concatentation
+} Prs_ManType_t; 
+
+////////////////////////////////////////////////////////////////////////
+///                         BASIC TYPES                              ///
+////////////////////////////////////////////////////////////////////////
+
+// network
+typedef struct Prs_Ntk_t_ Prs_Ntk_t;
+struct Prs_Ntk_t_
+{
+    // general info
+    int          iModuleName;
+    unsigned     fMapped : 1;
+    unsigned     fSlices : 1;
+    Abc_Nam_t *  pStrs;
+    // interface
+    Vec_Int_t    vOrder;     // order of signals
+    // signal names
+    Vec_Int_t    vInouts;    // inouts 
+    Vec_Int_t    vInputs;    // inputs 
+    Vec_Int_t    vOutputs;   // outputs
+    Vec_Int_t    vWires;     // wires  
+    // signal ranges
+    Vec_Int_t    vInoutsR;   // inouts 
+    Vec_Int_t    vInputsR;   // inputs 
+    Vec_Int_t    vOutputsR;  // outputs
+    Vec_Int_t    vWiresR;    // wires  
+    // slices/concatenations/objects
+    Vec_Int_t    vSlices;    // NameId + RangeId
+    Vec_Int_t    vConcats;   // array of NameId/SliceId/ConstId
+    Vec_Int_t    vBoxes;     // ModuleId + InstId + array of pairs {FormNameId, ActSignalId(NameId/SliceId/ConstId/ConcatId)}
+    Vec_Int_t    vObjs;      // box handles
+};
+
+// parser
+typedef struct Prs_Man_t_ Prs_Man_t;
+struct Prs_Man_t_
+{
+    // input data
+    char *       pName;       // file name
+    char *       pBuffer;     // file contents
+    char *       pLimit;      // end of file
+    char *       pCur;        // current position
+    Abc_Nam_t *  pStrs;       // string manager
+    Prs_Ntk_t *  pNtk;        // current network
+    Vec_Ptr_t *  vNtks;       // input networks
+    // temporary data
+    Vec_Str_t    vCover;      // one SOP cover
+    Vec_Int_t    vTemp;       // array of tokens
+    Vec_Int_t    vTemp2;      // array of tokens
+    // statistics
+    Vec_Int_t    vKnown;
+    Vec_Int_t    vFailed;
+    Vec_Int_t    vSucceeded;
+    // error handling
+    int          fUsingTemp2; // vTemp2 is in use
+    char ErrorStr[1000];      // error
+};
+
+static inline Prs_Ntk_t * Prs_ManNtk( Vec_Ptr_t * vPrs, int i )        { return i >= 0 && i < Vec_PtrSize(vPrs) ? (Prs_Ntk_t *)Vec_PtrEntry(vPrs, i) : NULL; }
+static inline Prs_Ntk_t * Prs_ManRoot( Vec_Ptr_t * vPrs )              { return Prs_ManNtk(vPrs, 0);                             }
+static inline Abc_Nam_t * Prs_ManNameMan( Vec_Ptr_t * vPrs )           { return Prs_ManRoot(vPrs)->pStrs;                        }
+
+static inline int         Prs_NtkId( Prs_Ntk_t * p )                   { return p->iModuleName;                                  }
+static inline int         Prs_NtkPioNum( Prs_Ntk_t * p )               { return Vec_IntSize(&p->vInouts);                        }
+static inline int         Prs_NtkPiNum( Prs_Ntk_t * p )                { return Vec_IntSize(&p->vInputs);                        }
+static inline int         Prs_NtkPoNum( Prs_Ntk_t * p )                { return Vec_IntSize(&p->vOutputs);                       }
+static inline int         Prs_NtkBoxNum( Prs_Ntk_t * p )               { return Vec_IntSize(&p->vObjs);                          }
+static inline int         Prs_NtkObjNum( Prs_Ntk_t * p )               { return Prs_NtkPioNum(p) + Prs_NtkPiNum(p) + Prs_NtkPoNum(p) + Prs_NtkBoxNum(p); }
+static inline char *      Prs_NtkStr( Prs_Ntk_t * p, int h )           { return Abc_NamStr(p->pStrs, h);                         }
+static inline char *      Prs_NtkName( Prs_Ntk_t * p )                 { return Prs_NtkStr(p, Prs_NtkId(p));                     }
+static inline int         Prs_NtkSigName( Prs_Ntk_t * p, int i )       { if (!p->fSlices) return i; assert(Abc_Lit2Att2(i) == CBA_PRS_NAME); return Abc_Lit2Var2(i); }
+
+static inline int         Prs_SliceName( Prs_Ntk_t * p, int h )        { return Vec_IntEntry(&p->vSlices, h);                    }
+static inline int         Prs_SliceRange( Prs_Ntk_t * p, int h )       { return Vec_IntEntry(&p->vSlices, h+1);                  }
+
+static inline int         Prs_CatSize( Prs_Ntk_t * p, int h )          { return Vec_IntEntry(&p->vConcats, h);                   }
+static inline int *       Prs_CatArray( Prs_Ntk_t * p, int h )         { return Vec_IntEntryP(&p->vConcats, h+1);                }
+static inline Vec_Int_t * Prs_CatSignals( Prs_Ntk_t * p, int h )       { static Vec_Int_t V; V.nSize = V.nCap = Prs_CatSize(p, h); V.pArray = Prs_CatArray(p, h); return &V; }
+
+static inline int         Prs_BoxHand( Prs_Ntk_t * p, int i )          { return Vec_IntEntry(&p->vObjs, i);                      }
+static inline int         Prs_BoxSize( Prs_Ntk_t * p, int i )          { return Vec_IntEntry(&p->vBoxes, Prs_BoxHand(p, i))-2;   }
+static inline int         Prs_BoxIONum( Prs_Ntk_t * p, int i )         { return Prs_BoxSize(p, i) / 2;                           }
+static inline int         Prs_BoxNtk( Prs_Ntk_t * p, int i )           { return Vec_IntEntry(&p->vBoxes, Prs_BoxHand(p, i)+1);   }
+static inline void        Prs_BoxSetNtk( Prs_Ntk_t * p, int i, int m ) { Vec_IntWriteEntry(&p->vBoxes, Prs_BoxHand(p, i)+1, m);  }
+static inline int         Prs_BoxName( Prs_Ntk_t * p, int i )          { return Vec_IntEntry(&p->vBoxes, Prs_BoxHand(p, i)+2);   }
+static inline int         Prs_BoxIsNode( Prs_Ntk_t * p, int i )        { return!Vec_IntEntry(&p->vBoxes, Prs_BoxHand(p, i)+3);   } // no formal names
+static inline int *       Prs_BoxArray( Prs_Ntk_t * p, int i )         { return Vec_IntEntryP(&p->vBoxes, Prs_BoxHand(p, i)+3);  }
+static inline Vec_Int_t * Prs_BoxSignals( Prs_Ntk_t * p, int i )       { static Vec_Int_t V; V.nSize = V.nCap = Prs_BoxSize(p, i); V.pArray = Prs_BoxArray(p, i); return &V; }
+
+#define Prs_ManForEachNameVec( vVec, p, pName, i )   \
+    for ( i = 0; (i < Vec_IntSize(vVec)) && ((pName) = Abc_NamStr(p->pStrs, Vec_IntEntry(vVec,i))); i++ )
+
+#define Prs_NtkForEachPio( p, NameId, i )            \
+    for ( i = 0; i < Prs_NtkPioNum(p) && ((NameId) = Vec_IntEntry(&p->vInouts, i)); i++ )
+#define Prs_NtkForEachPi( p, NameId, i )             \
+    for ( i = 0; i < Prs_NtkPiNum(p) && ((NameId) = Vec_IntEntry(&p->vInputs, i)); i++ )
+#define Prs_NtkForEachPo( p, NameId, i )             \
+    for ( i = 0; i < Prs_NtkPoNum(p) && ((NameId) = Vec_IntEntry(&p->vOutputs, i)); i++ )
+#define Prs_NtkForEachBox( p, vVec, i )              \
+    for ( i = 0; i < Prs_NtkBoxNum(p) && ((vVec) = Prs_BoxSignals(p, i)); i++ )
+
+////////////////////////////////////////////////////////////////////////
+///                      MACRO DEFINITIONS                           ///
+////////////////////////////////////////////////////////////////////////
+
+// create error message
+static inline int Prs_ManErrorSet( Prs_Man_t * p, char * pError, int Value )
+{
+    assert( !p->ErrorStr[0] );
+    sprintf( p->ErrorStr, "%s", pError );
+    return Value;
+}
+// clear error message
+static inline void Prs_ManErrorClear( Prs_Man_t * p )
+{
+    p->ErrorStr[0] = '\0';
+}
+// print error message
+static inline int Prs_ManErrorPrint( Prs_Man_t * p )
+{
+    char * pThis; int iLine = 0;
+    if ( !p->ErrorStr[0] ) return 1;
+    for ( pThis = p->pBuffer; pThis < p->pCur; pThis++ )
+        iLine += (int)(*pThis == '\n');
+    printf( "Line %d: %s\n", iLine, p->ErrorStr );
+    return 0;
+}
+
+// parsing network
+static inline void Prs_ManInitializeNtk( Prs_Man_t * p, int iName, int fSlices )
+{
+    assert( p->pNtk == NULL );
+    p->pNtk = ABC_CALLOC( Prs_Ntk_t, 1 );
+    p->pNtk->iModuleName = iName;
+    p->pNtk->fSlices = fSlices;
+    p->pNtk->pStrs = Abc_NamRef( p->pStrs );
+    Vec_PtrPush( p->vNtks, p->pNtk );
+}
+static inline void Prs_ManFinalizeNtk( Prs_Man_t * p )
+{
+    assert( p->pNtk != NULL );
+    p->pNtk = NULL;
+}
+
+// parsing slice/concatentation/box
+static inline int Prs_NtkAddSlice( Prs_Ntk_t * p, int Name, int Range )
+{
+    int Value = Vec_IntSize(&p->vSlices);
+    Vec_IntPushTwo( &p->vSlices, Name, Range );
+    return Value;
+}
+static inline int Prs_NtkAddConcat( Prs_Ntk_t * p, Vec_Int_t * vTemp )
+{
+    int Value;
+    if ( !(Vec_IntSize(&p->vConcats) & 1) )
+        Vec_IntPush(&p->vConcats, -1);
+    Value = Vec_IntSize(&p->vConcats);
+    assert( Value & 1 );
+    Vec_IntPush( &p->vConcats, Vec_IntSize(vTemp) );
+    Vec_IntAppend( &p->vConcats, vTemp );
+    return Value;
+}
+static inline void Prs_NtkAddBox( Prs_Ntk_t * p, int ModName, int InstName, Vec_Int_t * vTemp )
+{
+    int Value;
+    assert( Vec_IntSize(vTemp) % 2 == 0 );
+    if ( !(Vec_IntSize(&p->vBoxes) & 1) )
+        Vec_IntPush(&p->vBoxes, -1);
+    Value = Vec_IntSize(&p->vBoxes);
+    assert( Value & 1 );
+    Vec_IntPush( &p->vObjs, Value );
+    // create entry
+    Vec_IntPush( &p->vBoxes, Vec_IntSize(vTemp)+2 );
+    Vec_IntPush( &p->vBoxes, ModName );
+    Vec_IntPush( &p->vBoxes, InstName );
+    Vec_IntAppend( &p->vBoxes, vTemp );
+}
+
+
+static inline char * Prs_ManLoadFile( char * pFileName, char ** ppLimit )
+{
+    char * pBuffer;
+    int nFileSize, RetValue;
+    FILE * pFile = fopen( pFileName, "rb" );
+    if ( pFile == NULL )
+    {
+        printf( "Cannot open input file.\n" );
+        return NULL;
+    }
+    // get the file size, in bytes
+    fseek( pFile, 0, SEEK_END );  
+    nFileSize = ftell( pFile );  
+    // move the file current reading position to the beginning
+    rewind( pFile ); 
+    // load the contents of the file into memory
+    pBuffer = ABC_ALLOC( char, nFileSize + 3 );
+    pBuffer[0] = '\n';
+    RetValue = fread( pBuffer+1, nFileSize, 1, pFile );
+    // terminate the string with '\0'
+    pBuffer[nFileSize + 0] = '\n';
+    pBuffer[nFileSize + 1] = '\0';
+    *ppLimit = pBuffer + nFileSize + 2;
+    return pBuffer;
+}
+static inline Prs_Man_t * Prs_ManAlloc( char * pFileName )
+{
+    Prs_Man_t * p;
+    char * pBuffer, * pLimit;
+    pBuffer = Prs_ManLoadFile( pFileName, &pLimit );
+    if ( pBuffer == NULL )
+        return NULL;
+    p = ABC_CALLOC( Prs_Man_t, 1 );
+    p->pName   = pFileName;
+    p->pBuffer = pBuffer;
+    p->pLimit  = pLimit;
+    p->pCur    = pBuffer;
+    p->pStrs   = Abc_NamStart( 1000, 24 );
+    p->vNtks   = Vec_PtrAlloc( 100 );
+    return p;
+}
+
+static inline void Prs_NtkFree( Prs_Ntk_t * p )
+{
+    if ( p->pStrs )
+        Abc_NamDeref( p->pStrs );
+    Vec_IntErase( &p->vOrder );
+    Vec_IntErase( &p->vInouts );
+    Vec_IntErase( &p->vInputs );
+    Vec_IntErase( &p->vOutputs );
+    Vec_IntErase( &p->vWires );
+    Vec_IntErase( &p->vInoutsR );
+    Vec_IntErase( &p->vInputsR );
+    Vec_IntErase( &p->vOutputsR );
+    Vec_IntErase( &p->vWiresR );
+    Vec_IntErase( &p->vSlices );
+    Vec_IntErase( &p->vConcats );
+    Vec_IntErase( &p->vBoxes );
+    Vec_IntErase( &p->vObjs );
+    ABC_FREE( p );
+}
+
+static inline void Prs_ManFree( Prs_Man_t * p )
+{
+    if ( p->pStrs )
+        Abc_NamDeref( p->pStrs );
+    if ( p->vNtks )
+        Prs_ManVecFree( p->vNtks );
+    // temporary
+    Vec_StrErase( &p->vCover );
+    Vec_IntErase( &p->vTemp );
+    Vec_IntErase( &p->vTemp2 );
+    Vec_IntErase( &p->vKnown );
+    Vec_IntErase( &p->vFailed );
+    Vec_IntErase( &p->vSucceeded );
+    ABC_FREE( p->pBuffer );
+    ABC_FREE( p );
+}
+
+static inline int Prs_NtkMemory( Prs_Ntk_t * p )
+{
+    int nMem = sizeof(Prs_Ntk_t);
+    nMem += Vec_IntMemory( &p->vOrder );
+    nMem += Vec_IntMemory( &p->vInouts );
+    nMem += Vec_IntMemory( &p->vInputs );
+    nMem += Vec_IntMemory( &p->vOutputs );
+    nMem += Vec_IntMemory( &p->vWires );
+    nMem += Vec_IntMemory( &p->vInoutsR );
+    nMem += Vec_IntMemory( &p->vInputsR );
+    nMem += Vec_IntMemory( &p->vOutputsR );
+    nMem += Vec_IntMemory( &p->vWiresR );
+    nMem += Vec_IntMemory( &p->vSlices );
+    nMem += Vec_IntMemory( &p->vBoxes );
+    nMem += Vec_IntMemory( &p->vConcats );
+    return nMem;
+}
+static inline int Prs_ManMemory( Vec_Ptr_t * vPrs )
+{
+    Prs_Ntk_t * pNtk; int i;
+    int nMem = Vec_PtrMemory(vPrs);
+    Vec_PtrForEachEntry( Prs_Ntk_t *, vPrs, pNtk, i )
+        nMem += Prs_NtkMemory( pNtk );
+    nMem += Abc_NamMemUsed(Prs_ManNameMan(vPrs));
+    return nMem;
+}
+
+
+
+////////////////////////////////////////////////////////////////////////
+///                             ITERATORS                            ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+///                    FUNCTION DECLARATIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/*=== cba.c ========================================================*/
+
+
+ABC_NAMESPACE_HEADER_END
+
+#endif
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
diff --git a/abc-build/src/base/cba/cbaPrsBuild.c b/abc-build/src/base/cba/cbaPrsBuild.c
new file mode 100644
--- /dev/null
+++ b/abc-build/src/base/cba/cbaPrsBuild.c
@@ -0,0 +1,376 @@
+/**CFile****************************************************************
+
+  FileName    [cbaPrsBuild.c]
+
+  SystemName  [ABC: Logic synthesis and verification system.]
+
+  PackageName [Hierarchical word-level netlist.]
+
+  Synopsis    [Parse tree to netlist transformation.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - November 29, 2014.]
+
+  Revision    [$Id: cbaPrsBuild.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "cba.h"
+#include "cbaPrs.h"
+#include "map/mio/mio.h"
+#include "base/main/main.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Prs_ManIsMapped( Prs_Ntk_t * pNtk )
+{
+    Vec_Int_t * vSigs; int iBox;
+    Mio_Library_t * pLib = (Mio_Library_t *)Abc_FrameReadLibGen( Abc_FrameGetGlobalFrame() );
+    if ( pLib == NULL )
+        return 0;
+    Prs_NtkForEachBox( pNtk, vSigs, iBox )
+        if ( !Prs_BoxIsNode(pNtk, iBox) )
+        {
+            int NtkId = Prs_BoxNtk( pNtk, iBox );
+            if ( Mio_LibraryReadGateByName(pLib, Prs_NtkStr(pNtk, NtkId), NULL) )
+                return 1;
+        }
+    return 0;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Prs_ManVecFree( Vec_Ptr_t * vPrs )
+{
+    Prs_Ntk_t * pNtk; int i;
+    Vec_PtrForEachEntry( Prs_Ntk_t *, vPrs, pNtk, i )
+        Prs_NtkFree( pNtk );
+    Vec_PtrFree( vPrs );
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Prs_NtkCountObjects( Prs_Ntk_t * pNtk )
+{
+    Vec_Int_t * vFanins; 
+    int i, Count = Prs_NtkObjNum(pNtk);
+    Prs_NtkForEachBox( pNtk, vFanins, i )
+        Count += Prs_BoxIONum(pNtk, i);
+    return Count;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+// replaces NameIds of formal names by their index in the box model
+void Prs_ManRemapOne( Vec_Int_t * vSigs, Prs_Ntk_t * pNtkBox, Vec_Int_t * vMap )
+{
+    int i, NameId;
+    // map formal names into I/O indexes
+    Prs_NtkForEachPi( pNtkBox, NameId, i )
+    {
+        assert( Vec_IntEntry(vMap, NameId) == -1 );
+        Vec_IntWriteEntry( vMap, NameId, i + 1 ); // +1 to keep 1st form input non-zero
+    }
+    Prs_NtkForEachPo( pNtkBox, NameId, i )
+    {
+        assert( Vec_IntEntry(vMap, NameId) == -1 );
+        Vec_IntWriteEntry( vMap, NameId, Prs_NtkPiNum(pNtkBox) + i + 1 ); // +1 to keep 1st form input non-zero
+    }
+    // remap box
+    assert( Vec_IntSize(vSigs) % 2 == 0 );
+    Vec_IntForEachEntry( vSigs, NameId, i )
+    {
+        assert( Vec_IntEntry(vMap, NameId) != -1 );
+        Vec_IntWriteEntry( vSigs, i++, Vec_IntEntry(vMap, NameId) );
+    }
+    // unmap formal inputs
+    Prs_NtkForEachPi( pNtkBox, NameId, i )
+        Vec_IntWriteEntry( vMap, NameId, -1 );
+    Prs_NtkForEachPo( pNtkBox, NameId, i )
+        Vec_IntWriteEntry( vMap, NameId, -1 );
+}
+void Prs_ManRemapGate( Vec_Int_t * vSigs )
+{
+    int i, FormId;
+    Vec_IntForEachEntry( vSigs, FormId, i )
+        Vec_IntWriteEntry( vSigs, i, i/2 + 1 ), i++;
+}
+void Prs_ManRemapBoxes( Cba_Man_t * pNew, Vec_Ptr_t * vDes, Prs_Ntk_t * pNtk, Vec_Int_t * vMap )
+{
+    Vec_Int_t * vSigs; int iBox;
+    Prs_NtkForEachBox( pNtk, vSigs, iBox )
+        if ( !Prs_BoxIsNode(pNtk, iBox) )
+        {
+            int NtkId = Prs_BoxNtk( pNtk, iBox );
+            int NtkIdNew = Cba_ManNtkFindId( pNew, Prs_NtkStr(pNtk, NtkId) );
+            Prs_BoxSetNtk( pNtk, iBox, NtkIdNew );
+            if ( NtkIdNew < Cba_ManNtkNum(pNew) )
+                Prs_ManRemapOne( vSigs, Prs_ManNtk(vDes, NtkIdNew), vMap );
+            //else
+            //    Prs_ManRemapGate( vSigs );
+        }
+}
+void Prs_ManCleanMap( Prs_Ntk_t * pNtk, Vec_Int_t * vMap )
+{
+    Vec_Int_t * vSigs; 
+    int i, k, NameId, Sig;
+    Prs_NtkForEachPi( pNtk, NameId, i )
+        Vec_IntWriteEntry( vMap, NameId, -1 );
+    Prs_NtkForEachBox( pNtk, vSigs, i )
+        Vec_IntForEachEntryDouble( vSigs, NameId, Sig, k )
+            Vec_IntWriteEntry( vMap, Prs_NtkSigName(pNtk, Sig), -1 );
+    Prs_NtkForEachPo( pNtk, NameId, i )
+        Vec_IntWriteEntry( vMap, NameId, -1 );
+}
+// create maps of NameId and boxes
+void Prs_ManBuildNtk( Cba_Ntk_t * pNew, Vec_Ptr_t * vDes, Prs_Ntk_t * pNtk, Vec_Int_t * vMap, Vec_Int_t * vBoxes )
+{
+    Prs_Ntk_t * pNtkBox; Vec_Int_t * vSigs; int iBox;
+    int i, Index, NameId, iObj, iConst0, iTerm;
+    int iNonDriven = -1, nNonDriven = 0;
+    assert( Prs_NtkPioNum(pNtk) == 0 );
+    Prs_ManRemapBoxes( pNew->pDesign, vDes, pNtk, vMap );
+    Cba_NtkStartNames( pNew );
+    // create primary inputs 
+    Prs_NtkForEachPi( pNtk, NameId, i )
+    {
+        if ( Vec_IntEntry(vMap, NameId) != -1 )
+            printf( "Primary inputs %d and %d have the same name.\n", Vec_IntEntry(vMap, NameId), i );
+        iObj = Cba_ObjAlloc( pNew, CBA_OBJ_PI, -1 );
+        Cba_ObjSetName( pNew, iObj, NameId );
+        Vec_IntWriteEntry( vMap, NameId, iObj );
+    }
+    // create box outputs
+    Vec_IntClear( vBoxes );
+    Prs_NtkForEachBox( pNtk, vSigs, iBox )
+        if ( !Prs_BoxIsNode(pNtk, iBox) )
+        {
+            pNtkBox = Prs_ManNtk( vDes, Prs_BoxNtk(pNtk, iBox) );
+            if ( pNtkBox == NULL )
+            {
+                iObj = Cba_BoxAlloc( pNew, CBA_BOX_GATE, Vec_IntSize(vSigs)/2-1, 1, Prs_BoxNtk(pNtk, iBox) + 1 ); // +1 to map NtkId into gate name
+                Cba_ObjSetName( pNew, iObj, Prs_BoxName(pNtk, iBox) );
+                // consider box output 
+                NameId = Vec_IntEntryLast( vSigs );
+                NameId = Prs_NtkSigName( pNtk, NameId );
+                if ( Vec_IntEntry(vMap, NameId) != -1 )
+                    printf( "Box output name %d is already driven.\n", NameId );
+                iTerm = Cba_BoxBo( pNew, iObj, 0 );
+                Cba_ObjSetName( pNew, iTerm, NameId );
+                Vec_IntWriteEntry( vMap, NameId, iTerm );
+            }
+            else
+            {
+                iObj = Cba_BoxAlloc( pNew, CBA_OBJ_BOX, Prs_NtkPiNum(pNtkBox), Prs_NtkPoNum(pNtkBox), Prs_BoxNtk(pNtk, iBox) );
+                Cba_ObjSetName( pNew, iObj, Prs_BoxName(pNtk, iBox) );
+                Cba_NtkSetHost( Cba_ManNtk(pNew->pDesign, Prs_BoxNtk(pNtk, iBox)), Cba_NtkId(pNew), iObj );
+                Vec_IntForEachEntry( vSigs, Index, i )
+                {
+                    i++;
+                    if ( --Index < Prs_NtkPiNum(pNtkBox) )
+                        continue;
+                    assert( Index - Prs_NtkPiNum(pNtkBox) < Prs_NtkPoNum(pNtkBox) );
+                    // consider box output 
+                    NameId = Vec_IntEntry( vSigs, i );
+                    NameId = Prs_NtkSigName( pNtk, NameId );
+                    if ( Vec_IntEntry(vMap, NameId) != -1 )
+                        printf( "Box output name %d is already driven.\n", NameId );
+                    iTerm = Cba_BoxBo( pNew, iObj, Index - Prs_NtkPiNum(pNtkBox) );
+                    Cba_ObjSetName( pNew, iTerm, NameId );
+                    Vec_IntWriteEntry( vMap, NameId, iTerm );
+                }
+            }
+            // remember box
+            Vec_IntPush( vBoxes, iObj );
+        }
+        else
+        {
+            iObj = Cba_BoxAlloc( pNew, Prs_BoxNtk(pNtk, iBox), Prs_BoxIONum(pNtk, iBox)-1, 1, -1 );
+            // consider box output 
+            NameId = Vec_IntEntryLast( vSigs );
+            NameId = Prs_NtkSigName( pNtk, NameId );
+            if ( Vec_IntEntry(vMap, NameId) != -1 )
+                printf( "Node output name %d is already driven.\n", NameId );
+            iTerm = Cba_BoxBo( pNew, iObj, 0 );
+            Cba_ObjSetName( pNew, iTerm, NameId );
+            Vec_IntWriteEntry( vMap, NameId, iTerm );
+            // remember box
+            Vec_IntPush( vBoxes, iObj );
+        }
+    // add fanins for box inputs
+    Prs_NtkForEachBox( pNtk, vSigs, iBox )
+        if ( !Prs_BoxIsNode(pNtk, iBox) )
+        {
+            pNtkBox = Prs_ManNtk( vDes, Prs_BoxNtk(pNtk, iBox) );
+            iObj = Vec_IntEntry( vBoxes, iBox );
+            if ( pNtkBox == NULL )
+            {
+                Vec_IntForEachEntryStop( vSigs, Index, i, Vec_IntSize(vSigs)-2 )
+                {
+                    i++;
+                    NameId = Vec_IntEntry( vSigs, i );
+                    NameId = Prs_NtkSigName( pNtk, NameId );
+                    iTerm = Cba_BoxBi( pNew, iObj, i/2 );
+                    if ( Vec_IntEntry(vMap, NameId) == -1 )
+                    {
+                        iConst0 = Cba_BoxAlloc( pNew, CBA_BOX_C0, 0, 1, -1 );
+                        Vec_IntWriteEntry( vMap, NameId, iConst0+1 );
+                        if ( iNonDriven == -1 )
+                            iNonDriven = NameId;
+                        nNonDriven++;
+                    }
+                    Cba_ObjSetFanin( pNew, iTerm, Vec_IntEntry(vMap, NameId) );
+                    Cba_ObjSetName( pNew, iTerm, NameId );
+                }
+            }
+            else
+            {
+                Vec_IntForEachEntry( vSigs, Index, i )
+                {
+                    i++;
+                    if ( --Index >= Prs_NtkPiNum(pNtkBox) )
+                        continue;
+                    NameId = Vec_IntEntry( vSigs, i );
+                    NameId = Prs_NtkSigName( pNtk, NameId );
+                    iTerm = Cba_BoxBi( pNew, iObj, Index );
+                    if ( Vec_IntEntry(vMap, NameId) == -1 )
+                    {
+                        iConst0 = Cba_BoxAlloc( pNew, CBA_BOX_C0, 0, 1, -1 );
+                        Vec_IntWriteEntry( vMap, NameId, iConst0+1 );
+                        if ( iNonDriven == -1 )
+                            iNonDriven = NameId;
+                        nNonDriven++;
+                    }
+                    Cba_ObjSetFanin( pNew, iTerm, Vec_IntEntry(vMap, NameId) );
+                    Cba_ObjSetName( pNew, iTerm, NameId );
+                }
+            }
+        }
+        else
+        {
+            iObj = Vec_IntEntry( vBoxes, iBox );
+            Vec_IntForEachEntryStop( vSigs, Index, i, Vec_IntSize(vSigs)-2 )
+            {
+                NameId = Vec_IntEntry( vSigs, ++i );
+                NameId = Prs_NtkSigName( pNtk, NameId );
+                iTerm = Cba_BoxBi( pNew, iObj, i/2 );
+                if ( Vec_IntEntry(vMap, NameId) == -1 )
+                {
+                    iConst0 = Cba_BoxAlloc( pNew, CBA_BOX_C0, 0, 1, -1 );
+                    Vec_IntWriteEntry( vMap, NameId, iConst0+1 );
+                    if ( iNonDriven == -1 )
+                        iNonDriven = NameId;
+                    nNonDriven++;
+                }
+                Cba_ObjSetFanin( pNew, iTerm, Vec_IntEntry(vMap, NameId) );
+                Cba_ObjSetName( pNew, iTerm, NameId );
+            }
+        }
+    // add fanins for primary outputs
+    Prs_NtkForEachPo( pNtk, NameId, i )
+        if ( Vec_IntEntry(vMap, NameId) == -1 )
+        {
+            iConst0 = Cba_BoxAlloc( pNew, CBA_BOX_C0, 0, 1, -1 );
+            Vec_IntWriteEntry( vMap, NameId, iConst0+1 );
+            if ( iNonDriven == -1 )
+                iNonDriven = NameId;
+            nNonDriven++;
+        }
+    Prs_NtkForEachPo( pNtk, NameId, i )
+    {
+        iObj = Cba_ObjAlloc( pNew, CBA_OBJ_PO, Vec_IntEntry(vMap, NameId) );
+        Cba_ObjSetName( pNew, iObj, NameId );
+    }
+    if ( nNonDriven )
+        printf( "Module %s has %d non-driven nets (for example, %s).\n", Prs_NtkName(pNtk), nNonDriven, Prs_NtkStr(pNtk, iNonDriven) );
+    Prs_ManCleanMap( pNtk, vMap );
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Cba_Man_t * Prs_ManBuildCba( char * pFileName, Vec_Ptr_t * vDes )
+{
+    Prs_Ntk_t * pNtk = Prs_ManRoot( vDes );  int i;
+    Cba_Man_t * pNew = Cba_ManAlloc( pFileName, Vec_PtrSize(vDes) );
+    Vec_Int_t * vMap = Vec_IntStartFull( Abc_NamObjNumMax(pNtk->pStrs) + 1 );
+    Vec_Int_t * vTmp = Vec_IntAlloc( Prs_NtkBoxNum(pNtk) );
+    Abc_NamDeref( pNew->pStrs );
+    pNew->pStrs = Abc_NamRef( pNtk->pStrs );  
+    Vec_PtrForEachEntry( Prs_Ntk_t *, vDes, pNtk, i )
+        Cba_NtkAlloc( Cba_ManNtk(pNew, i), Prs_NtkId(pNtk), Prs_NtkPiNum(pNtk), Prs_NtkPoNum(pNtk), Prs_NtkCountObjects(pNtk) );
+    if ( (pNtk->fMapped || (pNtk->fSlices && Prs_ManIsMapped(pNtk))) && !Cba_NtkBuildLibrary(pNew) )
+        Cba_ManFree(pNew), pNew = NULL;
+    else 
+        Vec_PtrForEachEntry( Prs_Ntk_t *, vDes, pNtk, i )
+            Prs_ManBuildNtk( Cba_ManNtk(pNew, i), vDes, pNtk, vMap, vTmp );
+    assert( Vec_IntCountEntry(vMap, -1) == Vec_IntSize(vMap) );
+    Vec_IntFree( vMap );
+    Vec_IntFree( vTmp );
+    return pNew;
+}
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/abc-build/src/base/cba/cbaPrsTrans.c b/abc-build/src/base/cba/cbaPrsTrans.c
new file mode 100644
--- /dev/null
+++ b/abc-build/src/base/cba/cbaPrsTrans.c
@@ -0,0 +1,117 @@
+/**CFile****************************************************************
+
+  FileName    [cbaPrsTrans.c]
+
+  SystemName  [ABC: Logic synthesis and verification system.]
+
+  PackageName [Hierarchical word-level netlist.]
+
+  Synopsis    [Parse tree to netlist transformation.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - November 29, 2014.]
+
+  Revision    [$Id: cbaPrsTrans.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "cba.h"
+#include "cbaPrs.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    [Count range size.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Prs_ManRangeSizeName( Prs_Ntk_t * p, int Name )
+{
+    return 1;
+}
+static inline int Prs_ManRangeSizeRange( Prs_Ntk_t * p, int Range )
+{
+    char * pStr; 
+    int Left, Right;
+    if ( Range == 0 ) 
+        return 1;
+    pStr = Prs_NtkStr( p, Range );
+    assert( pStr[0] == '[' );
+    Left = Right = atoi( pStr + 1 );
+    pStr = strstr( pStr, "=" );
+    if ( pStr )
+        Right = atoi( pStr + 1 );
+    return 1 + (Left > Right ? Left - Right : Right - Left);
+}
+static inline int Prs_ManRangeSizeConst( Prs_Ntk_t * p, int Const )
+{
+    return atoi( Prs_NtkStr(p, Const) );
+}
+static inline int Prs_ManRangeSizeConcat( Prs_Ntk_t * p, int Con )
+{
+    extern int Prs_ManRangeSizeArray( Prs_Ntk_t * p, Vec_Int_t * vSlices, int Start, int Stop );
+    Vec_Int_t * vSigs = Prs_CatSignals(p, Con);
+    return Prs_ManRangeSizeArray( p, vSigs, 0, Vec_IntSize(vSigs) );
+}
+static inline int Prs_ManRangeSizeSignal( Prs_Ntk_t * p, int Sig )
+{
+    int Value = Abc_Lit2Var2( Sig );
+    Prs_ManType_t Type = Abc_Lit2Att2( Sig );
+    if ( Type == CBA_PRS_NAME )
+        return Prs_ManRangeSizeName( p, Value );
+    if ( Type == CBA_PRS_SLICE )
+        return Prs_ManRangeSizeRange( p, Prs_SliceRange(p, Value) );
+    if ( Type == CBA_PRS_CONST )
+        return Prs_ManRangeSizeConst( p, Value );
+    if ( Type == CBA_PRS_CONCAT )
+        return Prs_ManRangeSizeConcat( p, Value );
+    assert( 0 );
+    return 0;
+}
+int Prs_ManRangeSizeArray( Prs_Ntk_t * p, Vec_Int_t * vSlices, int Start, int Stop )
+{
+    int i, Sig, Count = 0;
+    assert( Vec_IntSize(vSlices) > 0 );
+    Vec_IntForEachEntryStartStop( vSlices, Sig, i, Start, Stop )
+        Count += Prs_ManRangeSizeSignal( p, Sig );
+    return Count;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/abc-build/src/base/cba/cbaPtr.c b/abc-build/src/base/cba/cbaPtr.c
new file mode 100644
--- /dev/null
+++ b/abc-build/src/base/cba/cbaPtr.c
@@ -0,0 +1,405 @@
+/**CFile****************************************************************
+
+  FileName    [cbaPtr.c]
+
+  SystemName  [ABC: Logic synthesis and verification system.]
+
+  PackageName [Hierarchical word-level netlist.]
+
+  Synopsis    [Simple interface with external tools.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - November 29, 2014.]
+
+  Revision    [$Id: cbaPtr.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "base/abc/abc.h"
+#include "base/main/mainInt.h"
+#include "map/mio/mio.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+/*
+design = array containing design name (as the first entry in the array) followed by pointers to modules
+module = array containing module name (as the first entry in the array) followed by pointers to 6 arrays: 
+         {array of input names; array of output names; array of nodes; array of boxes, 
+          array of floating-point input-arrival times; array of floating-point output-required times}
+node   = array containing output name, followed by node type, followed by input names
+box    = array containing model name, instance name, followed by pairs of formal/actual names for each port
+
+  Comments:
+  - in describing boxes
+     - input formal/actual name pairs should be listed before output name pairs
+     - the order of formal names should be the same as the order of inputs/outputs in the module description
+     - all formal names present in the module description should be listed
+     - if an input pin is not driven or an output pin has no fanout, the actual pin name is NULL
+     - word-level formal name "a" is written as bit-level names (a[0]. a[1], etc) ordered LSB to MSB
+     - the boxes can appear in any order (topological order is not expected)
+  - in description of nodes and boxes, primitive names should be given as char*-strings ("AndT", "OrT", etc)
+  - constant 0/1 nets should be driven by constant nodes having primitive names "Const0T" and "Const1T"
+  - primitive modules should not be written, but the list of primitives and formal names should be provided
+  - currently only "boxes" are supported (the array of "nodes" should contain no entries)
+  - arrays of input-arrival/output-required times in the module description are optional
+*/
+
+// elementary gates
+typedef enum { 
+    PTR_GATE_NONE = 0,
+    PTR_GATE_C0,         // Const0T
+    PTR_GATE_C1,         // Const1T   
+    PTR_GATE_BUF,        // BufT  
+    PTR_GATE_INV,        // InvT  
+    PTR_GATE_AND,        // AndT  
+    PTR_GATE_NAND,       // NandT 
+    PTR_GATE_OR,         // OrT   
+    PTR_GATE_NOR,        // NorT  
+    PTR_GATE_XOR,        // XorT  
+    PTR_GATE_XNOR,       // XnorT 
+    PTR_GATE_UNKNOWN
+} Ptr_ObjType_t; 
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    [Free Ptr.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Cba_PtrFreeNtk( Vec_Ptr_t * vNtk )
+{
+    Vec_PtrFree( (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 1) );
+    Vec_PtrFree( (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 2) );
+    Vec_VecFree( (Vec_Vec_t *)Vec_PtrEntry(vNtk, 3) );
+    Vec_VecFree( (Vec_Vec_t *)Vec_PtrEntry(vNtk, 4) );
+    if ( Vec_PtrSize(vNtk) > 5 )
+        Vec_FltFree( (Vec_Flt_t *)Vec_PtrEntry(vNtk, 5) );
+    if ( Vec_PtrSize(vNtk) > 6 )
+        Vec_FltFree( (Vec_Flt_t *)Vec_PtrEntry(vNtk, 6) );
+    Vec_PtrFree( vNtk );
+}
+void Cba_PtrFree( Vec_Ptr_t * vDes )
+{
+    Vec_Ptr_t * vNtk; int i;
+    if ( !vDes ) return;
+    Vec_PtrForEachEntryStart( Vec_Ptr_t *, vDes, vNtk, i, 1 )
+        Cba_PtrFreeNtk( vNtk );
+    Vec_PtrFree( vDes );
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Count memory used by Ptr.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Cba_PtrMemoryArray( Vec_Ptr_t * vArray )
+{
+    return (int)Vec_PtrMemory(vArray);
+}
+int Cba_PtrMemoryArrayArray( Vec_Ptr_t * vArrayArray )
+{
+    Vec_Ptr_t * vArray; int i, nBytes = 0;
+    Vec_PtrForEachEntry( Vec_Ptr_t *, vArrayArray, vArray, i )
+        nBytes += Cba_PtrMemoryArray(vArray);
+    return nBytes;
+}
+int Cba_PtrMemoryNtk( Vec_Ptr_t * vNtk )
+{
+    int nBytes = (int)Vec_PtrMemory(vNtk);
+    nBytes += Cba_PtrMemoryArray( (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 1) );
+    nBytes += Cba_PtrMemoryArray( (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 2) );
+    nBytes += Cba_PtrMemoryArrayArray( (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 3) );
+    nBytes += Cba_PtrMemoryArrayArray( (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 4) );
+    return nBytes;
+}
+int Cba_PtrMemory( Vec_Ptr_t * vDes )
+{
+    Vec_Ptr_t * vNtk; int i, nBytes = (int)Vec_PtrMemory(vDes);
+    Vec_PtrForEachEntryStart( Vec_Ptr_t *, vDes, vNtk, i, 1 )
+        nBytes += Cba_PtrMemoryNtk(vNtk);
+    return nBytes;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Dumping Ptr into a BLIF file.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Cba_PtrDumpSignalsBlif( FILE * pFile, Vec_Ptr_t * vSigs, int fSkipLastComma )
+{
+    char * pSig; int i;
+    Vec_PtrForEachEntry( char *, vSigs, pSig, i )
+        fprintf( pFile, " %s", pSig );
+}
+void Cba_PtrDumpBoxBlif( FILE * pFile, Vec_Ptr_t * vBox )
+{
+    char * pName; int i;
+    fprintf( pFile, ".subckt" );
+    fprintf( pFile, " %s", (char *)Vec_PtrEntry(vBox, 0) );
+    //fprintf( pFile, " %s", (char *)Vec_PtrEntry(vBox, 1) ); // do not write intance name in BLIF
+    Vec_PtrForEachEntryStart( char *, vBox, pName, i, 2 )
+        fprintf( pFile, " %s=%s", pName, (char *)Vec_PtrEntry(vBox, i+1) ), i++;
+    fprintf( pFile, "\n" );
+}
+void Cba_PtrDumpBoxesBlif( FILE * pFile, Vec_Ptr_t * vBoxes )
+{
+    Vec_Ptr_t * vBox; int i;
+    Vec_PtrForEachEntry( Vec_Ptr_t *, vBoxes, vBox, i )
+        Cba_PtrDumpBoxBlif( pFile, vBox );
+}
+void Cba_PtrDumpModuleBlif( FILE * pFile, Vec_Ptr_t * vNtk )
+{
+    fprintf( pFile, ".model %s\n", (char *)Vec_PtrEntry(vNtk, 0) );
+    fprintf( pFile, ".inputs" );
+    Cba_PtrDumpSignalsBlif( pFile, (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 1), 0 );
+    fprintf( pFile, "\n" );
+    fprintf( pFile, ".outputs" );
+    Cba_PtrDumpSignalsBlif( pFile, (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 2), 1 );
+    fprintf( pFile, "\n" );
+    assert( Vec_PtrSize((Vec_Ptr_t *)Vec_PtrEntry(vNtk, 3)) == 0 ); // no nodes; only boxes
+    Cba_PtrDumpBoxesBlif( pFile, (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 4) );
+    fprintf( pFile, ".end\n\n" );
+}
+void Cba_PtrDumpBlif( char * pFileName, Vec_Ptr_t * vDes )
+{
+    FILE * pFile;
+    Vec_Ptr_t * vNtk; int i;
+    pFile = fopen( pFileName, "wb" );
+    if ( pFile == NULL )
+    {
+        printf( "Cannot open output file \"%s\".\n", pFileName );
+        return;
+    }
+    fprintf( pFile, "// Design \"%s\" written by ABC on %s\n\n", (char *)Vec_PtrEntry(vDes, 0), Extra_TimeStamp() );
+    Vec_PtrForEachEntryStart( Vec_Ptr_t *, vDes, vNtk, i, 1 )
+        Cba_PtrDumpModuleBlif( pFile, vNtk );
+    fclose( pFile );
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    [Collect elementary gates from the library.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Cba_ManCollectGateNameOne( Mio_Library_t * pLib, Ptr_ObjType_t Type, word Truth, Vec_Ptr_t * vGateNames )
+{
+    Mio_Gate_t * pGate = Mio_LibraryReadGateByTruth( pLib, Truth );
+    if ( pGate != NULL )
+        Vec_PtrWriteEntry( vGateNames, Type, Mio_GateReadName(pGate) );
+}
+Vec_Ptr_t * Cba_ManCollectGateNamesByTruth( Mio_Library_t * pLib )
+{
+    static word uTruths6[3] = {
+        ABC_CONST(0xAAAAAAAAAAAAAAAA),
+        ABC_CONST(0xCCCCCCCCCCCCCCCC),
+        ABC_CONST(0xF0F0F0F0F0F0F0F0),
+    };
+    Vec_Ptr_t * vGateNames = Vec_PtrStart( PTR_GATE_UNKNOWN );
+    Cba_ManCollectGateNameOne( pLib, PTR_GATE_C0,              0,                 vGateNames );
+    Cba_ManCollectGateNameOne( pLib, PTR_GATE_C1,       ~(word)0,                 vGateNames );
+    Cba_ManCollectGateNameOne( pLib, PTR_GATE_BUF,    uTruths6[0],                vGateNames );
+    Cba_ManCollectGateNameOne( pLib, PTR_GATE_INV,   ~uTruths6[0],                vGateNames );
+    Cba_ManCollectGateNameOne( pLib, PTR_GATE_AND,   (uTruths6[0] & uTruths6[1]), vGateNames );
+    Cba_ManCollectGateNameOne( pLib, PTR_GATE_NAND, ~(uTruths6[0] & uTruths6[1]), vGateNames );
+    Cba_ManCollectGateNameOne( pLib, PTR_GATE_OR,    (uTruths6[0] | uTruths6[1]), vGateNames );
+    Cba_ManCollectGateNameOne( pLib, PTR_GATE_NOR,  ~(uTruths6[0] | uTruths6[1]), vGateNames );
+    Cba_ManCollectGateNameOne( pLib, PTR_GATE_XOR,   (uTruths6[0] ^ uTruths6[1]), vGateNames );
+    Cba_ManCollectGateNameOne( pLib, PTR_GATE_XNOR, ~(uTruths6[0] ^ uTruths6[1]), vGateNames );
+    return vGateNames;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [This procedure transforms tech-ind Ptr into mapped Ptr.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Cba_PtrUpdateBox( Vec_Ptr_t * vBox, Vec_Ptr_t * vGatesNames )
+{
+    Mio_Gate_t * pGate;  Mio_Pin_t * pPin; int i = 1;
+    Mio_Library_t * pLib = (Mio_Library_t *)Abc_FrameReadLibGen( Abc_FrameGetGlobalFrame() );
+    // update gate name
+    char * pNameNew, * pName = (char *)Vec_PtrEntry(vBox, 0);
+    if ( !strcmp(pName, "Const0T") )
+        pNameNew = (char *)Vec_PtrEntry(vGatesNames, PTR_GATE_C0);
+    else if ( !strcmp(pName, "Const1T") )
+        pNameNew = (char *)Vec_PtrEntry(vGatesNames, PTR_GATE_C1);
+    else if ( !strcmp(pName, "BufT") )
+        pNameNew = (char *)Vec_PtrEntry(vGatesNames, PTR_GATE_BUF);
+    else if ( !strcmp(pName, "InvT") )
+        pNameNew = (char *)Vec_PtrEntry(vGatesNames, PTR_GATE_INV);
+    else if ( !strcmp(pName, "AndT") )
+        pNameNew = (char *)Vec_PtrEntry(vGatesNames, PTR_GATE_AND);
+    else if ( !strcmp(pName, "NandT") )
+        pNameNew = (char *)Vec_PtrEntry(vGatesNames, PTR_GATE_NAND);
+    else if ( !strcmp(pName, "OrT") )
+        pNameNew = (char *)Vec_PtrEntry(vGatesNames, PTR_GATE_OR);
+    else if ( !strcmp(pName, "NorT") )
+        pNameNew = (char *)Vec_PtrEntry(vGatesNames, PTR_GATE_NOR);
+    else if ( !strcmp(pName, "XorT") )
+        pNameNew = (char *)Vec_PtrEntry(vGatesNames, PTR_GATE_XOR);
+    else if ( !strcmp(pName, "XnorT") )
+        pNameNew = (char *)Vec_PtrEntry(vGatesNames, PTR_GATE_XNOR);
+    else // user hierarchy
+        return;
+    ABC_FREE( pName );
+    Vec_PtrWriteEntry( vBox, 0, Abc_UtilStrsav(pNameNew) );
+    // remove instance name
+    pName = (char *)Vec_PtrEntry(vBox, 1);
+    ABC_FREE( pName );
+    Vec_PtrWriteEntry( vBox, 1, NULL );
+    // update formal input names
+    pGate = Mio_LibraryReadGateByName( pLib, pNameNew, NULL );
+    Mio_GateForEachPin( pGate, pPin )
+    {
+        pName = (char *)Vec_PtrEntry( vBox, 2 * i );
+        ABC_FREE( pName );
+        pNameNew = Mio_PinReadName(pPin);
+        Vec_PtrWriteEntry( vBox, 2 * i++, Abc_UtilStrsav(pNameNew) );
+    }
+    // update output name
+    pName = (char *)Vec_PtrEntry( vBox, 2 * i );
+    pNameNew = Mio_GateReadOutName(pGate);
+    Vec_PtrWriteEntry( vBox, 2 * i++, Abc_UtilStrsav(pNameNew) );
+    assert( 2 * i == Vec_PtrSize(vBox) );
+}
+Vec_Ptr_t * Cba_PtrTransformSigs( Vec_Ptr_t * vSig )
+{
+    char * pName; int i;
+    Vec_Ptr_t * vNew = Vec_PtrAllocExact( Vec_PtrSize(vSig) );
+    Vec_PtrForEachEntry( char *, vSig, pName, i )
+        Vec_PtrPush( vNew, Abc_UtilStrsav(pName) );
+    return vNew;
+}
+Vec_Ptr_t * Cba_PtrTransformBox( Vec_Ptr_t * vBox, Vec_Ptr_t * vGatesNames )
+{
+    char * pName; int i;
+    Vec_Ptr_t * vNew = Vec_PtrAllocExact( Vec_PtrSize(vBox) );
+    Vec_PtrForEachEntry( char *, vBox, pName, i )
+        Vec_PtrPush( vNew, Abc_UtilStrsav(pName) );
+    if ( vGatesNames )
+        Cba_PtrUpdateBox( vNew, vGatesNames );
+    return vNew;
+}
+Vec_Ptr_t * Cba_PtrTransformBoxes( Vec_Ptr_t * vBoxes, Vec_Ptr_t * vGatesNames )
+{
+    Vec_Ptr_t * vBox; int i;
+    Vec_Ptr_t * vNew = Vec_PtrAllocExact( Vec_PtrSize(vBoxes) );
+    Vec_PtrForEachEntry( Vec_Ptr_t *, vBoxes, vBox, i )
+        Vec_PtrPush( vNew, Cba_PtrTransformBox(vBox, vGatesNames) );
+    return vNew;
+}
+Vec_Ptr_t * Cba_PtrTransformNtk( Vec_Ptr_t * vNtk, Vec_Ptr_t * vGatesNames )
+{
+    char * pName = (char *)Vec_PtrEntry(vNtk, 0);
+    Vec_Ptr_t * vInputs  = (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 1);
+    Vec_Ptr_t * vOutputs = (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 2);
+    Vec_Ptr_t * vBoxes   = (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 4);
+    Vec_Ptr_t * vNew     = Vec_PtrAllocExact( Vec_PtrSize(vNtk) );
+    Vec_PtrPush( vNew, Abc_UtilStrsav(pName) );
+    Vec_PtrPush( vNew, Cba_PtrTransformSigs(vInputs) );
+    Vec_PtrPush( vNew, Cba_PtrTransformSigs(vOutputs) );
+    Vec_PtrPush( vNew, Vec_PtrAllocExact(0) );
+    Vec_PtrPush( vNew, Cba_PtrTransformBoxes(vBoxes, vGatesNames) );
+    return vNew;
+}
+Vec_Ptr_t * Cba_PtrTransformTest( Vec_Ptr_t * vDes )
+{
+    Mio_Library_t * pLib;
+    Vec_Ptr_t * vGatesNames;
+    Vec_Ptr_t * vNtk, * vNew; int i;
+    // dump BLIF before transformation
+    Cba_PtrDumpBlif( "test1.blif", vDes );
+    if ( Abc_FrameGetGlobalFrame() == NULL )
+    {
+        printf( "ABC framework is not started.\n" );
+        return NULL;
+    }
+    pLib = (Mio_Library_t *)Abc_FrameReadLibGen( Abc_FrameGetGlobalFrame() );
+    if ( pLib == NULL )
+    {
+        printf( "Standard cell library is not entered.\n" );
+        return NULL;
+    }
+    vGatesNames = Cba_ManCollectGateNamesByTruth( pLib );
+    // transform
+    vNew = Vec_PtrAllocExact( Vec_PtrSize(vDes) );
+    Vec_PtrPush( vNew, Abc_UtilStrsav((char *)Vec_PtrEntry(vDes, 0)) );
+    Vec_PtrForEachEntryStart( Vec_Ptr_t *, vDes, vNtk, i, 1 )
+        Vec_PtrPush( vNew, Cba_PtrTransformNtk(vNtk, vGatesNames) );
+    // dump BLIF after transformation
+    Cba_PtrDumpBlif( "test2.blif", vNew );
+    Vec_PtrFree( vGatesNames );
+    return vNew;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Test the testing procedure.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Cba_PtrTransformTestTest()
+{
+    char * pFileName = "c/hie/dump/1/netlist_1.v";
+    Abc_Ntk_t * pNtk = Io_ReadNetlist( pFileName, Io_ReadFileType(pFileName), 0 );
+    extern Vec_Ptr_t * Ptr_AbcDeriveDes( Abc_Ntk_t * pNtk );
+    Vec_Ptr_t * vDes = Ptr_AbcDeriveDes( pNtk );
+    Vec_Ptr_t * vNew = Cba_PtrTransformTest( vDes );
+    Cba_PtrFree( vDes );
+    Cba_PtrFree( vNew );
+}
+
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/abc-build/src/base/cba/cbaPtrAbc.c b/abc-build/src/base/cba/cbaPtrAbc.c
new file mode 100644
--- /dev/null
+++ b/abc-build/src/base/cba/cbaPtrAbc.c
@@ -0,0 +1,481 @@
+/**CFile****************************************************************
+
+  FileName    [cbaPtrAbc.c]
+
+  SystemName  [ABC: Logic synthesis and verification system.]
+
+  PackageName [Hierarchical word-level netlist.]
+
+  Synopsis    [Simple interface with external tools.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - November 29, 2014.]
+
+  Revision    [$Id: cbaPtrAbc.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "cba.h"
+#include "base/abc/abc.h"
+#include "map/mio/mio.h"
+#include "base/main/mainInt.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    [Node type conversions.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+char * Ptr_HopToType( Abc_Obj_t * pObj )
+{
+    static word uTruth, uTruths6[3] = {
+        ABC_CONST(0xAAAAAAAAAAAAAAAA),
+        ABC_CONST(0xCCCCCCCCCCCCCCCC),
+        ABC_CONST(0xF0F0F0F0F0F0F0F0),
+    };
+    assert( Abc_ObjIsNode(pObj) );
+    uTruth = Hop_ManComputeTruth6( (Hop_Man_t *)Abc_ObjNtk(pObj)->pManFunc, (Hop_Obj_t *)pObj->pData, Abc_ObjFaninNum(pObj) );
+/*
+    if ( uTruth ==  0 )                           return "CBA_BOX_C0";
+    if ( uTruth == ~(word)0 )                     return "CBA_BOX_C1";
+    if ( uTruth ==  uTruths6[0] )                 return "CBA_BOX_BUF";
+    if ( uTruth == ~uTruths6[0] )                 return "CBA_BOX_INV";
+    if ( uTruth == (uTruths6[0] & uTruths6[1]) )  return "CBA_BOX_AND";
+    if ( uTruth ==~(uTruths6[0] & uTruths6[1]) )  return "CBA_BOX_NAND";
+    if ( uTruth == (uTruths6[0] | uTruths6[1]) )  return "CBA_BOX_OR";
+    if ( uTruth ==~(uTruths6[0] | uTruths6[1]) )  return "CBA_BOX_NOR";
+    if ( uTruth == (uTruths6[0] ^ uTruths6[1]) )  return "CBA_BOX_XOR";
+    if ( uTruth ==~(uTruths6[0] ^ uTruths6[1]) )  return "CBA_BOX_XNOR";
+*/
+    if ( uTruth ==  0 )                           return "Const0T";
+    if ( uTruth == ~(word)0 )                     return "Const1T";
+    if ( uTruth ==  uTruths6[0] )                 return "BufT";
+    if ( uTruth == ~uTruths6[0] )                 return "InvT";
+    if ( uTruth == (uTruths6[0] & uTruths6[1]) )  return "AndT";
+    if ( uTruth ==~(uTruths6[0] & uTruths6[1]) )  return "NandT";
+    if ( uTruth == (uTruths6[0] | uTruths6[1]) )  return "OrT";
+    if ( uTruth ==~(uTruths6[0] | uTruths6[1]) )  return "NorT";
+    if ( uTruth == (uTruths6[0] ^ uTruths6[1]) )  return "XorT";
+    if ( uTruth ==~(uTruths6[0] ^ uTruths6[1]) )  return "XnorT";
+    assert( 0 );
+    return NULL;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    [Create Ptr from Abc_Ntk_t.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+char * Ptr_AbcObjName( Abc_Obj_t * pObj )
+{
+    if ( Abc_ObjIsNet(pObj) || Abc_ObjIsBox(pObj) )
+        return Abc_ObjName(pObj);
+    if ( Abc_ObjIsCi(pObj) || Abc_ObjIsNode(pObj) )
+        return Ptr_AbcObjName(Abc_ObjFanout0(pObj));
+    if ( Abc_ObjIsCo(pObj) )
+        return Ptr_AbcObjName(Abc_ObjFanin0(pObj));
+    assert( 0 );
+    return NULL;
+}
+static int Ptr_CheckArray( Vec_Ptr_t * vArray )
+{
+    assert( Vec_PtrSize(vArray) == Vec_PtrCap(vArray) );
+    return 1;
+}
+Vec_Ptr_t * Ptr_AbcDeriveNode( Abc_Obj_t * pObj )
+{
+    Abc_Obj_t * pFanin; int i;
+    Vec_Ptr_t * vNode = Vec_PtrAllocExact( 2 + 2 * (1 + Abc_ObjFaninNum(pObj)) );
+    assert( Abc_ObjIsNode(pObj) );
+    if ( Abc_NtkHasAig(pObj->pNtk) )
+        Vec_PtrPush( vNode, Ptr_HopToType(pObj) );
+    else if ( Abc_NtkHasSop(pObj->pNtk) )
+        Vec_PtrPush( vNode, Ptr_SopToTypeName((char *)pObj->pData) );
+    else assert( 0 );
+    Vec_PtrPush( vNode, Ptr_AbcObjName(pObj) );
+    assert( Abc_ObjFaninNum(pObj) <= 2 );
+    Abc_ObjForEachFanin( pObj, pFanin, i )
+    {
+        Vec_PtrPush( vNode, i ? "r" : "l" );
+        Vec_PtrPush( vNode, Ptr_AbcObjName(pFanin) );
+    }
+    Vec_PtrPush( vNode, "o" );
+    Vec_PtrPush( vNode, Ptr_AbcObjName(pObj) );
+    assert( Ptr_CheckArray(vNode) );
+    return vNode;
+}
+Vec_Ptr_t * Ptr_AbcDeriveBox( Abc_Obj_t * pObj )
+{
+    Abc_Obj_t * pNext; int i;
+    Abc_Ntk_t * pNtk = Abc_ObjModel(pObj);
+    Vec_Ptr_t * vBox = Vec_PtrAllocExact( 2 + 2 * Abc_ObjFaninNum(pObj) + 2 * Abc_ObjFanoutNum(pObj) );
+    assert( Abc_ObjIsBox(pObj) );
+    Vec_PtrPush( vBox, Abc_NtkName(pNtk) );
+    Vec_PtrPush( vBox, Ptr_AbcObjName(pObj) );
+    Abc_ObjForEachFanin( pObj, pNext, i )
+    {
+        Vec_PtrPush( vBox, Ptr_AbcObjName(Abc_NtkPi(pNtk, i)) );
+        Vec_PtrPush( vBox, Ptr_AbcObjName(pNext) );
+    }
+    Abc_ObjForEachFanout( pObj, pNext, i )
+    {
+        Vec_PtrPush( vBox, Ptr_AbcObjName(Abc_NtkPo(pNtk, i)) );
+        Vec_PtrPush( vBox, Ptr_AbcObjName(pNext) );
+    }
+    assert( Ptr_CheckArray(vBox) );
+    return vBox;
+}
+Vec_Ptr_t * Ptr_AbcDeriveBoxes( Abc_Ntk_t * pNtk )
+{
+    Abc_Obj_t * pObj; int i;
+    Vec_Ptr_t * vBoxes = Vec_PtrAllocExact( Abc_NtkBoxNum(pNtk) + Abc_NtkNodeNum(pNtk) );
+    Abc_NtkForEachBox( pNtk, pObj, i )
+        Vec_PtrPush( vBoxes, Ptr_AbcDeriveBox(pObj) );
+    Abc_NtkForEachNode( pNtk, pObj, i )
+        Vec_PtrPush( vBoxes, Ptr_AbcDeriveNode(pObj) );
+    assert( Ptr_CheckArray(vBoxes) );
+    return vBoxes;
+}
+
+Vec_Ptr_t * Ptr_AbcDeriveInputs( Abc_Ntk_t * pNtk )
+{
+    Abc_Obj_t * pObj; int i;
+    Vec_Ptr_t * vSigs = Vec_PtrAllocExact( Abc_NtkPiNum(pNtk) );
+    Abc_NtkForEachPi( pNtk, pObj, i )
+        Vec_PtrPush( vSigs, Ptr_AbcObjName(pObj) );
+    assert( Ptr_CheckArray(vSigs) );
+    return vSigs;
+}
+Vec_Ptr_t * Ptr_AbcDeriveOutputs( Abc_Ntk_t * pNtk )
+{
+    Abc_Obj_t * pObj; int i;
+    Vec_Ptr_t * vSigs = Vec_PtrAllocExact( Abc_NtkPoNum(pNtk) );
+    Abc_NtkForEachPo( pNtk, pObj, i )
+        Vec_PtrPush( vSigs, Ptr_AbcObjName(pObj) );
+    assert( Ptr_CheckArray(vSigs) );
+    return vSigs;
+}
+Vec_Ptr_t * Ptr_AbcDeriveNtk( Abc_Ntk_t * pNtk )
+{
+    Vec_Ptr_t * vNtk = Vec_PtrAllocExact( 5 );
+    Vec_PtrPush( vNtk, Abc_NtkName(pNtk) );
+    Vec_PtrPush( vNtk, Ptr_AbcDeriveInputs(pNtk) );
+    Vec_PtrPush( vNtk, Ptr_AbcDeriveOutputs(pNtk) );
+    Vec_PtrPush( vNtk, Vec_PtrAllocExact(0) );
+    Vec_PtrPush( vNtk, Ptr_AbcDeriveBoxes(pNtk) );
+    assert( Ptr_CheckArray(vNtk) );
+    return vNtk;
+}
+Vec_Ptr_t * Ptr_AbcDeriveDes( Abc_Ntk_t * pNtk )
+{
+    Vec_Ptr_t * vDes;
+    Abc_Ntk_t * pTemp; int i;
+    vDes = Vec_PtrAllocExact( 1 + Vec_PtrSize(pNtk->pDesign->vModules) );
+    Vec_PtrPush( vDes, pNtk->pDesign->pName );
+    Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pTemp, i )
+        Vec_PtrPush( vDes, Ptr_AbcDeriveNtk(pTemp) );
+    assert( Ptr_CheckArray(vDes) );
+    return vDes;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Ptr_ManExperiment( Abc_Ntk_t * pNtk )
+{
+    abctime clk = Abc_Clock();
+    char * pFileName = Extra_FileNameGenericAppend(pNtk->pDesign->pName, "_out.blif");
+    Vec_Ptr_t * vDes = Ptr_AbcDeriveDes( pNtk );
+    printf( "Converting to Ptr:  Memory = %6.3f MB  ", 1.0*Cba_PtrMemory(vDes)/(1<<20) );
+    Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
+    Cba_PtrDumpBlif( pFileName, vDes );
+    printf( "Finished writing output file \"%s\".  ", pFileName );
+    Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
+    Cba_PtrFree( vDes );
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Create Cba_Man_t from tech-ind Ptr.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Ptr_NameToType( char * pSop )
+{
+    if ( !strcmp(pSop, "Const0T") )      return CBA_BOX_C0;
+    if ( !strcmp(pSop, "Const1T") )      return CBA_BOX_C1;
+    if ( !strcmp(pSop, "BufT") )         return CBA_BOX_BUF;
+    if ( !strcmp(pSop, "InvT") )         return CBA_BOX_INV;
+    if ( !strcmp(pSop, "AndT") )         return CBA_BOX_AND;
+    if ( !strcmp(pSop, "NandT") )        return CBA_BOX_NAND;
+    if ( !strcmp(pSop, "OrT") )          return CBA_BOX_OR;
+    if ( !strcmp(pSop, "NorT") )         return CBA_BOX_NOR;
+    if ( !strcmp(pSop, "XorT") )         return CBA_BOX_XOR;
+    if ( !strcmp(pSop, "XnorT") )        return CBA_BOX_XNOR;
+    return CBA_OBJ_BOX;
+}
+int Ptr_ManCountNtk( Vec_Ptr_t * vNtk )
+{
+    Vec_Ptr_t * vInputs = (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 1);
+    Vec_Ptr_t * vOutputs = (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 2);
+    Vec_Ptr_t * vNodes = (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 3);
+    Vec_Ptr_t * vBoxes = (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 4);
+    Vec_Ptr_t * vBox; int i, Counter = 0;
+    assert( Vec_PtrSize(vNodes) == 0 );
+    Counter += Vec_PtrSize(vInputs);
+    Counter += Vec_PtrSize(vOutputs);
+    Vec_PtrForEachEntry( Vec_Ptr_t *, vBoxes, vBox, i )
+        Counter += Vec_PtrSize(vBox)/2;
+    return Counter;
+}
+int Cba_BoxCountOutputs( Cba_Ntk_t * pNtk, char * pBoxNtk )
+{
+    int ModuleId = Cba_ManNtkFindId( pNtk->pDesign, pBoxNtk );
+    if ( ModuleId == -1 )
+        return 1;
+    return Cba_NtkPoNumAlloc( Cba_ManNtk(pNtk->pDesign, ModuleId) );
+}
+int Cba_NtkDeriveFromPtr( Cba_Ntk_t * pNtk, Vec_Ptr_t * vNtk, Vec_Int_t * vMap, Vec_Int_t * vBox2Id )
+{
+    char * pName, * pModuleName = (char *)Vec_PtrEntry(vNtk, 0);
+    Vec_Ptr_t * vInputs  = (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 1);
+    Vec_Ptr_t * vOutputs = (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 2);
+    Vec_Ptr_t * vBoxes   = (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 4), * vBox;
+    int i, k, iObj, iTerm, NameId;
+    // start network with the given name
+    NameId = Abc_NamStrFindOrAdd( pNtk->pDesign->pStrs, pModuleName, NULL );
+    assert( Cba_NtkNameId(pNtk) == NameId );
+    // map driven NameIds into their ObjIds for PIs
+    Vec_PtrForEachEntry( char *, vInputs, pName, i )
+    {
+        NameId = Abc_NamStrFindOrAdd( pNtk->pDesign->pStrs, pName, NULL );
+        if ( Vec_IntGetEntryFull(vMap, NameId) != -1 )
+            { printf( "PI with name \"%s\" is not unique module \"%s\".\n", pName, pModuleName ); return 0; }
+        iObj = Cba_ObjAlloc( pNtk, CBA_OBJ_PI, -1 );
+        Cba_ObjSetName( pNtk, iObj, NameId );
+        Vec_IntSetEntryFull( vMap, NameId, iObj );
+    }
+    // map driven NameIds into their ObjIds for BOs
+    Vec_IntClear( vBox2Id );
+    Vec_PtrForEachEntry( Vec_Ptr_t *, vBoxes, vBox, i )
+    {
+        char * pBoxNtk = (char *)Vec_PtrEntry(vBox, 0);
+        char * pBoxName = (char *)Vec_PtrEntry(vBox, 1);
+        int nOutputs = Cba_BoxCountOutputs( pNtk, pBoxNtk );
+        int nInputs = Vec_PtrSize(vBox)/2 - nOutputs - 1;
+        int NtkId = Cba_ManNtkFindId( pNtk->pDesign, pBoxNtk );
+        assert( Vec_PtrSize(vBox) % 2 == 0 );
+        assert( nOutputs > 0 && 2*(nOutputs + 1) <= Vec_PtrSize(vBox) );
+        iObj = Cba_BoxAlloc( pNtk, Ptr_NameToType(pBoxNtk), nInputs, nOutputs, NtkId );
+        if ( NtkId >= 0 )
+            Cba_NtkSetHost( Cba_ManNtk(pNtk->pDesign, NtkId), Cba_NtkId(pNtk), iObj );
+        Cba_ObjSetName( pNtk, iObj, Abc_NamStrFindOrAdd(pNtk->pDesign->pStrs, pBoxName, NULL) );
+        Cba_BoxForEachBo( pNtk, iObj, iTerm, k )
+        {
+            pName = (char *)Vec_PtrEntry( vBox, Vec_PtrSize(vBox) - 2*(nOutputs - k) + 1 );
+            NameId = Abc_NamStrFindOrAdd( pNtk->pDesign->pStrs, pName, NULL );
+            if ( Vec_IntGetEntryFull(vMap, NameId) != -1 )
+                { printf( "Signal \"%s\" has multiple drivers in module \"%s\".\n", pName, pModuleName ); return 0; }
+            Cba_ObjSetName( pNtk, iTerm, NameId );
+            Vec_IntSetEntryFull( vMap, NameId, iTerm );
+        }
+        Vec_IntPush( vBox2Id, iObj );
+    }
+    assert( Vec_IntSize(vBox2Id) == Vec_PtrSize(vBoxes) );
+    // connect BIs
+    Vec_PtrForEachEntry( Vec_Ptr_t *, vBoxes, vBox, i )
+    {
+        iObj = Vec_IntEntry( vBox2Id, i );
+        Cba_BoxForEachBi( pNtk, iObj, iTerm, k )
+        {
+            pName = (char *)Vec_PtrEntry( vBox, 2*(k + 1) + 1 );
+            NameId = Abc_NamStrFindOrAdd( pNtk->pDesign->pStrs, pName, NULL );
+            if ( Vec_IntGetEntryFull(vMap, NameId) == -1 )
+                printf( "Signal \"%s\" in not driven in module \"%s\".\n", pName, pModuleName );
+            Cba_ObjSetFanin( pNtk, iTerm, Vec_IntGetEntryFull(vMap, NameId) );
+            Cba_ObjSetName( pNtk, iTerm, NameId );
+        }
+    }
+    // connect POs
+    Vec_PtrForEachEntry( char *, vOutputs, pName, i )
+    {
+        NameId = Abc_NamStrFindOrAdd( pNtk->pDesign->pStrs, pName, NULL );
+        if ( Vec_IntGetEntryFull(vMap, NameId) == -1 )
+            printf( "PO with name \"%s\" in not driven in module \"%s\".\n", pName, pModuleName );
+        iObj = Cba_ObjAlloc( pNtk, CBA_OBJ_PO, Vec_IntGetEntryFull(vMap, NameId) );
+        Cba_ObjSetName( pNtk, iObj, NameId );
+    }
+    // update map
+    Cba_NtkForEachCi( pNtk, iObj )
+        Vec_IntSetEntryFull( vMap, Cba_ObjName(pNtk, iObj), -1 );
+    // double check
+    Vec_IntForEachEntry( vMap, iObj, i )
+        assert( iObj == -1 );
+    assert( Cba_NtkObjNum(pNtk) == Vec_StrCap(&pNtk->vType) );
+    return 1;
+}
+Cba_Man_t * Cba_PtrTransformToCba( Vec_Ptr_t * vDes )
+{
+    char * pName = (char *)Vec_PtrEntry(vDes, 0);
+    Cba_Man_t * pNew = Cba_ManAlloc( pName, Vec_PtrSize(vDes) - 1 );
+    Vec_Int_t * vMap = Vec_IntStartFull( 1000 );
+    Vec_Int_t * vBox2Id = Vec_IntAlloc( 1000 );
+    // create interfaces
+    Cba_Ntk_t * pNtk; int i;
+    Cba_ManForEachNtk( pNew, pNtk, i )
+    {
+        Vec_Ptr_t * vNtk = (Vec_Ptr_t *)Vec_PtrEntry(vDes, i+1);
+        Vec_Ptr_t * vInputs = (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 1);
+        Vec_Ptr_t * vOutputs = (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 2);
+        int NameId = Abc_NamStrFindOrAdd( pNew->pStrs, (char *)Vec_PtrEntry(vNtk, 0), NULL );
+        Cba_NtkAlloc( pNtk, NameId, Vec_PtrSize(vInputs), Vec_PtrSize(vOutputs), Ptr_ManCountNtk(vNtk) );
+        Cba_NtkStartNames( pNtk );
+    }
+    // parse the networks
+    Cba_ManForEachNtk( pNew, pNtk, i )
+    {
+        Vec_Ptr_t * vNtk = (Vec_Ptr_t *)Vec_PtrEntry(vDes, i+1);
+        if ( !Cba_NtkDeriveFromPtr( pNtk, vNtk, vMap, vBox2Id ) )
+            break;
+    }
+    if ( i < Cba_ManNtkNum(pNew) )
+       Cba_ManFree(pNew), pNew = NULL;
+    Vec_IntFree( vBox2Id );
+    Vec_IntFree( vMap );
+    return pNew;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    [Create Ptr from mapped Cba_Man_t.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Vec_Ptr_t * Cba_NtkTransformToPtrBox( Cba_Ntk_t * p, int iBox )
+{
+    int i, iTerm, fUser = Cba_ObjIsBoxUser( p, iBox );
+    Cba_Ntk_t * pBoxNtk = Cba_BoxNtk( p, iBox );
+    Mio_Library_t * pLib = (Mio_Library_t *)p->pDesign->pMioLib;
+    Mio_Gate_t * pGate = Mio_LibraryReadGateByName( pLib, Cba_BoxNtkName(p, iBox), NULL );
+    Vec_Ptr_t * vBox = Vec_PtrAllocExact( Cba_BoxSize(p, iBox) );
+    Vec_PtrPush( vBox, Cba_BoxNtkName(p, iBox) );
+    Vec_PtrPush( vBox, Cba_ObjNameStr(p, iBox) );
+    Cba_BoxForEachBi( p, iBox, iTerm, i )
+    {
+        Vec_PtrPush( vBox, fUser ? Cba_ObjNameStr(pBoxNtk, Cba_NtkPi(pBoxNtk, i)) : Mio_GateReadPinName(pGate, i) );
+        Vec_PtrPush( vBox, Cba_ObjNameStr(p, iTerm) );
+    }
+    Cba_BoxForEachBo( p, iBox, iTerm, i )
+    {
+        Vec_PtrPush( vBox, fUser ? Cba_ObjNameStr(pBoxNtk, Cba_NtkPo(pBoxNtk, i)) : Mio_GateReadOutName(pGate) );
+        Vec_PtrPush( vBox, Cba_ObjNameStr(p, iTerm) );
+    }
+    assert( Ptr_CheckArray(vBox) );
+    return vBox;
+}
+Vec_Ptr_t * Cba_NtkTransformToPtrBoxes( Cba_Ntk_t * p )
+{
+    int iBox;
+    Vec_Ptr_t * vBoxes = Vec_PtrAllocExact( Cba_NtkBoxNum(p) );
+    Cba_NtkForEachBox( p, iBox )
+        Vec_PtrPush( vBoxes, Cba_NtkTransformToPtrBox(p, iBox) );
+    assert( Ptr_CheckArray(vBoxes) );
+    return vBoxes;
+}
+
+Vec_Ptr_t * Cba_NtkTransformToPtrInputs( Cba_Ntk_t * p )
+{
+    int i, iTerm;
+    Vec_Ptr_t * vSigs = Vec_PtrAllocExact( Cba_NtkPiNum(p) );
+    Cba_NtkForEachPi( p, iTerm, i )
+        Vec_PtrPush( vSigs, Cba_ObjNameStr(p, iTerm) );
+    assert( Ptr_CheckArray(vSigs) );
+    return vSigs;
+}
+Vec_Ptr_t * Cba_NtkTransformToPtrOutputs( Cba_Ntk_t * p )
+{
+    int i, iTerm;
+    Vec_Ptr_t * vSigs = Vec_PtrAllocExact( Cba_NtkPoNum(p) );
+    Cba_NtkForEachPo( p, iTerm, i )
+        Vec_PtrPush( vSigs, Cba_ObjNameStr(p, iTerm) );
+    assert( Ptr_CheckArray(vSigs) );
+    return vSigs;
+}
+Vec_Ptr_t * Cba_NtkTransformToPtr( Cba_Ntk_t * p )
+{
+    Vec_Ptr_t * vNtk = Vec_PtrAllocExact(5);
+    Vec_PtrPush( vNtk, Cba_NtkName(p) );
+    Vec_PtrPush( vNtk, Cba_NtkTransformToPtrInputs(p) );
+    Vec_PtrPush( vNtk, Cba_NtkTransformToPtrOutputs(p) );
+    Vec_PtrPush( vNtk, Vec_PtrAllocExact(0) );
+    Vec_PtrPush( vNtk, Cba_NtkTransformToPtrBoxes(p) );
+    assert( Ptr_CheckArray(vNtk) );
+    return vNtk;
+}
+Vec_Ptr_t * Cba_PtrDeriveFromCba( Cba_Man_t * p )
+{
+    Vec_Ptr_t * vDes;
+    Cba_Ntk_t * pTemp; int i;
+    if ( p == NULL )
+        return NULL;
+    Cba_ManAssignInternNames( p );
+    vDes = Vec_PtrAllocExact( 1 + Cba_ManNtkNum(p) );
+    Vec_PtrPush( vDes, p->pName );
+    Cba_ManForEachNtk( p, pTemp, i )
+        Vec_PtrPush( vDes, Cba_NtkTransformToPtr(pTemp) );
+    assert( Ptr_CheckArray(vDes) );
+    return vDes;
+}
+
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/abc-build/src/base/cba/cbaReadBlif.c b/abc-build/src/base/cba/cbaReadBlif.c
new file mode 100644
--- /dev/null
+++ b/abc-build/src/base/cba/cbaReadBlif.c
@@ -0,0 +1,439 @@
+/**CFile****************************************************************
+
+  FileName    [cbaReadBlif.c]
+
+  SystemName  [ABC: Logic synthesis and verification system.]
+
+  PackageName [Hierarchical word-level netlist.]
+
+  Synopsis    [BLIF parser.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - November 29, 2014.]
+
+  Revision    [$Id: cbaReadBlif.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "cba.h"
+#include "cbaPrs.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+// BLIF keywords
+typedef enum { 
+    PRS_BLIF_NONE = 0, // 0:   unused
+    PRS_BLIF_MODEL,    // 1:   .model
+    PRS_BLIF_INOUTS,   // 2:   .inouts
+    PRS_BLIF_INPUTS,   // 3:   .inputs
+    PRS_BLIF_OUTPUTS,  // 4:   .outputs
+    PRS_BLIF_NAMES,    // 5:   .names
+    PRS_BLIF_SUBCKT,   // 6:   .subckt
+    PRS_BLIF_GATE,     // 7:   .gate
+    PRS_BLIF_LATCH,    // 8:   .latch
+    PRS_BLIF_SHORT,    // 9:   .short
+    PRS_BLIF_END,      // 10:  .end
+    PRS_BLIF_UNKNOWN   // 11:  unknown
+} Cba_BlifType_t;
+
+const char * s_BlifTypes[PRS_BLIF_UNKNOWN+1] = {
+    NULL,              // 0:   unused
+    ".model",          // 1:   .model   
+    ".inouts",         // 2:   .inputs
+    ".inputs",         // 3:   .inputs
+    ".outputs",        // 4:   .outputs
+    ".names",          // 5:   .names
+    ".subckt",         // 6:   .subckt
+    ".gate",           // 7:   .gate
+    ".latch",          // 8:   .latch
+    ".short",          // 9:   .short
+    ".end",            // 10:  .end
+    NULL               // 11:  unknown
+};
+
+static inline void Prs_NtkAddBlifDirectives( Prs_Man_t * p )
+{
+    int i;
+    for ( i = 1; s_BlifTypes[i]; i++ )
+        Abc_NamStrFindOrAdd( p->pStrs, (char *)s_BlifTypes[i], NULL );
+    assert( Abc_NamObjNumMax(p->pStrs) == i );
+}
+
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    [Reading characters.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int  Prs_CharIsSpace( char c )                { return c == ' ' || c == '\t' || c == '\r';              }
+static inline int  Prs_CharIsStop( char c )                 { return c == '#' || c == '\\' || c == '\n' || c == '=';  }
+static inline int  Prs_CharIsLit( char c )                  { return c == '0' || c == '1'  || c == '-';               }
+
+static inline int  Prs_ManIsSpace( Prs_Man_t * p )          { return Prs_CharIsSpace(*p->pCur);                       }
+static inline int  Prs_ManIsStop( Prs_Man_t * p )           { return Prs_CharIsStop(*p->pCur);                        }
+static inline int  Prs_ManIsLit( Prs_Man_t * p )            { return Prs_CharIsLit(*p->pCur);                         }
+
+static inline int  Prs_ManIsChar( Prs_Man_t * p, char c )   { return *p->pCur == c;                                   }
+static inline int  Prs_ManIsChar2( Prs_Man_t * p, char c )  { return *p->pCur++ == c;                                 }
+
+static inline void Prs_ManSkip( Prs_Man_t * p )             { p->pCur++;                                              }
+static inline char Prs_ManSkip2( Prs_Man_t * p )            { return *p->pCur++;                                      }
+
+
+/**Function*************************************************************
+
+  Synopsis    [Reading names.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline void Prs_ManSkipToChar( Prs_Man_t * p, char c )  
+{ 
+    while ( !Prs_ManIsChar(p, c) ) 
+        Prs_ManSkip(p);
+}
+static inline void Prs_ManSkipSpaces( Prs_Man_t * p )
+{
+    while ( 1 )
+    {
+        while ( Prs_ManIsSpace(p) )
+            Prs_ManSkip(p);
+        if ( Prs_ManIsChar(p, '\\') )
+        {
+            Prs_ManSkipToChar( p, '\n' );
+            Prs_ManSkip(p);
+            continue;
+        }
+        if ( Prs_ManIsChar(p, '#') )  
+            Prs_ManSkipToChar( p, '\n' );
+        break;
+    }
+    assert( !Prs_ManIsSpace(p) );
+}
+static inline int Prs_ManReadName( Prs_Man_t * p )
+{
+    char * pStart;
+    Prs_ManSkipSpaces( p );
+    if ( Prs_ManIsChar(p, '\n') )
+        return 0;
+    pStart = p->pCur;
+    while ( !Prs_ManIsSpace(p) && !Prs_ManIsStop(p) )
+        Prs_ManSkip(p);
+    if ( pStart == p->pCur )
+        return 0;
+    return Abc_NamStrFindOrAddLim( p->pStrs, pStart, p->pCur, NULL );
+}
+static inline int Prs_ManReadList( Prs_Man_t * p )
+{
+    int iToken;
+    Vec_IntClear( &p->vTemp );
+    while ( (iToken = Prs_ManReadName(p)) )
+        Vec_IntPush( &p->vTemp, iToken );
+    if ( Vec_IntSize(&p->vTemp) == 0 )                return Prs_ManErrorSet(p, "Signal list is empty.", 1);
+    return 0;
+}
+static inline int Prs_ManReadList2( Prs_Man_t * p )
+{
+    int iToken;
+    Vec_IntClear( &p->vTemp );
+    while ( (iToken = Prs_ManReadName(p)) )
+        Vec_IntPushTwo( &p->vTemp, 0, iToken );
+    if ( Vec_IntSize(&p->vTemp) == 0 )                return Prs_ManErrorSet(p, "Signal list is empty.", 1);
+    return 0;
+}
+static inline int Prs_ManReadList3( Prs_Man_t * p )
+{
+    Vec_IntClear( &p->vTemp );
+    while ( !Prs_ManIsChar(p, '\n') )
+    {
+        int iToken = Prs_ManReadName(p);
+        if ( iToken == 0 )              return Prs_ManErrorSet(p, "Cannot read formal name.", 1);
+        Vec_IntPush( &p->vTemp, iToken );
+        Prs_ManSkipSpaces( p );
+        if ( !Prs_ManIsChar2(p, '=') )  return Prs_ManErrorSet(p, "Cannot find symbol \"=\".", 1);
+        iToken = Prs_ManReadName(p);
+        if ( iToken == 0 )              return Prs_ManErrorSet(p, "Cannot read actual name.", 1);
+        Vec_IntPush( &p->vTemp, iToken );
+        Prs_ManSkipSpaces( p );
+    }
+    if ( Vec_IntSize(&p->vTemp) == 0 )  return Prs_ManErrorSet(p, "Cannot read a list of formal/actual names.", 1);
+    if ( Vec_IntSize(&p->vTemp) % 2  )  return Prs_ManErrorSet(p, "The number of formal/actual names is not even.", 1);
+    return 0;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Prs_ManReadCube( Prs_Man_t * p )
+{
+    assert( Prs_ManIsLit(p) );
+    while ( Prs_ManIsLit(p) )
+        Vec_StrPush( &p->vCover, Prs_ManSkip2(p) );
+    Prs_ManSkipSpaces( p );
+    if ( Prs_ManIsChar(p, '\n') )
+    {
+        if ( Vec_StrSize(&p->vCover) != 1 )            return Prs_ManErrorSet(p, "Cannot read cube.", 1);
+        // fix single literal cube by adding space
+        Vec_StrPush( &p->vCover, Vec_StrEntry(&p->vCover,0) );
+        Vec_StrWriteEntry( &p->vCover, 0, ' ' );
+        Vec_StrPush( &p->vCover, '\n' );
+        return 0;
+    }
+    if ( !Prs_ManIsLit(p) )                           return Prs_ManErrorSet(p, "Cannot read output literal.", 1);
+    Vec_StrPush( &p->vCover, ' ' );
+    Vec_StrPush( &p->vCover, Prs_ManSkip2(p) );
+    Vec_StrPush( &p->vCover, '\n' );
+    Prs_ManSkipSpaces( p );
+    if ( !Prs_ManIsChar(p, '\n') )                    return Prs_ManErrorSet(p, "Cannot read end of cube.", 1);
+    return 0;
+}
+static inline void Prs_ManSaveCover( Prs_Man_t * p )
+{
+    int iToken;
+    assert( Vec_StrSize(&p->vCover) > 0 );
+    Vec_StrPush( &p->vCover, '\0' );
+    iToken = Abc_NamStrFindOrAdd( p->pStrs, Vec_StrArray(&p->vCover), NULL );
+    Vec_StrClear( &p->vCover );
+    // set the cover to the module of this box
+    assert( Prs_BoxNtk(p->pNtk, Prs_NtkBoxNum(p->pNtk)-1) == 1 ); // default const 0
+    Prs_BoxSetNtk( p->pNtk, Prs_NtkBoxNum(p->pNtk)-1, iToken );
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Prs_ManReadInouts( Prs_Man_t * p )
+{
+    if ( Prs_ManReadList(p) )    return 1;
+    Vec_IntAppend( &p->pNtk->vInouts, &p->vTemp );
+    return 0;
+}
+static inline int Prs_ManReadInputs( Prs_Man_t * p )
+{
+    if ( Prs_ManReadList(p) )    return 1;
+    Vec_IntAppend( &p->pNtk->vInputs, &p->vTemp );
+    return 0;
+}
+static inline int Prs_ManReadOutputs( Prs_Man_t * p )
+{
+    if ( Prs_ManReadList(p) )    return 1;
+    Vec_IntAppend( &p->pNtk->vOutputs, &p->vTemp );
+    return 0;
+}
+static inline int Prs_ManReadNode( Prs_Man_t * p )
+{
+    if ( Prs_ManReadList2(p) )   return 1;
+    // save results
+    Prs_NtkAddBox( p->pNtk, 1, 0, &p->vTemp ); // default const 0 function
+    return 0;
+}
+static inline int Prs_ManReadBox( Prs_Man_t * p, int fGate )
+{
+    int iToken = Prs_ManReadName(p);
+    if ( iToken == 0 )           return Prs_ManErrorSet(p, "Cannot read model name.", 1);
+    if ( Prs_ManReadList3(p) )   return 1;
+    // save results
+    Prs_NtkAddBox( p->pNtk, iToken, 0, &p->vTemp );
+    if ( fGate ) p->pNtk->fMapped = 1;
+    return 0;
+}
+static inline int Prs_ManReadLatch( Prs_Man_t * p )
+{
+    int iToken = Prs_ManReadName(p);
+    Vec_IntClear( &p->vTemp );
+    if ( iToken == 0 )                 return Prs_ManErrorSet(p, "Cannot read latch input.", 1);
+    Vec_IntWriteEntry( &p->vTemp, 1, iToken );
+    iToken = Prs_ManReadName(p);
+    if ( iToken == 0 )                 return Prs_ManErrorSet(p, "Cannot read latch output.", 1);
+    Vec_IntWriteEntry( &p->vTemp, 0, iToken );
+    Prs_ManSkipSpaces( p );
+    if ( Prs_ManIsChar(p, '0') )
+        iToken = 0;
+    else if ( Prs_ManIsChar(p, '1') )
+        iToken = 1;
+    else 
+        iToken = 2;
+    Prs_ManSkipToChar( p, '\n' );
+    // save results
+    Prs_NtkAddBox( p->pNtk, -1, iToken, &p->vTemp ); // -1 stands for latch
+    return 0;
+}
+static inline int Prs_ManReadShort( Prs_Man_t * p )
+{
+    int iToken = Prs_ManReadName(p);
+    Vec_IntClear( &p->vTemp );
+    if ( iToken == 0 )                 return Prs_ManErrorSet(p, "Cannot read .short input.", 1);
+    Vec_IntWriteEntry( &p->vTemp, 1, iToken );
+    iToken = Prs_ManReadName(p);
+    if ( iToken == 0 )                 return Prs_ManErrorSet(p, "Cannot read .short output.", 1);
+    Vec_IntWriteEntry( &p->vTemp, 0, iToken );
+    Prs_ManSkipSpaces( p );
+    if ( !Prs_ManIsChar(p, '\n') )     return Prs_ManErrorSet(p, "Trailing symbols on .short line.", 1);
+    // save results
+    iToken = Abc_NamStrFindOrAdd( p->pStrs, "1 1\n", NULL );
+    Prs_NtkAddBox( p->pNtk, iToken, 0, &p->vTemp );
+    return 0;
+}
+static inline int Prs_ManReadModel( Prs_Man_t * p )
+{
+    int iToken;
+    if ( p->pNtk != NULL )                         return Prs_ManErrorSet(p, "Parsing previous model is unfinished.", 1);
+    iToken = Prs_ManReadName(p);
+    if ( iToken == 0 )                             return Prs_ManErrorSet(p, "Cannot read model name.", 1);
+    Prs_ManInitializeNtk( p, iToken, 0 );
+    Prs_ManSkipSpaces( p );
+    if ( !Prs_ManIsChar(p, '\n') )                 return Prs_ManErrorSet(p, "Trailing symbols on .model line.", 1);
+    return 0;
+}
+static inline int Prs_ManReadEnd( Prs_Man_t * p )
+{
+    if ( p->pNtk == 0 )                            return Prs_ManErrorSet(p, "Directive .end without .model.", 1);
+    //printf( "Saving model \"%s\".\n", Abc_NamStr(p->pStrs, p->iModuleName) );
+    Prs_ManFinalizeNtk( p );
+    Prs_ManSkipSpaces( p );
+    if ( !Prs_ManIsChar(p, '\n') )                 return Prs_ManErrorSet(p, "Trailing symbols on .end line.", 1);
+    return 0;
+}
+
+static inline int Prs_ManReadDirective( Prs_Man_t * p )
+{
+    int iToken;
+    if ( !Prs_ManIsChar(p, '.') )
+        return Prs_ManReadCube( p );
+    if ( Vec_StrSize(&p->vCover) > 0 ) // SOP was specified for the previous node
+        Prs_ManSaveCover( p );
+    iToken = Prs_ManReadName( p );  
+    if ( iToken == PRS_BLIF_MODEL )
+        return Prs_ManReadModel( p );
+    if ( iToken == PRS_BLIF_INOUTS )
+        return Prs_ManReadInouts( p );
+    if ( iToken == PRS_BLIF_INPUTS )
+        return Prs_ManReadInputs( p );
+    if ( iToken == PRS_BLIF_OUTPUTS )
+        return Prs_ManReadOutputs( p );
+    if ( iToken == PRS_BLIF_NAMES )
+        return Prs_ManReadNode( p );
+    if ( iToken == PRS_BLIF_SUBCKT )
+        return Prs_ManReadBox( p, 0 );
+    if ( iToken == PRS_BLIF_GATE )
+        return Prs_ManReadBox( p, 1 );
+    if ( iToken == PRS_BLIF_LATCH )
+        return Prs_ManReadLatch( p );
+    if ( iToken == PRS_BLIF_SHORT )
+        return Prs_ManReadShort( p );
+    if ( iToken == PRS_BLIF_END )
+        return Prs_ManReadEnd( p );
+    printf( "Cannot read directive \"%s\".\n", Abc_NamStr(p->pStrs, iToken) );
+    return 1;
+}
+static inline int Prs_ManReadLines( Prs_Man_t * p )
+{
+    while ( p->pCur[1] != '\0' )
+    {
+        assert( Prs_ManIsChar(p, '\n') );
+        Prs_ManSkip(p);
+        Prs_ManSkipSpaces( p );
+        if ( Prs_ManIsChar(p, '\n') )
+            continue;
+        if ( Prs_ManReadDirective(p) )   
+            return 1;
+    }
+    return 0;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Vec_Ptr_t * Prs_ManReadBlif( char * pFileName )
+{
+    Vec_Ptr_t * vPrs = NULL;
+    Prs_Man_t * p = Prs_ManAlloc( pFileName );
+    if ( p == NULL )
+        return NULL;
+    Prs_NtkAddBlifDirectives( p );
+    Prs_ManReadLines( p );
+    if ( Prs_ManErrorPrint(p) )
+        ABC_SWAP( Vec_Ptr_t *, vPrs, p->vNtks );
+    Prs_ManFree( p );
+    return vPrs;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Prs_ManReadBlifTest()
+{
+    abctime clk = Abc_Clock();
+    extern void Prs_ManWriteBlif( char * pFileName, Vec_Ptr_t * vPrs );
+//    Vec_Ptr_t * vPrs = Prs_ManReadBlif( "aga/ray/ray_hie_oper.blif" );
+    Vec_Ptr_t * vPrs = Prs_ManReadBlif( "c/hie/dump/1/netlist_1_out8.blif" );
+    if ( !vPrs ) return;
+    printf( "Finished reading %d networks. ", Vec_PtrSize(vPrs) );
+    printf( "NameIDs = %d. ", Abc_NamObjNumMax(Prs_ManNameMan(vPrs)) );
+    printf( "Memory = %.2f MB. ", 1.0*Prs_ManMemory(vPrs)/(1<<20) );
+    Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
+//    Abc_NamPrint( p->pStrs );
+    Prs_ManWriteBlif( "c/hie/dump/1/netlist_1_out8_out.blif", vPrs );
+    Prs_ManVecFree( vPrs );
+}
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/abc-build/src/base/cba/cbaReadSmt.c b/abc-build/src/base/cba/cbaReadSmt.c
new file mode 100644
--- /dev/null
+++ b/abc-build/src/base/cba/cbaReadSmt.c
@@ -0,0 +1,42 @@
+/**CFile****************************************************************
+
+  FileName    [cbaReadSmt.c]
+
+  SystemName  [ABC: Logic synthesis and verification system.]
+
+  PackageName [Hierarchical word-level netlist.]
+
+  Synopsis    [BLIF parser.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - November 29, 2014.]
+
+  Revision    [$Id: cbaReadSmt.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "cba.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/abc-build/src/base/cba/cbaReadVer.c b/abc-build/src/base/cba/cbaReadVer.c
new file mode 100644
--- /dev/null
+++ b/abc-build/src/base/cba/cbaReadVer.c
@@ -0,0 +1,811 @@
+/**CFile****************************************************************
+
+  FileName    [cbaReadVer.c]
+
+  SystemName  [ABC: Logic synthesis and verification system.]
+
+  PackageName [Hierarchical word-level netlist.]
+
+  Synopsis    [BLIF writer.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - November 29, 2014.]
+
+  Revision    [$Id: cbaReadVer.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "cba.h"
+#include "cbaPrs.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+// Verilog keywords
+typedef enum { 
+    PRS_VER_NONE = 0,  // 0:  unused
+    PRS_VER_MODULE,    // 1:  module
+    PRS_VER_INOUT,     // 2:  inout
+    PRS_VER_INPUT,     // 3:  input
+    PRS_VER_OUTPUT,    // 4:  output
+    PRS_VER_WIRE,      // 5:  wire
+    PRS_VER_ASSIGN,    // 6:  assign
+    PRS_VER_REG,       // 7:  reg
+    PRS_VER_ALWAYS,    // 8:  always
+    PRS_VER_DEFPARAM,  // 9:  always
+    PRS_VER_BEGIN,     // 10: begin
+    PRS_VER_END,       // 11: end
+    PRS_VER_ENDMODULE, // 12: endmodule
+    PRS_VER_UNKNOWN    // 13: unknown
+} Cba_VerType_t;
+
+const char * s_VerTypes[PRS_VER_UNKNOWN+1] = {
+    NULL,              // 0:  unused
+    "module",          // 1:  module
+    "inout",           // 2:  inout
+    "input",           // 3:  input
+    "output",          // 4:  output
+    "wire",            // 5:  wire
+    "assign",          // 6:  assign
+    "reg",             // 7:  reg
+    "always",          // 8:  always
+    "defparam",        // 9:  defparam
+    "begin",           // 10: begin
+    "end",             // 11: end
+    "endmodule",       // 12: endmodule
+    NULL               // 13: unknown 
+};
+
+static inline void Prs_NtkAddVerilogDirectives( Prs_Man_t * p )
+{
+    int i;
+    for ( i = 1; s_VerTypes[i]; i++ )
+        Abc_NamStrFindOrAdd( p->pStrs, (char *)s_VerTypes[i],   NULL );
+    assert( Abc_NamObjNumMax(p->pStrs) == i );
+}
+
+
+// character recognition 
+static inline int Prs_CharIsSpace( char c )   { return (c == ' ' || c == '\t' || c == '\r' || c == '\n');                           }
+static inline int Prs_CharIsDigit( char c )   { return (c >= '0' && c <= '9');                                                      }
+static inline int Prs_CharIsDigitB( char c )  { return (c == '0' || c == '1'  || c == 'x' || c == 'z');                             }
+static inline int Prs_CharIsDigitH( char c )  { return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f');  }
+static inline int Prs_CharIsChar( char c )    { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');                            }
+static inline int Prs_CharIsSymb1( char c )   { return Prs_CharIsChar(c) || c == '_';                                               }
+static inline int Prs_CharIsSymb2( char c )   { return Prs_CharIsSymb1(c) || Prs_CharIsDigit(c) || c == '$';                        }
+
+static inline int Prs_ManIsChar( Prs_Man_t * p, char c )    { return p->pCur[0] == c;                        }
+static inline int Prs_ManIsChar1( Prs_Man_t * p, char c )   { return p->pCur[1] == c;                        }
+static inline int Prs_ManIsDigit( Prs_Man_t * p )           { return Prs_CharIsDigit(*p->pCur);              }
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+
+// collect predefined modules names
+const char * s_KnownModules[100] = {
+    NULL,     // CBA_OBJ_NONE = 0,  // 0:  unused
+    NULL,     // CBA_OBJ_PI,        // 1:  input
+    NULL,     // CBA_OBJ_PO,        // 2:  output
+    NULL,     // CBA_OBJ_BI,        // 3:  box input
+    NULL,     // CBA_OBJ_BO,        // 4:  box output
+    NULL,     // CBA_OBJ_BOX,       // 5:  box
+ 
+    "const0", // CBA_BOX_C0,   
+    "const1", // CBA_BOX_C1,   
+    "constX", // CBA_BOX_CX,   
+    "constZ", // CBA_BOX_CZ,   
+    "buf",    // CBA_BOX_BUF,  
+    "not",    // CBA_BOX_INV,  
+    "and",    // CBA_BOX_AND,  
+    "nand",   // CBA_BOX_NAND, 
+    "or",     // CBA_BOX_OR,   
+    "nor",    // CBA_BOX_NOR,  
+    "xor",    // CBA_BOX_XOR,  
+    "xnor",   // CBA_BOX_XNOR, 
+    "sharp",  // CBA_BOX_SHARP,
+    "mux",    // CBA_BOX_MUX,  
+    "maj",    // CBA_BOX_MAJ,  
+
+    "VERIFIC_",
+    "add_",                  
+    "mult_",                 
+    "div_",                  
+    "mod_",                  
+    "rem_",                  
+    "shift_left_",           
+    "shift_right_",          
+    "rotate_left_",          
+    "rotate_right_",         
+    "reduce_and_",           
+    "reduce_or_",            
+    "reduce_xor_",           
+    "reduce_nand_",          
+    "reduce_nor_",           
+    "reduce_xnor_",          
+    "LessThan_",             
+    "Mux_",                  
+    "Select_",               
+    "Decoder_",              
+    "EnabledDecoder_",       
+    "PrioSelect_",           
+    "DualPortRam_",          
+    "ReadPort_",             
+    "WritePort_",            
+    "ClockedWritePort_",     
+    "lut",                   
+    "and_",                  
+    "or_",                   
+    "xor_",                  
+    "nand_",                 
+    "nor_",                  
+    "xnor_",                 
+    "buf_",                  
+    "inv_",                  
+    "tri_",                  
+    "sub_",                  
+    "unary_minus_",          
+    "equal_",                
+    "not_equal_",            
+    "mux_",                  
+    "wide_mux_",             
+    "wide_select_",          
+    "wide_dff_",             
+    "wide_dlatch_",          
+    "wide_dffrs_",           
+    "wide_dlatchrs_",        
+    "wide_prio_select_",     
+    "pow_",                  
+    "PrioEncoder_",          
+    "abs",                   
+    NULL
+};
+
+// check if it is a known module
+static inline int Prs_ManIsKnownModule( Prs_Man_t * p, char * pName )
+{
+    int i;
+    for ( i = CBA_BOX_C0; s_KnownModules[i]; i++ )
+        if ( !strncmp(pName, s_KnownModules[i], strlen(s_KnownModules[i])) )
+            return i;
+    return 0;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+
+// skips Verilog comments (returns 1 if some comments were skipped)
+static inline int Prs_ManUtilSkipComments( Prs_Man_t * p )
+{
+    if ( !Prs_ManIsChar(p, '/') )
+        return 0;
+    if ( Prs_ManIsChar1(p, '/') )
+    {
+        for ( p->pCur += 2; p->pCur < p->pLimit; p->pCur++ )
+            if ( Prs_ManIsChar(p, '\n') )
+                { p->pCur++; return 1; }
+    }
+    else if ( Prs_ManIsChar1(p, '*') )
+    {
+        for ( p->pCur += 2; p->pCur < p->pLimit; p->pCur++ )
+            if ( Prs_ManIsChar(p, '*') && Prs_ManIsChar1(p, '/') )
+                { p->pCur++; p->pCur++; return 1; }
+    }
+    return 0;
+}
+static inline int Prs_ManUtilSkipName( Prs_Man_t * p )
+{
+    if ( !Prs_ManIsChar(p, '\\') )
+        return 0;
+    for ( p->pCur++; p->pCur < p->pLimit; p->pCur++ )
+        if ( Prs_ManIsChar(p, ' ') )
+            { p->pCur++; return 1; }
+    return 0;
+}
+
+// skip any number of spaces and comments
+static inline int Prs_ManUtilSkipSpaces( Prs_Man_t * p )
+{
+    while ( p->pCur < p->pLimit )
+    {
+        while ( Prs_CharIsSpace(*p->pCur) ) 
+            p->pCur++;
+        if ( !*p->pCur )
+            return Prs_ManErrorSet(p, "Unexpectedly reached end-of-file.", 1);
+        if ( !Prs_ManUtilSkipComments(p) )
+            return 0;
+    }
+    return Prs_ManErrorSet(p, "Unexpectedly reached end-of-file.", 1);
+}
+// skip everything including comments until the given char
+static inline int Prs_ManUtilSkipUntil( Prs_Man_t * p, char c )
+{
+    while ( p->pCur < p->pLimit )
+    {
+        if ( Prs_ManIsChar(p, c) )
+            return 1;
+        if ( Prs_ManUtilSkipComments(p) )
+            continue;
+        if ( Prs_ManUtilSkipName(p) )
+            continue;
+        p->pCur++;
+    }
+    return 0;
+}
+// skip everything including comments until the given word
+static inline int Prs_ManUtilSkipUntilWord( Prs_Man_t * p, char * pWord )
+{
+    char * pPlace = strstr( p->pCur, pWord );
+    if ( pPlace == NULL )  return 1;
+    p->pCur = pPlace + strlen(pWord);
+    return 0;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Prs_ManReadName( Prs_Man_t * p )
+{
+    char * pStart = p->pCur;
+    if ( Prs_ManIsChar(p, '\\') ) // escaped name
+    {
+        pStart = ++p->pCur;
+        while ( !Prs_ManIsChar(p, ' ') ) 
+            p->pCur++;
+    }    
+    else if ( Prs_CharIsSymb1(*p->pCur) ) // simple name
+    {
+        p->pCur++;
+        while ( Prs_CharIsSymb2(*p->pCur) ) 
+            p->pCur++;
+    }
+    else 
+        return 0;
+    return Abc_NamStrFindOrAddLim( p->pStrs, pStart, p->pCur, NULL );
+}
+static inline int Prs_ManReadNameList( Prs_Man_t * p, Vec_Int_t * vTemp, char LastSymb )
+{
+    Vec_IntClear( vTemp );
+    while ( 1 )
+    {
+        int Item = Prs_ManReadName(p);
+        if ( Item == 0 )                    return Prs_ManErrorSet(p, "Cannot read name in the list.", 0);
+        Vec_IntPush( vTemp, Item );
+        if ( Prs_ManIsChar(p, LastSymb) )   break;
+        if ( !Prs_ManIsChar(p, ',') )       return Prs_ManErrorSet(p, "Expecting comma in the list.", 0);
+        p->pCur++;
+        if ( Prs_ManUtilSkipSpaces(p) )     return 0;
+    }
+    return 1;
+}
+static inline int Prs_ManReadConstant( Prs_Man_t * p )
+{
+    char * pStart = p->pCur;
+    assert( Prs_ManIsDigit(p) );
+    while ( Prs_ManIsDigit(p) ) 
+        p->pCur++;
+    if ( !Prs_ManIsChar(p, '\'') )          return Prs_ManErrorSet(p, "Cannot read constant.", 0);
+    p->pCur++;
+    if ( Prs_ManIsChar(p, 'b') )
+    {
+        p->pCur++;
+        while ( Prs_CharIsDigitB(*p->pCur) ) 
+            p->pCur++;
+    }
+    else if ( Prs_ManIsChar(p, 'h') )
+    {
+        p->pCur++;
+        while ( Prs_CharIsDigitH(*p->pCur) ) 
+            p->pCur++;
+    }
+    else if ( Prs_ManIsChar(p, 'd') )
+    {
+        p->pCur++;
+        while ( Prs_ManIsDigit(p) ) 
+            p->pCur++;
+    }
+    else                                    return Prs_ManErrorSet(p, "Cannot read radix of constant.", 0);
+    return Abc_NamStrFindOrAddLim( p->pStrs, pStart, p->pCur, NULL );
+}
+static inline int Prs_ManReadRange( Prs_Man_t * p )
+{
+    assert( Prs_ManIsChar(p, '[') );
+    Vec_StrClear( &p->vCover );
+    Vec_StrPush( &p->vCover, *p->pCur++ );
+    if ( Prs_ManUtilSkipSpaces(p) )         return 0;
+    if ( !Prs_ManIsDigit(p) )               return Prs_ManErrorSet(p, "Cannot read digit in range specification.", 0);
+    while ( Prs_ManIsDigit(p) )
+        Vec_StrPush( &p->vCover, *p->pCur++ );
+    if ( Prs_ManUtilSkipSpaces(p) )         return 0;
+    if ( Prs_ManIsChar(p, ':') )
+    {
+        Vec_StrPush( &p->vCover, *p->pCur++ );
+        if ( Prs_ManUtilSkipSpaces(p) )     return 0;
+        if ( !Prs_ManIsDigit(p) )           return Prs_ManErrorSet(p, "Cannot read digit in range specification.", 0);
+        while ( Prs_ManIsDigit(p) )
+            Vec_StrPush( &p->vCover, *p->pCur++ );
+        if ( Prs_ManUtilSkipSpaces(p) )     return 0;
+    }
+    if ( !Prs_ManIsChar(p, ']') )           return Prs_ManErrorSet(p, "Cannot read closing brace in range specification.", 0);
+    Vec_StrPush( &p->vCover, *p->pCur++ );
+    Vec_StrPush( &p->vCover, '\0' );
+    return Abc_NamStrFindOrAdd( p->pStrs, Vec_StrArray(&p->vCover), NULL );
+}
+static inline int Prs_ManReadConcat( Prs_Man_t * p, Vec_Int_t * vTemp2 )
+{
+    extern int Prs_ManReadSignalList( Prs_Man_t * p, Vec_Int_t * vTemp, char LastSymb, int fAddForm );
+    assert( Prs_ManIsChar(p, '{') );
+    p->pCur++;
+    if ( !Prs_ManReadSignalList( p, vTemp2, '}', 0 ) ) return 0;
+    // check final
+    assert( Prs_ManIsChar(p, '}') );
+    p->pCur++;
+    // return special case
+    assert( Vec_IntSize(vTemp2) > 0 );
+    if ( Vec_IntSize(vTemp2) == 1 )
+        return Vec_IntEntry(vTemp2, 0);
+    return Abc_Var2Lit2( Prs_NtkAddConcat(p->pNtk, vTemp2), CBA_PRS_CONCAT );
+}
+static inline int Prs_ManReadSignal( Prs_Man_t * p )
+{
+    int Item;
+    if ( Prs_ManUtilSkipSpaces(p) )         return 0;
+    if ( Prs_ManIsDigit(p) )
+    {
+        Item = Prs_ManReadConstant(p);
+        if ( Item == 0 )                    return 0;
+        if ( Prs_ManUtilSkipSpaces(p) )     return 0;
+        return Abc_Var2Lit2( Item, CBA_PRS_CONST );
+    }
+    if ( Prs_ManIsChar(p, '{') )
+    {
+        if ( p->fUsingTemp2 )               return Prs_ManErrorSet(p, "Cannot read nested concatenations.", 0);
+        p->fUsingTemp2 = 1;
+        Item = Prs_ManReadConcat(p, &p->vTemp2);
+        p->fUsingTemp2 = 0;
+        if ( Item == 0 )                    return 0;
+        if ( Prs_ManUtilSkipSpaces(p) )     return 0;
+        return Item;
+    }
+    else
+    {
+        Item = Prs_ManReadName( p );
+        if ( Item == 0 )                    return 0;    // was        return 1;                
+        if ( Prs_ManUtilSkipSpaces(p) )     return 0;
+        if ( Prs_ManIsChar(p, '[') )
+        {
+            int Range = Prs_ManReadRange(p);
+            if ( Range == 0 )               return 0;
+            if ( Prs_ManUtilSkipSpaces(p) ) return 0;
+            return Abc_Var2Lit2( Prs_NtkAddSlice(p->pNtk, Item, Range), CBA_PRS_SLICE );
+        }
+        return Abc_Var2Lit2( Item, CBA_PRS_NAME );
+    }
+}
+int Prs_ManReadSignalList( Prs_Man_t * p, Vec_Int_t * vTemp, char LastSymb, int fAddForm )
+{
+    Vec_IntClear( vTemp );
+    while ( 1 )
+    {
+        int Item = Prs_ManReadSignal(p);
+        if ( Item == 0 )                    return Prs_ManErrorSet(p, "Cannot read signal in the list.", 0);
+        if ( fAddForm )
+            Vec_IntPush( vTemp, 0 );
+        Vec_IntPush( vTemp, Item );
+        if ( Prs_ManIsChar(p, LastSymb) )   break;
+        if ( !Prs_ManIsChar(p, ',') )       return Prs_ManErrorSet(p, "Expecting comma in the list.", 0);
+        p->pCur++;
+    }
+    return 1;
+}
+static inline int Prs_ManReadSignalList2( Prs_Man_t * p, Vec_Int_t * vTemp )
+{
+    int FormId, ActItem;
+    Vec_IntClear( vTemp );
+    assert( Prs_ManIsChar(p, '.') );
+    while ( Prs_ManIsChar(p, '.') )
+    {
+        p->pCur++;
+        FormId = Prs_ManReadName( p );
+        if ( FormId == 0 )                  return Prs_ManErrorSet(p, "Cannot read formal name of the instance.", 0);
+        if ( !Prs_ManIsChar(p, '(') )       return Prs_ManErrorSet(p, "Cannot read \"(\" in the instance.", 0);
+        p->pCur++;
+        if ( Prs_ManUtilSkipSpaces(p) )     return 0;
+        ActItem = Prs_ManReadSignal( p );
+        if ( ActItem == 0 )                 return Prs_ManErrorSet(p, "Cannot read actual name of the instance.", 0);
+        if ( !Prs_ManIsChar(p, ')') )       return Prs_ManErrorSet(p, "Cannot read \")\" in the instance.", 0);
+        p->pCur++;
+        Vec_IntPushTwo( vTemp, FormId, ActItem );
+        if ( Prs_ManUtilSkipSpaces(p) )     return 0;
+        if ( Prs_ManIsChar(p, ')') )        break;
+        if ( !Prs_ManIsChar(p, ',') )       return Prs_ManErrorSet(p, "Expecting comma in the instance.", 0);
+        p->pCur++;
+        if ( Prs_ManUtilSkipSpaces(p) )     return 0;
+    }
+    assert( Vec_IntSize(vTemp) > 0 );
+    assert( Vec_IntSize(vTemp) % 2 == 0 );
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Prs_ManReadDeclaration( Prs_Man_t * p, int Type )
+{
+    int i, Sig, RangeId = 0;
+    Vec_Int_t * vSigs[4]  = { &p->pNtk->vInouts,  &p->pNtk->vInputs,  &p->pNtk->vOutputs,  &p->pNtk->vWires };
+    Vec_Int_t * vSigsR[4] = { &p->pNtk->vInoutsR, &p->pNtk->vInputsR, &p->pNtk->vOutputsR, &p->pNtk->vWiresR };
+    assert( Type >= PRS_VER_INOUT && Type <= PRS_VER_WIRE );
+    if ( Prs_ManUtilSkipSpaces(p) )                                   return 0;
+    if ( Prs_ManIsChar(p, '[') && !(RangeId = Prs_ManReadRange(p)) )  return 0;
+    if ( !Prs_ManReadNameList( p, &p->vTemp, ';' ) )                  return 0;
+    Vec_IntForEachEntry( &p->vTemp, Sig, i )
+    {
+        Vec_IntPush( vSigs[Type - PRS_VER_INOUT], Sig );
+        Vec_IntPush( vSigsR[Type - PRS_VER_INOUT], RangeId );
+    }
+    return 1;
+}
+static inline int Prs_ManReadAssign( Prs_Man_t * p )
+{
+    int OutItem, InItem, fCompl = 0, Oper = 0;
+    // read output name
+    OutItem = Prs_ManReadSignal( p );
+    if ( OutItem == 0 )                     return Prs_ManErrorSet(p, "Cannot read output in assign-statement.", 0);
+    if ( !Prs_ManIsChar(p, '=') )           return Prs_ManErrorSet(p, "Expecting \"=\" in assign-statement.", 0);
+    p->pCur++;
+    if ( Prs_ManUtilSkipSpaces(p) )         return 0;
+    if ( Prs_ManIsChar(p, '~') ) 
+    { 
+        fCompl = 1; 
+        p->pCur++; 
+    }
+    // read first name
+    InItem = Prs_ManReadSignal( p );
+    if ( InItem == 0 )                      return Prs_ManErrorSet(p, "Cannot read first input name in the assign-statement.", 0);
+    Vec_IntClear( &p->vTemp );
+    Vec_IntPush( &p->vTemp, 0 );
+    Vec_IntPush( &p->vTemp, InItem );
+    // check unary operator
+    if ( Prs_ManIsChar(p, ';') )
+    {
+        Vec_IntPush( &p->vTemp, 0 );
+        Vec_IntPush( &p->vTemp, OutItem );
+        Oper = fCompl ? CBA_BOX_INV : CBA_BOX_BUF;
+        Prs_NtkAddBox( p->pNtk, Oper, 0, &p->vTemp );
+        return 1;
+    }
+    if ( Prs_ManIsChar(p, '&') ) 
+        Oper = CBA_BOX_AND;
+    else if ( Prs_ManIsChar(p, '|') ) 
+        Oper = CBA_BOX_OR;
+    else if ( Prs_ManIsChar(p, '^') ) 
+        Oper = fCompl ? CBA_BOX_XNOR : CBA_BOX_XOR;
+    else if ( Prs_ManIsChar(p, '?') ) 
+        Oper = CBA_BOX_MUX;
+    else                                    return Prs_ManErrorSet(p, "Unrecognized operator in the assign-statement.", 0);
+    p->pCur++; 
+    // read second name
+    InItem = Prs_ManReadSignal( p );
+    if ( InItem == 0 )                      return Prs_ManErrorSet(p, "Cannot read second input name in the assign-statement.", 0);
+    Vec_IntPush( &p->vTemp, 0 );
+    Vec_IntPush( &p->vTemp, InItem );
+    // read third argument
+    if ( Oper == CBA_BOX_MUX )
+    {
+        assert( fCompl == 0 ); 
+        if ( !Prs_ManIsChar(p, ':') )       return Prs_ManErrorSet(p, "Expected colon in the MUX assignment.", 0);
+        p->pCur++; 
+        // read third name
+        InItem = Prs_ManReadSignal( p );
+        if ( InItem == 0 )                  return Prs_ManErrorSet(p, "Cannot read third input name in the assign-statement.", 0);
+        Vec_IntPush( &p->vTemp, 0 );
+        Vec_IntPush( &p->vTemp, InItem );
+        if ( !Prs_ManIsChar(p, ';') )       return Prs_ManErrorSet(p, "Expected semicolon at the end of the assign-statement.", 0);
+    }
+    // write binary operator
+    Vec_IntPush( &p->vTemp, 0 );
+    Vec_IntPush( &p->vTemp, OutItem );
+    Prs_NtkAddBox( p->pNtk, Oper, 0, &p->vTemp );
+    return 1;
+}
+static inline int Prs_ManReadInstance( Prs_Man_t * p, int Func )
+{
+    int InstId, Status;
+/*
+    static Counter = 0;
+    if ( ++Counter == 7 )
+    {
+        int s=0;
+    }
+*/
+    if ( Prs_ManUtilSkipSpaces(p) )         return 0;
+    if ( (InstId = Prs_ManReadName(p)) )
+        if (Prs_ManUtilSkipSpaces(p))       return 0;
+    if ( !Prs_ManIsChar(p, '(') )           return Prs_ManErrorSet(p, "Expecting \"(\" in module instantiation.", 0);
+    p->pCur++;
+    if ( Prs_ManUtilSkipSpaces(p) )         return 0;
+    if ( Prs_ManIsChar(p, '.') ) // box
+        Status = Prs_ManReadSignalList2(p, &p->vTemp);
+    else  // node
+    {
+        //char * s = Abc_NamStr(p->pStrs, Func);
+        // translate elementary gate
+        int iFuncNew = Prs_ManIsKnownModule(p, Abc_NamStr(p->pStrs, Func));
+        if ( iFuncNew == 0 )                return Prs_ManErrorSet(p, "Cannot find elementary gate.", 0);
+        Func = iFuncNew;
+        Status = Prs_ManReadSignalList( p, &p->vTemp, ')', 1 );
+    }
+    if ( Status == 0 )                      return 0;
+    assert( Prs_ManIsChar(p, ')') );
+    p->pCur++;
+    if ( Prs_ManUtilSkipSpaces(p) )         return 0;
+    if ( !Prs_ManIsChar(p, ';') )           return Prs_ManErrorSet(p, "Expecting semicolon in the instance.", 0);
+    // add box 
+    Prs_NtkAddBox( p->pNtk, Func, InstId, &p->vTemp );
+    return 1;
+}
+static inline int Prs_ManReadArguments( Prs_Man_t * p )
+{
+    int iRange = 0, iType = -1;
+    Vec_Int_t * vSigs[3]  = { &p->pNtk->vInouts,  &p->pNtk->vInputs,  &p->pNtk->vOutputs };
+    Vec_Int_t * vSigsR[3] = { &p->pNtk->vInoutsR, &p->pNtk->vInputsR, &p->pNtk->vOutputsR };
+    assert( Prs_ManIsChar(p, '(') );
+    p->pCur++;
+    if ( Prs_ManUtilSkipSpaces(p) )             return 0;
+    while ( 1 )
+    {
+        int iName = Prs_ManReadName( p );
+        if ( iName == 0 )                       return 0;
+        if ( Prs_ManUtilSkipSpaces(p) )         return 0;
+        if ( iName >= PRS_VER_INOUT && iName <= PRS_VER_OUTPUT ) // declaration
+        {
+            iType = iName;
+            if ( Prs_ManIsChar(p, '[') )
+            {
+                iRange = Prs_ManReadRange(p);
+                if ( iRange == 0 )              return 0;
+                if ( Prs_ManUtilSkipSpaces(p) ) return 0;
+            }
+        }
+        if ( iType > 0 )
+        {
+            Vec_IntPush( vSigs[iType - PRS_VER_INOUT], iName );
+            Vec_IntPush( vSigsR[iType - PRS_VER_INOUT], iRange );
+        }
+        Vec_IntPush( &p->pNtk->vOrder, iName );
+        if ( Prs_ManIsChar(p, ')') )
+            break;
+        if ( !Prs_ManIsChar(p, ',') )           return Prs_ManErrorSet(p, "Expecting comma in the instance.", 0);
+        p->pCur++;
+        if ( Prs_ManUtilSkipSpaces(p) )         return 0;
+    }
+    // check final
+    assert( Prs_ManIsChar(p, ')') );
+    return 1;
+}
+// this procedure can return:
+// 0 = reached end-of-file; 1 = successfully parsed; 2 = recognized as primitive; 3 = failed and skipped; 4 = error (failed and could not skip)
+static inline int Prs_ManReadModule( Prs_Man_t * p )
+{
+    int iToken, Status;
+    if ( p->pNtk != NULL )                  return Prs_ManErrorSet(p, "Parsing previous module is unfinished.", 4);
+    if ( Prs_ManUtilSkipSpaces(p) )
+    { 
+        Prs_ManErrorClear( p );       
+        return 0; 
+    }
+    // read keyword
+    iToken = Prs_ManReadName( p );
+    if ( iToken != PRS_VER_MODULE )         return Prs_ManErrorSet(p, "Cannot read \"module\" keyword.", 4);
+    if ( Prs_ManUtilSkipSpaces(p) )         return 4;
+    // read module name
+    iToken = Prs_ManReadName( p );
+    if ( iToken == 0 )                      return Prs_ManErrorSet(p, "Cannot read module name.", 4);
+    if ( Prs_ManIsKnownModule(p, Abc_NamStr(p->pStrs, iToken)) )
+    {
+        if ( Prs_ManUtilSkipUntilWord( p, "endmodule" ) ) return Prs_ManErrorSet(p, "Cannot find \"endmodule\" keyword.", 4);
+        //printf( "Warning! Skipped known module \"%s\".\n", Abc_NamStr(p->pStrs, iToken) );
+        Vec_IntPush( &p->vKnown, iToken );
+        return 2;
+    }
+    Prs_ManInitializeNtk( p, iToken, 1 );
+    // skip arguments
+    if ( Prs_ManUtilSkipSpaces(p) )         return 4;
+    if ( !Prs_ManIsChar(p, '(') )           return Prs_ManErrorSet(p, "Cannot find \"(\" in the argument declaration.", 4);
+    if ( !Prs_ManReadArguments(p) )         return 4;
+    assert( *p->pCur == ')' );
+    p->pCur++;
+    if ( Prs_ManUtilSkipSpaces(p) )         return 4;
+    // read declarations and instances
+    while ( Prs_ManIsChar(p, ';') )
+    {
+        p->pCur++;
+        if ( Prs_ManUtilSkipSpaces(p) )     return 4;
+        iToken = Prs_ManReadName( p );
+        if ( iToken == PRS_VER_ENDMODULE )
+        {
+            Vec_IntPush( &p->vSucceeded, p->pNtk->iModuleName );
+            Prs_ManFinalizeNtk( p );
+            return 1;
+        }
+        if ( iToken >= PRS_VER_INOUT && iToken <= PRS_VER_WIRE ) // declaration
+            Status = Prs_ManReadDeclaration( p, iToken );
+        else if ( iToken == PRS_VER_REG || iToken == PRS_VER_DEFPARAM ) // unsupported keywords
+            Status = Prs_ManUtilSkipUntil( p, ';' );
+        else // read instance
+        {
+            if ( iToken == PRS_VER_ASSIGN )
+                Status = Prs_ManReadAssign( p );
+            else
+                Status = Prs_ManReadInstance( p, iToken );
+            if ( Status == 0 )
+            {
+                if ( Prs_ManUtilSkipUntilWord( p, "endmodule" ) ) return Prs_ManErrorSet(p, "Cannot find \"endmodule\" keyword.", 4);
+                //printf( "Warning! Failed to parse \"%s\". Adding module \"%s\" as blackbox.\n", 
+                //    Abc_NamStr(p->pStrs, iToken), Abc_NamStr(p->pStrs, p->pNtk->iModuleName) );
+                Vec_IntPush( &p->vFailed, p->pNtk->iModuleName );
+                // cleanup
+                Vec_IntErase( &p->pNtk->vWires );
+                Vec_IntErase( &p->pNtk->vWiresR );
+                Vec_IntErase( &p->pNtk->vSlices );
+                Vec_IntErase( &p->pNtk->vConcats );
+                Vec_IntErase( &p->pNtk->vBoxes );
+                Vec_IntErase( &p->pNtk->vObjs );
+                p->fUsingTemp2 = 0;
+                // add
+                Prs_ManFinalizeNtk( p );
+                Prs_ManErrorClear( p );
+                return 3;
+            }
+        }
+        if ( !Status )                      return 4;
+        if ( Prs_ManUtilSkipSpaces(p) )     return 4;
+    }
+    return Prs_ManErrorSet(p, "Cannot find \";\" in the module definition.", 4);
+}
+static inline int Prs_ManReadDesign( Prs_Man_t * p )
+{
+    while ( 1 )
+    {
+        int RetValue = Prs_ManReadModule( p );
+        if ( RetValue == 0 ) // end of file
+            break;
+        if ( RetValue == 1 ) // successfully parsed
+            continue;
+        if ( RetValue == 2 ) // recognized as primitive
+            continue;
+        if ( RetValue == 3 ) // failed and skipped
+            continue;
+        if ( RetValue == 4 ) // error
+            return 0;
+        assert( 0 );
+    }
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Prs_ManPrintModules( Prs_Man_t * p )
+{
+    char * pName; int i; 
+    printf( "Succeeded parsing %d models:\n", Vec_IntSize(&p->vSucceeded) );
+    Prs_ManForEachNameVec( &p->vSucceeded, p, pName, i )
+        printf( " %s", pName );
+    printf( "\n" );
+    printf( "Skipped %d known models:\n", Vec_IntSize(&p->vKnown) );
+    Prs_ManForEachNameVec( &p->vKnown, p, pName, i )
+        printf( " %s", pName );
+    printf( "\n" );
+    printf( "Skipped %d failed models:\n", Vec_IntSize(&p->vFailed) );
+    Prs_ManForEachNameVec( &p->vFailed, p, pName, i )
+        printf( " %s", pName );
+    printf( "\n" );
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Vec_Ptr_t * Prs_ManReadVerilog( char * pFileName )
+{
+    Vec_Ptr_t * vPrs = NULL;
+    Prs_Man_t * p = Prs_ManAlloc( pFileName );
+    if ( p == NULL )
+        return NULL;
+    Prs_NtkAddVerilogDirectives( p );
+    Prs_ManReadDesign( p );   
+    //Prs_ManPrintModules( p );
+    if ( Prs_ManErrorPrint(p) )
+        ABC_SWAP( Vec_Ptr_t *, vPrs, p->vNtks );
+    Prs_ManFree( p );
+    return vPrs;
+}
+
+void Prs_ManReadVerilogTest( char * pFileName )
+{
+    abctime clk = Abc_Clock();
+    extern void Prs_ManWriteVerilog( char * pFileName, Vec_Ptr_t * p );
+    Vec_Ptr_t * vPrs = Prs_ManReadVerilog( "c/hie/dump/1/netlist_1.v" );
+//    Vec_Ptr_t * vPrs = Prs_ManReadVerilog( "aga/me/me_wide.v" );
+//    Vec_Ptr_t * vPrs = Prs_ManReadVerilog( "aga/ray/ray_wide.v" );
+    if ( !vPrs ) return;
+    printf( "Finished reading %d networks. ", Vec_PtrSize(vPrs) );
+    printf( "NameIDs = %d. ", Abc_NamObjNumMax(Prs_ManNameMan(vPrs)) );
+    printf( "Memory = %.2f MB. ", 1.0*Prs_ManMemory(vPrs)/(1<<20) );
+    Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
+    Prs_ManWriteVerilog( "c/hie/dump/1/netlist_1_out_new.v", vPrs );
+//    Prs_ManWriteVerilog( "aga/me/me_wide_out.v", vPrs );
+//    Prs_ManWriteVerilog( "aga/ray/ray_wide_out.v", vPrs );
+//    Abc_NamPrint( p->pStrs );
+    Prs_ManVecFree( vPrs );
+}
+
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/abc-build/src/base/cba/cbaWriteBlif.c b/abc-build/src/base/cba/cbaWriteBlif.c
new file mode 100644
--- /dev/null
+++ b/abc-build/src/base/cba/cbaWriteBlif.c
@@ -0,0 +1,236 @@
+/**CFile****************************************************************
+
+  FileName    [cbaWriteBlif.c]
+
+  SystemName  [ABC: Logic synthesis and verification system.]
+
+  PackageName [Hierarchical word-level netlist.]
+
+  Synopsis    [Verilog parser.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - November 29, 2014.]
+
+  Revision    [$Id: cbaWriteBlif.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "cba.h"
+#include "cbaPrs.h"
+#include "map/mio/mio.h"
+#include "base/main/main.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    [Writing parser state into a file.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Prs_ManWriteBlifArray( FILE * pFile, Prs_Ntk_t * p, Vec_Int_t * vFanins )
+{
+    int i, NameId;
+    Vec_IntForEachEntry( vFanins, NameId, i )
+        fprintf( pFile, " %s", Prs_NtkStr(p, NameId) );
+    fprintf( pFile, "\n" );
+}
+void Prs_ManWriteBlifLines( FILE * pFile, Prs_Ntk_t * p )
+{
+    Vec_Int_t * vBox; 
+    int i, k, FormId, ActId;
+    Prs_NtkForEachBox( p, vBox, i )
+    {
+        int NtkId = Prs_BoxNtk(p, i);
+        assert( Prs_BoxIONum(p, i) > 0 );
+        assert( Vec_IntSize(vBox) % 2 == 0 );
+        if ( NtkId == -1 ) // latch
+        {
+            fprintf( pFile, ".latch" );
+            fprintf( pFile, " %s", Prs_NtkStr(p, Vec_IntEntry(vBox, 1)) );
+            fprintf( pFile, " %s", Prs_NtkStr(p, Vec_IntEntry(vBox, 3)) );
+            fprintf( pFile, " %c\n", '0' + Prs_BoxName(p, i) );
+        }
+        else if ( Prs_BoxIsNode(p, i) ) // node
+        {
+            fprintf( pFile, ".names" );
+            Vec_IntForEachEntryDouble( vBox, FormId, ActId, k )
+                fprintf( pFile, " %s", Prs_NtkStr(p, ActId) );
+            fprintf( pFile, "\n%s", Prs_NtkStr(p, NtkId) );
+        }
+        else // box
+        {
+            fprintf( pFile, ".subckt" );
+            fprintf( pFile, " %s", Prs_NtkStr(p, NtkId) );
+            Vec_IntForEachEntryDouble( vBox, FormId, ActId, k )
+                fprintf( pFile, " %s=%s", Prs_NtkStr(p, FormId), Prs_NtkStr(p, ActId) );
+            fprintf( pFile, "\n" );
+        }
+    }
+}
+void Prs_ManWriteBlifNtk( FILE * pFile, Prs_Ntk_t * p )
+{
+    // write header
+    fprintf( pFile, ".model %s\n", Prs_NtkStr(p, p->iModuleName) );
+    if ( Vec_IntSize(&p->vInouts) )
+    fprintf( pFile, ".inouts" );
+    if ( Vec_IntSize(&p->vInouts) )
+    Prs_ManWriteBlifArray( pFile, p, &p->vInouts );
+    fprintf( pFile, ".inputs" );
+    Prs_ManWriteBlifArray( pFile, p, &p->vInputs );
+    fprintf( pFile, ".outputs" );
+    Prs_ManWriteBlifArray( pFile, p, &p->vOutputs );
+    // write objects
+    Prs_ManWriteBlifLines( pFile, p );
+    fprintf( pFile, ".end\n\n" );
+}
+void Prs_ManWriteBlif( char * pFileName, Vec_Ptr_t * vPrs )
+{
+    Prs_Ntk_t * pNtk = Prs_ManRoot(vPrs);
+    FILE * pFile = fopen( pFileName, "wb" ); int i;
+    if ( pFile == NULL )
+    {
+        printf( "Cannot open output file \"%s\".\n", pFileName );
+        return;
+    }
+    fprintf( pFile, "# Design \"%s\" written by ABC on %s\n\n", Prs_NtkStr(pNtk, pNtk->iModuleName), Extra_TimeStamp() );
+    Vec_PtrForEachEntry( Prs_Ntk_t *, vPrs, pNtk, i )
+        Prs_ManWriteBlifNtk( pFile, pNtk );
+    fclose( pFile );
+}
+
+
+
+/**Function*************************************************************
+
+  Synopsis    [Write elaborated design.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Cba_ManWriteBlifGate( FILE * pFile, Cba_Ntk_t * p, Mio_Gate_t * pGate, Vec_Int_t * vFanins, int iObj )
+{
+    int iFanin, i;
+    Vec_IntForEachEntry( vFanins, iFanin, i )
+        fprintf( pFile, " %s=%s", Mio_GateReadPinName(pGate, i), Cba_ObjNameStr(p, iFanin) );
+    fprintf( pFile, " %s=%s", Mio_GateReadOutName(pGate), Cba_ObjNameStr(p, iObj) );
+    fprintf( pFile, "\n" );
+}
+void Cba_ManWriteBlifArray( FILE * pFile, Cba_Ntk_t * p, Vec_Int_t * vFanins, int iObj )
+{
+    int iFanin, i;
+    Vec_IntForEachEntry( vFanins, iFanin, i )
+        fprintf( pFile, " %s", Cba_ObjNameStr(p, iFanin) );
+    if ( iObj >= 0 )
+        fprintf( pFile, " %s", Cba_ObjNameStr(p, iObj) );
+    fprintf( pFile, "\n" );
+}
+void Cba_ManWriteBlifArray2( FILE * pFile, Cba_Ntk_t * p, int iObj )
+{
+    int iTerm, i;
+    Cba_Ntk_t * pModel = Cba_BoxNtk( p, iObj );
+    Cba_NtkForEachPi( pModel, iTerm, i )
+        fprintf( pFile, " %s=%s", Cba_ObjNameStr(pModel, iTerm), Cba_ObjNameStr(p, Cba_BoxBi(p, iObj, i)) );
+    Cba_NtkForEachPo( pModel, iTerm, i )
+        fprintf( pFile, " %s=%s", Cba_ObjNameStr(pModel, iTerm), Cba_ObjNameStr(p, Cba_BoxBo(p, iObj, i)) );
+    fprintf( pFile, "\n" );
+}
+void Cba_ManWriteBlifLines( FILE * pFile, Cba_Ntk_t * p )
+{
+    int i, k, iTerm;
+    Cba_NtkForEachBox( p, i )
+    {
+        if ( Cba_ObjIsBoxUser(p, i) )
+        {
+            fprintf( pFile, ".subckt" );
+            fprintf( pFile, " %s", Cba_NtkName(Cba_BoxNtk(p, i)) );
+            Cba_ManWriteBlifArray2( pFile, p, i );
+        }
+        else if ( Cba_ObjIsGate(p, i) )
+        {
+            char * pGateName = Abc_NamStr(p->pDesign->pMods, Cba_BoxNtkId(p, i));
+            Mio_Library_t * pLib = (Mio_Library_t *)Abc_FrameReadLibGen( Abc_FrameGetGlobalFrame() );
+            Mio_Gate_t * pGate = Mio_LibraryReadGateByName( pLib, pGateName, NULL );
+            fprintf( pFile, ".gate %s", pGateName );
+            Cba_BoxForEachBi( p, i, iTerm, k )
+                fprintf( pFile, " %s=%s", Mio_GateReadPinName(pGate, k), Cba_ObjNameStr(p, iTerm) );
+            Cba_BoxForEachBo( p, i, iTerm, k )
+                fprintf( pFile, " %s=%s", Mio_GateReadOutName(pGate), Cba_ObjNameStr(p, iTerm) );
+            fprintf( pFile, "\n" );
+        }
+        else
+        {
+            fprintf( pFile, ".names" );
+            Cba_BoxForEachBi( p, i, iTerm, k )
+                fprintf( pFile, " %s", Cba_ObjNameStr(p, iTerm) );
+            Cba_BoxForEachBo( p, i, iTerm, k )
+                fprintf( pFile, " %s", Cba_ObjNameStr(p, iTerm) );
+            fprintf( pFile, "\n%s",  Ptr_TypeToSop(Cba_ObjType(p, i)) );
+        }
+    }
+}
+void Cba_ManWriteBlifNtk( FILE * pFile, Cba_Ntk_t * p )
+{
+    assert( Vec_IntSize(&p->vFanin) == Cba_NtkObjNum(p) );
+    // write header
+    fprintf( pFile, ".model %s\n", Cba_NtkName(p) );
+    fprintf( pFile, ".inputs" );
+    Cba_ManWriteBlifArray( pFile, p, &p->vInputs, -1 );
+    fprintf( pFile, ".outputs" );
+    Cba_ManWriteBlifArray( pFile, p, &p->vOutputs, -1 );
+    // write objects
+    Cba_ManWriteBlifLines( pFile, p );
+    fprintf( pFile, ".end\n\n" );
+}
+void Cba_ManWriteBlif( char * pFileName, Cba_Man_t * p )
+{
+    FILE * pFile;
+    Cba_Ntk_t * pNtk; 
+    int i;
+    // check the library
+    if ( p->pMioLib && p->pMioLib != Abc_FrameReadLibGen() )
+    {
+        printf( "Genlib library used in the mapped design is not longer a current library.\n" );
+        return;
+    }
+    pFile = fopen( pFileName, "wb" );
+    if ( pFile == NULL )
+    {
+        printf( "Cannot open output file \"%s\".\n", pFileName );
+        return;
+    }
+    fprintf( pFile, "# Design \"%s\" written by ABC on %s\n\n", Cba_ManName(p), Extra_TimeStamp() );
+    Cba_ManAssignInternNames( p );
+    Cba_ManForEachNtk( p, pNtk, i )
+        Cba_ManWriteBlifNtk( pFile, pNtk );
+    fclose( pFile );
+}
+
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/abc-build/src/base/cba/cbaWriteSmt.c b/abc-build/src/base/cba/cbaWriteSmt.c
new file mode 100644
--- /dev/null
+++ b/abc-build/src/base/cba/cbaWriteSmt.c
@@ -0,0 +1,52 @@
+/**CFile****************************************************************
+
+  FileName    [cbaWriteSmt.c]
+
+  SystemName  [ABC: Logic synthesis and verification system.]
+
+  PackageName [Hierarchical word-level netlist.]
+
+  Synopsis    [Verilog parser.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - November 29, 2014.]
+
+  Revision    [$Id: cbaWriteSmt.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "cba.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/abc-build/src/base/cba/cbaWriteVer.c b/abc-build/src/base/cba/cbaWriteVer.c
new file mode 100644
--- /dev/null
+++ b/abc-build/src/base/cba/cbaWriteVer.c
@@ -0,0 +1,381 @@
+/**CFile****************************************************************
+
+  FileName    [cbaWriteVer.c]
+
+  SystemName  [ABC: Logic synthesis and verification system.]
+
+  PackageName [Hierarchical word-level netlist.]
+
+  Synopsis    [Verilog writer.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - November 29, 2014.]
+
+  Revision    [$Id: cbaWriteVer.c,v 1.00 2014/11/29 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "cba.h"
+#include "cbaPrs.h"
+#include "map/mio/mio.h"
+#include "base/main/main.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    [Writing parser state into a file.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Prs_ManWriteVerilogConcat( FILE * pFile, Prs_Ntk_t * p, int Con )
+{
+    extern void Prs_ManWriteVerilogArray( FILE * pFile, Prs_Ntk_t * p, Vec_Int_t * vSigs, int Start, int Stop, int fOdd );
+    Vec_Int_t * vSigs = Prs_CatSignals(p, Con);
+    fprintf( pFile, "{" );
+    Prs_ManWriteVerilogArray( pFile, p, vSigs, 0, Vec_IntSize(vSigs), 0 );
+    fprintf( pFile, "}" );
+}
+void Prs_ManWriteVerilogSignal( FILE * pFile, Prs_Ntk_t * p, int Sig )
+{
+    int Value = Abc_Lit2Var2( Sig );
+    Prs_ManType_t Type = Abc_Lit2Att2( Sig );
+    if ( Type == CBA_PRS_NAME || Type == CBA_PRS_CONST )
+        fprintf( pFile, "%s", Prs_NtkStr(p, Value) );
+    else if ( Type == CBA_PRS_SLICE )
+        fprintf( pFile, "%s%s", Prs_NtkStr(p, Prs_SliceName(p, Value)), Prs_NtkStr(p, Prs_SliceRange(p, Value)) );
+    else if ( Type == CBA_PRS_CONCAT )
+        Prs_ManWriteVerilogConcat( pFile, p, Value );
+    else assert( 0 );
+}
+void Prs_ManWriteVerilogArray( FILE * pFile, Prs_Ntk_t * p, Vec_Int_t * vSigs, int Start, int Stop, int fOdd )
+{
+    int i, Sig;
+    assert( Vec_IntSize(vSigs) > 0 );
+    Vec_IntForEachEntryStartStop( vSigs, Sig, i, Start, Stop )
+    {
+        if ( fOdd && !(i & 1) )
+            continue;
+        Prs_ManWriteVerilogSignal( pFile, p, Sig );
+        fprintf( pFile, "%s", i == Stop - 1 ? "" : ", " );
+    }
+}
+void Prs_ManWriteVerilogArray2( FILE * pFile, Prs_Ntk_t * p, Vec_Int_t * vSigs )
+{
+    int i, FormId, ActSig;
+    assert( Vec_IntSize(vSigs) % 2 == 0 );
+    Vec_IntForEachEntryDouble( vSigs, FormId, ActSig, i )
+    {
+        fprintf( pFile, "." );
+        fprintf( pFile, "%s", Prs_NtkStr(p, FormId) );
+        fprintf( pFile, "(" );
+        Prs_ManWriteVerilogSignal( pFile, p, ActSig );
+        fprintf( pFile, ")%s", (i == Vec_IntSize(vSigs) - 2) ? "" : ", " );
+    }
+}
+void Prs_ManWriteVerilogMux( FILE * pFile, Prs_Ntk_t * p, Vec_Int_t * vSigs )
+{
+    int i, FormId, ActSig;
+    char * pStrs[4] = { " = ", " ? ", " : ", ";\n" };
+    assert( Vec_IntSize(vSigs) == 8 );
+    fprintf( pFile, "  assign " );
+    Prs_ManWriteVerilogSignal( pFile, p, Vec_IntEntryLast(vSigs) );
+    fprintf( pFile, "%s", pStrs[0] );
+    Vec_IntForEachEntryDouble( vSigs, FormId, ActSig, i )
+    {
+        Prs_ManWriteVerilogSignal( pFile, p, ActSig );
+        fprintf( pFile, "%s", pStrs[1+i/2] );
+        if ( i == 4 )
+            break;
+    }
+}
+void Prs_ManWriteVerilogBoxes( FILE * pFile, Prs_Ntk_t * p )
+{
+    Vec_Int_t * vBox; int i;
+    Prs_NtkForEachBox( p, vBox, i )
+    {
+        int NtkId = Prs_BoxNtk(p, i);
+        if ( NtkId == CBA_BOX_MUX )
+            Prs_ManWriteVerilogMux( pFile, p, vBox );
+        else if ( Prs_BoxIsNode(p, i) ) // node   ------- check order of fanins
+        {
+            fprintf( pFile, "  %s (", Ptr_TypeToName(NtkId) );
+            Prs_ManWriteVerilogSignal( pFile, p, Vec_IntEntryLast(vBox) );
+            if ( Prs_BoxIONum(p, i) > 1 )
+                fprintf( pFile, ", " );                
+            Prs_ManWriteVerilogArray( pFile, p, vBox, 0, Vec_IntSize(vBox)-2, 1 );
+            fprintf( pFile, ");\n" );
+        }
+        else // box
+        {
+            //char * s = Prs_NtkStr(p, Vec_IntEntry(vBox, 0));
+            fprintf( pFile, "  %s %s (", Prs_NtkStr(p, NtkId), Prs_BoxName(p, i) ? Prs_NtkStr(p, Prs_BoxName(p, i)) : "" );
+            Prs_ManWriteVerilogArray2( pFile, p, vBox );
+            fprintf( pFile, ");\n" );
+        }
+    }
+}
+void Prs_ManWriteVerilogIos( FILE * pFile, Prs_Ntk_t * p, int SigType )
+{
+    int NameId, RangeId, i;
+    char * pSigNames[4]   = { "inout", "input", "output", "wire" }; 
+    Vec_Int_t * vSigs[4]  = { &p->vInouts,  &p->vInputs,  &p->vOutputs,  &p->vWires };
+    Vec_Int_t * vSigsR[4] = { &p->vInoutsR, &p->vInputsR, &p->vOutputsR, &p->vWiresR };
+    if ( SigType == 3 )
+        fprintf( pFile, "\n" );
+    Vec_IntForEachEntryTwo( vSigs[SigType], vSigsR[SigType], NameId, RangeId, i )
+        fprintf( pFile, "  %s %s%s;\n", pSigNames[SigType], RangeId ? Prs_NtkStr(p, RangeId) : "", Prs_NtkStr(p, NameId) );
+}
+void Prs_ManWriteVerilogIoOrder( FILE * pFile, Prs_Ntk_t * p, Vec_Int_t * vOrder )
+{
+    int i, NameId;
+    Vec_IntForEachEntry( vOrder, NameId, i )
+        fprintf( pFile, "%s%s", Prs_NtkStr(p, NameId), i == Vec_IntSize(vOrder) - 1 ? "" : ", " );
+}
+void Prs_ManWriteVerilogNtk( FILE * pFile, Prs_Ntk_t * p )
+{
+    int s;
+    // write header
+    fprintf( pFile, "module %s (\n    ", Prs_NtkStr(p, p->iModuleName) );
+    Prs_ManWriteVerilogIoOrder( pFile, p, &p->vOrder );
+    fprintf( pFile, "\n  );\n" );
+    // write declarations
+    for ( s = 0; s < 4; s++ )
+        Prs_ManWriteVerilogIos( pFile, p, s );
+    fprintf( pFile, "\n" );
+    // write objects
+    Prs_ManWriteVerilogBoxes( pFile, p );
+    fprintf( pFile, "endmodule\n\n" );
+}
+void Prs_ManWriteVerilog( char * pFileName, Vec_Ptr_t * vPrs )
+{
+    Prs_Ntk_t * pNtk = Prs_ManRoot(vPrs); int i;
+    FILE * pFile = fopen( pFileName, "wb" );
+    if ( pFile == NULL )
+    {
+        printf( "Cannot open output file \"%s\".\n", pFileName );
+        return;
+    }
+    fprintf( pFile, "// Design \"%s\" written by ABC on %s\n\n", Prs_NtkStr(pNtk, pNtk->iModuleName), Extra_TimeStamp() );
+    Vec_PtrForEachEntry( Prs_Ntk_t *, vPrs, pNtk, i )
+        Prs_ManWriteVerilogNtk( pFile, pNtk );
+    fclose( pFile );
+}
+
+
+
+/**Function*************************************************************
+
+  Synopsis    [Collect all nodes names used that are not inputs/outputs.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Vec_Int_t * Cba_NtkCollectWires( Cba_Ntk_t * p, Vec_Int_t * vMap, Vec_Int_t * vWires )
+{
+    int i, k, iTerm, iObj, NameId;
+    Vec_IntClear( vWires );
+    Cba_NtkForEachPi( p, iObj, i )
+        Vec_IntWriteEntry( vMap, Cba_ObjName(p, iObj), 1 );
+    Cba_NtkForEachPo( p, iObj, i )
+        Vec_IntWriteEntry( vMap, Cba_ObjName(p, iObj), 1 );
+    Cba_NtkForEachBox( p, iObj )
+    {
+        Cba_BoxForEachBi( p, iObj, iTerm, k )
+        {
+            NameId = Cba_ObjName( p, iTerm );
+            if ( Vec_IntEntry(vMap, NameId) == 0 )
+            {
+                Vec_IntWriteEntry( vMap, NameId, 1 );
+                Vec_IntPush( vWires, iTerm );
+            }
+        }
+        Cba_BoxForEachBo( p, iObj, iTerm, k )
+        {
+            NameId = Cba_ObjName( p, iTerm );
+            if ( Vec_IntEntry(vMap, NameId) == 0 )
+            {
+                Vec_IntWriteEntry( vMap, NameId, 1 );
+                Vec_IntPush( vWires, iTerm );
+            }
+        }
+    }
+    Cba_NtkForEachPi( p, iObj, i )
+        Vec_IntWriteEntry( vMap, Cba_ObjName(p, iObj), 0 );
+    Cba_NtkForEachPo( p, iObj, i )
+        Vec_IntWriteEntry( vMap, Cba_ObjName(p, iObj), 0 );
+    Vec_IntForEachEntry( vWires, iObj, i )
+        Vec_IntWriteEntry( vMap, Cba_ObjName(p, iObj), 0 );
+    //Vec_IntSort( vWires, 0 );
+    return vWires;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Cba_ManWriteVerilogArray2( FILE * pFile, Cba_Ntk_t * p, int iObj, Vec_Int_t * vFanins )
+{
+    int i, iFanin;
+    fprintf( pFile, "%s%s", Cba_ObjNameStr(p, iObj), (Vec_IntSize(vFanins) == 0) ? "" : ", " );
+    Vec_IntForEachEntry( vFanins, iFanin, i )
+        fprintf( pFile, "%s%s", Cba_ObjNameStr(p, iFanin), (i == Vec_IntSize(vFanins) - 1) ? "" : ", " );
+}
+void Cba_ManWriteVerilogBoxes( FILE * pFile, Cba_Ntk_t * p )
+{
+    int i, k, iTerm;
+    Cba_NtkForEachBox( p, i ) // .subckt/.gate/box (formal/actual binding) 
+    {
+        if ( Cba_ObjIsBoxUser(p, i) )
+        {
+            Cba_Ntk_t * pModel = Cba_BoxNtk( p, i );
+            fprintf( pFile, "  %s %s (", Cba_NtkName(pModel), Cba_ObjNameStr(p, i) ? Cba_ObjNameStr(p, i) : "" );
+            Cba_NtkForEachPi( pModel, iTerm, k )
+                fprintf( pFile, "%s.%s(%s)", k ? ", " : "", Cba_ObjNameStr(pModel, iTerm), Cba_ObjNameStr(p, Cba_BoxBi(p, i, k)) );
+            Cba_NtkForEachPo( pModel, iTerm, k )
+                fprintf( pFile, "%s.%s(%s)", Cba_NtkPiNum(pModel) ? ", " : "", Cba_ObjNameStr(pModel, iTerm), Cba_ObjNameStr(p, Cba_BoxBo(p, i, k)) );
+            fprintf( pFile, ");\n" );
+        }
+        else if ( Cba_ObjIsGate(p, i) )
+        {
+            char * pGateName = Abc_NamStr(p->pDesign->pMods, Cba_BoxNtkId(p, i));
+            Mio_Library_t * pLib = (Mio_Library_t *)Abc_FrameReadLibGen( Abc_FrameGetGlobalFrame() );
+            Mio_Gate_t * pGate = Mio_LibraryReadGateByName( pLib, pGateName, NULL );
+            fprintf( pFile, "  %s (", pGateName );
+            Cba_BoxForEachBi( p, i, iTerm, k )
+                fprintf( pFile, "%s.%s(%s)", k ? ", " : "", Mio_GateReadPinName(pGate, k), Cba_ObjNameStr(p, iTerm) );
+            Cba_BoxForEachBo( p, i, iTerm, k )
+                fprintf( pFile, "%s.%s(%s)", Cba_BoxBiNum(p, i) ? ", " : "", Mio_GateReadOutName(pGate), Cba_ObjNameStr(p, iTerm) );
+            fprintf( pFile, ");\n" );
+        }
+        else
+        {
+            Cba_ObjType_t Type = Cba_ObjType( p, i );
+            int nInputs = Cba_BoxBiNum(p, i);
+            fprintf( pFile, "  %s (", Ptr_TypeToName(Type) );
+            Cba_BoxForEachBo( p, i, iTerm, k )
+                fprintf( pFile, "%s%s", Cba_ObjNameStr(p, iTerm), nInputs ? ", " : "" );
+            Cba_BoxForEachBi( p, i, iTerm, k )
+                fprintf( pFile, "%s%s", Cba_ObjNameStr(p, iTerm), k < nInputs - 1 ? ", " : "" );
+            fprintf( pFile, ");\n" );
+        }
+    }
+}
+void Cba_ManWriteVerilogSignals( FILE * pFile, Cba_Ntk_t * p, int SigType, int fNoRange, Vec_Int_t * vWires )
+{
+    int NameId, RangeId, i;
+    char * pSigNames[3]  = { "input", "output", "wire" }; 
+    Vec_Int_t * vSigs[3] = { &p->vInputs, &p->vOutputs, vWires };
+    if ( fNoRange )
+    {
+        Vec_IntForEachEntry( vSigs[SigType], NameId, i )
+            fprintf( pFile, "  %s %s;\n", pSigNames[SigType], SigType==3 ? Cba_NtkStr(p, NameId) : Cba_ObjNameStr(p, NameId) );
+    }
+    else
+    {
+        Vec_IntForEachEntryDouble( vSigs[SigType], NameId, RangeId, i )
+            fprintf( pFile, "  %s %s%s;\n", pSigNames[SigType], RangeId ? Cba_NtkStr(p, RangeId) : "", SigType==3 ? Cba_NtkStr(p, NameId) : Cba_ObjNameStr(p, NameId) );
+    }
+}
+void Cba_ManWriteVerilogSignalList( FILE * pFile, Cba_Ntk_t * p, int SigType, int fSkipComma, int fNoRange, Vec_Int_t * vWires )
+{
+    int NameId, RangeId, i;
+    Vec_Int_t * vSigs[3] = { &p->vInputs, &p->vOutputs, vWires };
+    if ( fNoRange )
+    {
+        Vec_IntForEachEntry( vSigs[SigType], NameId, i )
+            fprintf( pFile, "%s%s", Cba_ObjNameStr(p, NameId), (fSkipComma && i == Vec_IntSize(vSigs[SigType]) - 1) ? "" : ", " );
+    }
+    else
+    {
+        Vec_IntForEachEntryDouble( vSigs[SigType], NameId, RangeId, i )
+            fprintf( pFile, "%s%s", Cba_ObjNameStr(p, NameId), (fSkipComma && i == Vec_IntSize(vSigs[SigType]) - 2) ? "" : ", " );
+    }
+}
+void Cba_ManWriteVerilogNtk( FILE * pFile, Cba_Ntk_t * p, Vec_Int_t * vMap, Vec_Int_t * vWires )
+{
+    int s;
+    assert( Vec_IntSize(&p->vFanin) == Cba_NtkObjNum(p) );
+    // collect wires
+    Cba_NtkCollectWires( p, vMap, vWires );
+    // write header
+    fprintf( pFile, "module %s (\n", Cba_NtkName(p) );
+    for ( s = 0; s < 2; s++ )
+    {
+        fprintf( pFile, "    " );
+        Cba_ManWriteVerilogSignalList( pFile, p, s, s==1, 1, vWires );
+        fprintf( pFile, "\n" );
+    }
+    fprintf( pFile, "  );\n" );
+    // write declarations
+    for ( s = 0; s < 3; s++ )
+        Cba_ManWriteVerilogSignals( pFile, p, s, 1, vWires );
+    fprintf( pFile, "\n" );
+    // write objects
+    Cba_ManWriteVerilogBoxes( pFile, p );
+    fprintf( pFile, "endmodule\n\n" );
+}
+void Cba_ManWriteVerilog( char * pFileName, Cba_Man_t * p )
+{
+    FILE * pFile;
+    Cba_Ntk_t * pNtk; 
+    Vec_Int_t * vMap, * vWires;
+    int i;
+    // check the library
+    if ( p->pMioLib && p->pMioLib != Abc_FrameReadLibGen() )
+    {
+        printf( "Genlib library used in the mapped design is not longer a current library.\n" );
+        return;
+    }
+    pFile = fopen( pFileName, "wb" );
+    if ( pFile == NULL )
+    {
+        printf( "Cannot open output file \"%s\".\n", pFileName );
+        return;
+    }
+    fprintf( pFile, "// Design \"%s\" written by ABC on %s\n\n", Cba_ManName(p), Extra_TimeStamp() );
+    Cba_ManAssignInternNames( p );
+    vMap = Vec_IntStart( Abc_NamObjNumMax(p->pStrs) + 1 );
+    vWires = Vec_IntAlloc( 1000 );
+    Cba_ManForEachNtk( p, pNtk, i )
+        Cba_ManWriteVerilogNtk( pFile, pNtk, vMap, vWires );
+    Vec_IntFree( vWires );
+    Vec_IntFree( vMap );
+    fclose( pFile );
+}
+
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/abc-build/src/base/cba/module.make b/abc-build/src/base/cba/module.make
new file mode 100644
--- /dev/null
+++ b/abc-build/src/base/cba/module.make
@@ -0,0 +1,15 @@
+SRC +=	src/base/cba/cbaBlast.c \
+	src/base/cba/cbaCba.c \
+	src/base/cba/cbaCom.c \
+	src/base/cba/cbaLib.c \
+	src/base/cba/cbaNtk.c \
+	src/base/cba/cbaPrsBuild.c \
+	src/base/cba/cbaPrsTrans.c \
+	src/base/cba/cbaPtr.c \
+	src/base/cba/cbaPtrAbc.c \
+	src/base/cba/cbaReadBlif.c \
+	src/base/cba/cbaReadSmt.c \
+	src/base/cba/cbaReadVer.c \
+	src/base/cba/cbaWriteBlif.c \
+	src/base/cba/cbaWriteSmt.c \
+	src/base/cba/cbaWriteVer.c 
diff --git a/abc-build/src/base/cmd/cmd.c b/abc-build/src/base/cmd/cmd.c
--- a/abc-build/src/base/cmd/cmd.c
+++ b/abc-build/src/base/cmd/cmd.c
@@ -51,6 +51,7 @@
 static int CmdCommandEmpty         ( Abc_Frame_t * pAbc, int argc, char ** argv );
 #if defined(WIN32) && !defined(__cplusplus)
 static int CmdCommandScanDir       ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int CmdCommandRenameFiles   ( Abc_Frame_t * pAbc, int argc, char ** argv );
 static int CmdCommandLs            ( Abc_Frame_t * pAbc, int argc, char ** argv );
 static int CmdCommandScrGen        ( Abc_Frame_t * pAbc, int argc, char ** argv );
 #endif
@@ -98,6 +99,7 @@
     Cmd_CommandAdd( pAbc, "Basic", "empty",         CmdCommandEmpty,           0 );
 #if defined(WIN32) && !defined(__cplusplus)
     Cmd_CommandAdd( pAbc, "Basic", "scandir",       CmdCommandScanDir,         0 );
+    Cmd_CommandAdd( pAbc, "Basic", "renamefiles",   CmdCommandRenameFiles,     0 );
     Cmd_CommandAdd( pAbc, "Basic", "ls",            CmdCommandLs,              0 );
     Cmd_CommandAdd( pAbc, "Basic", "scrgen",        CmdCommandScrGen,          0 );
 #endif
@@ -1283,6 +1285,223 @@
     return 1;
 }
 
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int CmfFindNumber( char * pName )
+{
+    char * pTemp;
+    for ( pTemp = pName; *pTemp; pTemp++ )
+        if ( *pTemp == '.' )
+            break;
+    if ( *pTemp == 0 )
+        return -1;
+    for ( --pTemp; pTemp > pName; pTemp-- )
+        if ( *pTemp < '0' || *pTemp > '9' )
+        {
+            pTemp++;
+            break;
+        }
+    if ( *pTemp == '.' )
+        return -2;
+    return atoi( pTemp );
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void CnfDupFileUnzip( char * pOldName )
+{
+    extern char * Io_MvLoadFileBz2( char * pFileName, int * pnFileSize );
+    char pNewName[1000];
+    FILE * pFile;
+    int nFileSize;
+    char * pBuffer = Io_MvLoadFileBz2( pOldName, &nFileSize );
+    assert( strlen(pOldName) < 1000 );
+    sprintf( pNewName, "%s.v", pOldName );
+    pFile = fopen( pNewName, "wb" );
+    fwrite( pBuffer, nFileSize, 1, pFile );
+    fclose( pFile );
+    ABC_FREE( pBuffer );
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Command to print the contents of the current directory (Windows).]
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int CmdCommandRenameFiles( Abc_Frame_t * pAbc, int argc, char **argv )
+{
+    struct _finddata_t c_file;
+    long   hFile;
+    char pNewName[1000];
+    char * pDirStr = NULL;
+    char * pDirCur = NULL;
+    char * pNameNew = NULL;
+    char * pNameExt = NULL;
+    int c, i, nBase = 0;
+    Extra_UtilGetoptReset();
+    while ( (c = Extra_UtilGetopt(argc, argv, "DENB") ) != EOF )
+    {
+        switch (c)
+        {
+            case 'D':
+                if ( globalUtilOptind >= argc )
+                {
+                    fprintf( pAbc->Err, "Command line switch \"-D\" should be followed by a string.\n" );
+                    goto usage;
+                }
+                pDirStr = argv[globalUtilOptind];
+                globalUtilOptind++;
+                break;
+            case 'E':
+                if ( globalUtilOptind >= argc )
+                {
+                    fprintf( pAbc->Err, "Command line switch \"-E\" should be followed by a string.\n" );
+                    goto usage;
+                }
+                pNameExt = argv[globalUtilOptind];
+                globalUtilOptind++;
+                break;
+            case 'N':
+                if ( globalUtilOptind >= argc )
+                {
+                    fprintf( pAbc->Err, "Command line switch \"-N\" should be followed by a string.\n" );
+                    goto usage;
+                }
+                pNameNew = argv[globalUtilOptind];
+                globalUtilOptind++;
+                break;
+            case 'B':
+                if ( globalUtilOptind >= argc )
+                {
+                    fprintf( pAbc->Err, "Command line switch \"-B\" should be followed by a positive integer.\n" );
+                    goto usage;
+                }
+                nBase = atoi(argv[globalUtilOptind]);
+                globalUtilOptind++;
+                if ( nBase < 0 )
+                    goto usage;
+                break;
+            default:
+                goto usage;
+        }
+    }
+
+    if ( pNameExt == NULL )
+    {
+        printf( "Extension of the files should be given on the command line.\n" );
+        return 0;
+    }
+
+    if ( pDirStr )
+    {
+        if( (pDirCur = _getcwd( NULL, 0 )) == NULL )
+        {
+            printf( "Cannot read current directory\n" );
+            return 0;
+        }
+        if ( _chdir(pDirStr) )
+        {
+            printf( "Cannot change to directory: %s\n", pDirStr );
+            return 0;
+        }
+    }
+
+    sprintf( pNewName, "*.%s", pNameExt );
+    if( (hFile = _findfirst( pNewName, &c_file )) == -1L )
+    {
+        if ( pDirStr )
+            printf( "No .aig files in the current directory.\n" );
+        else
+            printf( "No .aig files in directory: %s\n", pDirStr );
+    }
+    else
+    {
+        char * pName, * pOldName;
+        int nDigits, * pOrder;
+        Vec_Ptr_t * vNames = Vec_PtrAlloc( 1000 );
+        Vec_Int_t * vNums  = Vec_IntAlloc( 1000 );
+        // collect names
+        do {
+            Vec_PtrPush( vNames, Abc_UtilStrsav(c_file.name) );
+        } while( _findnext( hFile, &c_file ) == 0 );
+        _findclose( hFile );
+        // sort files by number
+        Vec_PtrForEachEntry( char *, vNames, pName, i )
+        {
+            Vec_IntPush( vNums, CmfFindNumber(pName) );
+            if ( Vec_IntEntryLast(vNums) < 0 )
+            {
+                printf( "Directory \"%s\" contains file (%s) with extension %s without number\n", pDirStr, pName, pNameExt );
+                Vec_PtrFreeFree( vNames );
+                Vec_IntFree( vNums );
+                return 0;
+            }
+        }
+        // sort by number
+        pOrder = Abc_QuickSortCost( Vec_IntArray(vNums), Vec_IntSize(vNums), 0 );
+        // rename files in that order
+//        nDigits = Abc_Base10Log( nBase + Vec_IntSize(vNums) );
+        nDigits = Abc_Base10Log( nBase + Vec_IntEntry(vNums, pOrder[Vec_IntSize(vNums)-1]) + 1 );
+        for ( i = 0; i < Vec_IntSize(vNums); i++ )
+        {
+            pOldName = (char *)Vec_PtrEntry( vNames, pOrder[i] );
+            sprintf( pNewName, "%s%0*d.%s", pNameNew ? pNameNew : "", nDigits, nBase+Vec_IntEntry(vNums, pOrder[i]), pNameExt );
+            rename( pOldName, pNewName );
+            printf( "%s -> %s\n", pOldName, pNewName );
+//            CnfDupFileUnzip( pOldName );
+        }
+        // cleanup
+        Vec_PtrFreeFree( vNames );
+        Vec_IntFree( vNums );
+        ABC_FREE( pOrder );
+    }
+    if ( pDirStr )
+    {
+        if ( _chdir(pDirCur) )
+        {
+            ABC_FREE( pDirCur );
+            printf( "Cannot change to directory: %s\n", pDirCur );
+            return 0;
+        }
+        ABC_FREE( pDirCur );
+    }
+    return 0;
+
+usage:
+    fprintf( pAbc->Err, "usage: renamefiles [-DEN str] [-B num]\n" );
+    fprintf( pAbc->Err, "            performs renaming of files in the given directory\n" );
+    fprintf( pAbc->Err, "\t-D str  : the directory to read files from [default = current]\n" );
+    fprintf( pAbc->Err, "\t-E str  : the extension of files to look for [default = none]\n" );
+    fprintf( pAbc->Err, "\t-N str  : the root of the resulting files [default = none]\n" );
+    fprintf( pAbc->Err, "\t-B num  : the base number for all files [default = %d]\n", nBase );
+    return 1;
+}
 
 
 /**Function*************************************************************
diff --git a/abc-build/src/base/cmd/cmd.h b/abc-build/src/base/cmd/cmd.h
--- a/abc-build/src/base/cmd/cmd.h
+++ b/abc-build/src/base/cmd/cmd.h
@@ -51,7 +51,8 @@
 extern void        Cmd_Init( Abc_Frame_t * pAbc );
 extern void        Cmd_End( Abc_Frame_t * pAbc );
 /*=== cmdApi.c ========================================================*/
-typedef int (*Cmd_CommandFuncType)(Abc_Frame_t*, int, char**);
+typedef int (*Cmd_CommandFuncType)(Abc_Frame_t*, int, char**);
+extern int         Cmd_CommandIsDefined( Abc_Frame_t * pAbc, const char * sName );
 extern void        Cmd_CommandAdd( Abc_Frame_t * pAbc, const char * sGroup, const char * sName, Cmd_CommandFuncType pFunc, int fChanges );
 extern ABC_DLL int Cmd_CommandExecute( Abc_Frame_t * pAbc, const char * sCommand );
 /*=== cmdFlag.c ========================================================*/
diff --git a/abc-build/src/base/cmd/cmdApi.c b/abc-build/src/base/cmd/cmdApi.c
--- a/abc-build/src/base/cmd/cmdApi.c
+++ b/abc-build/src/base/cmd/cmdApi.c
@@ -32,6 +32,22 @@
 ////////////////////////////////////////////////////////////////////////
 ///                     FUNCTION DEFINITIONS                         ///
 ////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Cmd_CommandIsDefined( Abc_Frame_t * pAbc, const char * sName )
+{
+    return st__is_member( pAbc->tCommands, sName );
+}
 
 /**Function*************************************************************
 
diff --git a/abc-build/src/base/cmd/cmdHist.c b/abc-build/src/base/cmd/cmdHist.c
--- a/abc-build/src/base/cmd/cmdHist.c
+++ b/abc-build/src/base/cmd/cmdHist.c
@@ -59,9 +59,11 @@
         Buffer[Len-1] = 0;
     if ( strlen(Buffer) > 3 &&
          strncmp(Buffer,"set",3) && 
+         strncmp(Buffer,"unset",5) && 
          strncmp(Buffer,"time",4) && 
          strncmp(Buffer,"quit",4) && 
-         strncmp(Buffer,"source",6) && 
+         strncmp(Buffer,"alias",5) && 
+//         strncmp(Buffer,"source",6) && 
          strncmp(Buffer,"history",7) && strncmp(Buffer,"hi ", 3) && strcmp(Buffer,"hi") &&
          Buffer[strlen(Buffer)-1] != '?' )
     {
diff --git a/abc-build/src/base/cmd/cmdStarter.c b/abc-build/src/base/cmd/cmdStarter.c
--- a/abc-build/src/base/cmd/cmdStarter.c
+++ b/abc-build/src/base/cmd/cmdStarter.c
@@ -248,7 +248,7 @@
     fflush( stdout );
 }
 
-#endif
+#endif // pthreads are used
 
 ////////////////////////////////////////////////////////////////////////
 ///                       END OF FILE                                ///
diff --git a/abc-build/src/base/cmd/cmdUtils.c b/abc-build/src/base/cmd/cmdUtils.c
--- a/abc-build/src/base/cmd/cmdUtils.c
+++ b/abc-build/src/base/cmd/cmdUtils.c
@@ -482,13 +482,21 @@
   SeeAlso     []
 
 ***********************************************************************/
-void CmdFreeArgv( int argc, char **argv )
-{
-    int i;
-    for ( i = 0; i < argc; i++ )
-        ABC_FREE( argv[i] );
-    ABC_FREE( argv );
-}
+void CmdFreeArgv( int argc, char **argv )
+{
+    int i;
+    for ( i = 0; i < argc; i++ )
+        ABC_FREE( argv[i] );
+    ABC_FREE( argv );
+}
+char ** CmdDupArgv( int argc, char **argv )
+{
+    char ** argvNew = ABC_ALLOC( char *, argc );
+    int i;
+    for ( i = 0; i < argc; i++ )
+        argvNew[i] = Abc_UtilStrsav( argv[i] );
+    return argvNew;
+}
 
 /**Function*************************************************************
 
diff --git a/abc-build/src/base/io/io.c b/abc-build/src/base/io/io.c
--- a/abc-build/src/base/io/io.c
+++ b/abc-build/src/base/io/io.c
@@ -170,13 +170,14 @@
     char Command[1000];
     Abc_Ntk_t * pNtk;
     char * pFileName, * pTemp;
-    int c, fCheck, fBarBufs;
+    int c, fCheck, fBarBufs, fReadGia;
 
     fCheck = 1;
-    fBarBufs = 0;
+    fBarBufs = 0;
+    fReadGia = 0;
     glo_fMapped = 0;
     Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "mcbh" ) ) != EOF )
+    while ( ( c = Extra_UtilGetopt( argc, argv, "mcbgh" ) ) != EOF )
     {
         switch ( c )
         {
@@ -189,6 +190,9 @@
             case 'b':
                 fBarBufs ^= 1;
                 break;
+            case 'g':
+                fReadGia ^= 1;
+                break;
             case 'h':
                 goto usage;
             default:
@@ -225,6 +229,22 @@
         Cmd_CommandExecute( pAbc, Command );
         return 0;
     }
+    if ( fReadGia )
+    {
+        Abc_Ntk_t * pNtk = Io_ReadNetlist( pFileName, Io_ReadFileType(pFileName), fCheck );
+        if ( pNtk )
+        {
+            Gia_Man_t * pGia = Abc_NtkFlattenHierarchyGia( pNtk, NULL, 0 );
+            Abc_NtkDelete( pNtk );
+            if ( pGia == NULL )
+            {
+                Abc_Print( 1, "Abc_CommandBlast(): Bit-blasting has failed.\n" );
+                return 0;
+            }
+            Abc_FrameUpdateGia( pAbc, pGia );
+        }
+        return 0;
+    }
     // check if the library is available
     if ( glo_fMapped && Abc_FrameReadLibGen() == NULL )
     {
@@ -247,13 +267,14 @@
     return 0;
 
 usage:
-    fprintf( pAbc->Err, "usage: read [-mcbh] <file>\n" );
+    fprintf( pAbc->Err, "usage: read [-mcbgh] <file>\n" );
     fprintf( pAbc->Err, "\t         replaces the current network by the network read from <file>\n" );
     fprintf( pAbc->Err, "\t         by calling the parser that matches the extension of <file>\n" );
     fprintf( pAbc->Err, "\t         (to read a hierarchical design, use \"read_hie\")\n" );
     fprintf( pAbc->Err, "\t-m     : toggle reading mapped Verilog [default = %s]\n", glo_fMapped? "yes":"no" );
     fprintf( pAbc->Err, "\t-c     : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" );
     fprintf( pAbc->Err, "\t-b     : toggle reading barrier buffers [default = %s]\n", fBarBufs? "yes":"no" );
+    fprintf( pAbc->Err, "\t-g     : toggle reading and flattening into &-space [default = %s]\n", fBarBufs? "yes":"no" );
     fprintf( pAbc->Err, "\t-h     : prints the command summary\n" );
     fprintf( pAbc->Err, "\tfile   : the name of a file to read\n" );
     return 1;
@@ -685,7 +706,7 @@
     fprintf( pAbc->Err, "\t          (in this case CA=11001010 is truth table of MUX(Data0,Data1,Ctrl))\n" );
     fprintf( pAbc->Err, "\t          The lower chars (a,b,c,etc) are reserved for elementary variables.\n" );
     fprintf( pAbc->Err, "\t          The upper chars (A,B,C,etc) are reserved for hexadecimal digits.\n" );
-    fprintf( pAbc->Err, "\t          No spaces are allowed in formulas. In parantheses, LSB goes first.\n" );
+    fprintf( pAbc->Err, "\t          No spaces are allowed in formulas. In parentheses, LSB goes first.\n" );
     return 1;
 }
 
@@ -1939,14 +1960,16 @@
 int IoCommandWriteCnf2( Abc_Frame_t * pAbc, int argc, char **argv )
 {
     extern void Jf_ManDumpCnf( Gia_Man_t * p, char * pFileName, int fVerbose );
-    extern void Mf_ManDumpCnf( Gia_Man_t * p, char * pFileName, int nLutSize, int fVerbose );
+    extern void Mf_ManDumpCnf( Gia_Man_t * p, char * pFileName, int nLutSize, int fCnfObjIds, int fAddOrCla, int fVerbose );
     FILE * pFile;
     char * pFileName;
-    int nLutSize = 6;
-    int fNewAlgo = 1;
+    int nLutSize    = 6;
+    int fNewAlgo    = 1;
+    int fCnfObjIds  = 0;
+    int fAddOrCla   = 1;
     int c, fVerbose = 0;
     Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "Kavh" ) ) != EOF )
+    while ( ( c = Extra_UtilGetopt( argc, argv, "Kaiovh" ) ) != EOF )
     {
         switch ( c )
         {
@@ -1962,6 +1985,12 @@
             case 'a':
                 fNewAlgo ^= 1;
                 break;
+            case 'i':
+                fCnfObjIds ^= 1;
+                break;
+            case 'o':
+                fAddOrCla ^= 1;
+                break;
             case 'v':
                 fVerbose ^= 1;
                 break;
@@ -2003,16 +2032,18 @@
     }
     fclose( pFile );
     if ( fNewAlgo )
-        Mf_ManDumpCnf( pAbc->pGia, pFileName, nLutSize, fVerbose );
+        Mf_ManDumpCnf( pAbc->pGia, pFileName, nLutSize, fCnfObjIds, fAddOrCla, fVerbose );
     else
         Jf_ManDumpCnf( pAbc->pGia, pFileName, fVerbose );
     return 0;
 
 usage:
-    fprintf( pAbc->Err, "usage: &write_cnf [-Kavh] <file>\n" );
+    fprintf( pAbc->Err, "usage: &write_cnf [-Kaiovh] <file>\n" );
     fprintf( pAbc->Err, "\t           writes CNF produced by a new generator\n" );
     fprintf( pAbc->Err, "\t-K <num> : the LUT size (3 <= num <= 8) [default = %d]\n", nLutSize );
     fprintf( pAbc->Err, "\t-a       : toggle using new algorithm [default = %s]\n", fNewAlgo? "yes" : "no" );
+    fprintf( pAbc->Err, "\t-i       : toggle using AIG object IDs as CNF variables [default = %s]\n", fCnfObjIds? "yes" : "no" );
+    fprintf( pAbc->Err, "\t-o       : toggle adding OR clause for the outputs [default = %s]\n", fAddOrCla? "yes" : "no" );
     fprintf( pAbc->Err, "\t-v       : toggle printing verbose information [default = %s]\n", fVerbose? "yes" : "no" );
     fprintf( pAbc->Err, "\t-h       : print the help massage\n" );
     fprintf( pAbc->Err, "\tfile     : the name of the file to write\n" );
@@ -2448,13 +2479,16 @@
 int IoCommandWritePla( Abc_Frame_t * pAbc, int argc, char **argv )
 {
     char * pFileName;
-    int c;
+    int c, fUseMoPla = 0;
 
     Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+    while ( ( c = Extra_UtilGetopt( argc, argv, "mh" ) ) != EOF )
     {
         switch ( c )
         {
+            case 'm':
+                fUseMoPla ^= 1;
+                break;
             case 'h':
                 goto usage;
             default:
@@ -2470,13 +2504,14 @@
         goto usage;
     // get the output file name
     pFileName = argv[globalUtilOptind];
-    // call the corresponding file writer
-    Io_Write( pAbc->pNtkCur, pFileName, IO_FILE_PLA );
+    // call the corresponding file writer
+    Io_Write( pAbc->pNtkCur, pFileName, fUseMoPla ? IO_FILE_MOPLA : IO_FILE_PLA );
     return 0;
 
 usage:
-    fprintf( pAbc->Err, "usage: write_pla [-h] <file>\n" );
+    fprintf( pAbc->Err, "usage: write_pla [-mh] <file>\n" );
     fprintf( pAbc->Err, "\t         writes the collapsed network into a PLA file\n" );
+    fprintf( pAbc->Err, "\t-m     : toggle writing multi-output PLA [default = %s]\n", fUseMoPla? "yes":"no" );
     fprintf( pAbc->Err, "\t-h     : print the help massage\n" );
     fprintf( pAbc->Err, "\tfile   : the name of the file to write\n" );
     return 1;
diff --git a/abc-build/src/base/io/ioAbc.h b/abc-build/src/base/io/ioAbc.h
--- a/abc-build/src/base/io/ioAbc.h
+++ b/abc-build/src/base/io/ioAbc.h
@@ -59,6 +59,7 @@
     IO_FILE_GML,      
     IO_FILE_LIST,      
     IO_FILE_PLA,      
+    IO_FILE_MOPLA,      
     IO_FILE_SMV,      
     IO_FILE_VERILOG,    
     IO_FILE_UNKNOWN       
@@ -128,6 +129,7 @@
 extern void               Io_WriteList( Abc_Ntk_t * pNtk, char * pFileName, int fUseHost );
 /*=== abcWritePla.c ===========================================================*/
 extern int                Io_WritePla( Abc_Ntk_t * pNtk, char * FileName );
+extern int                Io_WriteMoPla( Abc_Ntk_t * pNtk, char * FileName );
 /*=== abcWriteSmv.c ===========================================================*/
 extern int                Io_WriteSmv( Abc_Ntk_t * pNtk, char * FileName );
 /*=== abcWriteVerilog.c =======================================================*/
diff --git a/abc-build/src/base/io/ioReadAiger.c b/abc-build/src/base/io/ioReadAiger.c
--- a/abc-build/src/base/io/ioReadAiger.c
+++ b/abc-build/src/base/io/ioReadAiger.c
@@ -477,7 +477,7 @@
  
     // read the names if present
     pCur = pSymbols;
-    if ( *pCur != 'c' )
+    if ( pCur < pContents + nFileSize && *pCur != 'c' )
     {
         int Counter = 0;
         while ( pCur < pContents + nFileSize && *pCur != 'c' )
diff --git a/abc-build/src/base/io/ioReadBlifMv.c b/abc-build/src/base/io/ioReadBlifMv.c
--- a/abc-build/src/base/io/ioReadBlifMv.c
+++ b/abc-build/src/base/io/ioReadBlifMv.c
@@ -548,7 +548,7 @@
   struct buflist * next;
 } buflist;
 
-static char * Io_MvLoadFileBz2( char * pFileName, int * pnFileSize )
+char * Io_MvLoadFileBz2( char * pFileName, int * pnFileSize )
 {
     FILE    * pFile;
     int       nFileSize = 0;
diff --git a/abc-build/src/base/io/ioReadDsd.c b/abc-build/src/base/io/ioReadDsd.c
--- a/abc-build/src/base/io/ioReadDsd.c
+++ b/abc-build/src/base/io/ioReadDsd.c
@@ -90,17 +90,17 @@
             // skip hex truth table
             while ( (*pCur >= '0' && *pCur <= '9') || (*pCur >= 'A' && *pCur <= 'F') )
                 pCur++;
-            // process parantheses
+            // process parentheses
             if ( *pCur != '(' )
             {
-                printf( "Cannot find the opening paranthesis.\n" );
+                printf( "Cannot find the opening parenthesis.\n" );
                 break;
             }
-            // find the corresponding closing paranthesis
+            // find the corresponding closing parenthesis
             pCur = Io_ReadDsdFindEnd( pCur );
             if ( pCur == NULL )
             {
-                printf( "Cannot find the closing paranthesis.\n" );
+                printf( "Cannot find the closing parenthesis.\n" );
                 break;
             }
             pCur++;
@@ -254,7 +254,7 @@
         Abc_ObjAssignName( Abc_NtkCreatePi(pNtk), (char *)Vec_PtrEntry(vNames, i), NULL );
     Abc_NodeFreeNames( vNames );
 
-    // transform the formula by inserting parantheses
+    // transform the formula by inserting parentheses
     // this transforms strings like PRIME(a,b,cd) into (PRIME((a),(b),(cd)))
     pCur = pFormCopy = ABC_ALLOC( char, 3 * strlen(pForm) + 10 );
     *pCur++ = '(';
diff --git a/abc-build/src/base/io/ioReadPla.c b/abc-build/src/base/io/ioReadPla.c
--- a/abc-build/src/base/io/ioReadPla.c
+++ b/abc-build/src/base/io/ioReadPla.c
@@ -19,6 +19,7 @@
 ***********************************************************************/
 
 #include "ioAbc.h"
+#include "misc/util/utilTruth.h"
 
 ABC_NAMESPACE_IMPL_START
 
@@ -32,6 +33,287 @@
 ////////////////////////////////////////////////////////////////////////
 ///                     FUNCTION DEFINITIONS                         ///
 ////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    [Checks if cubes are distance-1.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline void Io_ReadPlaPrintCube( word * p, int nVars )
+{
+    char Symbs[3] = {'-', '0', '1'}; int v;
+    for ( v = 0; v < nVars; v++ )
+        printf( "%c", Symbs[Abc_TtGetQua(p, v)] );
+    printf( "\n" );
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Checks if cubes are distance-1.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Io_ReadPlaDistance1( word * p, word * q, int nWords )
+{
+    word Test; int c, fFound = 0;
+    for ( c = 0; c < nWords; c++ )
+    {
+        if ( p[c] == q[c] )
+            continue;
+        if ( fFound )
+            return 0;
+        // check if the number of 1s is one
+//        Test = ((p[c] ^ q[c]) & ((p[c] ^ q[c]) >> 1)) & ABC_CONST(0x5555555555555555); // exactly one 0/1 literal (but may be -/0 or -/1)
+        Test = ((p[c] ^ q[c]) | ((p[c] ^ q[c]) >> 1)) & ABC_CONST(0x5555555555555555);
+        if ( !Abc_TtOnlyOneOne(Test) )
+            return 0;
+        fFound = 1;
+    }
+    return fFound;
+}
+static inline int Io_ReadPlaConsensus( word * p, word * q, int nWords, int * piVar )
+{
+    word Test; int c, fFound = 0;
+    for ( c = 0; c < nWords; c++ )
+    {
+        if ( p[c] == q[c] )
+            continue;
+        if ( fFound )
+            return 0;
+        // check if there is exactly one opposite literal (0/1) but may have other diffs (-/0 or -/1)
+        Test = ((p[c] ^ q[c]) & ((p[c] ^ q[c]) >> 1)) & ABC_CONST(0x5555555555555555); 
+        if ( !Abc_TtOnlyOneOne(Test) )
+            return 0;
+        fFound = 1;
+        *piVar = c * 32 + Abc_Tt6FirstBit(Test)/2;
+    }
+    return fFound;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Io_ReadPlaMarkIdentical( word ** pCs, int nCubes, int nWords, Vec_Bit_t * vMarks )
+{
+    int c1, c2;
+    Vec_BitFill( vMarks, nCubes, 0 );
+    for ( c1 = 0; c1 < nCubes; c1++ )
+        if ( !Vec_BitEntry(vMarks, c1) )
+            for ( c2 = c1 + 1; c2 < nCubes; c2++ )
+                if ( !Vec_BitEntry(vMarks, c2) )
+                    if ( Abc_TtEqual(pCs[c1], pCs[c2], nWords) )
+                        Vec_BitWriteEntry( vMarks, c2, 1 );
+}
+void Io_ReadPlaMarkContained( word ** pCs, int nCubes, int nWords, Vec_Bit_t * vMarks )
+{
+    int c1, c2;
+    Vec_BitFill( vMarks, nCubes, 0 );
+    for ( c1 = 0; c1 < nCubes; c1++ )
+        if ( !Vec_BitEntry(vMarks, c1) )
+            for ( c2 = c1 + 1; c2 < nCubes; c2++ )
+                if ( !Vec_BitEntry(vMarks, c2) )
+                {
+                    if ( Abc_TtImply(pCs[c1], pCs[c2], nWords) )
+                        Vec_BitWriteEntry( vMarks, c2, 1 );
+                    else if ( Abc_TtImply(pCs[c2], pCs[c1], nWords) )
+                    {
+                        Vec_BitWriteEntry( vMarks, c1, 1 );
+                        break;
+                    }
+                }
+}
+int Io_ReadPlaRemoveMarked( word ** pCs, int nCubes, int nWords, Vec_Bit_t * vMarks )
+{
+    int c1, c;
+    for ( c1 = c = 0; c1 < nCubes; c1++ )
+        if ( !Vec_BitEntry(vMarks, c1) )
+        {
+            if ( c == c1 )
+                c++;
+            else
+                Abc_TtCopy( pCs[c++], pCs[c1], nWords, 0 );
+        }
+    return c;
+}
+int Io_ReadPlaMergeDistance1( word ** pCs, int nCubes, int nWords, Vec_Bit_t * vMarks )
+{
+    int c1, c2, Res, Counter = 0;
+    Vec_BitFill( vMarks, nCubes, 0 );
+    for ( c1 = 0; c1 < nCubes; c1++ )
+        if ( !Vec_BitEntry(vMarks, c1) )
+            for ( c2 = c1 + 1; c2 < nCubes; c2++ )
+                if ( !Vec_BitEntry(vMarks, c2) )
+                {
+                    Res = Io_ReadPlaDistance1( pCs[c1], pCs[c2], nWords );
+                    if ( !Res )
+                        continue;
+                    Abc_TtAnd( pCs[c1], pCs[c1], pCs[c2], nWords, 0 );
+                    Vec_BitWriteEntry( vMarks, c2, 1 );
+                    Counter++;
+                    break;
+                }
+    return Counter;
+}
+int Io_ReadPlaSelfSubsumption( word ** pCs, int nCubes, int nWords, Vec_Bit_t * vMarks )
+{
+    int c1, c2, Res, Counter = 0, iVar = -1, Val0, Val1;
+    Vec_BitFill( vMarks, nCubes, 0 );
+    for ( c1 = 0; c1 < nCubes; c1++ )
+        if ( !Vec_BitEntry(vMarks, c1) )
+            for ( c2 = c1 + 1; c2 < nCubes; c2++ )
+                if ( !Vec_BitEntry(vMarks, c2) )
+                {
+                    Res = Io_ReadPlaConsensus( pCs[c1], pCs[c2], nWords, &iVar );
+                    if ( !Res )
+                        continue;
+                    assert( iVar >= 0  && iVar < nWords*32 );
+                    Val0 = Abc_TtGetQua( pCs[c1], iVar );
+                    Val1 = Abc_TtGetQua( pCs[c2], iVar );
+                    // remove values
+                    Abc_TtXorQua( pCs[c1], iVar, Val0 );
+                    Abc_TtXorQua( pCs[c2], iVar, Val1 );
+                    // check containment
+                    if ( Abc_TtImply(pCs[c1], pCs[c2], nWords) )
+                    {
+                        Abc_TtXorQua( pCs[c1], iVar, Val0 );
+                        Vec_BitWriteEntry( vMarks, c2, 1 );
+                        Counter++;
+                    }
+                    else if ( Abc_TtImply(pCs[c2], pCs[c1], nWords) )
+                    {
+                        Abc_TtXorQua( pCs[c2], iVar, Val1 );
+                        Vec_BitWriteEntry( vMarks, c1, 1 );
+                        Counter++;
+                        break;
+                    }
+                    else
+                    {
+                        Abc_TtXorQua( pCs[c1], iVar, Val0 );
+                        Abc_TtXorQua( pCs[c2], iVar, Val1 );
+                    }
+
+/*
+                    printf( "Var = %3d  ", iVar );
+                    printf( "Cube0 = %d  ", Abc_TtGetQua(pCs[c1], iVar) );
+                    printf( "Cube1 = %d  ", Abc_TtGetQua(pCs[c2], iVar) );
+                    printf( "\n" );
+                    Io_ReadPlaPrintCube( pCs[c1], 32 * nWords );
+                    Io_ReadPlaPrintCube( pCs[c2], 32 * nWords );
+                    printf( "\n" );
+*/
+                    break;
+                }
+    return Counter;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+word ** Io_ReadPlaCubeSetup( Vec_Str_t * vSop )
+{
+    char * pSop = Vec_StrArray( vSop ), * pCube, Lit;
+    int nCubes  = Abc_SopGetCubeNum( pSop );
+    int nVars   = Abc_SopGetVarNum( pSop );
+    int nWords  = Abc_Bit6WordNum( 2*nVars ), c, v;
+    word ** pCs = ABC_ALLOC( word *, nCubes );
+    pCs[0] = ABC_CALLOC( word, nCubes * nWords );
+    for ( c = 1; c < nCubes; c++ )
+        pCs[c] = pCs[c-1] + nWords;
+    c = 0;
+    Abc_SopForEachCube( pSop, nVars, pCube )
+    {
+        Abc_CubeForEachVar( pCube, Lit, v )
+            if ( Lit == '0' )
+                Abc_TtSetBit( pCs[c], Abc_Var2Lit(v,0) );
+            else if ( Lit == '1' )
+                Abc_TtSetBit( pCs[c], Abc_Var2Lit(v,1) );
+        c++;
+    }
+    assert( c == nCubes );
+    return pCs;
+}
+void Io_ReadPlaCubeSetdown( Vec_Str_t * vSop, word ** pCs, int nCubes, int nVars )
+{
+    char Symbs[3] = {'-', '0', '1'}; int c, v;
+    Vec_StrClear( vSop );
+    for ( c = 0; c < nCubes; c++ )
+    {
+        for ( v = 0; v < nVars; v++ )
+            Vec_StrPush( vSop, Symbs[Abc_TtGetQua(pCs[c], v)] );
+        Vec_StrPrintStr( vSop, " 1\n" );
+    }
+    Vec_StrPush( vSop, 0 );
+}
+void Io_ReadPlaCubePreprocess( Vec_Str_t * vSop, int iCover, int fVerbose )
+{
+    word ** pCs = Io_ReadPlaCubeSetup( vSop );
+    int nCubes  = Abc_SopGetCubeNum( Vec_StrArray(vSop) );
+    int nVars   = Abc_SopGetVarNum( Vec_StrArray(vSop) );
+    int nWords  = Abc_Bit6WordNum( 2*nVars );
+    int nCubesNew, Count, Iter = 0;
+    Vec_Bit_t * vMarks = Vec_BitStart( nCubes );
+    if ( fVerbose )
+        printf( "Cover %5d : V =%5d  C%d =%5d", iCover, nVars, Iter, nCubes );
+
+    do 
+    {
+        Iter++;
+        do 
+        {
+            // remove contained
+            Io_ReadPlaMarkContained( pCs, nCubes, nWords, vMarks );
+            nCubesNew = Io_ReadPlaRemoveMarked( pCs, nCubes, nWords, vMarks );
+            //if ( fVerbose )
+            //    printf( "  C =%5d", nCubes - nCubesNew );
+            nCubes = nCubesNew;
+            // merge distance-1
+            Count = Io_ReadPlaMergeDistance1( pCs, nCubes, nWords, vMarks );
+        } while ( Count );
+        if ( fVerbose )
+            printf( "  C%d =%5d", Iter, nCubes );
+        // try consensus
+        //Count = Io_ReadPlaSelfSubsumption( pCs, nCubes, nWords, vMarks );
+        if ( fVerbose )
+            printf( "%4d", Count );
+    } while ( Count );
+
+    // translate
+    Io_ReadPlaCubeSetdown( vSop, pCs, nCubes, nVars );
+    // finalize
+    if ( fVerbose )
+        printf( "\n" );
+    Vec_BitFree( vMarks );
+    ABC_FREE( pCs[0] );
+    ABC_FREE( pCs );
+}
 
 /**Function*************************************************************
 
@@ -269,7 +551,8 @@
             Vec_StrFree( ppSops[i] );
             continue;
         }
-        Vec_StrPush( ppSops[i], 0 );
+        Vec_StrPush( ppSops[i], 0 );
+        Io_ReadPlaCubePreprocess( ppSops[i], i, 0 );
         pNode->pData = Abc_SopRegister( (Mem_Flex_t *)pNtk->pManFunc, ppSops[i]->pArray );
         Vec_StrFree( ppSops[i] );
     }
diff --git a/abc-build/src/base/io/ioUtil.c b/abc-build/src/base/io/ioUtil.c
--- a/abc-build/src/base/io/ioUtil.c
+++ b/abc-build/src/base/io/ioUtil.c
@@ -157,8 +157,20 @@
         fprintf( stdout, "Reading network from file has failed.\n" );
         return NULL;
     }
-    if ( Abc_NtkBlackboxNum(pNtk) || Abc_NtkWhiteboxNum(pNtk) )
-        fprintf( stdout, "Warning: The network contains hierarchy.\n" );
+    if ( fCheck && (Abc_NtkBlackboxNum(pNtk) || Abc_NtkWhiteboxNum(pNtk)) )
+    {
+        int i, fCycle = 0;
+        Abc_Ntk_t * pModel;
+        fprintf( stdout, "Warning: The network contains hierarchy.\n" );
+        Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pModel, i )
+                if ( !Abc_NtkIsAcyclicWithBoxes( pModel ) )
+                    fCycle = 1;
+        if ( fCycle )
+        {
+            Abc_NtkDelete( pNtk );
+            return NULL;    
+        }
+    }
     return pNtk;
 }
 
@@ -387,6 +399,10 @@
         if ( !Abc_NtkToSop( pNtkTemp, 1 ) )
             return;
     }
+    else if ( FileType == IO_FILE_MOPLA )
+    {
+        pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
+    }
     else if ( FileType == IO_FILE_BENCH )
     {
         if ( !Abc_NtkIsStrash(pNtk) )
@@ -397,7 +413,7 @@
         pNtkTemp = Abc_NtkToNetlistBench( pNtk );
     }
     else if ( FileType == IO_FILE_SMV )
-    {
+    {
         if ( !Abc_NtkIsStrash(pNtk) )
         {
             fprintf( stdout, "Writing traditional SMV is available for AIGs only.\n" );
@@ -432,6 +448,8 @@
         Io_WriteBook( pNtkTemp, pFileName );
     else if ( FileType == IO_FILE_PLA )
         Io_WritePla( pNtkTemp, pFileName );
+    else if ( FileType == IO_FILE_MOPLA )
+        Io_WriteMoPla( pNtkTemp, pFileName );
     else if ( FileType == IO_FILE_EQN )
     {
         if ( !Abc_NtkHasAig(pNtkTemp) )
diff --git a/abc-build/src/base/io/ioWriteBench.c b/abc-build/src/base/io/ioWriteBench.c
--- a/abc-build/src/base/io/ioWriteBench.c
+++ b/abc-build/src/base/io/ioWriteBench.c
@@ -57,7 +57,7 @@
     assert( Abc_NtkIsSopNetlist(pNtk) );
     if ( !Io_WriteBenchCheckNames(pNtk) )
     {
-        fprintf( stdout, "Io_WriteBench(): Signal names in this benchmark contain parantheses making them impossible to reproduce in the BENCH format. Use \"short_names\".\n" );
+        fprintf( stdout, "Io_WriteBench(): Signal names in this benchmark contain parentheses making them impossible to reproduce in the BENCH format. Use \"short_names\".\n" );
         return 0;
     }
     pFile = fopen( pFileName, "w" );
@@ -179,7 +179,7 @@
     assert( Abc_NtkIsAigNetlist(pNtk) );
     if ( !Io_WriteBenchCheckNames(pNtk) )
     {
-        fprintf( stdout, "Io_WriteBenchLut(): Signal names in this benchmark contain parantheses making them impossible to reproduce in the BENCH format. Use \"short_names\".\n" );
+        fprintf( stdout, "Io_WriteBenchLut(): Signal names in this benchmark contain parentheses making them impossible to reproduce in the BENCH format. Use \"short_names\".\n" );
         return 0;
     }
     pFile = fopen( pFileName, "w" );
diff --git a/abc-build/src/base/io/ioWriteBlif.c b/abc-build/src/base/io/ioWriteBlif.c
--- a/abc-build/src/base/io/ioWriteBlif.c
+++ b/abc-build/src/base/io/ioWriteBlif.c
@@ -614,10 +614,19 @@
     int RetValue = 0;
     if ( Abc_NtkHasMapping(pNode->pNtk) )
     {
-        // write the .gate line
-        fprintf( pFile, ".gate" );
-        RetValue = Io_NtkWriteNodeGate( pFile, pNode, Length );
-        fprintf( pFile, "\n" );
+        // write the .gate line
+        if ( Abc_ObjIsBarBuf(pNode) )
+        {
+            fprintf( pFile, ".barbuf " );
+            fprintf( pFile, "%s %s", Abc_ObjName(Abc_ObjFanin0(pNode)), Abc_ObjName(Abc_ObjFanout0(pNode)) );
+            fprintf( pFile, "\n" );
+        }
+        else
+        {
+            fprintf( pFile, ".gate" );
+            RetValue = Io_NtkWriteNodeGate( pFile, pNode, Length );
+            fprintf( pFile, "\n" );
+        }
     }
     else
     {
diff --git a/abc-build/src/base/io/ioWriteEqn.c b/abc-build/src/base/io/ioWriteEqn.c
--- a/abc-build/src/base/io/ioWriteEqn.c
+++ b/abc-build/src/base/io/ioWriteEqn.c
@@ -219,7 +219,7 @@
     int i, k, Length;
     int RetValue = 1;
 
-    // make sure the network does not have proper names, such as "0" or "1" or containing parantheses
+    // make sure the network does not have proper names, such as "0" or "1" or containing parentheses
     Abc_NtkForEachObj( pNtk, pObj, i )
     {
         pName = Nm_ManFindNameById(pNtk->pManName, i);
diff --git a/abc-build/src/base/io/ioWriteList.c b/abc-build/src/base/io/ioWriteList.c
--- a/abc-build/src/base/io/ioWriteList.c
+++ b/abc-build/src/base/io/ioWriteList.c
@@ -38,7 +38,7 @@
 simply list all vertices, one per line and for each vertex "V_source" I
 list all vertices that are "sinks" with respect to it, i.e. such that
 there is a distinct arc between "V_source" and each of them (in
-paranthesis I list the name of the edge and its weight (number of latency
+parenthesis I list the name of the edge and its weight (number of latency
 on that path). For instance, if you look at the following graph, you have
 that vertex "v_5" is connected to vertex "v_6" through a directed arc
 called "v_5_to_v_6" whose latency is equal to 3, i.e. there are three
diff --git a/abc-build/src/base/io/ioWritePla.c b/abc-build/src/base/io/ioWritePla.c
--- a/abc-build/src/base/io/ioWritePla.c
+++ b/abc-build/src/base/io/ioWritePla.c
@@ -19,6 +19,7 @@
 ***********************************************************************/
 
 #include "ioAbc.h"
+#include "misc/extra/extraBdd.h"
 
 ABC_NAMESPACE_IMPL_START
 
@@ -27,8 +28,6 @@
 ///                        DECLARATIONS                              ///
 ////////////////////////////////////////////////////////////////////////
 
-static int    Io_WritePlaOne( FILE * pFile, Abc_Ntk_t * pNtk );
-
 ////////////////////////////////////////////////////////////////////////
 ///                     FUNCTION DEFINITIONS                         ///
 ////////////////////////////////////////////////////////////////////////
@@ -44,43 +43,6 @@
   SeeAlso     []
 
 ***********************************************************************/
-int Io_WritePla( Abc_Ntk_t * pNtk, char * pFileName )
-{
-    Abc_Ntk_t * pExdc;
-    FILE * pFile;
-
-    assert( Abc_NtkIsSopNetlist(pNtk) );
-    assert( Abc_NtkLevel(pNtk) == 1 );
-
-    pFile = fopen( pFileName, "w" );
-    if ( pFile == NULL )
-    {
-        fprintf( stdout, "Io_WritePla(): Cannot open the output file.\n" );
-        return 0;
-    }
-    fprintf( pFile, "# Benchmark \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
-    // write the network
-    Io_WritePlaOne( pFile, pNtk );
-    // write EXDC network if it exists
-    pExdc = Abc_NtkExdc( pNtk );
-    if ( pExdc )
-        printf( "Io_WritePla: EXDC is not written (warning).\n" );
-    // finalize the file
-    fclose( pFile );
-    return 1;
-}
-
-/**Function*************************************************************
-
-  Synopsis    [Writes the network in PLA format.]
-
-  Description []
-               
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
 int Io_WritePlaOne( FILE * pFile, Abc_Ntk_t * pNtk )
 {
     ProgressBar * pProgress;
@@ -191,7 +153,293 @@
     ABC_FREE( pCubeOut );
     return 1;
 }
+
+/**Function*************************************************************
+
+  Synopsis    [Writes the network in PLA format.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Io_WritePla( Abc_Ntk_t * pNtk, char * pFileName )
+{
+    Abc_Ntk_t * pExdc;
+    FILE * pFile;
+
+    assert( Abc_NtkIsSopNetlist(pNtk) );
+    assert( Abc_NtkLevel(pNtk) == 1 );
+
+    pFile = fopen( pFileName, "w" );
+    if ( pFile == NULL )
+    {
+        fprintf( stdout, "Io_WritePla(): Cannot open the output file.\n" );
+        return 0;
+    }
+    fprintf( pFile, "# Benchmark \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
+    // write the network
+    Io_WritePlaOne( pFile, pNtk );
+    // write EXDC network if it exists
+    pExdc = Abc_NtkExdc( pNtk );
+    if ( pExdc )
+        printf( "Io_WritePla: EXDC is not written (warning).\n" );
+    // finalize the file
+    fclose( pFile );
+    return 1;
+}
 
+
+/**Function*************************************************************
+
+  Synopsis    [Writes the network in PLA format.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Io_WriteMoPlaOneInt( FILE * pFile, Abc_Ntk_t * pNtk, DdManager * dd, Vec_Ptr_t * vFuncs )
+{
+    Abc_Obj_t * pNode;
+    DdNode * bOnset, * bOffset, * bCube, * bFunc, * bTemp, * zCover;
+    int i, k, nInputs, nOutputs;
+    int nCubes, fPhase;
+
+    assert( Vec_PtrSize(vFuncs) == Abc_NtkCoNum(pNtk) );
+    assert( dd->size == Abc_NtkCiNum(pNtk) );
+    assert( dd->size <= 1000 );
+
+    // collect the parameters
+    nInputs   = Abc_NtkCiNum(pNtk);
+    nOutputs  = Abc_NtkCoNum(pNtk);
+    assert( nOutputs > 1 );
+
+    // create extra variables
+    for ( i = 0; i < nOutputs; i++ )
+        Cudd_bddNewVarAtLevel( dd, i );
+    assert( dd->size == nInputs + nOutputs );
+
+    // create ON and OFF sets
+    bOnset = Cudd_ReadLogicZero( dd );  Cudd_Ref(bOnset);
+    bOffset = Cudd_ReadLogicZero( dd ); Cudd_Ref(bOffset);
+    for ( i = 0; i < nOutputs; i++ )
+    {
+        bFunc = (DdNode *)Vec_PtrEntry(vFuncs, i);
+        // create onset
+        bCube = Cudd_bddAnd( dd, Cudd_bddIthVar(dd, nInputs+i), bFunc );  Cudd_Ref(bCube);
+        for ( k = 0; k < nOutputs; k++ ) 
+            if ( k != i )
+            {
+                bCube = Cudd_bddAnd( dd, bTemp = bCube, Cudd_Not(Cudd_bddIthVar(dd, nInputs+k)) );  Cudd_Ref(bCube);
+                Cudd_RecursiveDeref( dd, bTemp );
+            }
+        bOnset = Cudd_bddOr( dd, bTemp = bOnset, bCube );   Cudd_Ref(bOnset);
+        Cudd_RecursiveDeref( dd, bTemp );
+        Cudd_RecursiveDeref( dd, bCube );
+        // create offset
+        bCube = Cudd_bddAnd( dd, Cudd_bddIthVar(dd, nInputs+i), Cudd_Not(bFunc) );  Cudd_Ref(bCube);
+        bOffset = Cudd_bddOr( dd, bTemp = bOffset, bCube );                         Cudd_Ref(bOffset);
+        Cudd_RecursiveDeref( dd, bTemp );
+        Cudd_RecursiveDeref( dd, bCube );
+
+        printf( "Trying %d output.\n", i );
+        printf( "Onset = %d nodes.\n", Cudd_DagSize(bOnset) );
+        printf( "Offset = %d nodes.\n", Cudd_DagSize(bOffset) );
+    }
+
+    Cudd_zddVarsFromBddVars( dd, 2 );
+
+    // derive ISOP
+    {
+        extern int Abc_CountZddCubes( DdManager * dd, DdNode * zCover );
+        DdNode * bCover, * zCover0, * zCover1;
+        int nCubes0, nCubes1;
+        // get the ZDD of the negative polarity
+        bCover = Cudd_zddIsop( dd, bOffset, Cudd_Not(bOnset), &zCover0 );
+        Cudd_Ref( zCover0 );
+        Cudd_Ref( bCover );
+        Cudd_RecursiveDeref( dd, bCover );
+        nCubes0 = Abc_CountZddCubes( dd, zCover0 );
+
+        // get the ZDD of the positive polarity
+        bCover = Cudd_zddIsop( dd, bOnset, Cudd_Not(bOffset), &zCover1 );
+        Cudd_Ref( zCover1 );
+        Cudd_Ref( bCover );
+        Cudd_RecursiveDeref( dd, bCover );
+        nCubes1 = Abc_CountZddCubes( dd, zCover1 );
+
+        // compare the number of cubes
+        if ( nCubes1 <= nCubes0 )
+        { // use positive polarity
+            nCubes = nCubes1;
+            zCover = zCover1;
+            Cudd_RecursiveDerefZdd( dd, zCover0 );
+            fPhase = 1;
+        }
+        else
+        { // use negative polarity
+            nCubes = nCubes0;
+            zCover = zCover0;
+            Cudd_RecursiveDerefZdd( dd, zCover1 );
+            fPhase = 0;
+        }
+    }
+    Cudd_RecursiveDeref( dd, bOnset );
+    Cudd_RecursiveDeref( dd, bOffset );
+    Cudd_RecursiveDerefZdd( dd, zCover );
+    printf( "Cover = %d nodes.\n", Cudd_DagSize(zCover) );
+    printf( "ISOP = %d\n", nCubes );
+
+    // write the header
+    fprintf( pFile, ".i %d\n", nInputs );
+    fprintf( pFile, ".o %d\n", nOutputs );
+    fprintf( pFile, ".ilb" );
+    Abc_NtkForEachCi( pNtk, pNode, i )
+        fprintf( pFile, " %s", Abc_ObjName(pNode) );
+    fprintf( pFile, "\n" );
+    fprintf( pFile, ".ob" );
+    Abc_NtkForEachCo( pNtk, pNode, i )
+        fprintf( pFile, " %s", Abc_ObjName(pNode) );
+    fprintf( pFile, "\n" );
+    fprintf( pFile, ".p %d\n", nCubes );
+
+
+    fprintf( pFile, ".e\n" );
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Writes the network in PLA format.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Io_WriteMoPlaOneIntMinterms( FILE * pFile, Abc_Ntk_t * pNtk, DdManager * dd, Vec_Ptr_t * vFuncs )
+{
+    int pValues[1000];
+    Abc_Obj_t * pNode;
+    int i, k, nProducts, nInputs, nOutputs;
+    assert( Vec_PtrSize(vFuncs) == Abc_NtkCoNum(pNtk) );
+    assert( dd->size == Abc_NtkCiNum(pNtk) );
+    assert( dd->size <= 1000 );
+
+    // collect the parameters
+    nInputs   = Abc_NtkCiNum(pNtk);
+    nOutputs  = Abc_NtkCoNum(pNtk);
+    nProducts = (1 << nInputs);
+
+    // write the header
+    fprintf( pFile, ".i %d\n", nInputs );
+    fprintf( pFile, ".o %d\n", nOutputs );
+    fprintf( pFile, ".ilb" );
+    Abc_NtkForEachCi( pNtk, pNode, i )
+        fprintf( pFile, " %s", Abc_ObjName(pNode) );
+    fprintf( pFile, "\n" );
+    fprintf( pFile, ".ob" );
+    Abc_NtkForEachCo( pNtk, pNode, i )
+        fprintf( pFile, " %s", Abc_ObjName(pNode) );
+    fprintf( pFile, "\n" );
+    fprintf( pFile, ".p %d\n", nProducts );
+
+    // iterate through minterms
+    for ( k = 0; k < nProducts; k++ )
+    {
+        for ( i = 0; i < nInputs; i++ )
+            fprintf( pFile, "%c", '0' + (pValues[i] = ((k >> i) & 1)) );
+        fprintf( pFile, " " );
+        for ( i = 0; i < nOutputs; i++ )
+            fprintf( pFile, "%c", '0' + (Cudd_ReadOne(dd) == Cudd_Eval(dd, (DdNode *)Vec_PtrEntry(vFuncs, i), pValues)) );
+        fprintf( pFile, "\n" );
+    }
+
+    fprintf( pFile, ".e\n" );
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Writes the network in PLA format.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Io_WriteMoPlaOne( FILE * pFile, Abc_Ntk_t * pNtk )
+{
+    int fVerbose = 1;
+    DdManager * dd;
+    DdNode * bFunc;
+    Vec_Ptr_t * vFuncsGlob;
+    Abc_Obj_t * pObj;
+    int i;
+    assert( Abc_NtkIsStrash(pNtk) );
+    dd = (DdManager *)Abc_NtkBuildGlobalBdds( pNtk, 10000000, 1, 1, fVerbose );
+    if ( dd == NULL )
+        return 0;
+    if ( fVerbose )
+        printf( "Shared BDD size = %6d nodes.\n", Cudd_ReadKeys(dd) - Cudd_ReadDead(dd) );
+
+    // complement the global functions
+    vFuncsGlob = Vec_PtrAlloc( Abc_NtkCoNum(pNtk) );
+    Abc_NtkForEachCo( pNtk, pObj, i )
+        Vec_PtrPush( vFuncsGlob, Abc_ObjGlobalBdd(pObj) );
+
+    // consider minterms
+    Io_WriteMoPlaOneIntMinterms( pFile, pNtk, dd, vFuncsGlob );
+    Abc_NtkFreeGlobalBdds( pNtk, 0 );
+
+    // cleanup
+    Vec_PtrForEachEntry( DdNode *, vFuncsGlob, bFunc, i )
+        Cudd_RecursiveDeref( dd, bFunc );
+    Vec_PtrFree( vFuncsGlob );
+    Extra_StopManager( dd );
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Writes the network in PLA format.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Io_WriteMoPla( Abc_Ntk_t * pNtk, char * pFileName )
+{
+    FILE * pFile;
+    assert( Abc_NtkIsStrash(pNtk) );
+    if ( Abc_NtkCiNum(pNtk) > 16 )
+    {
+        printf( "Cannot write multi-output PLA for more than 16 inputs.\n" );
+        return 0;
+    }    
+    pFile = fopen( pFileName, "w" );
+    if ( pFile == NULL )
+    {
+        fprintf( stdout, "Io_WritePla(): Cannot open the output file.\n" );
+        return 0;
+    }
+    fprintf( pFile, "# Benchmark \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
+    Io_WriteMoPlaOne( pFile, pNtk );
+    fclose( pFile );
+    return 1;
+}
 
 ////////////////////////////////////////////////////////////////////////
 ///                       END OF FILE                                ///
diff --git a/abc-build/src/base/io/ioWriteSmv.c b/abc-build/src/base/io/ioWriteSmv.c
--- a/abc-build/src/base/io/ioWriteSmv.c
+++ b/abc-build/src/base/io/ioWriteSmv.c
@@ -75,7 +75,7 @@
     assert( Abc_NtkIsSopNetlist(pNtk) );
     if ( !Io_WriteSmvCheckNames(pNtk) )
     {
-        fprintf( stdout, "Io_WriteSmv(): Signal names in this benchmark contain parantheses making them impossible to reproduce in the SMV format. Use \"short_names\".\n" );
+        fprintf( stdout, "Io_WriteSmv(): Signal names in this benchmark contain parentheses making them impossible to reproduce in the SMV format. Use \"short_names\".\n" );
         return 0;
     }
     pFile = fopen( pFileName, "w" );
diff --git a/abc-build/src/base/main/main.c b/abc-build/src/base/main/main.c
--- a/abc-build/src/base/main/main.c
+++ b/abc-build/src/base/main/main.c
@@ -1,384 +1,6 @@
-/*////////////////////////////////////////////////////////////////////////////
-
-ABC: System for Sequential Synthesis and Verification
-
-http://www.eecs.berkeley.edu/~alanmi/abc/
-
-Copyright (c) The Regents of the University of California. All rights reserved.
-
-Permission is hereby granted, without written agreement and without license or
-royalty fees, to use, copy, modify, and distribute this software and its
-documentation for any purpose, provided that the above copyright notice and
-the following two paragraphs appear in all copies of this software.
-
-IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
-DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
-THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
-CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS,
-AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
-SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
-
-////////////////////////////////////////////////////////////////////////////*/
-
-/**CFile****************************************************************
-
-  FileName    [main.c]
-
-  SystemName  [ABC: Logic synthesis and verification system.]
-
-  PackageName [The main package.]
-
-  Synopsis    [Here everything starts.]
-
-  Author      [Alan Mishchenko]
-  
-  Affiliation [UC Berkeley]
-
-  Date        [Ver. 1.0. Started - June 20, 2005.]
-
-  Revision    [$Id: main.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-
-#ifdef ABC_PYTHON_EMBED
-#include <Python.h>
-#endif /* ABC_PYTHON_EMBED */
-
-#include "base/abc/abc.h"
-#include "mainInt.h"
-
-ABC_NAMESPACE_IMPL_START
-
-// this line should be included in the library project
-//#define ABC_LIB
-
-//#define ABC_USE_BINARY 1
-
-////////////////////////////////////////////////////////////////////////
-///                        DECLARATIONS                              ///
-////////////////////////////////////////////////////////////////////////
-
-static int TypeCheck( Abc_Frame_t * pAbc, const char * s);
-
-////////////////////////////////////////////////////////////////////////
-///                     FUNCTION DEFINITIONS                         ///
-////////////////////////////////////////////////////////////////////////
-
-#ifndef ABC_LIB
-
-/**Function*************************************************************
-
-  Synopsis    [The main() procedure.]
-
-  Description []
-               
-  SideEffects []
-
-  SeeAlso     []
-
-***********************************************************************/
-int Abc_RealMain( int argc, char * argv[] )
-{
-    Abc_Frame_t * pAbc;
-    char sCommandUsr[ABC_MAX_STR] = {0}, sCommandTmp[ABC_MAX_STR], sReadCmd[1000], sWriteCmd[1000];
-    const char * sOutFile, * sInFile;
-    char * sCommand;
-    int  fStatus = 0;
-    int c, fInitSource, fInitRead, fFinalWrite;
-
-    enum {
-        INTERACTIVE, // interactive mode
-        BATCH, // batch mode, run a command and quit
-        BATCH_THEN_INTERACTIVE, // run a command, then back to interactive mode
-        BATCH_QUIET // as in batch mode, but don't echo the command
-    } fBatch;
-
-    // added to detect memory leaks
-    // watch for {,,msvcrtd.dll}*__p__crtBreakAlloc()
-    // (http://support.microsoft.com/kb/151585)
-#if defined(_DEBUG) && defined(_MSC_VER)
-    _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
-#endif
-
-    // get global frame (singleton pattern)
-    // will be initialized on first call
-    pAbc = Abc_FrameGetGlobalFrame();
-    pAbc->sBinary = argv[0];
-
-#ifdef ABC_PYTHON_EMBED
-    {
-        PyObject* pModule;
-        void init_pyabc(void);
-
-        Py_SetProgramName(argv[0]);
-        Py_NoSiteFlag = 1;
-        Py_Initialize();
-
-        init_pyabc();
-
-        pModule = PyImport_ImportModule("pyabc");
-        if (pModule)
-        {
-            Py_DECREF(pModule);
-        }
-        else
-        {
-            fprintf( pAbc->Err, "error: pyabc.py not found. PYTHONPATH may not be set properly.\n");
-        }
-    }
-#endif /* ABC_PYTHON_EMBED */
-
-    // default options
-    fBatch      = INTERACTIVE;
-    fInitSource = 1;
-    fInitRead   = 0;
-    fFinalWrite = 0;
-    sInFile = sOutFile = NULL;
-    sprintf( sReadCmd,  "read"  );
-    sprintf( sWriteCmd, "write" );
-
-    Extra_UtilGetoptReset();
-    while ((c = Extra_UtilGetopt(argc, argv, "c:q:C:hf:F:o:st:T:xb")) != EOF) {
-        switch(c) {
-            case 'c':
-                strcpy( sCommandUsr, globalUtilOptarg );
-                fBatch = BATCH;
-                break;
-
-            case 'q':
-                strcpy( sCommandUsr, globalUtilOptarg );
-                fBatch = BATCH_QUIET;
-                break;
-
-            case 'C':
-                strcpy( sCommandUsr, globalUtilOptarg );
-                fBatch = BATCH_THEN_INTERACTIVE;
-                break;
-
-            case 'f':
-                sprintf(sCommandUsr, "source %s", globalUtilOptarg);
-                fBatch = BATCH;
-                break;
-
-            case 'F':
-                sprintf(sCommandUsr, "source -x %s", globalUtilOptarg);
-                fBatch = BATCH;
-                break;
-
-            case 'h':
-                goto usage;
-                break;
-
-            case 'o':
-                sOutFile = globalUtilOptarg;
-                fFinalWrite = 1;
-                break;
-
-            case 's':
-                fInitSource = 0;
-                break;
-
-            case 't':
-                if ( TypeCheck( pAbc, globalUtilOptarg ) )
-                {
-                    if ( !strcmp(globalUtilOptarg, "none") == 0 )
-                    {
-                        fInitRead = 1;
-                        sprintf( sReadCmd, "read_%s", globalUtilOptarg );
-                    }
-                }
-                else {
-                    goto usage;
-                }
-                fBatch = BATCH;
-                break;
-
-            case 'T':
-                if ( TypeCheck( pAbc, globalUtilOptarg ) )
-                {
-                    if (!strcmp(globalUtilOptarg, "none") == 0)
-                    {
-                        fFinalWrite = 1;
-                        sprintf( sWriteCmd, "write_%s", globalUtilOptarg);
-                    }
-                }
-                else {
-                    goto usage;
-                }
-                fBatch = BATCH;
-                break;
-
-            case 'x':
-                fFinalWrite = 0;
-                fInitRead   = 0;
-                fBatch = BATCH;
-                break;
-
-            case 'b':
-                Abc_FrameSetBridgeMode();
-                break;
-
-            default:
-                goto usage;
-        }
-    }
-
-    if ( Abc_FrameIsBridgeMode() )
-    {
-        extern Gia_Man_t * Gia_ManFromBridge( FILE * pFile, Vec_Int_t ** pvInit );
-        pAbc->pGia = Gia_ManFromBridge( stdin, NULL );
-    }
-    else if ( fBatch!=INTERACTIVE && fBatch!=BATCH_QUIET && sCommandUsr[0] )
-        Abc_Print( 1, "ABC command line: \"%s\".\n\n", sCommandUsr );
-
-    if ( fBatch!=INTERACTIVE )
-    {
-        pAbc->fBatchMode = 1;
-
-
-        if (argc - globalUtilOptind == 0)
-        {
-            sInFile = NULL;
-        }
-        else if (argc - globalUtilOptind == 1)
-        {
-            fInitRead = 1;
-            sInFile = argv[globalUtilOptind];
-        }
-        else
-        {
-            Abc_UtilsPrintUsage( pAbc, argv[0] );
-        }
-
-        // source the resource file
-        if ( fInitSource )
-        {
-            Abc_UtilsSource( pAbc );
-        }
-
-        fStatus = 0;
-        if ( fInitRead && sInFile )
-        {
-            sprintf( sCommandTmp, "%s %s", sReadCmd, sInFile );
-            fStatus = Cmd_CommandExecute( pAbc, sCommandTmp );
-        }
-
-        if ( fStatus == 0 )
-        {
-            /* cmd line contains `source <file>' */
-            fStatus = Cmd_CommandExecute( pAbc, sCommandUsr );
-            if ( (fStatus == 0 || fStatus == -1) && fFinalWrite && sOutFile )
-            {
-                sprintf( sCommandTmp, "%s %s", sWriteCmd, sOutFile );
-                fStatus = Cmd_CommandExecute( pAbc, sCommandTmp );
-            }
-        }
-
-        if (fBatch == BATCH_THEN_INTERACTIVE){
-            fBatch = INTERACTIVE;
-            pAbc->fBatchMode = 0;
-        }
-
-    }
-
-    if ( fBatch==INTERACTIVE )
-    {
-        // start interactive mode
-
-        // print the hello line
-        Abc_UtilsPrintHello( pAbc );
-        // print history of the recent commands
-        Cmd_HistoryPrint( pAbc, 10 );
-
-        // source the resource file
-        if ( fInitSource )
-        {
-            Abc_UtilsSource( pAbc );
-        }
-
-        // execute commands given by the user
-        while ( !feof(stdin) )
-        {
-            // print command line prompt and
-            // get the command from the user
-            sCommand = Abc_UtilsGetUsersInput( pAbc );
-
-            // execute the user's command
-            fStatus = Cmd_CommandExecute( pAbc, sCommand );
-
-            // stop if the user quitted or an error occurred
-            if ( fStatus == -1 || fStatus == -2 )
-                break;
-        }
-    }
-
-#ifdef ABC_PYTHON_EMBED
-    {
-        Py_Finalize();
-    }
-#endif /* ABC_PYTHON_EMBED */
-
-    // if the memory should be freed, quit packages
-//    if ( fStatus < 0 ) 
-    {
-        Abc_Stop();
-    }
-    return 0;
-
-usage:
-    Abc_UtilsPrintHello( pAbc );
-    Abc_UtilsPrintUsage( pAbc, argv[0] );
-    return 1;
-}
-
-#endif
-
-/**Function********************************************************************
-
-  Synopsis    [Returns 1 if s is a file type recognized, else returns 0.]
-
-  Description [Returns 1 if s is a file type recognized by ABC, else returns 0. 
-  Recognized types are "blif", "bench", "pla", and "none".]
-
-  SideEffects []
-
-******************************************************************************/
-static int TypeCheck( Abc_Frame_t * pAbc, const char * s )
-{
-    if (strcmp(s, "blif") == 0)
-        return 1;
-    else if (strcmp(s, "bench") == 0)
-        return 1;
-    else if (strcmp(s, "pla") == 0)
-        return 1;
-    else if (strcmp(s, "none") == 0)
-        return 1;
-    else {
-        fprintf( pAbc->Err, "unknown type %s\n", s );
-        return 0;
-    }
-}
-
-
-
-
-////////////////////////////////////////////////////////////////////////
-///                       END OF FILE                                ///
-////////////////////////////////////////////////////////////////////////
-
-
-ABC_NAMESPACE_IMPL_END
-
-#if defined(ABC_USE_BINARY)
-int main_( int argc, char * argv[] )
-#else
-int main( int argc, char * argv[] )
-#endif
-{
-  return ABC_NAMESPACE_PREFIX Abc_RealMain(argc, argv);
-}
+extern int Abc_RealMain(int argc, char *argv[]);
+
+int main(int argc, char *argv[])
+{
+   return Abc_RealMain(argc, argv);
+}
diff --git a/abc-build/src/base/main/mainFrame.c b/abc-build/src/base/main/mainFrame.c
--- a/abc-build/src/base/main/mainFrame.c
+++ b/abc-build/src/base/main/mainFrame.c
@@ -198,6 +198,7 @@
     if ( p->pSave4    )  Aig_ManStop( (Aig_Man_t *)p->pSave4 );
     if ( p->pManDsd   )  If_DsdManFree( (If_DsdMan_t *)p->pManDsd, 0 );
     if ( p->pManDsd2  )  If_DsdManFree( (If_DsdMan_t *)p->pManDsd2, 0 );
+    if ( p->pNtkBackup)  Abc_NtkDelete( p->pNtkBackup );
     if ( p->vPlugInComBinPairs ) 
     {
         char * pTemp;
diff --git a/abc-build/src/base/main/mainInit.c b/abc-build/src/base/main/mainInit.c
--- a/abc-build/src/base/main/mainInit.c
+++ b/abc-build/src/base/main/mainInit.c
@@ -22,9 +22,6 @@
 #include "mainInt.h"
 
 ABC_NAMESPACE_IMPL_START
-
-//#define USE_ABC2
-//#define USE_ABC85
  
 ////////////////////////////////////////////////////////////////////////
 ///                        DECLARATIONS                              ///
@@ -52,6 +49,8 @@
 extern void Scl_End( Abc_Frame_t * pAbc );
 extern void Wlc_Init( Abc_Frame_t * pAbc );
 extern void Wlc_End( Abc_Frame_t * pAbc );
+extern void Cba_Init( Abc_Frame_t * pAbc );
+extern void Cba_End( Abc_Frame_t * pAbc );
 extern void Test_Init( Abc_Frame_t * pAbc );
 extern void Test_End( Abc_Frame_t * pAbc );
 extern void Abc2_Init( Abc_Frame_t * pAbc );
@@ -59,6 +58,24 @@
 extern void Abc85_Init( Abc_Frame_t * pAbc );
 extern void Abc85_End( Abc_Frame_t * pAbc );
 
+static Abc_FrameInitializer_t* s_InitializerStart = NULL;
+static Abc_FrameInitializer_t* s_InitializerEnd = NULL;
+
+void Abc_FrameAddInitializer( Abc_FrameInitializer_t* p )
+{
+	if( ! s_InitializerStart )
+		s_InitializerStart = p;
+
+	p->next = NULL;
+	p->prev = s_InitializerEnd;
+
+	if ( s_InitializerEnd )
+		s_InitializerEnd->next = p;
+
+	s_InitializerEnd = p;
+
+}
+
 ////////////////////////////////////////////////////////////////////////
 ///                     FUNCTION DEFINITIONS                         ///
 ////////////////////////////////////////////////////////////////////////
@@ -76,6 +93,7 @@
 ***********************************************************************/
 void Abc_FrameInit( Abc_Frame_t * pAbc )
 {
+    Abc_FrameInitializer_t* p;
     Cmd_Init( pAbc );
     Cmd_CommandExecute( pAbc, "set checkread" ); 
     Io_Init( pAbc );
@@ -88,14 +106,11 @@
     Load_Init( pAbc );
     Scl_Init( pAbc );
     Wlc_Init( pAbc );
+    Cba_Init( pAbc );
     Test_Init( pAbc );
-#ifdef USE_ABC2
-    Abc2_Init( pAbc );
-#endif
-#ifdef USE_ABC85
-    Abc85_Init( pAbc );
-#endif
-    EXT_ABC_INIT(pAbc) // plugin for external functionality
+    for( p = s_InitializerStart ; p ; p = p->next )
+    	if(p->init)
+    		p->init(pAbc);
 }
 
 
@@ -112,6 +127,10 @@
 ***********************************************************************/
 void Abc_FrameEnd( Abc_Frame_t * pAbc )
 {
+    Abc_FrameInitializer_t* p;
+    for( p = s_InitializerEnd ; p ; p = p->prev )
+    	if ( p->destroy )
+    		p->destroy(pAbc);
     Abc_End( pAbc );
     Io_End( pAbc );
     Cmd_End( pAbc );
@@ -123,14 +142,8 @@
     Load_End( pAbc );
     Scl_End( pAbc );
     Wlc_End( pAbc );
+    Cba_End( pAbc );
     Test_End( pAbc );
-#ifdef USE_ABC2
-    Abc2_End( pAbc );
-#endif
-#ifdef USE_ABC85
-    Abc85_End( pAbc );
-#endif
-    EXT_ABC_END(pAbc) // plugin for external functionality
 }
 
 
diff --git a/abc-build/src/base/main/mainInt.h b/abc-build/src/base/main/mainInt.h
--- a/abc-build/src/base/main/mainInt.h
+++ b/abc-build/src/base/main/mainInt.h
@@ -35,7 +35,6 @@
 #include "proof/fra/fra.h"
 //#include "aig/nwk/nwkMerge.h"
 //#include "aig/ntl/ntlnwk.h"
-#include "misc/ext/ext.h"
 #include "misc/extra/extraBdd.h"
 
 ABC_NAMESPACE_HEADER_START
@@ -68,6 +67,7 @@
     Abc_Ntk_t *     pNtkCur;       // the current network
     Abc_Ntk_t *     pNtkBestDelay; // the current network
     Abc_Ntk_t *     pNtkBestArea;  // the current network
+    Abc_Ntk_t *     pNtkBackup;    // the current network
     int             nSteps;        // the counter of different network processed
     int             fSource;       // marks the source mode
     int             fAutoexac;     // marks the autoexec mode
@@ -127,8 +127,21 @@
     void *          pAbc85Best;
     void *          pAbc85Delay;
     void *          pAbcWlc;
+    void *          pAbcCba;
+};
 
-    EXT_ABC_FRAME   // plugin for external functionality
+typedef void (*Abc_Frame_Initialization_Func)( Abc_Frame_t * pAbc );
+
+struct Abc_FrameInitializer_t_;
+typedef struct Abc_FrameInitializer_t_ Abc_FrameInitializer_t;
+
+struct Abc_FrameInitializer_t_
+{
+	Abc_Frame_Initialization_Func init;
+	Abc_Frame_Initialization_Func destroy;
+
+	Abc_FrameInitializer_t* next;
+	Abc_FrameInitializer_t* prev;
 };
 
 ////////////////////////////////////////////////////////////////////////
@@ -149,6 +162,7 @@
 /*=== mvInit.c ===================================================*/
 extern ABC_DLL void            Abc_FrameInit( Abc_Frame_t * pAbc );
 extern ABC_DLL void            Abc_FrameEnd( Abc_Frame_t * pAbc );
+extern ABC_DLL void            Abc_FrameAddInitializer( Abc_FrameInitializer_t* p );
 /*=== mvFrame.c =====================================================*/
 extern ABC_DLL Abc_Frame_t *   Abc_FrameAllocate();
 extern ABC_DLL void            Abc_FrameDeallocate( Abc_Frame_t * p );
diff --git a/abc-build/src/base/main/mainReal.c b/abc-build/src/base/main/mainReal.c
new file mode 100644
--- /dev/null
+++ b/abc-build/src/base/main/mainReal.c
@@ -0,0 +1,369 @@
+/*////////////////////////////////////////////////////////////////////////////
+
+ABC: System for Sequential Synthesis and Verification
+
+http://www.eecs.berkeley.edu/~alanmi/abc/
+
+Copyright (c) The Regents of the University of California. All rights reserved.
+
+Permission is hereby granted, without written agreement and without license or
+royalty fees, to use, copy, modify, and distribute this software and its
+documentation for any purpose, provided that the above copyright notice and
+the following two paragraphs appear in all copies of this software.
+
+IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS,
+AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+////////////////////////////////////////////////////////////////////////////*/
+
+/**CFile****************************************************************
+
+  FileName    [main.c]
+
+  SystemName  [ABC: Logic synthesis and verification system.]
+
+  PackageName [The main package.]
+
+  Synopsis    [Here everything starts.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - June 20, 2005.]
+
+  Revision    [$Id: main.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+
+#ifdef ABC_PYTHON_EMBED
+#include <Python.h>
+#endif /* ABC_PYTHON_EMBED */
+
+#include "base/abc/abc.h"
+#include "mainInt.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+static int TypeCheck( Abc_Frame_t * pAbc, const char * s);
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+
+/**Function*************************************************************
+
+  Synopsis    [The main() procedure.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_RealMain( int argc, char * argv[] )
+{
+    Abc_Frame_t * pAbc;
+    char sCommandUsr[ABC_MAX_STR] = {0}, sCommandTmp[ABC_MAX_STR], sReadCmd[1000], sWriteCmd[1000];
+    const char * sOutFile, * sInFile;
+    char * sCommand;
+    int  fStatus = 0;
+    int c, fInitSource, fInitRead, fFinalWrite;
+
+    enum {
+        INTERACTIVE, // interactive mode
+        BATCH, // batch mode, run a command and quit
+        BATCH_THEN_INTERACTIVE, // run a command, then back to interactive mode
+        BATCH_QUIET // as in batch mode, but don't echo the command
+    } fBatch;
+
+    // added to detect memory leaks
+    // watch for {,,msvcrtd.dll}*__p__crtBreakAlloc()
+    // (http://support.microsoft.com/kb/151585)
+#if defined(_DEBUG) && defined(_MSC_VER)
+    _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
+#endif
+
+    // get global frame (singleton pattern)
+    // will be initialized on first call
+    pAbc = Abc_FrameGetGlobalFrame();
+    pAbc->sBinary = argv[0];
+
+#ifdef ABC_PYTHON_EMBED
+    {
+        PyObject* pModule;
+        void init_pyabc(void);
+
+        Py_SetProgramName(argv[0]);
+        Py_NoSiteFlag = 1;
+        Py_Initialize();
+
+        init_pyabc();
+
+        pModule = PyImport_ImportModule("pyabc");
+        if (pModule)
+        {
+            Py_DECREF(pModule);
+        }
+        else
+        {
+            fprintf( pAbc->Err, "error: pyabc.py not found. PYTHONPATH may not be set properly.\n");
+        }
+    }
+#endif /* ABC_PYTHON_EMBED */
+
+    // default options
+    fBatch      = INTERACTIVE;
+    fInitSource = 1;
+    fInitRead   = 0;
+    fFinalWrite = 0;
+    sInFile = sOutFile = NULL;
+    sprintf( sReadCmd,  "read"  );
+    sprintf( sWriteCmd, "write" );
+
+    Extra_UtilGetoptReset();
+    while ((c = Extra_UtilGetopt(argc, argv, "c:q:C:hf:F:o:st:T:xb")) != EOF) {
+        switch(c) {
+            case 'c':
+                strcpy( sCommandUsr, globalUtilOptarg );
+                fBatch = BATCH;
+                break;
+
+            case 'q':
+                strcpy( sCommandUsr, globalUtilOptarg );
+                fBatch = BATCH_QUIET;
+                break;
+
+            case 'C':
+                strcpy( sCommandUsr, globalUtilOptarg );
+                fBatch = BATCH_THEN_INTERACTIVE;
+                break;
+
+            case 'f':
+                sprintf(sCommandUsr, "source %s", globalUtilOptarg);
+                fBatch = BATCH;
+                break;
+
+            case 'F':
+                sprintf(sCommandUsr, "source -x %s", globalUtilOptarg);
+                fBatch = BATCH;
+                break;
+
+            case 'h':
+                goto usage;
+                break;
+
+            case 'o':
+                sOutFile = globalUtilOptarg;
+                fFinalWrite = 1;
+                break;
+
+            case 's':
+                fInitSource = 0;
+                break;
+
+            case 't':
+                if ( TypeCheck( pAbc, globalUtilOptarg ) )
+                {
+                    if ( !strcmp(globalUtilOptarg, "none") == 0 )
+                    {
+                        fInitRead = 1;
+                        sprintf( sReadCmd, "read_%s", globalUtilOptarg );
+                    }
+                }
+                else {
+                    goto usage;
+                }
+                fBatch = BATCH;
+                break;
+
+            case 'T':
+                if ( TypeCheck( pAbc, globalUtilOptarg ) )
+                {
+                    if (!strcmp(globalUtilOptarg, "none") == 0)
+                    {
+                        fFinalWrite = 1;
+                        sprintf( sWriteCmd, "write_%s", globalUtilOptarg);
+                    }
+                }
+                else {
+                    goto usage;
+                }
+                fBatch = BATCH;
+                break;
+
+            case 'x':
+                fFinalWrite = 0;
+                fInitRead   = 0;
+                fBatch = BATCH;
+                break;
+
+            case 'b':
+                Abc_FrameSetBridgeMode();
+                break;
+
+            default:
+                goto usage;
+        }
+    }
+
+    if ( Abc_FrameIsBridgeMode() )
+    {
+        extern Gia_Man_t * Gia_ManFromBridge( FILE * pFile, Vec_Int_t ** pvInit );
+        pAbc->pGia = Gia_ManFromBridge( stdin, NULL );
+    }
+    else if ( fBatch!=INTERACTIVE && fBatch!=BATCH_QUIET && sCommandUsr[0] )
+        Abc_Print( 1, "ABC command line: \"%s\".\n\n", sCommandUsr );
+
+    if ( fBatch!=INTERACTIVE )
+    {
+        pAbc->fBatchMode = 1;
+
+
+        if (argc - globalUtilOptind == 0)
+        {
+            sInFile = NULL;
+        }
+        else if (argc - globalUtilOptind == 1)
+        {
+            fInitRead = 1;
+            sInFile = argv[globalUtilOptind];
+        }
+        else
+        {
+            Abc_UtilsPrintUsage( pAbc, argv[0] );
+        }
+
+        // source the resource file
+        if ( fInitSource )
+        {
+            Abc_UtilsSource( pAbc );
+        }
+
+        fStatus = 0;
+        if ( fInitRead && sInFile )
+        {
+            sprintf( sCommandTmp, "%s %s", sReadCmd, sInFile );
+            fStatus = Cmd_CommandExecute( pAbc, sCommandTmp );
+        }
+
+        if ( fStatus == 0 )
+        {
+            /* cmd line contains `source <file>' */
+            fStatus = Cmd_CommandExecute( pAbc, sCommandUsr );
+            if ( (fStatus == 0 || fStatus == -1) && fFinalWrite && sOutFile )
+            {
+                sprintf( sCommandTmp, "%s %s", sWriteCmd, sOutFile );
+                fStatus = Cmd_CommandExecute( pAbc, sCommandTmp );
+            }
+        }
+
+        if (fBatch == BATCH_THEN_INTERACTIVE){
+            fBatch = INTERACTIVE;
+            pAbc->fBatchMode = 0;
+        }
+
+    }
+
+    if ( fBatch==INTERACTIVE )
+    {
+        // start interactive mode
+
+        // print the hello line
+        Abc_UtilsPrintHello( pAbc );
+        // print history of the recent commands
+        Cmd_HistoryPrint( pAbc, 10 );
+
+        // source the resource file
+        if ( fInitSource )
+        {
+            Abc_UtilsSource( pAbc );
+        }
+
+        // execute commands given by the user
+        while ( !feof(stdin) )
+        {
+            // print command line prompt and
+            // get the command from the user
+            sCommand = Abc_UtilsGetUsersInput( pAbc );
+
+            // execute the user's command
+            fStatus = Cmd_CommandExecute( pAbc, sCommand );
+
+            // stop if the user quitted or an error occurred
+            if ( fStatus == -1 || fStatus == -2 )
+                break;
+        }
+    }
+
+#ifdef ABC_PYTHON_EMBED
+    {
+        Py_Finalize();
+    }
+#endif /* ABC_PYTHON_EMBED */
+
+    // if the memory should be freed, quit packages
+//    if ( fStatus < 0 ) 
+    {
+        Abc_Stop();
+    }
+    return 0;
+
+usage:
+    Abc_UtilsPrintHello( pAbc );
+    Abc_UtilsPrintUsage( pAbc, argv[0] );
+    return 1;
+}
+
+/**Function********************************************************************
+
+  Synopsis    [Returns 1 if s is a file type recognized, else returns 0.]
+
+  Description [Returns 1 if s is a file type recognized by ABC, else returns 0. 
+  Recognized types are "blif", "bench", "pla", and "none".]
+
+  SideEffects []
+
+******************************************************************************/
+static int TypeCheck( Abc_Frame_t * pAbc, const char * s )
+{
+    if (strcmp(s, "blif") == 0)
+        return 1;
+    else if (strcmp(s, "bench") == 0)
+        return 1;
+    else if (strcmp(s, "pla") == 0)
+        return 1;
+    else if (strcmp(s, "none") == 0)
+        return 1;
+    else {
+        fprintf( pAbc->Err, "unknown type %s\n", s );
+        return 0;
+    }
+}
+
+
+
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/abc-build/src/base/main/module.make b/abc-build/src/base/main/module.make
--- a/abc-build/src/base/main/module.make
+++ b/abc-build/src/base/main/module.make
@@ -1,5 +1,6 @@
 SRC +=  src/base/main/mainFrame.c \
 	src/base/main/mainInit.c \
 	src/base/main/mainLib.c \
+	src/base/main/mainReal.c \
 	src/base/main/libSupport.c \
 	src/base/main/mainUtils.c
diff --git a/abc-build/src/base/ver/verCore.c b/abc-build/src/base/ver/verCore.c
--- a/abc-build/src/base/ver/verCore.c
+++ b/abc-build/src/base/ver/verCore.c
@@ -412,7 +412,7 @@
     // get the network with this name
     pNtk = Ver_ParseFindOrCreateNetwork( pMan, pWord );
 
-    // make sure we stopped at the opening paranthesis
+    // make sure we stopped at the opening parenthesis
     if ( Ver_StreamPopChar(p) != '(' )
     {
         sprintf( pMan->sError, "Cannot find \"(\" after \"module\" in network %s.", pNtk->pName );
@@ -420,7 +420,7 @@
         return 0;
     }
 
-    // skip to the end of parantheses
+    // skip to the end of parentheses
     do {
         if ( Ver_ParseGetName( pMan ) == NULL )
             return 0;
@@ -432,7 +432,7 @@
     Symbol = Ver_StreamPopChar(p);
     if ( Symbol != ';' )
     {
-        sprintf( pMan->sError, "Expected closing paranthesis after \"module\"." );
+        sprintf( pMan->sError, "Expected closing parenthesis after \"module\"." );
         Ver_ParsePrintErrorMessage( pMan );
         return 0;
     }
@@ -654,7 +654,7 @@
     {
         assert( *pWord == ':' );
         nLsb = atoi( pWord + 1 );
-        // find the closing paranthesis
+        // find the closing parenthesis
         while ( *pWord && *pWord != ']' )
             pWord++;
         if ( *pWord == 0 )
@@ -1340,7 +1340,7 @@
     // this is gate name - throw it away
     if ( Ver_StreamPopChar(p) != '(' )
     {
-        sprintf( pMan->sError, "Cannot parse a standard gate (expected opening paranthesis)." );
+        sprintf( pMan->sError, "Cannot parse a standard gate (expected opening parenthesis)." );
         Ver_ParsePrintErrorMessage( pMan );
         return 0;
     }
@@ -1377,7 +1377,7 @@
         // skip comma
         if ( Symbol != ',' )
         {
-            sprintf( pMan->sError, "Cannot parse a standard gate %s (expected closing paranthesis).", Abc_ObjName(Abc_ObjFanout0(pNode)) );
+            sprintf( pMan->sError, "Cannot parse a standard gate %s (expected closing parenthesis).", Abc_ObjName(Abc_ObjFanout0(pNode)) );
             Ver_ParsePrintErrorMessage( pMan );
             return 0;
         }
@@ -1436,7 +1436,7 @@
     // this is gate name - throw it away
     if ( Ver_StreamPopChar(p) != '(' )
     {
-        sprintf( pMan->sError, "Cannot parse a standard gate (expected opening paranthesis)." );
+        sprintf( pMan->sError, "Cannot parse a standard gate (expected opening parenthesis)." );
         Ver_ParsePrintErrorMessage( pMan );
         return 0;
     }
@@ -1573,7 +1573,7 @@
     // this is gate name - throw it away
     if ( Ver_StreamPopChar(p) != '(' )
     {
-        sprintf( pMan->sError, "Cannot parse gate %s (expected opening paranthesis).", Mio_GateReadName(pGate) );
+        sprintf( pMan->sError, "Cannot parse gate %s (expected opening parenthesis).", Mio_GateReadName(pGate) );
         Ver_ParsePrintErrorMessage( pMan );
         return 0;
     }
@@ -1613,10 +1613,10 @@
             return 0;
         }
 
-        // open the paranthesis
+        // open the parenthesis
         if ( Ver_StreamPopChar(p) != '(' )
         {
-            sprintf( pMan->sError, "Cannot formal parameter %s of gate %s (expected opening paranthesis).", pWord, Mio_GateReadName(pGate) );
+            sprintf( pMan->sError, "Cannot formal parameter %s of gate %s (expected opening parenthesis).", pWord, Mio_GateReadName(pGate) );
             Ver_ParsePrintErrorMessage( pMan );
             return 0;
         }
@@ -1646,10 +1646,10 @@
             return 0;
         }
 
-        // close the paranthesis
+        // close the parenthesis
         if ( Ver_StreamPopChar(p) != ')' )
         {
-            sprintf( pMan->sError, "Cannot formal parameter %s of gate %s (expected closing paranthesis).", pWord, Mio_GateReadName(pGate) );
+            sprintf( pMan->sError, "Cannot formal parameter %s of gate %s (expected closing parenthesis).", pWord, Mio_GateReadName(pGate) );
             Ver_ParsePrintErrorMessage( pMan );
             return 0;
         }
@@ -1678,7 +1678,7 @@
         // skip comma
         if ( Symbol != ',' )
         {
-            sprintf( pMan->sError, "Cannot formal parameter %s of gate %s (expected closing paranthesis).", pWord, Mio_GateReadName(pGate) );
+            sprintf( pMan->sError, "Cannot formal parameter %s of gate %s (expected closing parenthesis).", pWord, Mio_GateReadName(pGate) );
             Ver_ParsePrintErrorMessage( pMan );
             return 0;
         }
@@ -1754,7 +1754,7 @@
     // continue parsing the box
     if ( Ver_StreamPopChar(p) != '(' )
     {
-        sprintf( pMan->sError, "Cannot parse box %s (expected opening paranthesis).", Abc_ObjName(pNode) );
+        sprintf( pMan->sError, "Cannot parse box %s (expected opening parenthesis).", Abc_ObjName(pNode) );
         Ver_ParsePrintErrorMessage( pMan );
         return 0;
     }
@@ -1791,10 +1791,10 @@
             // save the name
             pBundle->pNameFormal = Extra_UtilStrsav( pWord );
 
-            // open the paranthesis
+            // open the parenthesis
             if ( Ver_StreamPopChar(p) != '(' )
             {
-                sprintf( pMan->sError, "Cannot formal parameter %s of box %s (expected opening paranthesis).", pWord, Abc_ObjName(pNode));
+                sprintf( pMan->sError, "Cannot formal parameter %s of box %s (expected opening parenthesis).", pWord, Abc_ObjName(pNode));
                 Ver_ParsePrintErrorMessage( pMan );
                 return 0;
             }
@@ -2002,11 +2002,11 @@
 
         if ( fFormalIsGiven )
         {
-            // close the paranthesis
+            // close the parenthesis
             Ver_ParseSkipComments( pMan );
             if ( Ver_StreamPopChar(p) != ')' )
             {
-                sprintf( pMan->sError, "Cannot parse formal parameter %s of box %s (expected closing paranthesis).", pWord, Abc_ObjName(pNode) );
+                sprintf( pMan->sError, "Cannot parse formal parameter %s of box %s (expected closing parenthesis).", pWord, Abc_ObjName(pNode) );
                 Ver_ParsePrintErrorMessage( pMan );
                 return 0;
             }
@@ -2179,7 +2179,7 @@
             if ( !strcmp(pBundle->pNameFormal, pNameFormal) )
                 break;
         assert( pBundle != NULL );
-        // if the bundle is not found, try without parantheses
+        // if the bundle is not found, try without parentheses
         if ( k == Vec_PtrSize(vBundles) )
         {
             pBundle = NULL;
@@ -2230,7 +2230,7 @@
             if ( !strcmp(pBundle->pNameFormal, pNameFormal) )
                 break;
         assert( pBundle != NULL );
-        // if the name is not found, try without parantheses
+        // if the name is not found, try without parentheses
         if ( k == Vec_PtrSize(vBundles) )
         {
             pBundle = NULL;
@@ -2869,7 +2869,7 @@
 ***********************************************************************/
 int Ver_ParseAttachBoxes( Ver_Man_t * pMan )
 {
-    int fPrintLog = 1;
+    int fPrintLog = 0;
     Abc_Ntk_t * pNtk = NULL;
     Ver_Bundle_t * pBundle;
     Vec_Ptr_t * vUndefs;
diff --git a/abc-build/src/base/ver/verFormula.c b/abc-build/src/base/ver/verFormula.c
--- a/abc-build/src/base/ver/verFormula.c
+++ b/abc-build/src/base/ver/verFormula.c
@@ -28,8 +28,8 @@
 ////////////////////////////////////////////////////////////////////////
 
 // the list of operation symbols to be used in expressions
-#define VER_PARSE_SYM_OPEN    '('   // opening paranthesis
-#define VER_PARSE_SYM_CLOSE   ')'   // closing paranthesis
+#define VER_PARSE_SYM_OPEN    '('   // opening parenthesis
+#define VER_PARSE_SYM_CLOSE   ')'   // closing parenthesis
 #define VER_PARSE_SYM_CONST0  '0'   // constant 0
 #define VER_PARSE_SYM_CONST1  '1'   // constant 1
 #define VER_PARSE_SYM_NEGBEF1 '!'   // negation before the variable
@@ -47,7 +47,7 @@
 #define VER_PARSE_OPER_OR      4    // logic OR
 #define VER_PARSE_OPER_EQU     3    // equvalence   (a'b'| ab )
 #define VER_PARSE_OPER_MUX     2    // MUX(a,b,c)   (ab | a'c )
-#define VER_PARSE_OPER_MARK    1    // OpStack token standing for an opening paranthesis
+#define VER_PARSE_OPER_MARK    1    // OpStack token standing for an opening parenthesis
 
 // these are values of the internal Flag
 #define VER_PARSE_FLAG_START   1    // after the opening parenthesis 
@@ -91,7 +91,7 @@
     if ( !strcmp(pFormula, "1") || !strcmp(pFormula, "1\'b1") )
         return Hop_ManConst1((Hop_Man_t *)pMan);
 
-    // make sure that the number of opening and closing parantheses is the same
+    // make sure that the number of opening and closing parentheses is the same
     nParans = 0;
     for ( pTemp = pFormula; *pTemp; pTemp++ )
         if ( *pTemp == '(' )
@@ -100,11 +100,11 @@
             nParans--;
     if ( nParans != 0 )
     {
-        sprintf( pErrorMessage, "Parse_FormulaParser(): Different number of opening and closing parantheses ()." );
+        sprintf( pErrorMessage, "Parse_FormulaParser(): Different number of opening and closing parentheses ()." );
         return NULL;
     }
  
-    // add parantheses
+    // add parentheses
     pTemp = pFormula + strlen(pFormula) + 2;
     *pTemp-- = 0; *pTemp = ')';
     while ( --pTemp != pFormula )
@@ -186,7 +186,7 @@
         case VER_PARSE_SYM_OPEN:
 			if ( Flag == VER_PARSE_FLAG_VAR )
 			{
-				sprintf( pErrorMessage, "Parse_FormulaParser(): Variable before a paranthesis." );
+				sprintf( pErrorMessage, "Parse_FormulaParser(): Variable before a parenthesis." );
 				Flag = VER_PARSE_FLAG_ERROR; 
                 break;
 			}
@@ -202,7 +202,7 @@
 			    {
 				    if ( !Vec_IntSize( vStackOp ) )
 					{
-						sprintf( pErrorMessage, "Parse_FormulaParser(): There is no opening paranthesis\n" );
+						sprintf( pErrorMessage, "Parse_FormulaParser(): There is no opening parenthesis\n" );
 						Flag = VER_PARSE_FLAG_ERROR; 
                         break;
 					}
@@ -226,7 +226,7 @@
             }
 		    else
 			{
-				sprintf( pErrorMessage, "Parse_FormulaParser(): There is no opening paranthesis\n" );
+				sprintf( pErrorMessage, "Parse_FormulaParser(): There is no opening parenthesis\n" );
 				Flag = VER_PARSE_FLAG_ERROR; 
                 break;
 			}
diff --git a/abc-build/src/base/ver/verParse.c b/abc-build/src/base/ver/verParse.c
--- a/abc-build/src/base/ver/verParse.c
+++ b/abc-build/src/base/ver/verParse.c
@@ -63,7 +63,7 @@
         return Ver_ParseSkipComments( pMan );
     }
     if ( Symbol == '*' )
-    { // skip till the next occurance of */
+    { // skip till the next occurrence of */
         Ver_StreamPopChar( p );
         do {
             Ver_StreamSkipToChars( p, "*" );
diff --git a/abc-build/src/base/ver/verStream.c b/abc-build/src/base/ver/verStream.c
--- a/abc-build/src/base/ver/verStream.c
+++ b/abc-build/src/base/ver/verStream.c
@@ -48,7 +48,7 @@
     char *           pBufferEnd;    // the first position not used by currently loaded data
     char *           pBufferStop;   // the position where loading new data will be done
     // tokens given to the user
-    char             pChars[VER_WORD_SIZE+5]; // temporary storage for a word (plus end-of-string and two parantheses)
+    char             pChars[VER_WORD_SIZE+5]; // temporary storage for a word (plus end-of-string and two parentheses)
     int              nChars;        // the total number of characters in the word
     // status of the parser
     int              fStop;         // this flag goes high when the end of file is reached
diff --git a/abc-build/src/base/wlc/module.make b/abc-build/src/base/wlc/module.make
--- a/abc-build/src/base/wlc/module.make
+++ b/abc-build/src/base/wlc/module.make
@@ -1,6 +1,7 @@
-SRC +=	src/base/wlc/wlc.c \
+SRC +=	src/base/wlc/wlcAbs.c \
 	src/base/wlc/wlcBlast.c \
 	src/base/wlc/wlcCom.c \
 	src/base/wlc/wlcNtk.c \
+	src/base/wlc/wlcReadSmt.c \
 	src/base/wlc/wlcReadVer.c \
 	src/base/wlc/wlcWriteVer.c 
diff --git a/abc-build/src/base/wlc/wlc.h b/abc-build/src/base/wlc/wlc.h
--- a/abc-build/src/base/wlc/wlc.h
+++ b/abc-build/src/base/wlc/wlc.h
@@ -42,11 +42,11 @@
 // object types
 typedef enum { 
     WLC_OBJ_NONE = 0,      // 00: unknown
-    WLC_OBJ_PI,            // 01: primary input terminal
-    WLC_OBJ_PO,            // 02: primary output terminal
-    WLC_OBJ_BO,            // 03: box output
-    WLC_OBJ_BI,            // 04: box input
-    WLC_OBJ_FF,            // 05: flop
+    WLC_OBJ_PI,            // 01: primary input 
+    WLC_OBJ_PO,            // 02: primary output (unused)
+    WLC_OBJ_FO,            // 03: flop output
+    WLC_OBJ_FI,            // 04: flop input (unused)
+    WLC_OBJ_FF,            // 05: flop (unused)
     WLC_OBJ_CONST,         // 06: constant
     WLC_OBJ_BUF,           // 07: buffer
     WLC_OBJ_MUX,           // 08: multiplexer
@@ -54,55 +54,64 @@
     WLC_OBJ_SHIFT_RA,      // 10: shift right (arithmetic)
     WLC_OBJ_SHIFT_L,       // 11: shift left
     WLC_OBJ_SHIFT_LA,      // 12: shift left (arithmetic)
-    WLC_OBJ_BIT_NOT,       // 13: bitwise NOT
-    WLC_OBJ_BIT_AND,       // 14: bitwise AND
-    WLC_OBJ_BIT_OR,        // 15: bitwise OR
-    WLC_OBJ_BIT_XOR,       // 16: bitwise XOR
-    WLC_OBJ_BIT_SELECT,    // 17: bit selection
-    WLC_OBJ_BIT_CONCAT,    // 18: bit concatenation
-    WLC_OBJ_BIT_ZEROPAD,   // 19: zero padding
-    WLC_OBJ_BIT_SIGNEXT,   // 20: sign extension
-    WLC_OBJ_LOGIC_NOT,     // 21: logic NOT
-    WLC_OBJ_LOGIC_AND,     // 22: logic AND
-    WLC_OBJ_LOGIC_OR,      // 23: logic OR
-    WLC_OBJ_COMP_EQU,      // 24: compare equal
-    WLC_OBJ_COMP_NOT,      // 25: compare not equal
-    WLC_OBJ_COMP_LESS,     // 26: compare less
-    WLC_OBJ_COMP_MORE,     // 27: compare more
-    WLC_OBJ_COMP_LESSEQU,  // 28: compare less or equal
-    WLC_OBJ_COMP_MOREEQU,  // 29: compare more or equal
-    WLC_OBJ_REDUCT_AND,    // 30: reduction AND
-    WLC_OBJ_REDUCT_OR,     // 31: reduction OR
-    WLC_OBJ_REDUCT_XOR,    // 32: reduction XOR
-    WLC_OBJ_ARI_ADD,       // 33: arithmetic addition
-    WLC_OBJ_ARI_SUB,       // 34: arithmetic subtraction
-    WLC_OBJ_ARI_MULTI,     // 35: arithmetic multiplier
-    WLC_OBJ_ARI_DIVIDE,    // 36: arithmetic division
-    WLC_OBJ_ARI_MODULUS,   // 37: arithmetic modulus
-    WLC_OBJ_ARI_POWER,     // 38: arithmetic power
-    WLC_OBJ_NUMBER         // 39: unused
+    WLC_OBJ_ROTATE_R,      // 13: rotate right
+    WLC_OBJ_ROTATE_L,      // 14: rotate left
+    WLC_OBJ_BIT_NOT,       // 15: bitwise NOT
+    WLC_OBJ_BIT_AND,       // 16: bitwise AND
+    WLC_OBJ_BIT_OR,        // 17: bitwise OR
+    WLC_OBJ_BIT_XOR,       // 18: bitwise XOR
+    WLC_OBJ_BIT_SELECT,    // 19: bit selection
+    WLC_OBJ_BIT_CONCAT,    // 20: bit concatenation
+    WLC_OBJ_BIT_ZEROPAD,   // 21: zero padding
+    WLC_OBJ_BIT_SIGNEXT,   // 22: sign extension
+    WLC_OBJ_LOGIC_NOT,     // 23: logic NOT
+    WLC_OBJ_LOGIC_AND,     // 24: logic AND
+    WLC_OBJ_LOGIC_OR,      // 25: logic OR
+    WLC_OBJ_COMP_EQU,      // 26: compare equal
+    WLC_OBJ_COMP_NOTEQU,   // 27: compare not equal
+    WLC_OBJ_COMP_LESS,     // 28: compare less
+    WLC_OBJ_COMP_MORE,     // 29: compare more
+    WLC_OBJ_COMP_LESSEQU,  // 30: compare less or equal
+    WLC_OBJ_COMP_MOREEQU,  // 31: compare more or equal
+    WLC_OBJ_REDUCT_AND,    // 32: reduction AND
+    WLC_OBJ_REDUCT_OR,     // 33: reduction OR
+    WLC_OBJ_REDUCT_XOR,    // 34: reduction XOR
+    WLC_OBJ_ARI_ADD,       // 35: arithmetic addition
+    WLC_OBJ_ARI_SUB,       // 36: arithmetic subtraction
+    WLC_OBJ_ARI_MULTI,     // 37: arithmetic multiplier
+    WLC_OBJ_ARI_DIVIDE,    // 38: arithmetic division
+    WLC_OBJ_ARI_MODULUS,   // 39: arithmetic modulus
+    WLC_OBJ_ARI_POWER,     // 40: arithmetic power
+    WLC_OBJ_ARI_MINUS,     // 41: arithmetic minus
+    WLC_OBJ_TABLE,         // 42: bit table
+    WLC_OBJ_NUMBER         // 43: unused
 } Wlc_ObjType_t;
 
+
+// Unlike AIG managers and logic networks in ABC, this network treats POs and FIs 
+// as attributes of internal nodes and *not* as separate types of objects.
+
 
 ////////////////////////////////////////////////////////////////////////
 ///                         BASIC TYPES                              ///
 ////////////////////////////////////////////////////////////////////////
 
-typedef struct Wlc_Ntk_t_  Wlc_Ntk_t;
 typedef struct Wlc_Obj_t_  Wlc_Obj_t;
-
 struct Wlc_Obj_t_ // 16 bytes
 {
     unsigned               Type    :  6;       // node type
     unsigned               Signed  :  1;       // signed
     unsigned               Mark    :  1;       // user mark
-    unsigned               nFanins : 24;       // fanin count
+    unsigned               fIsPo   :  1;       // this is PO
+    unsigned               fIsFi   :  1;       // this is FI
+    unsigned               nFanins : 22;       // fanin count
     unsigned               End     : 16;       // range end
     unsigned               Beg     : 16;       // range begin
     union { int            Fanins[2];          // fanin IDs
             int *          pFanins[1]; };
 };
 
+typedef struct Wlc_Ntk_t_  Wlc_Ntk_t;
 struct Wlc_Ntk_t_ 
 {
     char *                 pName;              // model name
@@ -111,12 +120,17 @@
     Vec_Int_t              vCis;               // combinational inputs
     Vec_Int_t              vCos;               // combinational outputs
     Vec_Int_t              vFfs;               // flops
+    Vec_Int_t *            vInits;             // initial values
+    char *                 pInits;             // initial values
     int                    nObjs[WLC_OBJ_NUMBER]; // counter of objects of each type
+    int                    nAnds[WLC_OBJ_NUMBER]; // counter of AND gates after blasting
     // memory for objects
     Wlc_Obj_t *            pObjs;
     int                    iObj;
     int                    nObjsAlloc;
     Mem_Flex_t *           pMemFanin;
+    Mem_Flex_t *           pMemTable;
+    Vec_Ptr_t *            vTables;
     // object names
     Abc_Nam_t *            pManName;           // object names
     Vec_Int_t              vNameIds;           // object name IDs
@@ -126,49 +140,62 @@
     Vec_Int_t              vCopies;            // object first bits
 };
 
-static inline int          Wlc_NtkObjNum( Wlc_Ntk_t * p )                         { return p->iObj - 1;                                          }
-static inline int          Wlc_NtkObjNumMax( Wlc_Ntk_t * p )                      { return p->iObj;                                              }
-static inline int          Wlc_NtkPiNum( Wlc_Ntk_t * p )                          { return Vec_IntSize(&p->vPis);                                }
-static inline int          Wlc_NtkPoNum( Wlc_Ntk_t * p )                          { return Vec_IntSize(&p->vPos);                                }
-static inline int          Wlc_NtkCiNum( Wlc_Ntk_t * p )                          { return Vec_IntSize(&p->vCis);                                }
-static inline int          Wlc_NtkCoNum( Wlc_Ntk_t * p )                          { return Vec_IntSize(&p->vCos);                                }
-static inline int          Wlc_NtkFfNum( Wlc_Ntk_t * p )                          { return Vec_IntSize(&p->vFfs);                                }
+static inline int          Wlc_NtkObjNum( Wlc_Ntk_t * p )                           { return p->iObj - 1;                                                      }
+static inline int          Wlc_NtkObjNumMax( Wlc_Ntk_t * p )                        { return p->iObj;                                                          }
+static inline int          Wlc_NtkPiNum( Wlc_Ntk_t * p )                            { return Vec_IntSize(&p->vPis);                                            }
+static inline int          Wlc_NtkPoNum( Wlc_Ntk_t * p )                            { return Vec_IntSize(&p->vPos);                                            }
+static inline int          Wlc_NtkCiNum( Wlc_Ntk_t * p )                            { return Vec_IntSize(&p->vCis);                                            }
+static inline int          Wlc_NtkCoNum( Wlc_Ntk_t * p )                            { return Vec_IntSize(&p->vCos);                                            }
+static inline int          Wlc_NtkFfNum( Wlc_Ntk_t * p )                            { return Vec_IntSize(&p->vCis) - Vec_IntSize(&p->vPis);                    }
 
-static inline Wlc_Obj_t *  Wlc_NtkObj( Wlc_Ntk_t * p, int Id )                    { assert(Id > 0 && Id < p->nObjsAlloc); return p->pObjs + Id;  }
-static inline Wlc_Obj_t *  Wlc_NtkPi( Wlc_Ntk_t * p, int i )                      { return Wlc_NtkObj( p, Vec_IntEntry(&p->vPis, i) );           }
-static inline Wlc_Obj_t *  Wlc_NtkPo( Wlc_Ntk_t * p, int i )                      { return Wlc_NtkObj( p, Vec_IntEntry(&p->vPos, i) );           }
-static inline Wlc_Obj_t *  Wlc_NtkCi( Wlc_Ntk_t * p, int i )                      { return Wlc_NtkObj( p, Vec_IntEntry(&p->vCis, i) );           }
-static inline Wlc_Obj_t *  Wlc_NtkCo( Wlc_Ntk_t * p, int i )                      { return Wlc_NtkObj( p, Vec_IntEntry(&p->vCos, i) );           }
-static inline Wlc_Obj_t *  Wlc_NtkFf( Wlc_Ntk_t * p, int i )                      { return Wlc_NtkObj( p, Vec_IntEntry(&p->vFfs, i) );           }
+static inline Wlc_Obj_t *  Wlc_NtkObj( Wlc_Ntk_t * p, int Id )                      { assert(Id > 0 && Id < p->nObjsAlloc); return p->pObjs + Id;              }
+static inline Wlc_Obj_t *  Wlc_NtkPi( Wlc_Ntk_t * p, int i )                        { return Wlc_NtkObj( p, Vec_IntEntry(&p->vPis, i) );                       }
+static inline Wlc_Obj_t *  Wlc_NtkPo( Wlc_Ntk_t * p, int i )                        { return Wlc_NtkObj( p, Vec_IntEntry(&p->vPos, i) );                       }
+static inline Wlc_Obj_t *  Wlc_NtkCi( Wlc_Ntk_t * p, int i )                        { return Wlc_NtkObj( p, Vec_IntEntry(&p->vCis, i) );                       }
+static inline Wlc_Obj_t *  Wlc_NtkCo( Wlc_Ntk_t * p, int i )                        { return Wlc_NtkObj( p, Vec_IntEntry(&p->vCos, i) );                       }
+static inline Wlc_Obj_t *  Wlc_NtkFf( Wlc_Ntk_t * p, int i )                        { return Wlc_NtkObj( p, Vec_IntEntry(&p->vFfs, i) );                       }
 
-static inline int          Wlc_ObjId( Wlc_Ntk_t * p, Wlc_Obj_t * pObj )           { return pObj - p->pObjs;                                      }
-static inline int          Wlc_ObjPioId( Wlc_Obj_t * p )                          { assert(p->Type==WLC_OBJ_PI||p->Type==WLC_OBJ_PO);return p->Fanins[1]; }
-static inline int          Wlc_ObjFaninNum( Wlc_Obj_t * p )                       { return p->nFanins;                                           }
-static inline int          Wlc_ObjHasArray( Wlc_Obj_t * p )                       { return p->nFanins > 2 || p->Type == WLC_OBJ_CONST;           }
-static inline int *        Wlc_ObjFanins( Wlc_Obj_t * p )                         { return Wlc_ObjHasArray(p) ? p->pFanins[0] : p->Fanins;       }
-static inline int          Wlc_ObjFaninId( Wlc_Obj_t * p, int i )                 { return Wlc_ObjFanins(p)[i];                                  }
-static inline int          Wlc_ObjFaninId0( Wlc_Obj_t * p )                       { return Wlc_ObjFanins(p)[0];                                  }
-static inline int          Wlc_ObjFaninId1( Wlc_Obj_t * p )                       { return Wlc_ObjFanins(p)[1];                                  }
-static inline int          Wlc_ObjFaninId2( Wlc_Obj_t * p )                       { return Wlc_ObjFanins(p)[2];                                  }
-static inline Wlc_Obj_t *  Wlc_ObjFanin( Wlc_Ntk_t * p, Wlc_Obj_t * pObj, int i ) { return Wlc_NtkObj( p, Wlc_ObjFaninId(pObj, i) );             }
-static inline Wlc_Obj_t *  Wlc_ObjFanin0( Wlc_Ntk_t * p, Wlc_Obj_t * pObj )       { return Wlc_NtkObj( p, Wlc_ObjFaninId(pObj, 0) );             }
-static inline Wlc_Obj_t *  Wlc_ObjFanin1( Wlc_Ntk_t * p, Wlc_Obj_t * pObj )       { return Wlc_NtkObj( p, Wlc_ObjFaninId(pObj, 1) );             }
-static inline Wlc_Obj_t *  Wlc_ObjFanin2( Wlc_Ntk_t * p, Wlc_Obj_t * pObj )       { return Wlc_NtkObj( p, Wlc_ObjFaninId(pObj, 2) );             }
+static inline int          Wlc_ObjIsPi( Wlc_Obj_t * p )                             { return p->Type == WLC_OBJ_PI;                                            }
+static inline int          Wlc_ObjIsPo( Wlc_Obj_t * p )                             { return p->fIsPo;                                                         }
+static inline int          Wlc_ObjIsCi( Wlc_Obj_t * p )                             { return p->Type == WLC_OBJ_PI || p->Type == WLC_OBJ_FO;                   }
+static inline int          Wlc_ObjIsCo( Wlc_Obj_t * p )                             { return p->fIsPo || p->fIsFi;                                             }
 
-static inline int          Wlc_ObjRange( Wlc_Obj_t * p )                          { return p->End - p->Beg + 1;                                  }
-static inline int          Wlc_ObjRangeEnd( Wlc_Obj_t * p )                       { assert(p->Type == WLC_OBJ_BIT_SELECT); return p->Fanins[1] >> 16;     }
-static inline int          Wlc_ObjRangeBeg( Wlc_Obj_t * p )                       { assert(p->Type == WLC_OBJ_BIT_SELECT); return p->Fanins[1] & 0xFFFF;  }
-static inline int *        Wlc_ObjConstValue( Wlc_Obj_t * p )                     { assert(p->Type == WLC_OBJ_CONST);      return Wlc_ObjFanins(p);       }
+static inline int          Wlc_ObjId( Wlc_Ntk_t * p, Wlc_Obj_t * pObj )             { return pObj - p->pObjs;                                                  }
+static inline int          Wlc_ObjCiId( Wlc_Obj_t * p )                             { assert( Wlc_ObjIsCi(p) ); return p->Fanins[1];                           }
+static inline int          Wlc_ObjFaninNum( Wlc_Obj_t * p )                         { return p->nFanins;                                                       }
+static inline int          Wlc_ObjHasArray( Wlc_Obj_t * p )                         { return p->nFanins > 2 || p->Type == WLC_OBJ_CONST;                       }
+static inline int *        Wlc_ObjFanins( Wlc_Obj_t * p )                           { return Wlc_ObjHasArray(p) ? p->pFanins[0] : p->Fanins;                   }
+static inline int          Wlc_ObjFaninId( Wlc_Obj_t * p, int i )                   { return Wlc_ObjFanins(p)[i];                                              }
+static inline int          Wlc_ObjFaninId0( Wlc_Obj_t * p )                         { return Wlc_ObjFanins(p)[0];                                              }
+static inline int          Wlc_ObjFaninId1( Wlc_Obj_t * p )                         { return Wlc_ObjFanins(p)[1];                                              }
+static inline int          Wlc_ObjFaninId2( Wlc_Obj_t * p )                         { return Wlc_ObjFanins(p)[2];                                              }
+static inline Wlc_Obj_t *  Wlc_ObjFanin( Wlc_Ntk_t * p, Wlc_Obj_t * pObj, int i )   { return Wlc_NtkObj( p, Wlc_ObjFaninId(pObj, i) );                         }
+static inline Wlc_Obj_t *  Wlc_ObjFanin0( Wlc_Ntk_t * p, Wlc_Obj_t * pObj )         { return Wlc_NtkObj( p, Wlc_ObjFaninId(pObj, 0) );                         }
+static inline Wlc_Obj_t *  Wlc_ObjFanin1( Wlc_Ntk_t * p, Wlc_Obj_t * pObj )         { return Wlc_NtkObj( p, Wlc_ObjFaninId(pObj, 1) );                         }
+static inline Wlc_Obj_t *  Wlc_ObjFanin2( Wlc_Ntk_t * p, Wlc_Obj_t * pObj )         { return Wlc_NtkObj( p, Wlc_ObjFaninId(pObj, 2) );                         }
 
-static inline void         Wlc_NtkCleanCopy( Wlc_Ntk_t * p )                      { Vec_IntFill( &p->vCopies, p->nObjsAlloc, 0 );                }
-static inline int          Wlc_NtkHasCopy( Wlc_Ntk_t * p )                        { return Vec_IntSize( &p->vCopies ) > 0;                       }
-static inline void         Wlc_ObjSetCopy( Wlc_Ntk_t * p, int iObj, int i )       { Vec_IntWriteEntry( &p->vCopies, iObj, i );                   }
-static inline int          Wlc_ObjCopy( Wlc_Ntk_t * p, int iObj )                 { return Vec_IntEntry( &p->vCopies, iObj );                    }
+static inline int          Wlc_ObjRange( Wlc_Obj_t * p )                            { return p->End - p->Beg + 1;                                              }
+static inline int          Wlc_ObjRangeEnd( Wlc_Obj_t * p )                         { assert(p->Type == WLC_OBJ_BIT_SELECT); return p->Fanins[1] >> 16;        }
+static inline int          Wlc_ObjRangeBeg( Wlc_Obj_t * p )                         { assert(p->Type == WLC_OBJ_BIT_SELECT); return p->Fanins[1] & 0xFFFF;     }
+static inline int          Wlc_ObjIsSigned( Wlc_Obj_t * p )                         { return p->Signed;                                                        }
+static inline int          Wlc_ObjIsSignedFanin01( Wlc_Ntk_t * p, Wlc_Obj_t * pObj ){ return Wlc_ObjFanin0(p, pObj)->Signed && Wlc_ObjFanin1(p, pObj)->Signed; }
+static inline int          Wlc_ObjSign( Wlc_Obj_t * p )                             { return Abc_Var2Lit( Wlc_ObjRange(p), Wlc_ObjIsSigned(p) );               }
+static inline int *        Wlc_ObjConstValue( Wlc_Obj_t * p )                       { assert(p->Type == WLC_OBJ_CONST);      return Wlc_ObjFanins(p);          }
+static inline int          Wlc_ObjTableId( Wlc_Obj_t * p )                          { assert(p->Type == WLC_OBJ_TABLE);      return p->Fanins[1];              }
+static inline word *       Wlc_ObjTable( Wlc_Ntk_t * p, Wlc_Obj_t * pObj )          { return (word *)Vec_PtrEntry( p->vTables, Wlc_ObjTableId(pObj) );         }
 
-static inline void         Wlc_NtkCleanNameId( Wlc_Ntk_t * p )                    { Vec_IntFill( &p->vNameIds, p->nObjsAlloc, 0 );               }
-static inline int          Wlc_NtkHasNameId( Wlc_Ntk_t * p )                      { return Vec_IntSize( &p->vNameIds ) > 0;                      }
-static inline void         Wlc_ObjSetNameId( Wlc_Ntk_t * p, int iObj, int i )     { Vec_IntWriteEntry( &p->vNameIds, iObj, i );                  }
-static inline int          Wlc_ObjNameId( Wlc_Ntk_t * p, int iObj )               { return Vec_IntEntry( &p->vNameIds, iObj );                   }
+static inline void         Wlc_NtkCleanCopy( Wlc_Ntk_t * p )                        { Vec_IntFill( &p->vCopies, p->nObjsAlloc, 0 );                            }
+static inline int          Wlc_NtkHasCopy( Wlc_Ntk_t * p )                          { return Vec_IntSize( &p->vCopies ) > 0;                                   }
+static inline void         Wlc_ObjSetCopy( Wlc_Ntk_t * p, int iObj, int i )         { Vec_IntWriteEntry( &p->vCopies, iObj, i );                               }
+static inline int          Wlc_ObjCopy( Wlc_Ntk_t * p, int iObj )                   { return Vec_IntEntry( &p->vCopies, iObj );                                }
+static inline Wlc_Obj_t *  Wlc_ObjCopyObj(Wlc_Ntk_t * pNew, Wlc_Ntk_t * p, Wlc_Obj_t * pObj) {return Wlc_NtkObj(pNew, Wlc_ObjCopy(p, Wlc_ObjId(p, pObj)));   }
+
+static inline void         Wlc_NtkCleanNameId( Wlc_Ntk_t * p )                      { Vec_IntFill( &p->vNameIds, p->nObjsAlloc, 0 );                           }
+static inline int          Wlc_NtkHasNameId( Wlc_Ntk_t * p )                        { return Vec_IntSize( &p->vNameIds ) > 0;                                  }
+static inline void         Wlc_ObjSetNameId( Wlc_Ntk_t * p, int iObj, int i )       { Vec_IntWriteEntry( &p->vNameIds, iObj, i );                              }
+static inline int          Wlc_ObjNameId( Wlc_Ntk_t * p, int iObj )                 { return Vec_IntEntry( &p->vNameIds, iObj );                               }
+
+static inline Wlc_Obj_t *  Wlc_ObjFoToFi( Wlc_Ntk_t * p, Wlc_Obj_t * pObj )        { assert( pObj->Type == WLC_OBJ_FO ); return Wlc_NtkCo(p, Wlc_NtkCoNum(p) - Wlc_NtkCiNum(p) + Wlc_ObjCiId(pObj)); } 
 
 ////////////////////////////////////////////////////////////////////////
 ///                      MACRO DEFINITIONS                           ///
@@ -180,6 +207,8 @@
 
 #define Wlc_NtkForEachObj( p, pObj, i )                                             \
     for ( i = 1; (i < Wlc_NtkObjNumMax(p)) && (((pObj) = Wlc_NtkObj(p, i)), 1); i++ )
+#define Wlc_NtkForEachObjVec( vVec, p, pObj, i )                                    \
+    for ( i = 0; (i < Vec_IntSize(vVec)) && (((pObj) = Wlc_NtkObj(p, Vec_IntEntry(vVec, i))), 1); i++ )
 #define Wlc_NtkForEachPi( p, pPi, i )                                               \
     for ( i = 0; (i < Wlc_NtkPiNum(p)) && (((pPi) = Wlc_NtkPi(p, i)), 1); i++ )
 #define Wlc_NtkForEachPo( p, pPo, i )                                               \
@@ -188,6 +217,8 @@
     for ( i = 0; (i < Wlc_NtkCiNum(p)) && (((pCi) = Wlc_NtkCi(p, i)), 1); i++ )
 #define Wlc_NtkForEachCo( p, pCo, i )                                               \
     for ( i = 0; (i < Wlc_NtkCoNum(p)) && (((pCo) = Wlc_NtkCo(p, i)), 1); i++ )
+#define Wlc_NtkForEachFf( p, pFf, i )                                               \
+    for ( i = 0; (i < Vec_IntSize(&p->vFfs)) && (((pFf) = Wlc_NtkFf(p, i)), 1); i++ )
 
 #define Wlc_ObjForEachFanin( pObj, iFanin, i )                                      \
     for ( i = 0; (i < Wlc_ObjFaninNum(pObj)) && (((iFanin) = Wlc_ObjFaninId(pObj, i)), 1); i++ )
@@ -198,23 +229,34 @@
 ////////////////////////////////////////////////////////////////////////
 ///                    FUNCTION DECLARATIONS                         ///
 ////////////////////////////////////////////////////////////////////////
-
+
+/*=== wlcAbs.c ========================================================*/
+extern int            Wlc_NtkPairIsUifable( Wlc_Ntk_t * p, Wlc_Obj_t * pObj, Wlc_Obj_t * pObj2 );
+extern Vec_Int_t *    Wlc_NtkCollectMultipliers( Wlc_Ntk_t * p );
+extern Vec_Int_t *    Wlc_NtkFindUifableMultiplierPairs( Wlc_Ntk_t * p );
+extern Wlc_Ntk_t *    Wlc_NtkAbstractNodes( Wlc_Ntk_t * pNtk, Vec_Int_t * vNodes );
+extern Wlc_Ntk_t *    Wlc_NtkUifNodePairs( Wlc_Ntk_t * pNtk, Vec_Int_t * vPairs );
 /*=== wlcBlast.c ========================================================*/
-extern Gia_Man_t *    Wlc_NtkBitBlast( Wlc_Ntk_t * p );
+extern Gia_Man_t *    Wlc_NtkBitBlast( Wlc_Ntk_t * p, Vec_Int_t * vBoxIds );
 /*=== wlcNtk.c ========================================================*/
 extern Wlc_Ntk_t *    Wlc_NtkAlloc( char * pName, int nObjsAlloc );
 extern int            Wlc_ObjAlloc( Wlc_Ntk_t * p, int Type, int Signed, int End, int Beg );
+extern int            Wlc_ObjCreate( Wlc_Ntk_t * p, int Type, int Signed, int End, int Beg, Vec_Int_t * vFanins );
+extern void           Wlc_ObjSetCi( Wlc_Ntk_t * p, Wlc_Obj_t * pObj );
+extern void           Wlc_ObjSetCo( Wlc_Ntk_t * p, Wlc_Obj_t * pObj, int fFlopInput );
 extern char *         Wlc_ObjName( Wlc_Ntk_t * p, int iObj );
 extern void           Wlc_ObjUpdateType( Wlc_Ntk_t * p, Wlc_Obj_t * pObj, int Type );
 extern void           Wlc_ObjAddFanins( Wlc_Ntk_t * p, Wlc_Obj_t * pObj, Vec_Int_t * vFanins );
 extern void           Wlc_NtkFree( Wlc_Ntk_t * p );
 extern void           Wlc_NtkPrintNodes( Wlc_Ntk_t * p, int Type );
-extern void           Wlc_NtkPrintStats( Wlc_Ntk_t * p, int fVerbose );
+extern void           Wlc_NtkPrintStats( Wlc_Ntk_t * p, int fDistrib, int fVerbose );
 extern Wlc_Ntk_t *    Wlc_NtkDupDfs( Wlc_Ntk_t * p );
 extern void           Wlc_NtkTransferNames( Wlc_Ntk_t * pNew, Wlc_Ntk_t * p );
-/*=== wlcReadWord.c ========================================================*/
+/*=== wlcReadSmt.c ========================================================*/
+extern Wlc_Ntk_t *    Wlc_ReadSmt( char * pFileName );
+/*=== wlcReadVer.c ========================================================*/
 extern Wlc_Ntk_t *    Wlc_ReadVer( char * pFileName );
-/*=== wlcWriteWord.c ========================================================*/
+/*=== wlcWriteVer.c ========================================================*/
 extern void           Wlc_WriteVer( Wlc_Ntk_t * p, char * pFileName );
 
 
diff --git a/abc-build/src/base/wlc/wlcAbs.c b/abc-build/src/base/wlc/wlcAbs.c
new file mode 100644
--- /dev/null
+++ b/abc-build/src/base/wlc/wlcAbs.c
@@ -0,0 +1,292 @@
+/**CFile****************************************************************
+
+  FileName    [wlcAbs.c]
+
+  SystemName  [ABC: Logic synthesis and verification system.]
+
+  PackageName [Verilog parser.]
+
+  Synopsis    [Abstraction for word-level networks.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - August 22, 2014.]
+
+  Revision    [$Id: wlcAbs.c,v 1.00 2014/09/12 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "wlc.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    [Check if two objects have the same input/output signatures.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Wlc_NtkPairIsUifable( Wlc_Ntk_t * p, Wlc_Obj_t * pObj, Wlc_Obj_t * pObj2 )
+{
+    Wlc_Obj_t * pFanin, * pFanin2;  int k;
+    if ( Wlc_ObjRange(pObj) != Wlc_ObjRange(pObj2) )
+        return 0;
+    if ( Wlc_ObjIsSigned(pObj) != Wlc_ObjIsSigned(pObj2) )
+        return 0;
+    if ( Wlc_ObjFaninNum(pObj) != Wlc_ObjFaninNum(pObj2) )
+        return 0;
+    for ( k = 0; k < Wlc_ObjFaninNum(pObj); k++ )
+    {
+        pFanin = Wlc_ObjFanin(p, pObj, k);
+        pFanin2 = Wlc_ObjFanin(p, pObj2, k);
+        if ( Wlc_ObjRange(pFanin) != Wlc_ObjRange(pFanin2) )
+            return 0;
+        if ( Wlc_ObjIsSigned(pFanin) != Wlc_ObjIsSigned(pFanin2) )
+            return 0;
+    }
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Collect IDs of the multipliers.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Vec_Int_t * Wlc_NtkCollectMultipliers( Wlc_Ntk_t * p )
+{
+    Wlc_Obj_t * pObj;  int i;
+    Vec_Int_t * vBoxIds = Vec_IntAlloc( 100 );
+    Wlc_NtkForEachObj( p, pObj, i )
+        if ( pObj->Type == WLC_OBJ_ARI_MULTI )
+            Vec_IntPush( vBoxIds, i );
+    if ( Vec_IntSize( vBoxIds ) > 0 )
+        return vBoxIds;
+    Vec_IntFree( vBoxIds );
+    return NULL;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Returns all pairs of uifable multipliers.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Vec_Int_t * Wlc_NtkFindUifableMultiplierPairs( Wlc_Ntk_t * p )
+{
+    Vec_Int_t * vMultis = Wlc_NtkCollectMultipliers( p );
+    Vec_Int_t * vPairs = Vec_IntAlloc( 2 );
+    Wlc_Obj_t * pObj, * pObj2;  int i, k;
+    // iterate through unique pairs
+    Wlc_NtkForEachObjVec( vMultis, p, pObj, i )
+        Wlc_NtkForEachObjVec( vMultis, p, pObj2, k )
+        {
+            if ( k == i )  
+                break;
+            if ( Wlc_NtkPairIsUifable( p, pObj, pObj2 ) )
+            {
+                Vec_IntPush( vPairs, Wlc_ObjId(p, pObj) );
+                Vec_IntPush( vPairs, Wlc_ObjId(p, pObj2) );
+            }
+        }
+    Vec_IntFree( vMultis );
+    if ( Vec_IntSize( vPairs ) > 0 )
+        return vPairs;
+    Vec_IntFree( vPairs );
+    return NULL;
+}
+
+
+
+/**Function*************************************************************
+
+  Synopsis    [Abstracts nodes by replacing their outputs with new PIs.]
+
+  Description [If array is NULL, abstract all multipliers.]
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Wlc_Ntk_t * Wlc_NtkAbstractNodes( Wlc_Ntk_t * p, Vec_Int_t * vNodesInit )
+{
+    Vec_Int_t * vNodes = vNodesInit;
+    Wlc_Ntk_t * pNew;
+    Wlc_Obj_t * pObj;
+    int i, k, iObj, iFanin;
+    // get multipliers if not given
+    if ( vNodes == NULL )
+        vNodes = Wlc_NtkCollectMultipliers( p );
+    if ( vNodes == NULL )
+        return NULL;
+    // mark nodes
+    Wlc_NtkForEachObjVec( vNodes, p, pObj, i )
+        pObj->Mark = 1;
+    // iterate through the nodes in the DFS order
+    Wlc_NtkCleanCopy( p );
+    Wlc_NtkForEachObj( p, pObj, i )
+    {
+        if ( i == Vec_IntSize(&p->vCopies) )
+            break;
+        if ( pObj->Mark ) {
+            // clean
+            pObj->Mark = 0;
+            // add fresh PI with the same number of bits
+            iObj = Wlc_ObjAlloc( p, WLC_OBJ_PI, Wlc_ObjIsSigned(pObj), Wlc_ObjRange(pObj) - 1, 0 );
+        }
+        else {
+            // update fanins 
+            Wlc_ObjForEachFanin( pObj, iFanin, k )
+                Wlc_ObjFanins(pObj)[k] = Wlc_ObjCopy(p, iFanin);
+            // node to remain
+            iObj = i;
+        }
+        Wlc_ObjSetCopy( p, i, iObj );
+    }
+    // POs do not change in this procedure
+    if ( vNodes != vNodesInit )
+        Vec_IntFree( vNodes );
+    // reconstruct topological order
+    pNew = Wlc_NtkDupDfs( p );
+    Wlc_NtkTransferNames( pNew, p );
+    return pNew;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Adds UIF constraints to node pairs and updates POs.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Wlc_Ntk_t * Wlc_NtkUifNodePairs( Wlc_Ntk_t * p, Vec_Int_t * vPairsInit )
+{
+    Vec_Int_t * vPairs = vPairsInit;
+    Wlc_Ntk_t * pNew;
+    Wlc_Obj_t * pObj, * pObj2;
+    Vec_Int_t * vUifConstrs, * vCompares, * vFanins;
+    int i, k, iObj, iObj2, iObjNew, iObjNew2;
+    int iFanin, iFanin2, iFaninNew;
+    // get multiplier pairs if not given
+    if ( vPairs == NULL )
+        vPairs = Wlc_NtkFindUifableMultiplierPairs( p );
+    if ( vPairs == NULL )
+        return NULL;
+    // sanity checks
+    assert( Vec_IntSize(vPairs) > 0 && Vec_IntSize(vPairs) % 2 == 0 );
+    // iterate through node pairs
+    vFanins = Vec_IntAlloc( 100 );
+    vCompares = Vec_IntAlloc( 100 );
+    vUifConstrs = Vec_IntAlloc( 100 );
+    Vec_IntForEachEntryDouble( vPairs, iObj, iObj2, i )
+    {
+        // get two nodes
+        pObj  = Wlc_NtkObj( p, iObj );
+        pObj2 = Wlc_NtkObj( p, iObj2 );
+        assert( Wlc_NtkPairIsUifable(p, pObj, pObj2) );
+        // create fanin comparator nodes
+        Vec_IntClear( vCompares );
+        Wlc_ObjForEachFanin( pObj, iFanin, k )
+        {
+            iFanin2 = Wlc_ObjFaninId( pObj2, k );
+            Vec_IntFillTwo( vFanins, 2, iFanin, iFanin2 );
+            iFaninNew = Wlc_ObjCreate( p, WLC_OBJ_COMP_NOTEQU, 0, 0, 0, vFanins );
+            Vec_IntPush( vCompares, iFaninNew );
+            // note that a pointer to Wlc_Obj_t (for example, pObj) can be invalidated after a call to 
+            // Wlc_ObjCreate() due to a possible realloc of the internal array of objects...
+            pObj = Wlc_NtkObj( p, iObj );
+        }
+        // concatenate fanin comparators
+        iObjNew = Wlc_ObjCreate( p, WLC_OBJ_BIT_CONCAT, 0, Vec_IntSize(vCompares) - 1, 0, vCompares );
+        // create reduction-OR node
+        Vec_IntFill( vFanins, 1, iObjNew );
+        iObjNew = Wlc_ObjCreate( p, WLC_OBJ_REDUCT_OR, 0, 0, 0, vFanins );
+        // craete output comparator node
+        Vec_IntFillTwo( vFanins, 2, iObj, iObj2 );
+        iObjNew2 = Wlc_ObjCreate( p, WLC_OBJ_COMP_EQU, 0, 0, 0, vFanins );
+        // create implication node (iObjNew is already complemented above)
+        Vec_IntFillTwo( vFanins, 2, iObjNew, iObjNew2 );
+        iObjNew = Wlc_ObjCreate( p, WLC_OBJ_LOGIC_OR, 0, 0, 0, vFanins );
+        // save the constraint
+        Vec_IntPush( vUifConstrs, iObjNew );
+    }
+    // derive the AND of the UIF contraints
+    assert( Vec_IntSize(vUifConstrs) > 0 );
+    if ( Vec_IntSize(vUifConstrs) == 1 )
+        iObjNew = Vec_IntEntry( vUifConstrs, 0 );
+    else
+    {
+        // concatenate
+        iObjNew = Wlc_ObjCreate( p, WLC_OBJ_BIT_CONCAT, 0, Vec_IntSize(vUifConstrs) - 1, 0, vUifConstrs );
+        // create reduction-AND node
+        Vec_IntFill( vFanins, 1, iObjNew );
+        iObjNew = Wlc_ObjCreate( p, WLC_OBJ_REDUCT_AND, 0, 0, 0, vFanins );
+    }
+    // update each PO to point to the new node
+    Wlc_NtkForEachPo( p, pObj, i )
+    {
+        iObj = Wlc_ObjId(p, pObj);
+        Vec_IntFillTwo( vFanins, 2, iObj, iObjNew );
+        iObjNew = Wlc_ObjCreate( p, WLC_OBJ_LOGIC_AND, 0, 0, 0, vFanins );
+        // note that a pointer to Wlc_Obj_t (for example, pObj) can be invalidated after a call to 
+        // Wlc_ObjCreate() due to a possible realloc of the internal array of objects...
+        pObj = Wlc_NtkObj( p, iObj );
+        // update PO/CO arrays
+        assert( Vec_IntEntry(&p->vPos, i) == iObj );
+        assert( Vec_IntEntry(&p->vCos, i) == iObj );
+        Vec_IntWriteEntry( &p->vPos, i, iObjNew );
+        Vec_IntWriteEntry( &p->vCos, i, iObjNew );
+        // transfer the PO attribute
+        Wlc_NtkObj(p, iObjNew)->fIsPo = 1;
+        assert( pObj->fIsPo );
+        pObj->fIsPo = 0;
+    }
+    // cleanup
+    Vec_IntFree( vUifConstrs );
+    Vec_IntFree( vCompares );
+    Vec_IntFree( vFanins );
+    if ( vPairs != vPairsInit )
+        Vec_IntFree( vPairs );
+    // reconstruct topological order
+    pNew = Wlc_NtkDupDfs( p );
+    Wlc_NtkTransferNames( pNew, p );
+    return pNew;
+}
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/abc-build/src/base/wlc/wlcBlast.c b/abc-build/src/base/wlc/wlcBlast.c
--- a/abc-build/src/base/wlc/wlcBlast.c
+++ b/abc-build/src/base/wlc/wlcBlast.c
@@ -19,6 +19,7 @@
 ***********************************************************************/
 
 #include "wlc.h"
+#include "misc/tim/tim.h"
 
 ABC_NAMESPACE_IMPL_START
 
@@ -33,7 +34,7 @@
 
 /**Function*************************************************************
 
-  Synopsis    []
+  Synopsis    [Helper functions.]
 
   Description []
                
@@ -54,8 +55,117 @@
     }
     return nBits;
 }
-int Wlc_NtkComputeReduction( Gia_Man_t * pNew, int * pFans, int nFans, int Type )
+int * Wlc_VecCopy( Vec_Int_t * vOut, int * pArray, int nSize )
 {
+    int i; Vec_IntClear( vOut );
+    for( i = 0; i < nSize; i++) 
+        Vec_IntPush( vOut, pArray[i] );
+    return Vec_IntArray( vOut );
+}
+int * Wlc_VecLoadFanins( Vec_Int_t * vOut, int * pFanins, int nFanins, int nTotal, int fSigned )
+{
+    int Fill = fSigned ? pFanins[nFanins-1] : 0;
+    int i; Vec_IntClear( vOut );
+    assert( nFanins <= nTotal );
+    for( i = 0; i < nTotal; i++) 
+        Vec_IntPush( vOut, i < nFanins ? pFanins[i] : Fill );
+    return Vec_IntArray( vOut );
+}
+int Wlc_BlastGetConst( int * pNum, int nNum )
+{
+    int i, Res = 0;
+    for ( i = 0; i < nNum; i++ )
+        if ( pNum[i] == 1 )
+            Res |= (1 << i);
+        else if ( pNum[i] != 0 )
+            return -1;
+    return Res;
+}
+int Wlc_NtkMuxTree_rec( Gia_Man_t * pNew, int * pCtrl, int nCtrl, Vec_Int_t * vData, int Shift )
+{
+    int iLit0, iLit1;
+    if ( nCtrl == 0 )
+        return Vec_IntEntry( vData, Shift );
+    iLit0 = Wlc_NtkMuxTree_rec( pNew, pCtrl, nCtrl-1, vData, Shift );
+    iLit1 = Wlc_NtkMuxTree_rec( pNew, pCtrl, nCtrl-1, vData, Shift + (1<<(nCtrl-1)) );
+    return Gia_ManHashMux( pNew, pCtrl[nCtrl-1], iLit1, iLit0 );
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Bit blasting for specific operations.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Wlc_BlastShiftRight( Gia_Man_t * pNew, int * pNum, int nNum, int * pShift, int nShift, int fSticky, Vec_Int_t * vRes )
+{
+    int * pRes = Wlc_VecCopy( vRes, pNum, nNum );
+    int Fill = fSticky ? pNum[nNum-1] : 0;
+    int i, j, fShort = 0;
+    assert( nShift <= 32 );
+    for( i = 0; i < nShift; i++ ) 
+        for( j = 0; j < nNum - fSticky; j++ ) 
+        {
+            if( fShort || j + (1<<i) >= nNum ) 
+            {
+                pRes[j] = Gia_ManHashMux( pNew, pShift[i], Fill, pRes[j] );
+                if ( (1<<i) > nNum ) 
+                    fShort = 1;
+            } 
+            else 
+                pRes[j] = Gia_ManHashMux( pNew, pShift[i], pRes[j+(1<<i)], pRes[j] );
+        }
+}
+void Wlc_BlastShiftLeft( Gia_Man_t * pNew, int * pNum, int nNum, int * pShift, int nShift, int fSticky, Vec_Int_t * vRes )
+{
+    int * pRes = Wlc_VecCopy( vRes, pNum, nNum );
+    int Fill = fSticky ? pNum[0] : 0;
+    int i, j, fShort = 0;
+    assert( nShift <= 32 );
+    for( i = 0; i < nShift; i++ ) 
+        for( j = nNum-1; j >= fSticky; j-- ) 
+        {
+            if( fShort || (1<<i) > j ) 
+            {
+                pRes[j] = Gia_ManHashMux( pNew, pShift[i], Fill, pRes[j] );
+                if ( (1<<i) > nNum ) 
+                    fShort = 1;
+            } 
+            else 
+                pRes[j] = Gia_ManHashMux( pNew, pShift[i], pRes[j-(1<<i)], pRes[j] );
+        }
+}
+void Wlc_BlastRotateRight( Gia_Man_t * pNew, int * pNum, int nNum, int * pShift, int nShift, Vec_Int_t * vRes )
+{
+    int * pRes = Wlc_VecCopy( vRes, pNum, nNum );
+    int i, j, * pTemp = ABC_ALLOC( int, nNum );
+    assert( nShift <= 32 );
+    for( i = 0; i < nShift; i++, pRes = Wlc_VecCopy(vRes, pTemp, nNum) ) 
+        for( j = 0; j < nNum; j++ ) 
+            pTemp[j] = Gia_ManHashMux( pNew, pShift[i], pRes[(j+(1<<i))%nNum], pRes[j] );
+    ABC_FREE( pTemp );
+}
+void Wlc_BlastRotateLeft( Gia_Man_t * pNew, int * pNum, int nNum, int * pShift, int nShift, Vec_Int_t * vRes )
+{
+    int * pRes = Wlc_VecCopy( vRes, pNum, nNum );
+    int i, j, * pTemp = ABC_ALLOC( int, nNum );
+    assert( nShift <= 32 );
+    for( i = 0; i < nShift; i++, pRes = Wlc_VecCopy(vRes, pTemp, nNum) ) 
+        for( j = 0; j < nNum; j++ ) 
+        {
+            int move = (j >= (1<<i)) ? (j-(1<<i))%nNum : (nNum - (((1<<i)-j)%nNum)) % nNum;
+            pTemp[j] = Gia_ManHashMux( pNew, pShift[i], pRes[move], pRes[j] );
+//            pTemp[j] = Gia_ManHashMux( pNew, pShift[i], pRes[((unsigned)(nNum-(1<<i)+j))%nNum], pRes[j] );
+        }
+    ABC_FREE( pTemp );
+}
+int Wlc_BlastReduction( Gia_Man_t * pNew, int * pFans, int nFans, int Type )
+{
     if ( Type == WLC_OBJ_REDUCT_AND )
     {
         int k, iLit = 1;
@@ -80,17 +190,25 @@
     assert( 0 );
     return -1;
 }
-int Wlc_NtkMuxTree_rec( Gia_Man_t * pNew, int * pCtrl, int nCtrl, Vec_Int_t * vData, int Shift )
+int Wlc_BlastLess( Gia_Man_t * pNew, int * pArg0, int * pArg1, int nBits )
 {
-    int iLit0, iLit1;
-    if ( nCtrl == 0 )
-        return Vec_IntEntry( vData, Shift );
-    iLit0 = Wlc_NtkMuxTree_rec( pNew, pCtrl, nCtrl-1, vData, Shift );
-    iLit1 = Wlc_NtkMuxTree_rec( pNew, pCtrl, nCtrl-1, vData, Shift + (1<<(nCtrl-1)) );
-    return Gia_ManHashMux( pNew, pCtrl[nCtrl-1], iLit1, iLit0 );
+    int k, iKnown = 0, iRes = 0;
+    for ( k = nBits - 1; k >= 0; k-- )
+    {
+        iRes   = Gia_ManHashMux( pNew, iKnown, iRes, Gia_ManHashAnd(pNew, Abc_LitNot(pArg0[k]), pArg1[k]) );
+        iKnown = Gia_ManHashOr( pNew, iKnown, Gia_ManHashXor(pNew, pArg0[k], pArg1[k]) );
+        if ( iKnown == 1 )
+            break;
+    }
+    return iRes;
 }
-void Wlc_NtkAdderChain( Gia_Man_t * pNew, int * pAdd0, int * pAdd1, int nBits )
+int Wlc_BlastLessSigned( Gia_Man_t * pNew, int * pArg0, int * pArg1, int nBits )
 {
+    int iDiffSign = Gia_ManHashXor( pNew, pArg0[nBits-1], pArg1[nBits-1] );
+    return Gia_ManHashMux( pNew, iDiffSign, pArg0[nBits-1], Wlc_BlastLess(pNew, pArg0, pArg1, nBits-1) );
+}
+void Wlc_BlastAdder( Gia_Man_t * pNew, int * pAdd0, int * pAdd1, int nBits ) // result is in pAdd0
+{
     int iCarry = 0, iTerm1, iTerm2, iTerm3, iSum, b;
     for ( b = 0; b < nBits; b++ )
     {
@@ -102,118 +220,397 @@
         pAdd0[b] = iSum;
     }
 }
-Gia_Man_t * Wlc_NtkBitBlast( Wlc_Ntk_t * p )
+void Wlc_BlastSubtract( Gia_Man_t * pNew, int * pAdd0, int * pAdd1, int nBits ) // result is in pAdd0
 {
-    Gia_Man_t * pTemp, * pNew;
-    Wlc_Obj_t * pObj;
-    Vec_Int_t * vBits, * vTemp0, * vTemp1, * vTemp2, * vTemp3;
+    int borrow = 0, top_bit, b;
+    for ( b = 0; b < nBits; b++ )
+    {
+        top_bit  = Gia_ManHashMux(pNew, borrow, Abc_LitNot(pAdd0[b]),  pAdd0[b]);
+        borrow   = Gia_ManHashMux(pNew, pAdd0[b], Gia_ManHashAnd(pNew, borrow, pAdd1[b]), Gia_ManHashOr(pNew, borrow, pAdd1[b]));
+        pAdd0[b] = Gia_ManHashXor(pNew, top_bit, pAdd1[b]);
+    }
+}
+void Wlc_BlastMinus( Gia_Man_t * pNew, int * pNum, int nNum, Vec_Int_t * vRes )
+{
+    int * pRes  = Wlc_VecCopy( vRes, pNum, nNum );
+    int i, invert = 0;
+    for ( i = 0; i < nNum; i++ )
+    {
+        pRes[i] = Gia_ManHashMux( pNew, invert, Abc_LitNot(pRes[i]), pRes[i] );
+        invert = Gia_ManHashOr( pNew, invert, pNum[i] );    
+    }
+}
+void Wlc_BlastMultiplier( Gia_Man_t * pNew, int * pArg0, int * pArg1, int nBits, Vec_Int_t * vTemp, Vec_Int_t * vRes )
+{
+    int i, j;
+    Vec_IntFill( vRes, nBits, 0 );
+    for ( i = 0; i < nBits; i++ )
+    {
+        Vec_IntFill( vTemp, i, 0 );
+        for ( j = 0; Vec_IntSize(vTemp) < nBits; j++ )
+            Vec_IntPush( vTemp, Gia_ManHashAnd(pNew, pArg0[j], pArg1[i]) );
+        assert( Vec_IntSize(vTemp) == nBits );
+        Wlc_BlastAdder( pNew, Vec_IntArray(vRes), Vec_IntArray(vTemp), nBits );
+    }
+}
+void Wlc_BlastDivider( Gia_Man_t * pNew, int * pNum, int nNum, int * pDiv, int nDiv, int fQuo, Vec_Int_t * vRes )
+{
+    int * pRes  = Wlc_VecCopy( vRes, pNum, nNum );
+    int * pQuo  = ABC_ALLOC( int, nNum );
+    int * pTemp = ABC_ALLOC( int, nNum );
+    int i, j, known, borrow, y_bit, top_bit;
+    assert( nNum == nDiv );
+    for ( j = nNum - 1; j >= 0; j-- ) 
+    {
+        known = 0;
+        for ( i = nNum - 1; i > nNum - 1 - j; i-- ) 
+        {
+            known = Gia_ManHashOr( pNew, known, pDiv[i] );
+            if( known == 1 ) 
+                break;
+        }
+        pQuo[j] = known;
+        for ( i = nNum - 1; i >= 0; i-- ) 
+        {
+            if ( known == 1 ) 
+                break;
+            y_bit = (i >= j) ? pDiv[i-j] : 0;
+            pQuo[j] = Gia_ManHashMux( pNew, known, pQuo[j], Gia_ManHashAnd( pNew, y_bit, Abc_LitNot(pRes[i]) ) );
+            known = Gia_ManHashOr( pNew, known, Gia_ManHashXor(pNew, y_bit, pRes[i]));
+        }
+        pQuo[j] = Abc_LitNot(pQuo[j]);
+        if ( pQuo[j] == 0 )
+            continue;
+        borrow = 0;
+        for ( i = 0; i < nNum; i++ ) 
+        {
+            top_bit  = Gia_ManHashMux( pNew, borrow, Abc_LitNot(pRes[i]), pRes[i] );
+            y_bit    = (i >= j) ? pDiv[i-j] : 0;
+            borrow   = Gia_ManHashMux( pNew, pRes[i], Gia_ManHashAnd(pNew, borrow, y_bit), Gia_ManHashOr(pNew, borrow, y_bit) );
+            pTemp[i] = Gia_ManHashXor( pNew, top_bit, y_bit );
+        }
+        if ( pQuo[j] == 1 ) 
+            Wlc_VecCopy( vRes, pTemp, nNum );
+        else 
+            for( i = 0; i < nNum; i++ ) 
+                pRes[i] = Gia_ManHashMux( pNew, pQuo[j], pTemp[i], pRes[i] );
+    }
+    ABC_FREE( pTemp );
+    if ( fQuo )
+        Wlc_VecCopy( vRes, pQuo, nNum );
+    ABC_FREE( pQuo );
+}
+void Wlc_BlastDividerSigned( Gia_Man_t * pNew, int * pNum, int nNum, int * pDiv, int nDiv, int fQuo, Vec_Int_t * vRes )
+{
+    Vec_Int_t * vNum   = Vec_IntAlloc( nNum );
+    Vec_Int_t * vDiv   = Vec_IntAlloc( nDiv );
+    Vec_Int_t * vRes00 = Vec_IntAlloc( nNum );
+    Vec_Int_t * vRes01 = Vec_IntAlloc( nNum );
+    Vec_Int_t * vRes10 = Vec_IntAlloc( nNum );
+    Vec_Int_t * vRes11 = Vec_IntAlloc( nNum );
+    Vec_Int_t * vRes2  = Vec_IntAlloc( nNum );
+    int k, iDiffSign   = Gia_ManHashXor( pNew, pNum[nNum-1], pDiv[nDiv-1] );
+    Wlc_BlastMinus( pNew, pNum, nNum, vNum );
+    Wlc_BlastMinus( pNew, pDiv, nDiv, vDiv );
+    Wlc_BlastDivider( pNew,               pNum, nNum,               pDiv, nDiv, fQuo, vRes00 );
+    Wlc_BlastDivider( pNew,               pNum, nNum, Vec_IntArray(vDiv), nDiv, fQuo, vRes01 );
+    Wlc_BlastDivider( pNew, Vec_IntArray(vNum), nNum,               pDiv, nDiv, fQuo, vRes10 );
+    Wlc_BlastDivider( pNew, Vec_IntArray(vNum), nNum, Vec_IntArray(vDiv), nDiv, fQuo, vRes11 );
+    Vec_IntClear( vRes );
+    for ( k = 0; k < nNum; k++ )
+    {
+        int Data0 =  Gia_ManHashMux( pNew, pDiv[nDiv-1], Vec_IntEntry(vRes01,k), Vec_IntEntry(vRes00,k) );
+        int Data1 =  Gia_ManHashMux( pNew, pDiv[nDiv-1], Vec_IntEntry(vRes11,k), Vec_IntEntry(vRes10,k) );
+        Vec_IntPush( vRes, Gia_ManHashMux(pNew, pNum[nNum-1], Data1, Data0) );
+    }
+    Wlc_BlastMinus( pNew, Vec_IntArray(vRes), nNum, vRes2 );
+    for ( k = 0; k < nNum; k++ )
+        Vec_IntWriteEntry( vRes, k, Gia_ManHashMux(pNew, fQuo ? iDiffSign : pNum[nNum-1], Vec_IntEntry(vRes2,k), Vec_IntEntry(vRes,k)) );
+    Vec_IntFree( vNum );
+    Vec_IntFree( vDiv );
+    Vec_IntFree( vRes00 );
+    Vec_IntFree( vRes01 );
+    Vec_IntFree( vRes10 );
+    Vec_IntFree( vRes11 );
+    Vec_IntFree( vRes2 );
+    assert( Vec_IntSize(vRes) == nNum );
+}
+void Wlc_BlastZeroCondition( Gia_Man_t * pNew, int * pDiv, int nDiv, Vec_Int_t * vRes )
+{
+    int i, Entry, iLit = Wlc_BlastReduction( pNew, pDiv, nDiv, WLC_OBJ_REDUCT_OR );
+    Vec_IntForEachEntry( vRes, Entry, i )
+        Vec_IntWriteEntry( vRes, i, Gia_ManHashAnd(pNew, iLit, Entry) );
+}
+void Wlc_BlastTable( Gia_Man_t * pNew, word * pTable, int * pFans, int nFans, int nOuts, Vec_Int_t * vRes )
+{
+    extern int Kit_TruthToGia( Gia_Man_t * pMan, unsigned * pTruth, int nVars, Vec_Int_t * vMemory, Vec_Int_t * vLeaves, int fHash );
+    Vec_Int_t * vMemory = Vec_IntAlloc( 0 );
+    Vec_Int_t vLeaves = { nFans, nFans, pFans };
+    word * pTruth = ABC_ALLOC( word, Abc_TtWordNum(nFans) );
+    int o, i, m, iLit, nMints = (1 << nFans);
+    Vec_IntClear( vRes );
+    for ( o = 0; o < nOuts; o++ )
+    {
+        // derive truth table
+        memset( pTruth, 0, sizeof(word) * Abc_TtWordNum(nFans) );
+        for ( m = 0; m < nMints; m++ )
+            for ( i = 0; i < nFans; i++ )
+                if ( Abc_TtGetBit( pTable, m * nFans + i ) )
+                    Abc_TtSetBit( pTruth, m );
+        // implement truth table
+        if ( nFans < 6 )
+            pTruth[0] = Abc_Tt6Stretch( pTruth[0], nFans );
+        iLit = Kit_TruthToGia( pNew, (unsigned *)pTruth, nFans, vMemory, &vLeaves, 1 );
+        Vec_IntPush( vRes, iLit );
+    }
+    Vec_IntFree( vMemory );
+    ABC_FREE( pTruth );
+}
+void Wlc_BlastPower( Gia_Man_t * pNew, int * pNum, int nNum, int * pExp, int nExp, Vec_Int_t * vTemp, Vec_Int_t * vRes )
+{
+    Vec_Int_t * vDegrees = Vec_IntAlloc( nNum );
+    Vec_Int_t * vResTemp = Vec_IntAlloc( nNum );
+    int i, * pDegrees = NULL, * pRes = Vec_IntArray(vRes);
+    int k, * pResTemp = Vec_IntArray(vResTemp);
+    Vec_IntFill( vRes, nNum, 0 );
+    Vec_IntWriteEntry( vRes, 0, 1 );
+    for ( i = 0; i < nExp; i++ )
+    {
+        if ( i == 0 )
+            pDegrees = Wlc_VecCopy( vDegrees, pNum, nNum );
+        else
+        {
+            Wlc_BlastMultiplier( pNew, pDegrees, pDegrees, nNum, vTemp, vResTemp );
+            pDegrees = Wlc_VecCopy( vDegrees, pResTemp, nNum );
+        }
+        Wlc_BlastMultiplier( pNew, pRes, pDegrees, nNum, vTemp, vResTemp );
+        for ( k = 0; k < nNum; k++ )
+            pRes[k] = Gia_ManHashMux( pNew, pExp[i], pResTemp[k], pRes[k] );
+    }
+    Vec_IntFree( vResTemp );
+    Vec_IntFree( vDegrees );
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Gia_Man_t * Wlc_NtkBitBlast( Wlc_Ntk_t * p, Vec_Int_t * vBoxIds )
+{
+    int fVerbose = 0;
+    Tim_Man_t * pManTime = NULL;
+    Gia_Man_t * pTemp, * pNew, * pExtra = NULL;
+    Wlc_Obj_t * pObj, * pPrev = NULL;
+    Vec_Int_t * vBits, * vTemp0, * vTemp1, * vTemp2, * vRes;
     int nBits = Wlc_NtkPrepareBits( p );
     int nRange, nRange0, nRange1, nRange2;
-    int i, k, b, iLit, * pFans0, * pFans1, * pFans2;
+    int i, k, b, iFanin, iLit, nAndPrev, * pFans0, * pFans1, * pFans2;
+    int nFFins = 0, nFFouts = 0, curPi = 0, curPo = 0;
+    int nBitCis = 0, nBitCos = 0;
     vBits  = Vec_IntAlloc( nBits );
     vTemp0 = Vec_IntAlloc( 1000 );
     vTemp1 = Vec_IntAlloc( 1000 );
     vTemp2 = Vec_IntAlloc( 1000 );
-    vTemp3 = Vec_IntAlloc( 1000 );
-    // craete AIG manager
+    vRes   = Vec_IntAlloc( 1000 );
+    // clean AND-gate counters
+    memset( p->nAnds, 0, sizeof(int) * WLC_OBJ_NUMBER );
+    // create AIG manager
     pNew = Gia_ManStart( 5 * Wlc_NtkObjNum(p) + 1000 );
     pNew->pName = Abc_UtilStrsav( p->pName );
     Gia_ManHashAlloc( pNew );
-    // create primary inputs
+    // prepare for AIG with boxes
+    if ( vBoxIds )
+    {
+        int nNewCis = 0, nNewCos = 0;
+        Wlc_NtkForEachObj( p, pObj, i )
+            pObj->Mark = 0;
+        // count bit-width of regular CIs/COs
+        Wlc_NtkForEachCi( p, pObj, i )
+            nBitCis += Wlc_ObjRange( pObj );
+        Wlc_NtkForEachCo( p, pObj, i )
+            nBitCos += Wlc_ObjRange( pObj );
+        // count bit-width of additional CIs/COs due to selected multipliers
+        assert( Vec_IntSize(vBoxIds) > 0 );
+        Wlc_NtkForEachObjVec( vBoxIds, p, pObj, i )
+        {
+            // currently works only for multipliers
+            assert( pObj->Type == WLC_OBJ_ARI_MULTI );
+            nNewCis += Wlc_ObjRange( pObj );
+            nNewCos += Wlc_ObjRange( Wlc_ObjFanin0(p, pObj) );
+            nNewCos += Wlc_ObjRange( Wlc_ObjFanin1(p, pObj) );
+            pObj->Mark = 1;
+        }
+        // create hierarchy manager
+        pManTime = Tim_ManStart( nBitCis + nNewCis, nBitCos + nNewCos );
+        curPi = nBitCis;
+        curPo = 0;
+        // create AIG manager for logic of the boxes
+        pExtra = Gia_ManStart( Wlc_NtkObjNum(p) );
+        Gia_ManHashAlloc( pExtra );
+    }
+    // blast in the topological order
     Wlc_NtkForEachObj( p, pObj, i )
     {
 //        char * pName = Wlc_ObjName(p, i);
+        nAndPrev = Gia_ManAndNum(pNew);
         nRange  = Wlc_ObjRange( pObj );
         nRange0 = Wlc_ObjFaninNum(pObj) > 0 ? Wlc_ObjRange( Wlc_ObjFanin0(p, pObj) ) : -1;
         nRange1 = Wlc_ObjFaninNum(pObj) > 1 ? Wlc_ObjRange( Wlc_ObjFanin1(p, pObj) ) : -1;
         nRange2 = Wlc_ObjFaninNum(pObj) > 2 ? Wlc_ObjRange( Wlc_ObjFanin2(p, pObj) ) : -1;
-        pFans0 = Wlc_ObjFaninNum(pObj) > 0 ? Vec_IntEntryP( vBits, Wlc_ObjCopy(p, Wlc_ObjFaninId0(pObj)) ) : NULL;
-        pFans1 = Wlc_ObjFaninNum(pObj) > 1 ? Vec_IntEntryP( vBits, Wlc_ObjCopy(p, Wlc_ObjFaninId1(pObj)) ) : NULL;
-        pFans2 = Wlc_ObjFaninNum(pObj) > 2 ? Vec_IntEntryP( vBits, Wlc_ObjCopy(p, Wlc_ObjFaninId2(pObj)) ) : NULL;
-        if ( pObj->Type == WLC_OBJ_PI )
+        pFans0  = Wlc_ObjFaninNum(pObj) > 0 ? Vec_IntEntryP( vBits, Wlc_ObjCopy(p, Wlc_ObjFaninId0(pObj)) ) : NULL;
+        pFans1  = Wlc_ObjFaninNum(pObj) > 1 ? Vec_IntEntryP( vBits, Wlc_ObjCopy(p, Wlc_ObjFaninId1(pObj)) ) : NULL;
+        pFans2  = Wlc_ObjFaninNum(pObj) > 2 ? Vec_IntEntryP( vBits, Wlc_ObjCopy(p, Wlc_ObjFaninId2(pObj)) ) : NULL;
+        Vec_IntClear( vRes );
+        assert( nRange > 0 );
+        if ( vBoxIds && pObj->Mark )
         {
+            pObj->Mark = 0;
+
+            // create new box
+            Tim_ManCreateBox( pManTime, curPo, nRange0 + nRange1, curPi, nRange, -1 );
+            curPi += nRange;
+            curPo += nRange0 + nRange1;
+
+            // create combinational outputs in the normal manager
+            for ( k = 0; k < nRange0; k++ )
+                Gia_ManAppendCo( pNew, pFans0[k] );
+            for ( k = 0; k < nRange1; k++ )
+                Gia_ManAppendCo( pNew, pFans1[k] );
+
+            // make sure there is enough primary inputs in the manager
+            for ( k = Gia_ManPiNum(pExtra); k < nRange0 + nRange1; k++ )
+                Gia_ManAppendCi( pExtra );
+            // create combinational inputs
+            Vec_IntClear( vTemp0 );
+            for ( k = 0; k < nRange0; k++ )
+                Vec_IntPush( vTemp0, Gia_Obj2Lit(pExtra, Gia_ManPi(pExtra, k)) );
+            Vec_IntClear( vTemp1 );
+            for ( k = 0; k < nRange1; k++ )
+                Vec_IntPush( vTemp1, Gia_Obj2Lit(pExtra, Gia_ManPi(pExtra, nRange0+k)) );
+            // get new fanin arrays
+            pFans0 = Vec_IntArray( vTemp0 );
+            pFans1 = Vec_IntArray( vTemp1 );
+            // bit-blast the multiplier in the external manager
+            {
+                int nRangeMax = Abc_MaxInt( nRange, Abc_MaxInt(nRange0, nRange1) );
+                int * pArg0 = Wlc_VecLoadFanins( vTemp0, pFans0, nRange0, nRangeMax, Wlc_ObjIsSignedFanin01(p, pObj) );
+                int * pArg1 = Wlc_VecLoadFanins( vTemp1, pFans1, nRange1, nRangeMax, Wlc_ObjIsSignedFanin01(p, pObj) );
+                Wlc_BlastMultiplier( pExtra, pArg0, pArg1, nRange, vTemp2, vRes );
+                Vec_IntShrink( vRes, nRange );
+            }
+            // create outputs in the external manager
             for ( k = 0; k < nRange; k++ )
-                Vec_IntPush( vBits, Gia_ManAppendCi(pNew) );
+                Gia_ManAppendCo( pExtra, Vec_IntEntry(vRes, k) );
+
+            // create combinational inputs in the normal manager
+            Vec_IntClear( vRes );
+            for ( k = 0; k < nRange; k++ )
+                Vec_IntPush( vRes, Gia_ManAppendCi(pNew) );
         }
-        else if ( pObj->Type == WLC_OBJ_PO || pObj->Type == WLC_OBJ_BUF )
+        else if ( Wlc_ObjIsCi(pObj) )
         {
-//            assert( nRange <= nRange0 );
             for ( k = 0; k < nRange; k++ )
-                Vec_IntPush( vBits, k < nRange0 ? pFans0[k] : 0 );
+                Vec_IntPush( vRes, Gia_ManAppendCi(pNew) );
+            if ( pObj->Type == WLC_OBJ_FO )
+                nFFouts += Vec_IntSize(vRes);
         }
+        else if ( pObj->Type == WLC_OBJ_BUF )
+        {
+            int nRangeMax = Abc_MaxInt( nRange0, nRange );
+            int * pArg0 = Wlc_VecLoadFanins( vTemp0, pFans0, nRange0, nRangeMax, Wlc_ObjFanin0(p, pObj)->Signed );
+            for ( k = 0; k < nRange; k++ )
+                Vec_IntPush( vRes, pArg0[k] );
+        }
         else if ( pObj->Type == WLC_OBJ_CONST )
         {
             word * pTruth = (word *)Wlc_ObjFanins(pObj);
             for ( k = 0; k < nRange; k++ )
-                Vec_IntPush( vBits, Abc_TtGetBit(pTruth, k) );
+                Vec_IntPush( vRes, Abc_TtGetBit(pTruth, k) );
         }
         else if ( pObj->Type == WLC_OBJ_MUX )
         {
-            assert( nRange0 == 1 );
-            assert( nRange1 == nRange );
-            assert( nRange2 == nRange );
-            for ( k = 0; k < nRange; k++ )
-                Vec_IntPush( vBits, Gia_ManHashMux(pNew, pFans0[0], pFans1[k], pFans2[k]) );
+            assert( 1 + (1 << nRange0) == Wlc_ObjFaninNum(pObj) );
+            for ( b = 0; b < nRange; b++ )
+            {
+                Vec_IntClear( vTemp0 );
+                Wlc_ObjForEachFanin( pObj, iFanin, k )
+                {
+                    if ( !k ) continue;
+                    //assert( nRange == Wlc_ObjRange(Wlc_NtkObj(p, iFanin)) );
+                    pFans1 = Vec_IntEntryP( vBits, Wlc_ObjCopy(p, iFanin) );
+                    Vec_IntPush( vTemp0, b < Wlc_ObjRange(Wlc_NtkObj(p, iFanin)) ? pFans1[b] : 0 );
+                }
+                Vec_IntPush( vRes, Wlc_NtkMuxTree_rec(pNew, pFans0, nRange0, vTemp0, 0) );
+            }
         }
-        else if ( pObj->Type == WLC_OBJ_SHIFT_R || pObj->Type == WLC_OBJ_SHIFT_RA )
+        else if ( pObj->Type == WLC_OBJ_SHIFT_R || pObj->Type == WLC_OBJ_SHIFT_RA ||
+                  pObj->Type == WLC_OBJ_SHIFT_L || pObj->Type == WLC_OBJ_SHIFT_LA )
         {
-            // prepare data
-            int Fill = pObj->Type == WLC_OBJ_SHIFT_R ? 0 : pFans0[nRange0-1];
-            int nTotal = nRange + (1 << nRange1);
-            Vec_IntClear( vTemp0 );
-            for ( k = 0; k < nRange0; k++ )
-                Vec_IntPush( vTemp0, pFans0[k] );
-            for ( k = 0; k < nTotal; k++ )
-                Vec_IntPush( vTemp0, Fill );
-            // derive the result
-            for ( k = 0; k < nRange; k++ )
-                Vec_IntPush( vBits, Wlc_NtkMuxTree_rec(pNew, pFans1, nRange1, vTemp0, k) );
+            int nRangeMax = Abc_MaxInt( nRange, nRange0 );
+            int * pArg0 = Wlc_VecLoadFanins( vTemp0, pFans0, nRange0, nRangeMax, Wlc_ObjFanin0(p, pObj)->Signed );
+            if ( pObj->Type == WLC_OBJ_SHIFT_R || pObj->Type == WLC_OBJ_SHIFT_RA )
+                Wlc_BlastShiftRight( pNew, pArg0, nRangeMax, pFans1, nRange1, Wlc_ObjFanin0(p, pObj)->Signed && pObj->Type == WLC_OBJ_SHIFT_RA, vRes );
+            else
+                Wlc_BlastShiftLeft( pNew, pArg0, nRangeMax, pFans1, nRange1, 0, vRes );
+            Vec_IntShrink( vRes, nRange );
         }
-        else if ( pObj->Type == WLC_OBJ_SHIFT_L || pObj->Type == WLC_OBJ_SHIFT_LA )
+        else if ( pObj->Type == WLC_OBJ_ROTATE_R )
         {
-            // prepare data
-            int Fill = pObj->Type == WLC_OBJ_SHIFT_L ? 0 : pFans0[0];
-            int nTotal = nRange + (1 << nRange1);
-            Vec_IntClear( vTemp0 );
-            for ( k = 0; k < nRange0; k++ )
-                Vec_IntPush( vTemp0, pFans0[k] );
-            for ( k = 0; k < nTotal; k++ )
-                Vec_IntPush( vTemp0, Fill );
-            // derive the result
-            for ( k = 0; k < nRange; k++ )
-                Vec_IntPush( vBits, Wlc_NtkMuxTree_rec(pNew, pFans1, nRange1, vTemp0, k) );
+            assert( nRange0 == nRange );
+            Wlc_BlastRotateRight( pNew, pFans0, nRange0, pFans1, nRange1, vRes );
         }
+        else if ( pObj->Type == WLC_OBJ_ROTATE_L )
+        {
+            assert( nRange0 == nRange );
+            Wlc_BlastRotateLeft( pNew, pFans0, nRange0, pFans1, nRange1, vRes );
+        }
         else if ( pObj->Type == WLC_OBJ_BIT_NOT )
         {
-            assert( nRange == nRange0 );
+            int nRangeMax = Abc_MaxInt( nRange, nRange0 );
+            int * pArg0 = Wlc_VecLoadFanins( vTemp0, pFans0, nRange0, nRangeMax, Wlc_ObjFanin0(p, pObj)->Signed );
             for ( k = 0; k < nRange; k++ )
-                Vec_IntPush( vBits, Abc_LitNot(pFans0[k]) );
+                Vec_IntPush( vRes, Abc_LitNot(pArg0[k]) );
         }
         else if ( pObj->Type == WLC_OBJ_BIT_AND )
         {
-            assert( nRange0 == nRange && nRange1 == nRange );
+            int nRangeMax = Abc_MaxInt( nRange, Abc_MaxInt(nRange0, nRange1) );
+            int * pArg0 = Wlc_VecLoadFanins( vTemp0, pFans0, nRange0, nRangeMax, Wlc_ObjIsSignedFanin01(p, pObj) );
+            int * pArg1 = Wlc_VecLoadFanins( vTemp1, pFans1, nRange1, nRangeMax, Wlc_ObjIsSignedFanin01(p, pObj) );
             for ( k = 0; k < nRange; k++ )
-                Vec_IntPush( vBits, Gia_ManHashAnd(pNew, pFans0[k], pFans1[k]) );
+                Vec_IntPush( vRes, Gia_ManHashAnd(pNew, pArg0[k], pArg1[k]) );
         }
         else if ( pObj->Type == WLC_OBJ_BIT_OR )
         {
-            assert( nRange0 == nRange && nRange1 == nRange );
+            int nRangeMax = Abc_MaxInt( nRange, Abc_MaxInt(nRange0, nRange1) );
+            int * pArg0 = Wlc_VecLoadFanins( vTemp0, pFans0, nRange0, nRangeMax, Wlc_ObjIsSignedFanin01(p, pObj) );
+            int * pArg1 = Wlc_VecLoadFanins( vTemp1, pFans1, nRange1, nRangeMax, Wlc_ObjIsSignedFanin01(p, pObj) );
             for ( k = 0; k < nRange; k++ )
-                Vec_IntPush( vBits, Gia_ManHashOr(pNew, pFans0[k], pFans1[k]) );
+                Vec_IntPush( vRes, Gia_ManHashOr(pNew, pArg0[k], pArg1[k]) );
         }
         else if ( pObj->Type == WLC_OBJ_BIT_XOR )
         {
-            assert( nRange0 == nRange && nRange1 == nRange );
+            int nRangeMax = Abc_MaxInt( nRange, Abc_MaxInt(nRange0, nRange1) );
+            int * pArg0 = Wlc_VecLoadFanins( vTemp0, pFans0, nRange0, nRangeMax, Wlc_ObjIsSignedFanin01(p, pObj) );
+            int * pArg1 = Wlc_VecLoadFanins( vTemp1, pFans1, nRange1, nRangeMax, Wlc_ObjIsSignedFanin01(p, pObj) );
             for ( k = 0; k < nRange; k++ )
-                Vec_IntPush( vBits, Gia_ManHashXor(pNew, pFans0[k], pFans1[k]) );
+                Vec_IntPush( vRes, Gia_ManHashXor(pNew, pArg0[k], pArg1[k]) );
         }
         else if ( pObj->Type == WLC_OBJ_BIT_SELECT )
         {
+            Wlc_Obj_t * pFanin = Wlc_ObjFanin0(p, pObj);
             int End = Wlc_ObjRangeEnd(pObj);
             int Beg = Wlc_ObjRangeBeg(pObj);
             assert( nRange == End - Beg + 1 );
+            assert( (int)pFanin->Beg <= Beg && End <= (int)pFanin->End );
             for ( k = Beg; k <= End; k++ )
-                Vec_IntPush( vBits, pFans0[k] );
+                Vec_IntPush( vRes, pFans0[k - pFanin->Beg] );
         }
         else if ( pObj->Type == WLC_OBJ_BIT_CONCAT )
         {
@@ -226,7 +623,7 @@
                 nRange0 = Wlc_ObjRange( Wlc_NtkObj(p, iFanin) );
                 pFans0 = Vec_IntEntryP( vBits, Wlc_ObjCopy(p, iFanin) );
                 for ( b = 0; b < nRange0; b++ )
-                    Vec_IntPush( vBits, pFans0[b] );
+                    Vec_IntPush( vRes, pFans0[b] );
             }
         }
         else if ( pObj->Type == WLC_OBJ_BIT_ZEROPAD || pObj->Type == WLC_OBJ_BIT_SIGNEXT )
@@ -234,122 +631,185 @@
             int Pad = pObj->Type == WLC_OBJ_BIT_ZEROPAD ? 0 : pFans0[nRange0-1];
             assert( nRange0 < nRange );
             for ( k = 0; k < nRange0; k++ )
-                Vec_IntPush( vBits, pFans0[k] );
+                Vec_IntPush( vRes, pFans0[k] );
             for (      ; k < nRange; k++ )
-                Vec_IntPush( vBits, Pad );
+                Vec_IntPush( vRes, Pad );
         }
         else if ( pObj->Type == WLC_OBJ_LOGIC_NOT )
         {
-            iLit = Wlc_NtkComputeReduction( pNew, pFans0, nRange, WLC_OBJ_REDUCT_OR );
-            assert( nRange == 1 );
-            Vec_IntPush( vBits, Abc_LitNot(iLit) );
+            iLit = Wlc_BlastReduction( pNew, pFans0, nRange0, WLC_OBJ_REDUCT_OR );
+            Vec_IntFill( vRes, 1, Abc_LitNot(iLit) );
+            for ( k = 1; k < nRange; k++ )
+                Vec_IntPush( vRes, 0 );
         }
         else if ( pObj->Type == WLC_OBJ_LOGIC_AND )
         {
-            int iLit0 = Wlc_NtkComputeReduction( pNew, pFans0, nRange, WLC_OBJ_REDUCT_OR );
-            int iLit1 = Wlc_NtkComputeReduction( pNew, pFans0, nRange, WLC_OBJ_REDUCT_OR );
-            assert( nRange == 1 );
-            Vec_IntPush( vBits, Gia_ManHashAnd(pNew, iLit0, iLit1) );
+            int iLit0 = Wlc_BlastReduction( pNew, pFans0, nRange0, WLC_OBJ_REDUCT_OR );
+            int iLit1 = Wlc_BlastReduction( pNew, pFans1, nRange1, WLC_OBJ_REDUCT_OR );
+            Vec_IntFill( vRes, 1, Gia_ManHashAnd(pNew, iLit0, iLit1) );
+            for ( k = 1; k < nRange; k++ )
+                Vec_IntPush( vRes, 0 );
         }
         else if ( pObj->Type == WLC_OBJ_LOGIC_OR )
         {
-            int iLit0 = Wlc_NtkComputeReduction( pNew, pFans0, nRange, WLC_OBJ_REDUCT_OR );
-            int iLit1 = Wlc_NtkComputeReduction( pNew, pFans0, nRange, WLC_OBJ_REDUCT_OR );
-            assert( nRange == 1 );
-            Vec_IntPush( vBits, Gia_ManHashOr(pNew, iLit0, iLit1) );
+            int iLit0 = Wlc_BlastReduction( pNew, pFans0, nRange0, WLC_OBJ_REDUCT_OR );
+            int iLit1 = Wlc_BlastReduction( pNew, pFans1, nRange1, WLC_OBJ_REDUCT_OR );
+            Vec_IntFill( vRes, 1, Gia_ManHashOr(pNew, iLit0, iLit1) );
+            for ( k = 1; k < nRange; k++ )
+                Vec_IntPush( vRes, 0 );
         }
-        else if ( pObj->Type == WLC_OBJ_COMP_EQU || pObj->Type == WLC_OBJ_COMP_NOT )
+        else if ( pObj->Type == WLC_OBJ_COMP_EQU || pObj->Type == WLC_OBJ_COMP_NOTEQU )
         {
-            int iLit = 0;
-            assert( nRange == 1 );
-            assert( nRange0 == nRange1 );
-            for ( k = 0; k < nRange0; k++ )
-                iLit = Gia_ManHashOr( pNew, iLit, Gia_ManHashXor(pNew, pFans0[k], pFans1[k]) ); 
-            Vec_IntPush( vBits, Abc_LitNotCond(iLit, pObj->Type == WLC_OBJ_COMP_EQU) );
+            int iLit = 0, nRangeMax = Abc_MaxInt( nRange0, nRange1 );
+            int * pArg0 = Wlc_VecLoadFanins( vTemp0, pFans0, nRange0, nRangeMax, Wlc_ObjIsSignedFanin01(p, pObj) );
+            int * pArg1 = Wlc_VecLoadFanins( vTemp1, pFans1, nRange1, nRangeMax, Wlc_ObjIsSignedFanin01(p, pObj) );
+            for ( k = 0; k < nRangeMax; k++ )
+                iLit = Gia_ManHashOr( pNew, iLit, Gia_ManHashXor(pNew, pArg0[k], pArg1[k]) ); 
+            Vec_IntFill( vRes, 1, Abc_LitNotCond(iLit, pObj->Type == WLC_OBJ_COMP_EQU) );
+            for ( k = 1; k < nRange; k++ )
+                Vec_IntPush( vRes, 0 );
         }
         else if ( pObj->Type == WLC_OBJ_COMP_LESS || pObj->Type == WLC_OBJ_COMP_MOREEQU ||
                   pObj->Type == WLC_OBJ_COMP_MORE || pObj->Type == WLC_OBJ_COMP_LESSEQU )
         {
-            int iTerm, iEqu = 1, iLit = 0;
-            assert( nRange == 1 );
-            assert( nRange0 == nRange1 );
-            if ( pObj->Type == WLC_OBJ_COMP_MORE || pObj->Type == WLC_OBJ_COMP_LESSEQU )
-                ABC_SWAP( int *, pFans0, pFans1 );
-            for ( k = nRange0 - 1; k >= 0; k-- )
-            {
-                iTerm = Gia_ManHashAnd( pNew, Abc_LitNot(pFans0[k]), pFans1[k] );
-                iTerm = Gia_ManHashAnd( pNew, iTerm, iEqu );
-                iLit  = Gia_ManHashOr( pNew, iLit, iTerm ); 
-                iEqu  = Abc_LitNot( Gia_ManHashXor( pNew, pFans0[k], pFans1[k] ) );
-            }
-            Vec_IntPush( vBits, Abc_LitNotCond(iLit, pObj->Type == WLC_OBJ_COMP_MOREEQU) );
+            int nRangeMax = Abc_MaxInt( nRange0, nRange1 );
+            int fSigned = Wlc_ObjIsSignedFanin01(p, pObj);
+            int * pArg0 = Wlc_VecLoadFanins( vTemp0, pFans0, nRange0, nRangeMax, fSigned );
+            int * pArg1 = Wlc_VecLoadFanins( vTemp1, pFans1, nRange1, nRangeMax, fSigned );
+            int fSwap  = (pObj->Type == WLC_OBJ_COMP_MORE    || pObj->Type == WLC_OBJ_COMP_LESSEQU);
+            int fCompl = (pObj->Type == WLC_OBJ_COMP_MOREEQU || pObj->Type == WLC_OBJ_COMP_LESSEQU);
+            if ( fSwap ) ABC_SWAP( int *, pArg0, pArg1 );
+            if ( fSigned )
+                iLit = Wlc_BlastLessSigned( pNew, pArg0, pArg1, nRangeMax );
+            else
+                iLit = Wlc_BlastLess( pNew, pArg0, pArg1, nRangeMax );
+            iLit = Abc_LitNotCond( iLit, fCompl );
+            Vec_IntFill( vRes, 1, iLit );
+            for ( k = 1; k < nRange; k++ )
+                Vec_IntPush( vRes, 0 );
         }
         else if ( pObj->Type == WLC_OBJ_REDUCT_AND || pObj->Type == WLC_OBJ_REDUCT_OR || pObj->Type == WLC_OBJ_REDUCT_XOR )
-            Vec_IntPush( vBits, Wlc_NtkComputeReduction( pNew, pFans0, nRange, pObj->Type ) );
-        else if ( pObj->Type == WLC_OBJ_ARI_ADD )
         {
-            int Pad0 = Wlc_ObjFanin0(p, pObj)->Signed ? pFans0[nRange0-1] : 0;
-            int Pad1 = Wlc_ObjFanin1(p, pObj)->Signed ? pFans1[nRange1-1] : 0;
-            assert( nRange0 <= nRange && nRange1 <= nRange );
-            Vec_IntClear( vTemp0 );
-            for ( k = 0; k < nRange; k++ )
-                Vec_IntPush( vTemp0, k < nRange0 ? pFans0[k] : Pad0 );
-            Vec_IntClear( vTemp1 );
-            for ( k = 0; k < nRange; k++ )
-                Vec_IntPush( vTemp1, k < nRange1 ? pFans1[k] : Pad1 );
-            Wlc_NtkAdderChain( pNew, Vec_IntArray(vTemp0), Vec_IntArray(vTemp1), nRange );
-            Vec_IntAppend( vBits, vTemp0 );
+            Vec_IntPush( vRes, Wlc_BlastReduction( pNew, pFans0, nRange0, pObj->Type ) );
+            for ( k = 1; k < nRange; k++ )
+                Vec_IntPush( vRes, 0 );
         }
+        else if ( pObj->Type == WLC_OBJ_ARI_ADD || pObj->Type == WLC_OBJ_ARI_SUB ) 
+        {
+            int nRangeMax = Abc_MaxInt( nRange, Abc_MaxInt(nRange0, nRange1) );
+            int * pArg0 = Wlc_VecLoadFanins( vRes,   pFans0, nRange0, nRangeMax, Wlc_ObjIsSignedFanin01(p, pObj) );
+            int * pArg1 = Wlc_VecLoadFanins( vTemp1, pFans1, nRange1, nRangeMax, Wlc_ObjIsSignedFanin01(p, pObj) );
+            if ( pObj->Type == WLC_OBJ_ARI_ADD )
+                Wlc_BlastAdder( pNew, pArg0, pArg1, nRange ); // result is in pFan0 (vRes)
+            else 
+                Wlc_BlastSubtract( pNew, pArg0, pArg1, nRange ); // result is in pFan0 (vRes)
+            Vec_IntShrink( vRes, nRange );
+        }
         else if ( pObj->Type == WLC_OBJ_ARI_MULTI )
         {
-            int Pad0 = Wlc_ObjFanin0(p, pObj)->Signed ? pFans0[nRange0-1] : 0;
-            int Pad1 = Wlc_ObjFanin1(p, pObj)->Signed ? pFans1[nRange1-1] : 0;
-            assert( nRange0 <= nRange && nRange1 <= nRange );
-            Vec_IntClear( vTemp0 );
-            for ( k = 0; k < nRange; k++ )
-                Vec_IntPush( vTemp0, k < nRange0 ? pFans0[k] : Pad0 );
-            Vec_IntClear( vTemp1 );
-            for ( k = 0; k < nRange; k++ )
-                Vec_IntPush( vTemp1, k < nRange1 ? pFans1[k] : Pad1 );
-            // iterate
-            Vec_IntFill( vTemp3, nRange, 0 );
-            for ( k = 0; k < nRange; k++ )
-            {
-                Vec_IntFill( vTemp2, k, 0 );
-                Vec_IntForEachEntry( vTemp0, iLit, b )
-                {
-                    Vec_IntPush( vTemp2, Gia_ManHashAnd(pNew, iLit, Vec_IntEntry(vTemp1, k)) );
-                    if ( Vec_IntSize(vTemp2) == nRange )
-                        break;
-                }
-                assert( Vec_IntSize(vTemp2) == nRange );
-                Wlc_NtkAdderChain( pNew, Vec_IntArray(vTemp3), Vec_IntArray(vTemp2), nRange );
-            }
-            assert( Vec_IntSize(vTemp3) == nRange );
-            Vec_IntAppend( vBits, vTemp3 );
+            int nRangeMax = Abc_MaxInt( nRange, Abc_MaxInt(nRange0, nRange1) );
+            int * pArg0 = Wlc_VecLoadFanins( vTemp0, pFans0, nRange0, nRangeMax, Wlc_ObjIsSignedFanin01(p, pObj) );
+            int * pArg1 = Wlc_VecLoadFanins( vTemp1, pFans1, nRange1, nRangeMax, Wlc_ObjIsSignedFanin01(p, pObj) );
+            Wlc_BlastMultiplier( pNew, pArg0, pArg1, nRange, vTemp2, vRes );
+            Vec_IntShrink( vRes, nRange );
         }
+        else if ( pObj->Type == WLC_OBJ_ARI_DIVIDE || pObj->Type == WLC_OBJ_ARI_MODULUS )
+        {
+            int nRangeMax = Abc_MaxInt( nRange, Abc_MaxInt(nRange0, nRange1) );
+            int fSigned = Wlc_ObjIsSignedFanin01(p, pObj);
+            int * pArg0 = Wlc_VecLoadFanins( vTemp0, pFans0, nRange0, nRangeMax, fSigned );
+            int * pArg1 = Wlc_VecLoadFanins( vTemp1, pFans1, nRange1, nRangeMax, fSigned );
+            if ( fSigned )
+                Wlc_BlastDividerSigned( pNew, pArg0, nRangeMax, pArg1, nRangeMax, pObj->Type == WLC_OBJ_ARI_DIVIDE, vRes );
+            else
+                Wlc_BlastDivider( pNew, pArg0, nRangeMax, pArg1, nRangeMax, pObj->Type == WLC_OBJ_ARI_DIVIDE, vRes );
+            Vec_IntShrink( vRes, nRange );
+            Wlc_BlastZeroCondition( pNew, pFans1, nRange1, vRes );
+        }
+        else if ( pObj->Type == WLC_OBJ_ARI_MINUS )
+        {
+            int nRangeMax = Abc_MaxInt( nRange0, nRange );
+            int * pArg0 = Wlc_VecLoadFanins( vTemp0, pFans0, nRange0, nRangeMax, Wlc_ObjFanin0(p, pObj)->Signed );
+            Wlc_BlastMinus( pNew, pArg0, nRangeMax, vRes );
+            Vec_IntShrink( vRes, nRange );
+        }
+        else if ( pObj->Type == WLC_OBJ_ARI_POWER )
+        {
+            int nRangeMax = Abc_MaxInt(nRange0, nRange);
+            int * pArg0 = Wlc_VecLoadFanins( vTemp0, pFans0, nRange0, nRangeMax, Wlc_ObjFanin0(p, pObj)->Signed );
+            int * pArg1 = Wlc_VecLoadFanins( vTemp1, pFans1, nRange1, nRange1, Wlc_ObjFanin1(p, pObj)->Signed );
+            Wlc_BlastPower( pNew, pArg0, nRangeMax, pArg1, nRange1, vTemp2, vRes );
+            Vec_IntShrink( vRes, nRange );
+        }
+        else if ( pObj->Type == WLC_OBJ_TABLE )
+            Wlc_BlastTable( pNew, Wlc_ObjTable(p, pObj), pFans0, nRange0, nRange, vRes );
         else assert( 0 );
+        assert( Vec_IntSize(vBits) == Wlc_ObjCopy(p, i) );
+        Vec_IntAppend( vBits, vRes );
+        pPrev = pObj;
+        p->nAnds[pObj->Type] += Gia_ManAndNum(pNew) - nAndPrev;
     }
+    p->nAnds[0] = Gia_ManAndNum(pNew);
     assert( nBits == Vec_IntSize(vBits) );
     Vec_IntFree( vTemp0 );
     Vec_IntFree( vTemp1 );
     Vec_IntFree( vTemp2 );
-    Vec_IntFree( vTemp3 );
-    // create POs
-    Wlc_NtkForEachPo( p, pObj, i )
+    Vec_IntFree( vRes );
+    // create COs
+    Wlc_NtkForEachCo( p, pObj, i )
     {
         nRange = Wlc_ObjRange( pObj );
-        nRange0 = Wlc_ObjFaninNum(pObj) > 0 ? Wlc_ObjRange( Wlc_ObjFanin0(p, pObj) ) : -1;
-        assert( nRange == nRange0 );
         pFans0 = Vec_IntEntryP( vBits, Wlc_ObjCopy(p, Wlc_ObjId(p, pObj)) );
+        if ( fVerbose )
+            printf( "%s(%d) ", Wlc_ObjName(p, Wlc_ObjId(p, pObj)), Gia_ManCoNum(pNew) );
         for ( k = 0; k < nRange; k++ )
             Gia_ManAppendCo( pNew, pFans0[k] );
+        if ( pObj->fIsFi )
+            nFFins += nRange;
     }
+    if ( fVerbose )
+        printf( "\n" );
     Vec_IntFree( vBits );
     Vec_IntErase( &p->vCopies );
-    // finalize and cleanup
+    // set the number of registers
+    assert( nFFins == nFFouts );
+    Gia_ManSetRegNum( pNew, nFFins );
+    // finalize AIG
     pNew = Gia_ManCleanup( pTemp = pNew );
     Gia_ManStop( pTemp );
+    // transform AIG with init state
+    if ( p->pInits )
+    {
+        if ( (int)strlen(p->pInits) != Gia_ManRegNum(pNew) )
+        {
+            printf( "The number of init values (%d) does not match the number of flops (%d).\n", (int)strlen(p->pInits), Gia_ManRegNum(pNew) );
+            printf( "It is assumed that the AIG has constant 0 initial state.\n" );
+        }
+        else
+        {
+            pNew = Gia_ManDupZeroUndc( pTemp = pNew, p->pInits, 1 );
+            Gia_ManStop( pTemp );
+        }
+    }
+    // finalize AIG with boxes
+    if ( vBoxIds )
+    {
+        curPo += nBitCos;
+        assert( curPi == Tim_ManCiNum(pManTime) );
+        assert( curPo == Tim_ManCoNum(pManTime) );
+        // finalize the extra AIG
+        pExtra = Gia_ManCleanup( pTemp = pExtra );
+        Gia_ManStop( pTemp );
+        assert( Gia_ManPoNum(pExtra) == Gia_ManCiNum(pNew) - nBitCis );
+        // attach
+        pNew->pAigExtra = pExtra;
+        pNew->pManTime = pManTime;
+        // normalize AIG
+        pNew = Gia_ManDupNormalize( pTemp = pNew );
+        Gia_ManTransferTiming( pNew, pTemp );
+        Gia_ManStop( pTemp );
+        //Tim_ManPrint( pManTime );
+    }
     return pNew;
 }
 
diff --git a/abc-build/src/base/wlc/wlcCom.c b/abc-build/src/base/wlc/wlcCom.c
--- a/abc-build/src/base/wlc/wlcCom.c
+++ b/abc-build/src/base/wlc/wlcCom.c
@@ -28,10 +28,11 @@
 ///                        DECLARATIONS                              ///
 ////////////////////////////////////////////////////////////////////////
 
-static int  Abc_CommandReadVer  ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int  Abc_CommandWriteVer ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int  Abc_CommandReadWlc  ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int  Abc_CommandWriteWlc ( Abc_Frame_t * pAbc, int argc, char ** argv );
 static int  Abc_CommandPs       ( Abc_Frame_t * pAbc, int argc, char ** argv );
 static int  Abc_CommandBlast    ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int  Abc_CommandTest     ( Abc_Frame_t * pAbc, int argc, char ** argv );
 
 static inline Wlc_Ntk_t * Wlc_AbcGetNtk( Abc_Frame_t * pAbc )                       { return (Wlc_Ntk_t *)pAbc->pAbcWlc;                      }
 static inline void        Wlc_AbcFreeNtk( Abc_Frame_t * pAbc )                      { if ( pAbc->pAbcWlc ) Wlc_NtkFree(Wlc_AbcGetNtk(pAbc));  }
@@ -54,10 +55,11 @@
 ******************************************************************************/
 void Wlc_Init( Abc_Frame_t * pAbc )
 {
-    Cmd_CommandAdd( pAbc, "Word level", "%read_ver",   Abc_CommandReadVer,   0 );
-    Cmd_CommandAdd( pAbc, "Word level", "%write_ver",  Abc_CommandWriteVer,  0 );
+    Cmd_CommandAdd( pAbc, "Word level", "%read",       Abc_CommandReadWlc,   0 );
+    Cmd_CommandAdd( pAbc, "Word level", "%write",      Abc_CommandWriteWlc,  0 );
     Cmd_CommandAdd( pAbc, "Word level", "%ps",         Abc_CommandPs,        0 );
     Cmd_CommandAdd( pAbc, "Word level", "%blast",      Abc_CommandBlast,     0 );
+    Cmd_CommandAdd( pAbc, "Word level", "%test",       Abc_CommandTest,      0 );
 }
 
 /**Function********************************************************************
@@ -88,7 +90,7 @@
   SeeAlso     []
 
 ******************************************************************************/
-int Abc_CommandReadVer( Abc_Frame_t * pAbc, int argc, char ** argv )
+int Abc_CommandReadWlc( Abc_Frame_t * pAbc, int argc, char ** argv )
 {
     FILE * pFile;
     Wlc_Ntk_t * pNtk = NULL;
@@ -110,7 +112,7 @@
     }
     if ( argc != globalUtilOptind + 1 )
     {
-        printf( "Abc_CommandReadVer(): Input file name should be given on the command line.\n" );
+        printf( "Abc_CommandReadWlc(): Input file name should be given on the command line.\n" );
         return 0;
     }
     // get the file name
@@ -118,7 +120,7 @@
     if ( (pFile = fopen( pFileName, "r" )) == NULL )
     {
         Abc_Print( 1, "Cannot open input file \"%s\". ", pFileName );
-        if ( (pFileName = Extra_FileGetSimilarName( pFileName, ".v", ".smt", NULL, NULL, NULL )) )
+        if ( (pFileName = Extra_FileGetSimilarName( pFileName, ".v", ".smt", ".smt2", NULL, NULL )) )
             Abc_Print( 1, "Did you mean \"%s\"?", pFileName );
         Abc_Print( 1, "\n" );
         return 0;
@@ -126,11 +128,19 @@
     fclose( pFile );
 
     // perform reading
-    pNtk = Wlc_ReadVer( pFileName );
+    if ( !strcmp( Extra_FileNameExtension(pFileName), "v" )  )
+        pNtk = Wlc_ReadVer( pFileName );
+    else if ( !strcmp( Extra_FileNameExtension(pFileName), "smt" ) || !strcmp( Extra_FileNameExtension(pFileName), "smt2" )  )
+        pNtk = Wlc_ReadSmt( pFileName );
+    else
+    {
+        printf( "Abc_CommandReadWlc(): Unknown file extension.\n" );
+        return 0;
+    }
     Wlc_AbcUpdateNtk( pAbc, pNtk );
     return 0;
 usage:
-    Abc_Print( -2, "usage: %%read_ver [-vh] <file_name>\n" );
+    Abc_Print( -2, "usage: %%read [-vh] <file_name>\n" );
     Abc_Print( -2, "\t         reads word-level design from Verilog file\n" );
     Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
     Abc_Print( -2, "\t-h     : print the command usage\n");
@@ -148,7 +158,7 @@
   SeeAlso     []
 
 ******************************************************************************/
-int Abc_CommandWriteVer( Abc_Frame_t * pAbc, int argc, char ** argv )
+int Abc_CommandWriteWlc( Abc_Frame_t * pAbc, int argc, char ** argv )
 {
     Wlc_Ntk_t * pNtk = Wlc_AbcGetNtk(pAbc);
     char * pFileName = NULL;
@@ -169,7 +179,7 @@
     }
     if ( pNtk == NULL )
     {
-        Abc_Print( 1, "Abc_CommandWriteVer(): There is no current design.\n" );
+        Abc_Print( 1, "Abc_CommandWriteWlc(): There is no current design.\n" );
         return 0;
     }
     if ( argc == globalUtilOptind )
@@ -184,7 +194,7 @@
     Wlc_WriteVer( pNtk, pFileName );
     return 0;
 usage:
-    Abc_Print( -2, "usage: %%write_ver [-vh]\n" );
+    Abc_Print( -2, "usage: %%write [-vh]\n" );
     Abc_Print( -2, "\t         writes the design into a file\n" );
     Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n",        fVerbose? "yes": "no" );
     Abc_Print( -2, "\t-h     : print the command usage\n");
@@ -208,9 +218,10 @@
     Wlc_Ntk_t * pNtk = Wlc_AbcGetNtk(pAbc);
     int fShowMulti   = 0;
     int fShowAdder   = 0;
+    int fDistrib     = 0;
     int c, fVerbose  = 0;
     Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "mavh" ) ) != EOF )
+    while ( ( c = Extra_UtilGetopt( argc, argv, "madvh" ) ) != EOF )
     {
         switch ( c )
         {
@@ -220,6 +231,9 @@
         case 'a':
             fShowAdder ^= 1;
             break;
+        case 'd':
+            fDistrib ^= 1;
+            break;
         case 'v':
             fVerbose ^= 1;
             break;
@@ -234,17 +248,18 @@
         Abc_Print( 1, "Abc_CommandPs(): There is no current design.\n" );
         return 0;
     }
-    Wlc_NtkPrintStats( pNtk, fVerbose );
+    Wlc_NtkPrintStats( pNtk, fDistrib, fVerbose );
     if ( fShowMulti )
         Wlc_NtkPrintNodes( pNtk, WLC_OBJ_ARI_MULTI );
     if ( fShowAdder )
         Wlc_NtkPrintNodes( pNtk, WLC_OBJ_ARI_ADD );
     return 0;
 usage:
-    Abc_Print( -2, "usage: %%ps [-mavh]\n" );
+    Abc_Print( -2, "usage: %%ps [-madvh]\n" );
     Abc_Print( -2, "\t         prints statistics\n" );
     Abc_Print( -2, "\t-m     : toggle printing multipliers [default = %s]\n",         fShowMulti? "yes": "no" );
     Abc_Print( -2, "\t-a     : toggle printing adders [default = %s]\n",              fShowAdder? "yes": "no" );
+    Abc_Print( -2, "\t-d     : toggle printing distrubition [default = %s]\n",        fDistrib? "yes": "no" );
     Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
     Abc_Print( -2, "\t-h     : print the command usage\n");
     return 1;
@@ -264,13 +279,17 @@
 int Abc_CommandBlast( Abc_Frame_t * pAbc, int argc, char ** argv )
 {
     Wlc_Ntk_t * pNtk = Wlc_AbcGetNtk(pAbc);
+    Vec_Int_t * vBoxIds = NULL;
     Gia_Man_t * pNew = NULL;
-    int c, fVerbose  = 0;
+    int c, fMulti = 0, fVerbose  = 0;
     Extra_UtilGetoptReset();
-    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
+    while ( ( c = Extra_UtilGetopt( argc, argv, "mvh" ) ) != EOF )
     {
         switch ( c )
         {
+        case 'm':
+            fMulti ^= 1;
+            break;
         case 'v':
             fVerbose ^= 1;
             break;
@@ -285,8 +304,15 @@
         Abc_Print( 1, "Abc_CommandBlast(): There is no current design.\n" );
         return 0;
     }
+    if ( fMulti )
+    {
+        vBoxIds = Wlc_NtkCollectMultipliers( pNtk );
+        if ( vBoxIds == NULL )
+            Abc_Print( 1, "Warning:  There is no multipliers in the design.\n" );
+    }
     // transform
-    pNew = Wlc_NtkBitBlast( pNtk );
+    pNew = Wlc_NtkBitBlast( pNtk, vBoxIds );
+    Vec_IntFreeP( &vBoxIds );
     if ( pNew == NULL )
     {
         Abc_Print( 1, "Abc_CommandBlast(): Bit-blasting has failed.\n" );
@@ -295,8 +321,56 @@
     Abc_FrameUpdateGia( pAbc, pNew );
     return 0;
 usage:
-    Abc_Print( -2, "usage: %%blast [-vh]\n" );
+    Abc_Print( -2, "usage: %%blast [-mvh]\n" );
     Abc_Print( -2, "\t         performs bit-blasting of the word-level design\n" );
+    Abc_Print( -2, "\t-m     : toggle creating boxes for all multipliers in the design [default = %s]\n", fMulti? "yes": "no" );
+    Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    Abc_Print( -2, "\t-h     : print the command usage\n");
+    return 1;
+}
+
+/**Function********************************************************************
+
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+******************************************************************************/
+int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+    Wlc_Ntk_t * pNtk = Wlc_AbcGetNtk(pAbc);
+    int c, fVerbose  = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pNtk == NULL )
+    {
+        Abc_Print( 1, "Abc_CommandBlast(): There is no current design.\n" );
+        return 0;
+    }
+    // transform
+    pNtk = Wlc_NtkUifNodePairs( pNtk, NULL );
+    pNtk = Wlc_NtkAbstractNodes( pNtk, NULL );
+    Wlc_AbcUpdateNtk( pAbc, pNtk );
+    return 0;
+usage:
+    Abc_Print( -2, "usage: %%test [-vh]\n" );
+    Abc_Print( -2, "\t         experiments with word-level networks\n" );
     Abc_Print( -2, "\t-v     : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
     Abc_Print( -2, "\t-h     : print the command usage\n");
     return 1;
diff --git a/abc-build/src/base/wlc/wlcNtk.c b/abc-build/src/base/wlc/wlcNtk.c
--- a/abc-build/src/base/wlc/wlcNtk.c
+++ b/abc-build/src/base/wlc/wlcNtk.c
@@ -19,6 +19,7 @@
 ***********************************************************************/
 
 #include "wlc.h"
+#include "misc/vec/vecWec.h"
 
 ABC_NAMESPACE_IMPL_START
 
@@ -32,7 +33,7 @@
     NULL,                  // 00: unknown
     "pi",                  // 01: primary input 
     "po",                  // 02: primary output 
-    "bo",                  // 03: box output
+    "ff",                  // 03: box output
     "bi",                  // 04: box input
     "ff",                  // 05: flop
     "const",               // 06: constant
@@ -42,33 +43,37 @@
     ">>>",                 // 10: shift right (arithmetic)
     "<<",                  // 11: shift left
     "<<<",                 // 12: shift left (arithmetic)
-    "~",                   // 13: bitwise NOT
-    "&",                   // 14: bitwise AND
-    "|",                   // 15: bitwise OR
-    "^",                   // 16: bitwise XOR
-    "[:]",                 // 17: bit selection
-    "{,}",                 // 18: bit concatenation
-    "BitPad",              // 19: zero padding
-    "SgnExt",              // 20: sign extension
-    "!",                   // 21: logic NOT
-    "&&",                  // 22: logic AND
-    "||",                  // 23: logic OR
-    "==",                  // 24: compare equal
-    "!=",                  // 25: compare not equal
-    "<",                   // 26: compare less
-    ">",                   // 27: compare more
-    "<=",                  // 28: compare less or equal
-    ">=",                  // 29: compare more or equal
-    "&",                   // 30: reduction AND
-    "|",                   // 31: reduction OR
-    "^",                   // 32: reduction XOR
-    "+",                   // 33: arithmetic addition
-    "-",                   // 34: arithmetic subtraction
-    "*",                   // 35: arithmetic multiplier
-    "//",                  // 36: arithmetic division
-    "%%",                  // 37: arithmetic modulus
-    "**",                  // 38: arithmetic power
-    NULL                   // 39: unused
+    "rotateR",             // 13: shift left (arithmetic)
+    "rotateL",             // 14: shift left (arithmetic)
+    "~",                   // 15: bitwise NOT
+    "&",                   // 16: bitwise AND
+    "|",                   // 17: bitwise OR
+    "^",                   // 18: bitwise XOR
+    "[:]",                 // 19: bit selection
+    "{,}",                 // 20: bit concatenation
+    "zeroPad",             // 21: zero padding
+    "signExt",             // 22: sign extension
+    "!",                   // 23: logic NOT
+    "&&",                  // 24: logic AND
+    "||",                  // 25: logic OR
+    "==",                  // 26: compare equal
+    "!=",                  // 27: compare not equal
+    "<",                   // 28: compare less
+    ">",                   // 29: compare more
+    "<=",                  // 30: compare less or equal
+    ">=",                  // 31: compare more or equal
+    "&",                   // 32: reduction AND
+    "|",                   // 33: reduction OR
+    "^",                   // 34: reduction XOR
+    "+",                   // 35: arithmetic addition
+    "-",                   // 36: arithmetic subtraction
+    "*",                   // 37: arithmetic multiplier
+    "//",                  // 38: arithmetic division
+    "%",                   // 39: arithmetic modulus
+    "**",                  // 40: arithmetic power
+    "-",                   // 41: arithmetic minus
+    "table",               // 42: bit table
+    NULL                   // 43: unused
 };
 
 ////////////////////////////////////////////////////////////////////////
@@ -102,9 +107,41 @@
     p->iObj = 1;
     return p;
 }
+void Wlc_ObjSetCi( Wlc_Ntk_t * p, Wlc_Obj_t * pObj )
+{
+    assert( Wlc_ObjIsCi(pObj) );
+    assert( Wlc_ObjFaninNum(pObj) == 0 );
+    if ( Wlc_NtkPiNum(p) == Wlc_NtkCiNum(p) || pObj->Type != WLC_OBJ_PI )
+    {
+        pObj->Fanins[1] = Vec_IntSize(&p->vCis);
+        Vec_IntPush( &p->vCis, Wlc_ObjId(p, pObj) );
+    }
+    else // insert in the array of CI at the end of PIs
+    {
+        Wlc_Obj_t * pTemp; int i;
+        Vec_IntInsert( &p->vCis, Wlc_NtkPiNum(p), Wlc_ObjId(p, pObj) );
+        // other CI IDs are invalidated... naive fix!
+        Wlc_NtkForEachCi( p, pTemp, i )
+            pTemp->Fanins[1] = i;
+    }
+    if ( pObj->Type == WLC_OBJ_PI )
+        Vec_IntPush( &p->vPis, Wlc_ObjId(p, pObj) );
+}
+void Wlc_ObjSetCo( Wlc_Ntk_t * p, Wlc_Obj_t * pObj, int fFlopInput )
+{
+//    pObj->Fanins[1] = Vec_IntSize(&p->vCos);
+    Vec_IntPush( &p->vCos, Wlc_ObjId(p, pObj) );
+    if ( !fFlopInput )
+        Vec_IntPush( &p->vPos, Wlc_ObjId(p, pObj) );
+    if ( fFlopInput )
+        pObj->fIsFi = 1;
+    else
+        pObj->fIsPo = 1;
+}
 int Wlc_ObjAlloc( Wlc_Ntk_t * p, int Type, int Signed, int End, int Beg )
 {
     Wlc_Obj_t * pObj;
+    assert( Type != WLC_OBJ_PO && Type != WLC_OBJ_FI );
     if ( p->iObj == p->nObjsAlloc )
     {
         p->pObjs = ABC_REALLOC( Wlc_Obj_t, p->pObjs, 2 * p->nObjsAlloc );
@@ -116,19 +153,17 @@
     pObj->Signed = Signed;
     pObj->End    = End;
     pObj->Beg    = Beg;
-    if ( Type == WLC_OBJ_PI )
-    {
-        pObj->Fanins[1] = Vec_IntSize(&p->vPis);
-        Vec_IntPush( &p->vPis, p->iObj );
-    }
-    else if ( Type == WLC_OBJ_PO )
-    {
-        pObj->Fanins[1] = Vec_IntSize(&p->vPos);
-        Vec_IntPush( &p->vPos, p->iObj );
-    }
+    if ( Wlc_ObjIsCi(pObj) )
+        Wlc_ObjSetCi( p, pObj );
     p->nObjs[Type]++;
     return p->iObj++;
 }
+int Wlc_ObjCreate( Wlc_Ntk_t * p, int Type, int Signed, int End, int Beg, Vec_Int_t * vFanins )
+{
+    int iFaninNew = Wlc_ObjAlloc( p, Type, Signed, End, Beg );
+    Wlc_ObjAddFanins( p, Wlc_NtkObj(p, iFaninNew), vFanins );
+    return iFaninNew;
+}
 char * Wlc_ObjName( Wlc_Ntk_t * p, int iObj )
 {
     static char Buffer[100];
@@ -139,11 +174,7 @@
 }                          
 void Wlc_ObjUpdateType( Wlc_Ntk_t * p, Wlc_Obj_t * pObj, int Type )
 {
-    if ( pObj->Type == WLC_OBJ_PO )
-    {
-        assert( Type == WLC_OBJ_BUF );
-        return;
-    }
+    assert( pObj->Type == WLC_OBJ_NONE );
     p->nObjs[pObj->Type]--;
     pObj->Type = Type;
     p->nObjs[pObj->Type]++;
@@ -155,10 +186,10 @@
     if ( Wlc_ObjHasArray(pObj) )
         pObj->pFanins[0] = (int *)Mem_FlexEntryFetch( p->pMemFanin, Vec_IntSize(vFanins) * sizeof(int) );
     memcpy( Wlc_ObjFanins(pObj), Vec_IntArray(vFanins), sizeof(int) * Vec_IntSize(vFanins) );
-    // special treatment of CONST and SELECT
+    // special treatment of CONST, SELECT and TABLE
     if ( pObj->Type == WLC_OBJ_CONST )
         pObj->nFanins = 0;
-    else if ( pObj->Type == WLC_OBJ_BIT_SELECT )
+    else if ( pObj->Type == WLC_OBJ_BIT_SELECT || pObj->Type == WLC_OBJ_TABLE )
         pObj->nFanins = 1;
 }
 void Wlc_NtkFree( Wlc_Ntk_t * p )
@@ -167,14 +198,19 @@
         Abc_NamStop( p->pManName );
     if ( p->pMemFanin )
         Mem_FlexStop( p->pMemFanin, 0 );
+    if ( p->pMemTable )
+        Mem_FlexStop( p->pMemTable, 0 );
+    Vec_PtrFreeP( &p->vTables );
     ABC_FREE( p->vPis.pArray );
     ABC_FREE( p->vPos.pArray );
     ABC_FREE( p->vCis.pArray );
     ABC_FREE( p->vCos.pArray );
     ABC_FREE( p->vFfs.pArray );
+    Vec_IntFreeP( &p->vInits );
     ABC_FREE( p->vTravIds.pArray );
     ABC_FREE( p->vNameIds.pArray );
     ABC_FREE( p->vCopies.pArray );
+    ABC_FREE( p->pInits );
     ABC_FREE( p->pObjs );
     ABC_FREE( p->pName );
     ABC_FREE( p );
@@ -192,6 +228,131 @@
     Mem += Mem_FlexReadMemUsage(p->pMemFanin);
     return Mem;
 }
+
+/**Function*************************************************************
+
+  Synopsis    [Prints distribution of operator types.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline void Vec_WrdSelectSortCost2( word * pArray, int nSize, word * pCosts )
+{
+    int i, j, best_i;
+    for ( i = 0; i < nSize-1; i++ )
+    {
+        best_i = i;
+        for ( j = i+1; j < nSize; j++ )
+            if ( pCosts[j] < pCosts[best_i] )
+                best_i = j;
+        ABC_SWAP( word, pArray[i], pArray[best_i] );
+        ABC_SWAP( word, pCosts[i], pCosts[best_i] );
+    }
+}
+static inline word Wlc_NtkPrintDistribMakeSign( int s, int s0, int s1 )
+{
+    return ((word)s1 << 42) | ((word)s0 << 21) | (word)s;
+}
+static inline void Wlc_NtkPrintDistribFromSign( word sss, int * s, int * s0, int * s1 )
+{
+    *s1 =  (int)(sss >> 42);  *s0 = (int)(sss >> 21) & 0x1FFFFF;  *s  =  (int)sss & 0x1FFFFF;
+}
+static inline void Wlc_NtkPrintDistribAddOne( Vec_Ptr_t * vTypes, Vec_Ptr_t * vOccurs, int Type, word Sign )
+{
+    Vec_Wrd_t * vType  = (Vec_Wrd_t *)Vec_PtrEntry( vTypes, Type );
+    Vec_Wrd_t * vOccur = (Vec_Wrd_t *)Vec_PtrEntry( vOccurs, Type );
+    word Entry; int i;
+    Vec_WrdForEachEntry( vType, Entry, i )
+        if ( Entry == Sign )
+        {
+            Vec_WrdAddToEntry( vOccur, i, 1 );
+            return;
+        }
+    Vec_WrdPush( vType, Sign );
+    Vec_WrdPush( vOccur, 1 );
+}
+void Wlc_NtkPrintDistribSortOne( Vec_Ptr_t * vTypes, Vec_Ptr_t * vOccurs, int Type )
+{
+    Vec_Wrd_t * vType  = (Vec_Wrd_t *)Vec_PtrEntry( vTypes, Type );
+    Vec_Wrd_t * vOccur = (Vec_Wrd_t *)Vec_PtrEntry( vOccurs, Type );
+    Vec_WrdSelectSortCost2( Vec_WrdArray(vType), Vec_WrdSize(vType), Vec_WrdArray(vOccur) );
+    Vec_WrdReverseOrder( vType );
+    Vec_WrdReverseOrder( vOccur );
+}
+void Wlc_NtkPrintDistrib( Wlc_Ntk_t * p, int fVerbose )
+{
+    Wlc_Obj_t * pObj; 
+    Vec_Ptr_t * vTypes, * vOccurs;
+    word Sign;
+    int i, k, s, s0, s1;
+    // allocate statistics arrays
+    vTypes  = Vec_PtrStart( WLC_OBJ_NUMBER );
+    vOccurs = Vec_PtrStart( WLC_OBJ_NUMBER );
+    for ( i = 0; i < WLC_OBJ_NUMBER; i++ )
+        Vec_PtrWriteEntry( vTypes, i, Vec_WrdAlloc(16) );
+    for ( i = 0; i < WLC_OBJ_NUMBER; i++ )
+        Vec_PtrWriteEntry( vOccurs, i, Vec_WrdAlloc(16) );
+    // add nodes
+    Wlc_NtkForEachObj( p, pObj, i )
+    {
+//        char * pName = Wlc_ObjName(p, i);
+        if ( Wlc_ObjSign(pObj) > 0x1FFFFF )
+            printf( "Object %6d has range %d, which is reduced to %d in the statistics.\n", 
+                i, Wlc_ObjRange(pObj), Wlc_ObjRange(pObj) & 0xFFFFF );
+        if ( pObj->Beg )
+            printf( "Object %6d has non-standard range %d=[%d:%d]\n", i, Wlc_ObjRange(pObj), pObj->End, pObj->Beg );
+       // 0-input types
+        if ( Wlc_ObjIsCi(pObj) || pObj->Type == WLC_OBJ_CONST || pObj->Type == WLC_OBJ_BIT_CONCAT )
+            Sign = Wlc_NtkPrintDistribMakeSign( Wlc_ObjSign(pObj), 0, 0 );
+        // 1-input types
+        else if ( pObj->Type == WLC_OBJ_BUF    || pObj->Type == WLC_OBJ_BIT_SELECT  || pObj->Type == WLC_OBJ_TABLE ||
+             pObj->Type == WLC_OBJ_BIT_ZEROPAD || pObj->Type == WLC_OBJ_BIT_SIGNEXT || 
+             pObj->Type == WLC_OBJ_BIT_NOT     || pObj->Type == WLC_OBJ_LOGIC_NOT   || pObj->Type == WLC_OBJ_ARI_MINUS )
+            Sign = Wlc_NtkPrintDistribMakeSign( Wlc_ObjSign(pObj), Wlc_ObjSign(Wlc_ObjFanin0(p, pObj)), 0 );
+        // 2-input types (including MUX)
+        else if ( Wlc_ObjFaninNum(pObj) == 1 )
+            Sign = Wlc_NtkPrintDistribMakeSign( Wlc_ObjSign(pObj), Wlc_ObjSign(Wlc_ObjFanin0(p, pObj)), 0 );
+        else
+        {
+            assert( Wlc_ObjFaninNum(pObj) >= 2 );
+            Sign = Wlc_NtkPrintDistribMakeSign( Wlc_ObjSign(pObj), Wlc_ObjSign(Wlc_ObjFanin0(p, pObj)), Wlc_ObjSign(Wlc_ObjFanin1(p, pObj)) );
+        }
+        // add to storage
+        Wlc_NtkPrintDistribAddOne( vTypes, vOccurs, pObj->Type, Sign );
+    }
+    // print by occurrence
+    printf( "ID  :  name  occurrence (occurrence)<output_range>=<input_range>.<input_range> ...\n" );
+    for ( i = 0; i < WLC_OBJ_NUMBER; i++ )
+    {
+        Vec_Wrd_t * vType  = (Vec_Wrd_t *)Vec_PtrEntry( vTypes, i );
+        Vec_Wrd_t * vOccur = (Vec_Wrd_t *)Vec_PtrEntry( vOccurs, i );
+        if ( p->nObjs[i] == 0 )
+            continue;
+        printf( "%2d  :  %-8s  %6d ", i, Wlc_Names[i], p->nObjs[i] );
+        // sort by occurence
+        Wlc_NtkPrintDistribSortOne( vTypes, vOccurs, i );
+        Vec_WrdForEachEntry( vType, Sign, k )
+        {
+            Wlc_NtkPrintDistribFromSign( Sign, &s, &s0, &s1 );
+            if ( ((k % 8) == 7 && s1) || ((k % 10) == 9 && !s1) )
+                printf( "\n                        " );
+            printf( "(%d)", (int)Vec_WrdEntry( vOccur, k ) );
+            printf( "%s%d",      Abc_LitIsCompl(s)?"-":"",  Abc_Lit2Var(s) );
+            if ( s0 )
+                printf( "=%s%d", Abc_LitIsCompl(s0)?"-":"", Abc_Lit2Var(s0) );
+            if ( s1 )
+                printf( ".%s%d", Abc_LitIsCompl(s1)?"-":"", Abc_Lit2Var(s1) );
+            printf( " " );
+        }
+        printf( "\n" );
+    }
+    Vec_VecFree( (Vec_Vec_t *)vTypes );
+    Vec_VecFree( (Vec_Vec_t *)vOccurs );
+}
 void Wlc_NtkPrintNodes( Wlc_Ntk_t * p, int Type )
 {
     Wlc_Obj_t * pObj; 
@@ -203,9 +364,9 @@
             continue;
         printf( "%8d  :",      Counter++ );
         printf( "%8d  :  ",    i );
-        printf( "%3d%s = ",    Wlc_ObjRange(pObj),                   pObj->Signed ? "s" : " " );
-        printf( "%3d%s  %s ",  Wlc_ObjRange(Wlc_ObjFanin0(p, pObj)), Wlc_ObjFanin0(p, pObj)->Signed ? "s" : " ", Wlc_Names[Type] );
-        printf( "%3d%s ",      Wlc_ObjRange(Wlc_ObjFanin1(p, pObj)), Wlc_ObjFanin1(p, pObj)->Signed ? "s" : " " );
+        printf( "%3d%s = ",    Wlc_ObjRange(pObj),                   Wlc_ObjIsSigned(pObj) ? "s" : " " );
+        printf( "%3d%s  %s ",  Wlc_ObjRange(Wlc_ObjFanin0(p, pObj)), Wlc_ObjIsSigned(Wlc_ObjFanin0(p, pObj)) ? "s" : " ", Wlc_Names[Type] );
+        printf( "%3d%s ",      Wlc_ObjRange(Wlc_ObjFanin1(p, pObj)), Wlc_ObjIsSigned(Wlc_ObjFanin1(p, pObj)) ? "s" : " " );
         printf( " :    " );
         printf( "%-12s =  ",   Wlc_ObjName(p, i) );
         printf( "%-12s  %s  ", Wlc_ObjName(p, Wlc_ObjFaninId0(pObj)), Wlc_Names[Type] );
@@ -213,7 +374,7 @@
         printf( "\n" );
     }
 }
-void Wlc_NtkPrintStats( Wlc_Ntk_t * p, int fVerbose )
+void Wlc_NtkPrintStats( Wlc_Ntk_t * p, int fDistrib, int fVerbose )
 {
     int i;
     printf( "%-20s : ",        p->pName );
@@ -223,13 +384,23 @@
     printf( "Obj = %6d  ",     Wlc_NtkObjNum(p) );
     printf( "Mem = %.3f MB",   1.0*Wlc_NtkMemUsage(p)/(1<<20) );
     printf( "\n" );
+    if ( fDistrib )
+    {
+        Wlc_NtkPrintDistrib( p, fVerbose );
+        return;
+    }
     if ( !fVerbose )
         return;
-    printf( "Node type statisticts:\n" );
-    for ( i = 0; i < WLC_OBJ_NUMBER; i++ )
-        if ( p->nObjs[i] )
-            printf( "%2d  :  %6d  %-8s\n", i, p->nObjs[i], Wlc_Names[i] );
-//    Wlc_NtkPrintNodes( p, WLC_OBJ_ARI_MULTI );
+    printf( "Node type statistics:\n" );
+    for ( i = 1; i < WLC_OBJ_NUMBER; i++ )
+    {
+        if ( !p->nObjs[i] )
+            continue;
+        if ( p->nAnds[0] && p->nAnds[i] )
+            printf( "%2d  :  %-8s  %6d  %7.2f %%\n", i, Wlc_Names[i], p->nObjs[i], 100.0*p->nAnds[i]/p->nAnds[0] );
+        else
+            printf( "%2d  :  %-8s  %6d\n", i, Wlc_Names[i], p->nObjs[i] );
+    }
 }
 
 /**Function*************************************************************
@@ -258,7 +429,7 @@
         for ( i = 0; i < nInts; i++ )
             Vec_IntPush( vFanins, pInts[i] );
     }
-    else if ( pObj->Type == WLC_OBJ_BIT_SELECT )
+    else if ( pObj->Type == WLC_OBJ_BIT_SELECT || pObj->Type == WLC_OBJ_TABLE )
     {
         assert( Vec_IntSize(vFanins) == 1 );
         Vec_IntPush( vFanins, pObj->Fanins[1] );
@@ -267,7 +438,7 @@
 int Wlc_ObjDup( Wlc_Ntk_t * pNew, Wlc_Ntk_t * p, int iObj, Vec_Int_t * vFanins )
 {
     Wlc_Obj_t * pObj = Wlc_NtkObj( p, iObj );
-    int iFaninNew = Wlc_ObjAlloc( pNew, pObj->Type, pObj->Signed, pObj->End, pObj->Beg );
+    int iFaninNew = Wlc_ObjAlloc( pNew, pObj->Type, Wlc_ObjIsSigned(pObj), pObj->End, pObj->Beg );
     Wlc_Obj_t * pObjNew = Wlc_NtkObj(pNew, iFaninNew);
     Wlc_ObjCollectCopyFanins( p, iObj, vFanins );
     Wlc_ObjAddFanins( pNew, pObjNew, vFanins );
@@ -294,12 +465,16 @@
     Wlc_NtkCleanCopy( p );
     vFanins = Vec_IntAlloc( 100 );
     pNew = Wlc_NtkAlloc( p->pName, p->nObjsAlloc );
-    Wlc_NtkForEachPi( p, pObj, i )
-        Wlc_ObjDup( pNew, p, Wlc_ObjId(p, pObj), vFanins );
-    Wlc_NtkForEachPo( p, pObj, i )
-        Wlc_NtkDupDfs_rec( pNew, p, Wlc_ObjFaninId0(pObj), vFanins );
-    Wlc_NtkForEachPo( p, pObj, i )
+    Wlc_NtkForEachCi( p, pObj, i )
         Wlc_ObjDup( pNew, p, Wlc_ObjId(p, pObj), vFanins );
+    Wlc_NtkForEachCo( p, pObj, i )
+        Wlc_NtkDupDfs_rec( pNew, p, Wlc_ObjId(p, pObj), vFanins );
+    Wlc_NtkForEachCo( p, pObj, i )
+        Wlc_ObjSetCo( pNew, Wlc_ObjCopyObj(pNew, p, pObj), pObj->fIsFi );
+    if ( p->vInits )
+    pNew->vInits = Vec_IntDup( p->vInits );
+    if ( p->pInits )
+    pNew->pInits = Abc_UtilStrsav( p->pInits );
     Vec_IntFree( vFanins );
     return pNew;
 }
@@ -311,11 +486,14 @@
     assert( pNew->pManName  == NULL && p->pManName != NULL );
     Wlc_NtkCleanNameId( pNew );
     for ( i = 0; i < p->nObjsAlloc; i++ )
-        if ( Wlc_ObjCopy(p, i) && Wlc_ObjNameId(p, i) )
+        if ( Wlc_ObjCopy(p, i) && i < Vec_IntSize(&p->vNameIds) && Wlc_ObjNameId(p, i) )
             Wlc_ObjSetNameId( pNew, Wlc_ObjCopy(p, i), Wlc_ObjNameId(p, i) );
     pNew->pManName = p->pManName; 
     p->pManName = NULL;
     Vec_IntErase( &p->vNameIds );
+    // transfer table
+    pNew->pMemTable = p->pMemTable;  p->pMemTable = NULL;
+    pNew->vTables = p->vTables;      p->vTables = NULL;
 }
 
 ////////////////////////////////////////////////////////////////////////
diff --git a/abc-build/src/base/wlc/wlcReadSmt.c b/abc-build/src/base/wlc/wlcReadSmt.c
new file mode 100644
--- /dev/null
+++ b/abc-build/src/base/wlc/wlcReadSmt.c
@@ -0,0 +1,681 @@
+/**CFile****************************************************************
+
+  FileName    [wlcReadSmt.c]
+
+  SystemName  [ABC: Logic synthesis and verification system.]
+
+  PackageName [Verilog parser.]
+
+  Synopsis    [Parses several flavors of word-level Verilog.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - August 22, 2014.]
+
+  Revision    [$Id: wlcReadSmt.c,v 1.00 2014/09/12 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "wlc.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+// parser name types
+typedef enum { 
+    PRS_SMT_NONE = 0, 
+    PRS_SMT_INPUT,    
+    PRS_SMT_CONST,    
+    PRS_SMT_LET,   
+    PRS_SMT_ASSERT
+} Prs_ManType_t; 
+
+// parser
+typedef struct Prs_Smt_t_ Prs_Smt_t;
+struct Prs_Smt_t_
+{
+    // input data
+    char *       pName;       // file name
+    char *       pBuffer;     // file contents
+    char *       pLimit;      // end of file
+    char *       pCur;        // current position
+    Abc_Nam_t *  pStrs;       // string manager
+    // network structure
+    Vec_Int_t    vData;       
+    // error handling
+    char ErrorStr[1000];      
+};
+
+
+// create error message
+static inline int Prs_SmtErrorSet( Prs_Smt_t * p, char * pError, int Value )
+{
+    assert( !p->ErrorStr[0] );
+    sprintf( p->ErrorStr, "%s", pError );
+    return Value;
+}
+// clear error message
+static inline void Prs_SmtErrorClear( Prs_Smt_t * p )
+{
+    p->ErrorStr[0] = '\0';
+}
+// print error message
+static inline int Prs_SmtErrorPrint( Prs_Smt_t * p )
+{
+    char * pThis; int iLine = 0;
+    if ( !p->ErrorStr[0] ) return 1;
+    for ( pThis = p->pBuffer; pThis < p->pCur; pThis++ )
+        iLine += (int)(*pThis == '\n');
+    printf( "Line %d: %s\n", iLine, p->ErrorStr );
+    return 0;
+}
+static inline char * Prs_SmtLoadFile( char * pFileName, char ** ppLimit )
+{
+    char * pBuffer;
+    int nFileSize, RetValue;
+    FILE * pFile = fopen( pFileName, "rb" );
+    if ( pFile == NULL )
+    {
+        printf( "Cannot open input file.\n" );
+        return NULL;
+    }
+    // get the file size, in bytes
+    fseek( pFile, 0, SEEK_END );  
+    nFileSize = ftell( pFile );  
+    // move the file current reading position to the beginning
+    rewind( pFile ); 
+    // load the contents of the file into memory
+    pBuffer = ABC_ALLOC( char, nFileSize + 3 );
+    pBuffer[0] = '\n';
+    RetValue = fread( pBuffer+1, nFileSize, 1, pFile );
+    // terminate the string with '\0'
+    pBuffer[nFileSize + 0] = '\n';
+    pBuffer[nFileSize + 1] = '\0';
+    *ppLimit = pBuffer + nFileSize + 2;
+    return pBuffer;
+}
+static inline Prs_Smt_t * Prs_SmtAlloc( char * pFileName )
+{
+    Prs_Smt_t * p;
+    char * pBuffer, * pLimit;
+    pBuffer = Prs_SmtLoadFile( pFileName, &pLimit );
+    if ( pBuffer == NULL )
+        return NULL;
+    p = ABC_CALLOC( Prs_Smt_t, 1 );
+    p->pName   = pFileName;
+    p->pBuffer = pBuffer;
+    p->pLimit  = pLimit;
+    p->pCur    = pBuffer;
+    p->pStrs   = Abc_NamStart( 1000, 24 );
+    Vec_IntGrow ( &p->vData, 1000 );
+    return p;
+}
+
+static inline void Prs_SmtFree( Prs_Smt_t * p )
+{
+    if ( p->pStrs )
+        Abc_NamDeref( p->pStrs );
+    Vec_IntErase( &p->vData );
+    ABC_FREE( p->pBuffer );
+    ABC_FREE( p );
+}
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline void Prs_SmtRemoveComments( Prs_Smt_t * p )
+{
+    char * pTemp;
+    for ( pTemp = p->pBuffer; pTemp < p->pLimit; pTemp++ )
+        if ( *pTemp == ';' )
+            while ( *pTemp && *pTemp != '\n' )
+                *pTemp++ = ' ';
+}
+static inline void Prs_SmtSkipSpaces( Prs_Smt_t * p )
+{
+    while ( *p->pCur == ' ' || *p->pCur == '\t' || *p->pCur == '\r' || *p->pCur == '\n' )
+        p->pCur++;
+}
+static inline int Prs_SmtIsWord( Prs_Smt_t * p, char * pWord )
+{
+    Prs_SmtSkipSpaces( p );
+    if ( strncmp( p->pCur, pWord, strlen(pWord) ) )
+        return 0;
+    p->pCur += strlen(pWord);
+    Prs_SmtSkipSpaces( p );
+    return 1;
+}
+static inline char * Prs_SmtFindNextPar( Prs_Smt_t * p )
+{
+    char * pTemp; int Count = 1;
+    for ( pTemp = p->pCur; pTemp < p->pLimit; pTemp++ )
+    {
+        if ( *pTemp == '(' )
+            Count++;
+        else if ( *pTemp == ')' )
+            Count--;
+        if ( Count == 0 )
+            break;
+    }
+    assert( *pTemp == ')' );
+    return pTemp;
+}
+static inline int Prs_SmtParseLet( Prs_Smt_t * p, char * pLimit, int Type )
+{
+    char * pToken;
+    assert( *pLimit == ')' );
+    *pLimit = 0;
+    Vec_IntPush( &p->vData, 0 );
+    Vec_IntPush( &p->vData, Type );
+    pToken = strtok( p->pCur, " ()" );
+    while ( pToken )
+    {
+        if ( pToken[0] != '_' && pToken[0] != '=' )
+            Vec_IntPush( &p->vData, Abc_NamStrFindOrAdd(p->pStrs, pToken, NULL) );
+        pToken = strtok( NULL, " ()" );
+    }
+    assert( *pLimit == 0 );
+    *pLimit = ')';
+    p->pCur = pLimit;
+    return 1;
+}
+static inline int Prs_SmtParseFun( Prs_Smt_t * p, char * pLimit, int Type )
+{
+    char * pToken;
+    assert( *pLimit == ')' );
+    *pLimit = 0;
+    Vec_IntPush( &p->vData, 0 );
+    Vec_IntPush( &p->vData, Type );
+    pToken = strtok( p->pCur, " ()" );
+    assert( pToken != NULL );
+    Vec_IntPush( &p->vData, Abc_NamStrFindOrAdd(p->pStrs, pToken, NULL) );
+    pToken = strtok( NULL, " ()" );
+    if ( pToken[0] == '_' )
+        pToken = strtok( NULL, " ()" );
+    if ( !strcmp(pToken, "Bool") )
+    {
+        Vec_IntPush( &p->vData, Abc_NamStrFindOrAdd(p->pStrs, "1", NULL) );
+        pToken = strtok( NULL, " ()" );
+        if ( !strcmp(pToken, "false") )
+            Vec_IntPush( &p->vData, Abc_NamStrFindOrAdd(p->pStrs, "#b0", NULL) );
+        else if ( !strcmp(pToken, "true") )
+            Vec_IntPush( &p->vData, Abc_NamStrFindOrAdd(p->pStrs, "#b1", NULL) );
+        else assert( 0 );
+    }
+    else if ( !strcmp(pToken, "BitVec") )
+    {
+        pToken = strtok( NULL, " ()" );
+        Vec_IntPush( &p->vData, Abc_NamStrFindOrAdd(p->pStrs, pToken, NULL) );
+        pToken = strtok( NULL, " ()" );
+        if ( pToken )
+        {
+            Vec_IntPush( &p->vData, Abc_NamStrFindOrAdd(p->pStrs, pToken, NULL) );
+            pToken = strtok( NULL, " ()" );
+            if ( pToken != NULL )
+                return Prs_SmtErrorSet(p, "Trailing symbols are not recognized.", 0);
+        }
+    }
+    else 
+        return Prs_SmtErrorSet(p, "Expecting either \"Bool\" or \"BitVec\".", 0);
+    assert( *pLimit == 0 );
+    *pLimit = ')';
+    p->pCur = pLimit;
+    return 1;
+}
+int Prs_SmtReadLines( Prs_Smt_t * p )
+{
+    Prs_SmtSkipSpaces( p );
+    while ( *p->pCur == '(' )
+    {
+        p->pCur++;
+        if ( Prs_SmtIsWord(p, "let") )
+        {
+            assert( *p->pCur == '(' );
+            p->pCur++;
+            if ( !Prs_SmtParseLet( p, Prs_SmtFindNextPar(p), PRS_SMT_LET ) )
+                return 0;
+            assert( *p->pCur == ')' );
+            p->pCur++;
+        }
+        else if ( Prs_SmtIsWord(p, "declare-fun")  )
+        {
+            if ( !Prs_SmtParseFun( p, Prs_SmtFindNextPar(p), PRS_SMT_INPUT ) )
+                return 0;
+            assert( *p->pCur == ')' );
+            p->pCur++;
+        }
+        else if ( Prs_SmtIsWord(p, "define-fun") )
+        {
+            if ( !Prs_SmtParseFun( p, Prs_SmtFindNextPar(p), PRS_SMT_CONST ) )
+                return 0;
+            assert( *p->pCur == ')' );
+            p->pCur++;
+        }
+        else if ( Prs_SmtIsWord(p, "check-sat") )
+        {
+            Vec_IntPush( &p->vData, 0 );
+            return 1;
+        }
+        else if ( Prs_SmtIsWord(p, "assert") )
+        {}
+        else if ( Prs_SmtIsWord(p, "set-option") || Prs_SmtIsWord(p, "set-logic") )
+            p->pCur = Prs_SmtFindNextPar(p) + 1;
+        else
+            break;
+            //return Prs_SmtErrorSet(p, "Unsupported directive.", 0);
+        Prs_SmtSkipSpaces( p );
+    }
+    // finish parsing assert
+    if ( !Prs_SmtParseLet( p, Prs_SmtFindNextPar(p), PRS_SMT_ASSERT ) )
+        return 0;
+    assert( *p->pCur == ')' );
+    Vec_IntPush( &p->vData, 0 );
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Prs_SmtPrintParser( Prs_Smt_t * p )
+{
+    int Entry, i;
+    Vec_IntForEachEntry( &p->vData, Entry, i )
+    {
+        if ( Entry == 0 )
+        {
+            printf( "\n" );
+            if ( i == Vec_IntSize(&p->vData) - 1 )
+                break;
+            Entry = Vec_IntEntry(&p->vData, ++i);
+            if ( Entry == PRS_SMT_INPUT )
+                printf( "declare-fun" );
+            else if ( Entry == PRS_SMT_CONST )
+                printf( "define-fun" );
+            else if ( Entry == PRS_SMT_LET )
+                printf( "let" );
+            else if ( Entry == PRS_SMT_ASSERT )
+                printf( "assert" );
+            else assert(0);
+            continue;
+        }
+        printf( " %s", Abc_NamStr(p->pStrs, Entry) );
+    }
+}
+
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Prs_SmtReadConstant( Wlc_Ntk_t * pNtk, char * pStr, int nBits, Vec_Int_t * vFanins, char * pName )
+{
+    char Buffer[100];
+    int i, nDigits, iObj, NameId, fFound;
+    Vec_IntClear( vFanins );
+    if ( pStr[0] != '#' )
+    {
+        // handle decimal number
+        int Number = atoi( pStr );
+        nBits = Abc_Base2Log( Number+1 );
+        assert( nBits < 32 );
+        Vec_IntPush( vFanins, Number );
+    }
+    else if ( pStr[1] == 'b' )
+    {
+        if ( nBits == -1 )
+            nBits = strlen(pStr+2);
+        Vec_IntFill( vFanins, Abc_BitWordNum(nBits), 0 );
+        for ( i = 0; i < nBits; i++ )
+            if ( pStr[2+i] == '1' )
+                Abc_InfoSetBit( (unsigned *)Vec_IntArray(vFanins), nBits-1-i );
+            else if ( pStr[2+i] != '0' )
+                return 0;
+    }
+    else if ( pStr[1] == 'x' )
+    {
+        if ( nBits == -1 )
+            nBits = strlen(pStr+2)*4;
+        Vec_IntFill( vFanins, Abc_BitWordNum(nBits), 0 );
+        nDigits = Abc_TtReadHexNumber( (word *)Vec_IntArray(vFanins), pStr+2 );
+        if ( nDigits != (nBits + 3)/4 )
+            assert( 0 );
+    }
+    else return 0;
+    // create constant node
+    iObj = Wlc_ObjAlloc( pNtk, WLC_OBJ_CONST, 0, nBits-1, 0 );
+    Wlc_ObjAddFanins( pNtk, Wlc_NtkObj(pNtk, iObj), vFanins );
+    // add node's name
+    if ( pName == NULL )
+    {
+        sprintf( Buffer, "_c%d_", iObj );
+        pName = Buffer;
+    }
+    NameId = Abc_NamStrFindOrAdd( pNtk->pManName, pName, &fFound );
+    assert( !fFound );
+    assert( iObj == NameId );
+    return NameId;
+}
+static inline int Prs_SmtReadName( Wlc_Ntk_t * pNtk, char * pStr, int nBits, Vec_Int_t * vFanins )
+{
+    if ( (pStr[0] >= '0' && pStr[0] <= '9') || pStr[0] == '#' )
+    {
+        Vec_Int_t * vTemp = Vec_IntAlloc(0);
+        int NameId = Prs_SmtReadConstant( pNtk, pStr, nBits, vTemp, NULL );
+        Vec_IntFree( vTemp );
+        if ( !NameId )
+            return 0;
+        Vec_IntPush( vFanins, NameId );
+        return 1;
+    }
+    else
+    {
+        // read name
+        int fFound, NameId = Abc_NamStrFindOrAdd( pNtk->pManName, pStr, &fFound );
+        assert( fFound );
+        Vec_IntPush( vFanins, NameId );
+        return 1;
+    }
+}
+static inline int Prs_SmtStrToType( char * pName )
+{
+    int Type = 0;
+    if ( !strcmp(pName, "ite") )
+        Type = WLC_OBJ_MUX;           // 08: multiplexer
+    else if ( !strcmp(pName, "bvlshr") )
+        Type = WLC_OBJ_SHIFT_R;       // 09: shift right
+    else if ( !strcmp(pName, "bvashr") )
+        Type = WLC_OBJ_SHIFT_RA;      // 10: shift right (arithmetic)
+    else if ( !strcmp(pName, "bvshl") )
+        Type = WLC_OBJ_SHIFT_L;       // 11: shift left
+//    else if ( !strcmp(pName, "") )
+//        Type = WLC_OBJ_SHIFT_LA;    // 12: shift left (arithmetic)
+    else if ( !strcmp(pName, "rotate_right") )
+        Type = WLC_OBJ_ROTATE_R;      // 13: rotate right
+    else if ( !strcmp(pName, "rotate_left") )
+        Type = WLC_OBJ_ROTATE_L;      // 14: rotate left
+    else if ( !strcmp(pName, "bvnot") )
+        Type = WLC_OBJ_BIT_NOT;       // 15: bitwise NOT
+    else if ( !strcmp(pName, "bvand") )
+        Type = WLC_OBJ_BIT_AND;       // 16: bitwise AND
+    else if ( !strcmp(pName, "bvor") )
+        Type = WLC_OBJ_BIT_OR;        // 17: bitwise OR
+    else if ( !strcmp(pName, "bvxor") )
+        Type = WLC_OBJ_BIT_XOR;       // 18: bitwise XOR
+    else if ( !strcmp(pName, "extract") )
+        Type = WLC_OBJ_BIT_SELECT;    // 19: bit selection
+    else if ( !strcmp(pName, "concat") )
+        Type = WLC_OBJ_BIT_CONCAT;    // 20: bit concatenation
+    else if ( !strcmp(pName, "zero_extend") )
+        Type = WLC_OBJ_BIT_ZEROPAD;   // 21: zero padding
+    else if ( !strcmp(pName, "sign_extend") )
+        Type = WLC_OBJ_BIT_SIGNEXT;   // 22: sign extension
+    else if ( !strcmp(pName, "not") )
+        Type = WLC_OBJ_LOGIC_NOT;     // 23: logic NOT
+    else if ( !strcmp(pName, "and") )
+        Type = WLC_OBJ_LOGIC_AND;     // 24: logic AND
+    else if ( !strcmp(pName, "or") )
+        Type = WLC_OBJ_LOGIC_OR;      // 25: logic OR
+    else if ( !strcmp(pName, "bvcomp") )
+        Type = WLC_OBJ_COMP_EQU;      // 26: compare equal
+//    else if ( !strcmp(pName, "") )
+//        Type = WLC_OBJ_COMP_NOTEQU;   // 27: compare not equal
+    else if ( !strcmp(pName, "bvult") )
+        Type = WLC_OBJ_COMP_LESS;     // 28: compare less
+    else if ( !strcmp(pName, "bvugt") )
+        Type = WLC_OBJ_COMP_MORE;     // 29: compare more
+    else if ( !strcmp(pName, "bvule") )
+        Type = WLC_OBJ_COMP_LESSEQU;  // 30: compare less or equal
+    else if ( !strcmp(pName, "bvuge") )
+        Type = WLC_OBJ_COMP_MOREEQU;  // 31: compare more or equal
+    else if ( !strcmp(pName, "bvredand") )
+        Type = WLC_OBJ_REDUCT_AND;    // 32: reduction AND
+    else if ( !strcmp(pName, "bvredor") )
+        Type = WLC_OBJ_REDUCT_OR;     // 33: reduction OR
+    else if ( !strcmp(pName, "bvredxor") )
+        Type = WLC_OBJ_REDUCT_XOR;    // 34: reduction XOR
+    else if ( !strcmp(pName, "bvadd") )
+        Type = WLC_OBJ_ARI_ADD;       // 35: arithmetic addition
+    else if ( !strcmp(pName, "bvsub") )
+        Type = WLC_OBJ_ARI_SUB;       // 36: arithmetic subtraction
+    else if ( !strcmp(pName, "bvmul") )
+        Type = WLC_OBJ_ARI_MULTI;     // 37: arithmetic multiplier
+    else if ( !strcmp(pName, "bvdiv") )
+        Type = WLC_OBJ_ARI_DIVIDE;    // 38: arithmetic division
+    else if ( !strcmp(pName, "bvurem") )
+        Type = WLC_OBJ_ARI_MODULUS;   // 39: arithmetic modulus
+//    else if ( !strcmp(pName, "") )
+//        Type = WLC_OBJ_ARI_POWER;     // 40: arithmetic power
+    else if ( !strcmp(pName, "bvneg") )
+        Type = WLC_OBJ_ARI_MINUS;     // 41: arithmetic minus
+//    else if ( !strcmp(pName, "") )
+//        Type = WLC_OBJ_TABLE;         // 42: bit table
+    else assert( 0 );
+    return Type;
+}
+static inline int Prs_SmtReadNode( Prs_Smt_t * p, Wlc_Ntk_t * pNtk, Vec_Int_t * vData, int i, Vec_Int_t * vFanins, int * pRange )
+{
+    int Type, NameId;
+    char * pName = Abc_NamStr( p->pStrs, Vec_IntEntry(vData, i) );
+    // read type
+    Type = Prs_SmtStrToType( pName );
+    if ( Type == 0 )
+        return 0;
+    *pRange = 0;
+    Vec_IntClear( vFanins );
+    if ( Type == WLC_OBJ_COMP_EQU )
+    {
+        *pRange = 1;
+        Prs_SmtReadName( pNtk, Abc_NamStr(p->pStrs, Vec_IntEntry(vData, ++i)), -1, vFanins );
+        Prs_SmtReadName( pNtk, Abc_NamStr(p->pStrs, Vec_IntEntry(vData, ++i)), -1, vFanins );
+        return WLC_OBJ_COMP_EQU;
+    }
+    else if ( Type == WLC_OBJ_LOGIC_NOT )
+    {
+        pName  = Abc_NamStr( p->pStrs, Vec_IntEntry(vData, ++i) );
+        if ( !strcmp(pName, "bvcomp") )
+        {
+            *pRange = 1;
+            Prs_SmtReadName( pNtk, Abc_NamStr(p->pStrs, Vec_IntEntry(vData, ++i)), -1, vFanins );
+            Prs_SmtReadName( pNtk, Abc_NamStr(p->pStrs, Vec_IntEntry(vData, ++i)), -1, vFanins );
+            return WLC_OBJ_COMP_NOTEQU;   // 26: compare equal
+        }
+        i--;
+    }
+    else if ( Type == WLC_OBJ_BIT_SELECT )
+    {
+        int End, Beg;
+        pName = Abc_NamStr( p->pStrs, Vec_IntEntry(vData, ++i) );
+        End = atoi( pName );
+        pName = Abc_NamStr( p->pStrs, Vec_IntEntry(vData, ++i) );
+        Beg = atoi( pName );
+        pName = Abc_NamStr( p->pStrs, Vec_IntEntry(vData, ++i) );
+        Prs_SmtReadName( pNtk, pName, -1, vFanins );
+        Vec_IntPush( vFanins, (End << 16) | Beg );
+        *pRange = End - Beg + 1;
+        return WLC_OBJ_BIT_SELECT;
+    }
+    while ( Vec_IntEntry(vData, ++i) )
+        Prs_SmtReadName( pNtk, Abc_NamStr(p->pStrs, Vec_IntEntry(vData, i)), -1, vFanins );
+    if ( Type == WLC_OBJ_ROTATE_R || Type == WLC_OBJ_ROTATE_L )
+    {
+        int * pArray = Vec_IntArray(vFanins);
+        assert( Vec_IntSize(vFanins) == 2 );
+        ABC_SWAP( int, pArray[0], pArray[1] );
+    }    
+    if ( Type >= WLC_OBJ_LOGIC_NOT && Type <= WLC_OBJ_REDUCT_XOR )
+        *pRange = 1;
+    else if ( Type == WLC_OBJ_BIT_CONCAT )
+    {
+        int k;
+        Vec_IntForEachEntry( vFanins, NameId, k )
+            *pRange += Wlc_ObjRange( Wlc_NtkObj(pNtk, NameId) );
+    }
+    else if ( Type == WLC_OBJ_MUX )
+    {
+        int * pArray = Vec_IntArray(vFanins);
+        assert( Vec_IntSize(vFanins) == 3 );
+        ABC_SWAP( int, pArray[1], pArray[2] );
+        NameId = Vec_IntEntry(vFanins, 1);
+        *pRange = Wlc_ObjRange( Wlc_NtkObj(pNtk, NameId) );
+    }
+    else // to determine range, look at the first argument
+    {
+        NameId = Vec_IntEntry(vFanins, 0);
+        *pRange = Wlc_ObjRange( Wlc_NtkObj(pNtk, NameId) );
+    }
+    return Type;
+}
+Wlc_Ntk_t * Prs_SmtBuild( Prs_Smt_t * p )
+{
+    Wlc_Ntk_t * pNtk;
+    char * pName, * pBits, * pConst;
+    Vec_Int_t * vFanins = Vec_IntAlloc( 100 );
+    int i, iObj, Type, Entry, NameId, fFound, Range;
+    // start network and create primary inputs
+    pNtk = Wlc_NtkAlloc( p->pName, Vec_IntCountEntry(&p->vData, 0) + 100 );
+    pNtk->pManName = Abc_NamStart( 1000, 24 );
+    for ( i = 0; i < Vec_IntSize(&p->vData) - 1; )
+    {
+        assert( Vec_IntEntry(&p->vData, i) == 0 );
+        if ( Vec_IntEntry(&p->vData, ++i) == PRS_SMT_INPUT )
+        {
+            pName = Abc_NamStr( p->pStrs, Vec_IntEntry(&p->vData, ++i) );
+            pBits = Abc_NamStr( p->pStrs, Vec_IntEntry(&p->vData, ++i) );
+            iObj = Wlc_ObjAlloc( pNtk, WLC_OBJ_PI, 0, atoi(pBits)-1, 0 );
+            NameId = Abc_NamStrFindOrAdd( pNtk->pManName, pName, &fFound );
+            assert( !fFound );
+            assert( iObj == NameId );
+        }
+        while ( Vec_IntEntry(&p->vData, ++i) );
+    }
+    // create logic nodes
+    for ( i = 0; i < Vec_IntSize(&p->vData) - 1; )
+    {
+        assert( Vec_IntEntry(&p->vData, i) == 0 );
+        Entry = Vec_IntEntry(&p->vData, ++i);
+        if ( Entry == PRS_SMT_INPUT )
+        {}
+        else if ( Entry == PRS_SMT_CONST )
+        {
+            pName  = Abc_NamStr( p->pStrs, Vec_IntEntry(&p->vData, ++i) );
+            pBits  = Abc_NamStr( p->pStrs, Vec_IntEntry(&p->vData, ++i) );
+            pConst = Abc_NamStr( p->pStrs, Vec_IntEntry(&p->vData, ++i) );
+            // create new node
+            if ( !Prs_SmtReadConstant( pNtk, pConst, atoi(pBits), vFanins, pName ) )
+                return NULL;
+        }
+        else if ( Entry == PRS_SMT_LET )
+        {
+            pName = Abc_NamStr( p->pStrs, Vec_IntEntry(&p->vData, ++i) );
+            Type = Prs_SmtReadNode( p, pNtk, &p->vData, ++i, vFanins, &Range );
+            if ( Type == WLC_OBJ_NONE )
+                return NULL;
+            assert( Range > 0 );
+            // create new node
+            iObj = Wlc_ObjAlloc( pNtk, Type, 0, Range-1, 0 );
+            Wlc_ObjAddFanins( pNtk, Wlc_NtkObj(pNtk, iObj), vFanins );
+            // add node's name
+            NameId = Abc_NamStrFindOrAdd( pNtk->pManName, pName, &fFound );
+            assert( !fFound );
+            assert( iObj == NameId );
+        }
+        else if ( Entry == PRS_SMT_ASSERT )
+        {
+            Type = WLC_OBJ_BUF;
+            Vec_IntClear( vFanins );
+            pName = Abc_NamStr( p->pStrs, Vec_IntEntry(&p->vData, ++i) );
+            if ( !strcmp(pName, "not") )
+            {
+                Type = WLC_OBJ_LOGIC_NOT;
+                pName = Abc_NamStr( p->pStrs, Vec_IntEntry(&p->vData, ++i) );
+                Range = 1;
+            }
+            // add fanin
+            NameId = Abc_NamStrFindOrAdd( pNtk->pManName, pName, &fFound );
+            assert( fFound );
+            Vec_IntPush( vFanins, NameId );
+            // find range
+            if ( Type == WLC_OBJ_BUF )
+            {
+                // find range
+                iObj = Vec_IntEntry(vFanins, 0);
+                Range = Wlc_ObjRange( Wlc_NtkObj(pNtk, iObj) );
+                assert( Range == 1 );
+            }
+            // create new node
+            iObj = Wlc_ObjAlloc( pNtk, Type, 0, Range-1, 0 );
+            Wlc_ObjAddFanins( pNtk, Wlc_NtkObj(pNtk, iObj), vFanins );
+            Wlc_ObjSetCo( pNtk, Wlc_NtkObj(pNtk, iObj), 0 );
+            // add node's name
+            NameId = Abc_NamStrFindOrAdd( pNtk->pManName, "miter_output", &fFound );
+            assert( !fFound );
+            assert( iObj == NameId );
+            break;
+        }
+        else assert( 0 );
+        while ( Vec_IntEntry(&p->vData, ++i) );
+    }
+    Vec_IntFree( vFanins );
+    // create nameIDs
+    vFanins = Vec_IntStartNatural( Wlc_NtkObjNumMax(pNtk) );
+    Vec_IntAppend( &pNtk->vNameIds, vFanins );
+    Vec_IntFree( vFanins );
+    return pNtk;
+}
+Wlc_Ntk_t * Wlc_ReadSmt( char * pFileName )
+{
+    Wlc_Ntk_t * pNtk = NULL;
+    Prs_Smt_t * p = Prs_SmtAlloc( pFileName );
+    if ( p == NULL )
+        return NULL;
+    Prs_SmtRemoveComments( p );
+    Prs_SmtReadLines( p );
+    //Prs_SmtPrintParser( p );
+    if ( Prs_SmtErrorPrint(p) )
+    {
+        pNtk = Prs_SmtBuild( p );
+    }
+    Prs_SmtFree( p );
+    return pNtk;
+}
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/abc-build/src/base/wlc/wlcReadVer.c b/abc-build/src/base/wlc/wlcReadVer.c
--- a/abc-build/src/base/wlc/wlcReadVer.c
+++ b/abc-build/src/base/wlc/wlcReadVer.c
@@ -40,6 +40,9 @@
     Vec_Int_t *            vStarts;
     Vec_Int_t *            vFanins;
     Wlc_Ntk_t *            pNtk;
+    Mem_Flex_t *           pMemTable;
+    Vec_Ptr_t *            vTables;
+    int                    nConsts;
     char                   sError[WLV_PRS_MAX_LINE];
 };
 
@@ -47,8 +50,10 @@
 static inline char *       Wlc_PrsStr( Wlc_Prs_t * p, int iOffset )     { return p->pBuffer + iOffset;                  }
 static inline int          Wlc_PrsStrCmp( char * pStr, char * pWhat )   { return !strncmp( pStr, pWhat, strlen(pWhat)); }
 
-#define Wlc_PrsForEachLine( p, pLine, i ) \
+#define Wlc_PrsForEachLine( p, pLine, i )             \
     for ( i = 0; (i < Vec_IntSize((p)->vStarts)) && ((pLine) = Wlc_PrsStr(p, Vec_IntEntry((p)->vStarts, i))); i++ )
+#define Wlc_PrsForEachLineStart( p, pLine, i, Start ) \
+    for ( i = Start; (i < Vec_IntSize((p)->vStarts)) && ((pLine) = Wlc_PrsStr(p, Vec_IntEntry((p)->vStarts, i))); i++ )
 
 
 ////////////////////////////////////////////////////////////////////////
@@ -79,12 +84,17 @@
     p->vLines    = Vec_IntAlloc( p->nFileSize / 50 );
     p->vStarts   = Vec_IntAlloc( p->nFileSize / 50 );
     p->vFanins   = Vec_IntAlloc( 100 );
+    p->vTables   = Vec_PtrAlloc( 1000 );
+    p->pMemTable = Mem_FlexStart();
     return p;
 }
 void Wlc_PrsStop( Wlc_Prs_t * p )
 {
     if ( p->pNtk )
         Wlc_NtkFree( p->pNtk );
+    if ( p->pMemTable )
+        Mem_FlexStop( p->pMemTable, 0 );
+    Vec_PtrFreeP( &p->vTables );
     Vec_IntFree( p->vLines );
     Vec_IntFree( p->vStarts );
     Vec_IntFree( p->vFanins );
@@ -124,7 +134,7 @@
                 break;
         sprintf( p->sError, "%s (line %d): %s\n", p->pFileName, iLine+1, pMessage );
     }
-    free( pMessage );
+    ABC_FREE( pMessage );
     return 0;
 }
 void Wlc_PrsPrintErrorMessage( Wlc_Prs_t * p )
@@ -154,7 +164,7 @@
     return (pStr[0] >= 'a' && pStr[0] <= 'z') || 
            (pStr[0] >= 'A' && pStr[0] <= 'Z') || 
            (pStr[0] >= '0' && pStr[0] <= '9') || 
-            pStr[0] == '_' || pStr[0] == '$';
+            pStr[0] == '_' || pStr[0] == '$' || pStr[0] == '\\';
 }
 static inline char * Wlc_PrsSkipSpaces( char * pStr )
 {
@@ -164,9 +174,16 @@
 }
 static inline char * Wlc_PrsFindSymbol( char * pStr, char Symb )
 {
+    int fNotName = 1;
     for ( ; *pStr; pStr++ )
-        if ( *pStr == Symb )
+    {
+        if ( fNotName && *pStr == Symb )
             return pStr;
+        if ( pStr[0] == '\\' )
+            fNotName = 0;
+        else if ( !fNotName && *pStr == ' ' )
+            fNotName = 1;
+    }
     return NULL;
 }
 static inline char * Wlc_PrsFindSymbolTwo( char * pStr, char Symb, char Symb2 )
@@ -176,7 +193,7 @@
             return pStr;
     return NULL;
 }
-static inline char * Wlc_PrsFindClosingParanthesis( char * pStr, char Open, char Close )
+static inline char * Wlc_PrsFindClosingParenthesis( char * pStr, char Open, char Close )
 {
     int Counter = 0;
     int fNotName = 1;
@@ -326,6 +343,67 @@
 
 /**Function*************************************************************
 
+  Synopsis    [Modified version of strtok().]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+char * Wlc_PrsStrtok( char * s, const char * delim )
+{
+  const char *spanp;
+  int c, sc;
+  char *tok;
+  static char *last;
+  if (s == NULL && (s = last) == NULL)
+      return NULL;
+  // skip leading delimiters
+cont:
+  c = *s++;
+  for (spanp = delim; (sc = *spanp++) != 0;) 
+      if (c == sc)
+          goto cont;
+  if (c == 0)    // no non-delimiter characters 
+      return (last = NULL);
+//  tok = s - 1;
+  if ( c != '\\' )
+      tok = s - 1;
+  else
+      tok = s - 1;
+  // go back to the first non-delimiter character
+  s--;
+  // find the token
+  for (;;) 
+  {
+      c = *s++;
+      if ( c == '\\' )  // skip blind characters
+      {
+          while ( c != ' ' )
+              c = *s++;
+          c = *s++;
+      }
+      spanp = delim;
+      do {
+          if ((sc = *spanp++) == c) 
+          {
+              if (c == 0)
+                  s = NULL;
+              else
+                  s[-1] = 0;
+              last = s;
+              return (tok);
+          }
+      } while (sc != 0);
+  }
+  // not reached
+  return NULL;
+}
+
+/**Function*************************************************************
+
   Synopsis    []
 
   Description []
@@ -335,6 +413,50 @@
   SeeAlso     []
 
 ***********************************************************************/
+char * Wlc_PrsConvertInitValues( Wlc_Ntk_t * p )
+{
+    Wlc_Obj_t * pObj; 
+    int i, k, Value, * pInits;
+    char * pResult;
+    Vec_Str_t * vStr = Vec_StrAlloc( 1000 );
+    Vec_IntForEachEntry( p->vInits, Value, i )
+    {
+        if ( Value < 0 )
+        {
+            for ( k = 0; k < -Value; k++ )
+                Vec_StrPush( vStr, '0' );
+            continue;
+        }
+        pObj = Wlc_NtkObj( p, Value );
+        Value = Wlc_ObjRange(pObj);
+        while ( pObj->Type == WLC_OBJ_BUF )
+            pObj = Wlc_NtkObj( p, Wlc_ObjFaninId0(pObj) );
+        pInits = pObj->Type == WLC_OBJ_CONST ? Wlc_ObjConstValue(pObj) : NULL;
+        for ( k = 0; k < Abc_MinInt(Value, Wlc_ObjRange(pObj)); k++ )
+            Vec_StrPush( vStr, (char)(pInits ? '0' + Abc_InfoHasBit((unsigned *)pInits, k) : 'X') );
+        // extend values with zero, in case the init value signal has different range compared to constant used
+        for ( ; k < Value; k++ )
+            Vec_StrPush( vStr, '0' );
+        // update vInits to contain either number of values or PI index
+        Vec_IntWriteEntry( p->vInits, i, pInits ? -Value : Wlc_ObjCiId(pObj) );
+    }
+    Vec_StrPush( vStr, '\0' );
+    pResult = Vec_StrReleaseArray( vStr );
+    Vec_StrFree( vStr );
+    return pResult;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
 static inline char * Wlc_PrsFindRange( char * pStr, int * End, int * Beg )
 {
     *End = *Beg = 0;
@@ -378,24 +500,111 @@
 {
     static char Buffer[WLV_PRS_MAX_LINE];
     char * pThis = *ppPlace = Buffer;
+    int fNotName = 1;
     pStr = Wlc_PrsSkipSpaces( pStr );
     if ( !Wlc_PrsIsChar(pStr) )
         return NULL;
-    while ( Wlc_PrsIsChar(pStr) )
+//    while ( Wlc_PrsIsChar(pStr) )
+//        *pThis++ = *pStr++;
+    while ( *pStr )
+    {
+        if ( fNotName && !Wlc_PrsIsChar(pStr) )
+            break;
+        if ( *pStr == '\\' )
+            fNotName = 0;
+        else if ( !fNotName && *pStr == ' ' )
+            fNotName = 1;
         *pThis++ = *pStr++;
+    }
     *pThis = 0;
     return pStr;
 }
+static inline char * Wlc_PrsReadConstant( Wlc_Prs_t * p, char * pStr, Vec_Int_t * vFanins, int * pRange, int * pSigned )
+{
+    int i, nDigits, nBits = atoi( pStr );
+    *pRange = -1;
+    *pSigned = 0;
+    pStr = Wlc_PrsSkipSpaces( pStr );
+    if ( Wlc_PrsFindSymbol( pStr, '\'' ) == NULL )
+    {
+        // handle decimal number
+        int Number = atoi( pStr );
+        *pRange = Abc_Base2Log( Number+1 );
+        assert( *pRange < 32 );
+        while ( Wlc_PrsIsDigit(pStr) )
+            pStr++;
+        Vec_IntFill( vFanins, 1, Number );
+        return pStr;
+    }
+    pStr = Wlc_PrsFindSymbol( pStr, '\'' );
+    if ( pStr[1] == 's' )
+    {
+        *pSigned = 1;
+        pStr++;
+    }
+    if ( pStr[1] == 'b' )
+    {
+        Vec_IntFill( vFanins, Abc_BitWordNum(nBits), 0 );
+        for ( i = 0; i < nBits; i++ )
+            if ( pStr[2+i] == '1' )
+                Abc_InfoSetBit( (unsigned *)Vec_IntArray(vFanins), nBits-1-i );
+            else if ( pStr[2+i] != '0' )
+                return (char *)(ABC_PTRINT_T)Wlc_PrsWriteErrorMessage( p, pStr, "Wrong digit in binary constant \"%c\".", pStr[2+i] );
+        *pRange = nBits;
+        pStr += 2 + nBits;
+        return pStr;
+    }
+    if ( pStr[1] != 'h' )
+        return (char *)(ABC_PTRINT_T)Wlc_PrsWriteErrorMessage( p, pStr, "Expecting hexadecimal constant and not \"%c\".", pStr[1] );
+    Vec_IntFill( vFanins, Abc_BitWordNum(nBits), 0 );
+    nDigits = Abc_TtReadHexNumber( (word *)Vec_IntArray(vFanins), pStr+2 );
+    if ( nDigits != (nBits + 3)/4 )
+    {
+//        return (char *)(ABC_PTRINT_T)Wlc_PrsWriteErrorMessage( p, pStr, "The length of a constant does not match." );
+//        printf( "Warning: The length of a constant (%d hex digits) does not match the number of bits (%d).\n", nDigits, nBits );
+    }
+    *pRange = nBits;
+    pStr += 2;
+    while ( Wlc_PrsIsChar(pStr) )
+        pStr++;
+    return pStr;
+}
 static inline char * Wlc_PrsReadName( Wlc_Prs_t * p, char * pStr, Vec_Int_t * vFanins )
 {
-    char * pName;
-    int NameId, fFound;
-    pStr = Wlc_PrsFindName( pStr, &pName );
-    if ( pStr == NULL )
-        return (char *)(ABC_PTRINT_T)Wlc_PrsWriteErrorMessage( p, pStr, "Cannot read name." );
-    NameId = Abc_NamStrFindOrAdd( p->pNtk->pManName, pName, &fFound );
-    if ( !fFound )
-        return (char *)(ABC_PTRINT_T)Wlc_PrsWriteErrorMessage( p, pStr, "Name %s is used but not declared.", pName );
+    int NameId, fFound, iObj;
+    pStr = Wlc_PrsSkipSpaces( pStr );
+    if ( Wlc_PrsIsDigit(pStr) )
+    {
+        char Buffer[100];
+        int Range, Signed;
+        Vec_Int_t * vFanins = Vec_IntAlloc(0);
+        pStr = Wlc_PrsReadConstant( p, pStr, vFanins, &Range, &Signed );
+        if ( pStr == NULL )
+        {
+            Vec_IntFree( vFanins );
+            return 0;
+        }
+        // create new node
+        iObj = Wlc_ObjAlloc( p->pNtk, WLC_OBJ_CONST, Signed, Range-1, 0 );
+        Wlc_ObjAddFanins( p->pNtk, Wlc_NtkObj(p->pNtk, iObj), vFanins );
+        Vec_IntFree( vFanins );
+        // add node's name
+        sprintf( Buffer, "_c%d_", p->nConsts++ );
+        NameId = Abc_NamStrFindOrAdd( p->pNtk->pManName, Buffer, &fFound );
+        if ( fFound )
+            return (char *)(ABC_PTRINT_T)Wlc_PrsWriteErrorMessage( p, pStr, "Name %s is already used.", Buffer );
+        assert( iObj == NameId );
+    }
+    else
+    {
+        char * pName;
+        pStr = Wlc_PrsFindName( pStr, &pName );
+        if ( pStr == NULL )
+            return (char *)(ABC_PTRINT_T)Wlc_PrsWriteErrorMessage( p, pStr, "Cannot read name in assign-statement." );
+        NameId = Abc_NamStrFindOrAdd( p->pNtk->pManName, pName, &fFound );
+        if ( !fFound )
+            return (char *)(ABC_PTRINT_T)Wlc_PrsWriteErrorMessage( p, pStr, "Name %s is used but not declared.", pName );
+    }
     Vec_IntPush( vFanins, NameId );
     return Wlc_PrsSkipSpaces( pStr );
 }
@@ -403,6 +612,7 @@
 {
     char * pName;
     int Type = WLC_OBJ_NONE;
+    int fRotating = 0;
     Vec_IntClear( vFanins );
     pStr = Wlc_PrsSkipSpaces( pStr );
     if ( pStr[0] != '=' )
@@ -410,27 +620,32 @@
     pStr = Wlc_PrsSkipSpaces( pStr+1 );
     if ( pStr[0] == '(' )
     {
-        char * pClose = Wlc_PrsFindClosingParanthesis( pStr, '(', ')' );
-        if ( pClose == NULL )
-            return Wlc_PrsWriteErrorMessage( p, pStr, "Expecting closing paranthesis." );
-        *pStr = *pClose = ' ';
-        pStr = Wlc_PrsSkipSpaces( pStr );
+        // consider rotating shifter
+        if ( Wlc_PrsFindSymbolTwo(pStr, '>', '>') && Wlc_PrsFindSymbolTwo(pStr, '<', '<') )
+        {
+            // THIS IS A HACK TO DETECT rotating shifters
+            char * pClose = Wlc_PrsFindClosingParenthesis( pStr, '(', ')' );
+            if ( pClose == NULL )
+                return Wlc_PrsWriteErrorMessage( p, pStr, "Expecting closing parenthesis." );
+            *pStr = ' '; *pClose = 0;
+            pStr = Wlc_PrsSkipSpaces( pStr );
+            fRotating = 1;
+        }
+        else
+        {
+            char * pClose = Wlc_PrsFindClosingParenthesis( pStr, '(', ')' );
+            if ( pClose == NULL )
+                return Wlc_PrsWriteErrorMessage( p, pStr, "Expecting closing parenthesis." );
+            *pStr = *pClose = ' ';
+            pStr = Wlc_PrsSkipSpaces( pStr );
+        }
     }
     if ( Wlc_PrsIsDigit(pStr) )
     {
-        int nDigits, nBits = atoi( pStr );
-        pStr = Wlc_PrsFindSymbol( pStr, '\'' );
+        int Range, Signed;
+        pStr = Wlc_PrsReadConstant( p, pStr, vFanins, &Range, &Signed );
         if ( pStr == NULL )
-            return Wlc_PrsWriteErrorMessage( p, pStr, "Expecting constant symbol (\')." );
-        if ( pStr[1] == 's' )
-            pStr++;
-        if ( pStr[1] != 'h' )
-            return Wlc_PrsWriteErrorMessage( p, pStr, "Expecting hexadecimal constant and not \"%c\".", pStr[1] );
-        Vec_IntFill( vFanins, Abc_BitWordNum(nBits), 0 );
-        nDigits = Abc_TtReadHexNumber( (word *)Vec_IntArray(vFanins), pStr+2 );
-        if ( nDigits != (nBits + 3)/4 )
-            return Wlc_PrsWriteErrorMessage( p, pStr, "The length of contant does not match." );
-        pStr += nDigits + 2;
+            return 0;
         Type = WLC_OBJ_CONST;
     }
     else if ( pStr[0] == '!' || pStr[0] == '~' )
@@ -440,10 +655,19 @@
         else if ( pStr[0] == '~' )
             Type = WLC_OBJ_BIT_NOT;
         else assert( 0 );
-        if ( !(pStr = Wlc_PrsReadName(p, pStr+1, vFanins)) )
+        // skip parentheses
+        pStr = Wlc_PrsSkipSpaces( pStr+1 );
+        if ( pStr[0] == '(' )
+        {
+            char * pClose = Wlc_PrsFindClosingParenthesis( pStr, '(', ')' );
+            if ( pClose == NULL )
+                return Wlc_PrsWriteErrorMessage( p, pStr, "Expecting closing parenthesis." );
+            *pStr = *pClose = ' ';
+        }
+        if ( !(pStr = Wlc_PrsReadName(p, pStr, vFanins)) )
             return Wlc_PrsWriteErrorMessage( p, pStr, "Cannot read name after !." );
     }
-    else if ( pStr[0] == '&' || pStr[0] == '|' || pStr[0] == '^' )
+    else if ( pStr[0] == '&' || pStr[0] == '|' || pStr[0] == '^' || pStr[0] == '-' )
     {
         if ( pStr[0] == '&' )
             Type = WLC_OBJ_REDUCT_AND;
@@ -451,13 +675,15 @@
             Type = WLC_OBJ_REDUCT_OR;
         else if ( pStr[0] == '^' )
             Type = WLC_OBJ_REDUCT_XOR;
+        else if ( pStr[0] == '-' )
+            Type = WLC_OBJ_ARI_MINUS;
         else assert( 0 );
         if ( !(pStr = Wlc_PrsReadName(p, pStr+1, vFanins)) )
-            return Wlc_PrsWriteErrorMessage( p, pStr, "Cannot read name after reduction operator." );
+            return Wlc_PrsWriteErrorMessage( p, pStr, "Cannot read name after a unary operator." );
     }
     else if ( pStr[0] == '{' )
     {
-        // THIS IS SHORTCUT TO DETECT zero padding AND sign extension
+        // THIS IS A HACK TO DETECT zero padding AND sign extension
         if ( Wlc_PrsFindSymbol(pStr+1, '{') )
         {
             if ( Wlc_PrsFindSymbol(pStr+1, '\'') )
@@ -477,7 +703,8 @@
         {
             while ( 1 )
             {
-                if ( !(pStr = Wlc_PrsReadName(p, pStr+1, vFanins)) )
+                pStr = Wlc_PrsSkipSpaces( pStr+1 );
+                if ( !(pStr = Wlc_PrsReadName(p, pStr, vFanins)) )
                     return Wlc_PrsWriteErrorMessage( p, pStr, "Cannot read name in concatenation." );
                 if ( pStr[0] == '}' )
                     break;
@@ -504,6 +731,8 @@
                 return Wlc_PrsWriteErrorMessage( p, pStr, "MUX lacks the colon symbol (:)." );
             if ( !(pStr = Wlc_PrsReadName(p, pStr+1, vFanins)) )
                 return Wlc_PrsWriteErrorMessage( p, pStr, "Cannot read name in MUX." );
+            assert( Vec_IntSize(vFanins) == 3 );
+            ABC_SWAP( int, Vec_IntArray(vFanins)[1], Vec_IntArray(vFanins)[2] );
             Type = WLC_OBJ_MUX;
         }
         else if ( pStr[0] == '[' )
@@ -515,9 +744,9 @@
         }
         else 
         {
-                 if ( pStr[0] == '>' && pStr[1] == '>' && pStr[2] != '>' ) pStr += 2, Type = WLC_OBJ_SHIFT_R;
+                 if ( pStr[0] == '>' && pStr[1] == '>' && pStr[2] != '>' ) pStr += 2, Type = fRotating ? WLC_OBJ_ROTATE_R : WLC_OBJ_SHIFT_R;
             else if ( pStr[0] == '>' && pStr[1] == '>' && pStr[2] == '>' ) pStr += 3, Type = WLC_OBJ_SHIFT_RA;      
-            else if ( pStr[0] == '<' && pStr[1] == '<' && pStr[2] != '<' ) pStr += 2, Type = WLC_OBJ_SHIFT_L;       
+            else if ( pStr[0] == '<' && pStr[1] == '<' && pStr[2] != '<' ) pStr += 2, Type = fRotating ? WLC_OBJ_ROTATE_L : WLC_OBJ_SHIFT_L;
             else if ( pStr[0] == '<' && pStr[1] == '<' && pStr[2] == '<' ) pStr += 3, Type = WLC_OBJ_SHIFT_LA;      
             else if ( pStr[0] == '&' && pStr[1] != '&'                   ) pStr += 1, Type = WLC_OBJ_BIT_AND;       
             else if ( pStr[0] == '|' && pStr[1] != '|'                   ) pStr += 1, Type = WLC_OBJ_BIT_OR;        
@@ -525,7 +754,7 @@
             else if ( pStr[0] == '&' && pStr[1] == '&'                   ) pStr += 2, Type = WLC_OBJ_LOGIC_AND;     
             else if ( pStr[0] == '|' && pStr[1] == '|'                   ) pStr += 2, Type = WLC_OBJ_LOGIC_OR;      
             else if ( pStr[0] == '=' && pStr[1] == '='                   ) pStr += 2, Type = WLC_OBJ_COMP_EQU;      
-            else if ( pStr[0] == '!' && pStr[1] == '='                   ) pStr += 2, Type = WLC_OBJ_COMP_NOT;      
+            else if ( pStr[0] == '!' && pStr[1] == '='                   ) pStr += 2, Type = WLC_OBJ_COMP_NOTEQU;      
             else if ( pStr[0] == '<' && pStr[1] != '='                   ) pStr += 1, Type = WLC_OBJ_COMP_LESS;     
             else if ( pStr[0] == '>' && pStr[1] != '='                   ) pStr += 1, Type = WLC_OBJ_COMP_MORE;     
             else if ( pStr[0] == '<' && pStr[1] == '='                   ) pStr += 2, Type = WLC_OBJ_COMP_LESSEQU;
@@ -550,77 +779,172 @@
     }
     return Type;
 }
+int Wlc_PrsReadDeclaration( Wlc_Prs_t * p, char * pStart )
+{
+    int fFound = 0, Type = WLC_OBJ_NONE, iObj; 
+    int Signed = 0, Beg = 0, End = 0, NameId, fIsPo = 0;
+    if ( Wlc_PrsStrCmp( pStart, "input" ) )
+        pStart += strlen("input"), Type = WLC_OBJ_PI;
+    else if ( Wlc_PrsStrCmp( pStart, "output" ) )
+        pStart += strlen("output"), fIsPo = 1;
+    pStart = Wlc_PrsSkipSpaces( pStart );
+    if ( Wlc_PrsStrCmp( pStart, "wire" ) )
+        pStart += strlen("wire");
+    else if ( Wlc_PrsStrCmp( pStart, "reg" ) )
+        pStart += strlen("reg");
+    // read 'signed'
+    pStart = Wlc_PrsFindWord( pStart, "signed", &Signed );
+    // read range
+    pStart = Wlc_PrsFindRange( pStart, &End, &Beg );
+    if ( pStart == NULL )
+        return Wlc_PrsWriteErrorMessage( p, pStart, "Cannot read range." );
+    while ( 1 )
+    {
+        char * pName;
+        // read name
+        pStart = Wlc_PrsFindName( pStart, &pName );
+        if ( pStart == NULL )
+            return Wlc_PrsWriteErrorMessage( p, pStart, "Cannot read name in declaration." );
+        NameId = Abc_NamStrFindOrAdd( p->pNtk->pManName, pName, &fFound );
+        if ( fFound )
+            return Wlc_PrsWriteErrorMessage( p, pStart, "Name %s is declared more than once.", pName );
+        iObj = Wlc_ObjAlloc( p->pNtk, Type, Signed, End, Beg );
+        if ( fIsPo ) Wlc_ObjSetCo( p->pNtk, Wlc_NtkObj(p->pNtk, iObj), 0 );
+        assert( iObj == NameId );
+        // check next definition
+        pStart = Wlc_PrsSkipSpaces( pStart );
+        if ( pStart[0] == ',' )
+        {
+            pStart++;
+            continue;
+        }
+        // check definition
+        Type = Wlc_PrsFindDefinition( p, pStart, p->vFanins );
+        if ( Type )
+        {
+            Wlc_Obj_t * pObj = Wlc_NtkObj( p->pNtk, iObj );
+            Wlc_ObjUpdateType( p->pNtk, pObj, Type );
+            Wlc_ObjAddFanins( p->pNtk, pObj, p->vFanins );
+        }
+        break;
+    }
+    return 1;
+}
 int Wlc_PrsDerive( Wlc_Prs_t * p )
 {
+    Wlc_Obj_t * pObj;
     char * pStart, * pName;
     int i;
     // go through the directives
     Wlc_PrsForEachLine( p, pStart, i )
     {
+startword:
         if ( Wlc_PrsStrCmp( pStart, "module" ) )
         {
             // get module name
-            pName = strtok( pStart + strlen("module"), " (" );
+            pName = Wlc_PrsStrtok( pStart + strlen("module"), " \r\n\t(,)" );
             if ( pName == NULL )
                 return Wlc_PrsWriteErrorMessage( p, pStart, "Cannot read model name." );
+            // THIS IS A HACK to skip definitions of modules beginning with "CPL_"
+            if ( Wlc_PrsStrCmp( pName, "CPL_" ) )
+            {
+                while ( ++i < Vec_IntSize(p->vStarts) )
+                {
+                    pStart = Wlc_PrsStr(p, Vec_IntEntry(p->vStarts, i));
+                    pStart = strstr( pStart, "endmodule" );
+                    if ( pStart != NULL )
+                        break;
+                }
+                continue;
+            }
+            if ( Wlc_PrsStrCmp( pName, "table" ) )
+            {
+                // THIS IS A HACK to detect table module descriptions
+                int Width1 = -1, Width2 = -1;
+                int v, b, Value, nBits, nInts;
+                unsigned * pTable;
+                Vec_Int_t * vValues = Vec_IntAlloc( 256 );
+                Wlc_PrsForEachLineStart( p, pStart, i, i+1 )
+                {
+                    if ( Wlc_PrsStrCmp( pStart, "endcase" ) )
+                        break;
+                    pStart = Wlc_PrsFindSymbol( pStart, '\'' );
+                    if ( pStart == NULL )
+                        continue;
+                    Width1 = atoi(pStart-1);
+                    pStart = Wlc_PrsFindSymbol( pStart+2, '\'' );
+                    if ( pStart == NULL )
+                        continue;
+                    Width2 = atoi(pStart-1);
+                    Value = 0;
+                    Abc_TtReadHexNumber( (word *)&Value, pStart+2 );
+                    Vec_IntPush( vValues, Value );
+                }
+                //Vec_IntPrint( vValues );
+                nBits = Abc_Base2Log( Vec_IntSize(vValues) );
+                if ( Vec_IntSize(vValues) != (1 << nBits) )
+                {
+                    Vec_IntFree( vValues );
+                    return Wlc_PrsWriteErrorMessage( p, pStart, "Cannot read module \"%s\".", pName );
+                }
+                assert( Width1 == nBits );
+                // create bitmap
+                nInts = Abc_BitWordNum( Width2 * Vec_IntSize(vValues) );
+                pTable = (unsigned *)Mem_FlexEntryFetch( p->pMemTable, nInts * sizeof(unsigned) );
+                memset( pTable, 0, nInts * sizeof(unsigned) );
+                Vec_IntForEachEntry( vValues, Value, v )
+                    for ( b = 0; b < Width2; b++ )
+                        if ( (Value >> b) & 1 )
+                            Abc_InfoSetBit( pTable, v * Width2 + b );
+                Vec_PtrPush( p->vTables, pTable );
+                Vec_IntFree( vValues );
+                continue;
+            }
             if ( p->pNtk != NULL )
                 return Wlc_PrsWriteErrorMessage( p, pStart, "Network is already defined." );
             p->pNtk = Wlc_NtkAlloc( pName, Vec_IntSize(p->vStarts) );
             p->pNtk->pManName = Abc_NamStart( Vec_IntSize(p->vStarts), 20 );
+            p->pNtk->pMemTable = p->pMemTable; p->pMemTable = NULL;
+            p->pNtk->vTables = p->vTables; p->vTables = NULL;
+            // read the argument definitions
+            while ( (pName = Wlc_PrsStrtok( NULL, "(,)" )) )
+            {
+                pName = Wlc_PrsSkipSpaces( pName );
+                if ( Wlc_PrsStrCmp( pName, "input" ) || Wlc_PrsStrCmp( pName, "output" ) || Wlc_PrsStrCmp( pName, "wire" ) )
+                {
+                    if ( !Wlc_PrsReadDeclaration( p, pName ) )
+                        return 0;
+                }
+            }
         }
         else if ( Wlc_PrsStrCmp( pStart, "endmodule" ) )
         {
             Vec_Int_t * vTemp = Vec_IntStartNatural( Wlc_NtkObjNumMax(p->pNtk) );
             Vec_IntAppend( &p->pNtk->vNameIds, vTemp );
             Vec_IntFree( vTemp );
+            if ( p->pNtk->vInits )
+            {
+                // move FO/FI to be part of CI/CO
+                assert( (Vec_IntSize(&p->pNtk->vFfs) & 1) == 0 );
+                assert( Vec_IntSize(&p->pNtk->vFfs) == 2 * Vec_IntSize(p->pNtk->vInits) );
+                Wlc_NtkForEachFf( p->pNtk, pObj, i )
+                    if ( i & 1 )
+                        Wlc_ObjSetCo( p->pNtk, pObj, 1 );
+                    else
+                        Wlc_ObjSetCi( p->pNtk, pObj );
+                Vec_IntClear( &p->pNtk->vFfs );
+                // convert init values into binary string
+                //Vec_IntPrint( &p->pNtk->vInits );
+                p->pNtk->pInits = Wlc_PrsConvertInitValues( p->pNtk );
+                //printf( "%s", p->pNtk->pInits );
+            }
             break;
         }
         // these are read as part of the interface
-        else if ( Wlc_PrsStrCmp( pStart, "input" ) || Wlc_PrsStrCmp( pStart, "output" ) || Wlc_PrsStrCmp( pStart, "wire" ) )
+        else if ( Wlc_PrsStrCmp( pStart, "input" ) || Wlc_PrsStrCmp( pStart, "output" ) || Wlc_PrsStrCmp( pStart, "wire" ) || Wlc_PrsStrCmp( pStart, "reg" ) )
         {
-            int fFound = 0, Type = WLC_OBJ_NONE, iObj; 
-            int Signed = 0, Beg = 0, End = 0, NameId;
-            if ( Wlc_PrsStrCmp( pStart, "input" ) )
-                Type = WLC_OBJ_PI, pStart += strlen("input");
-            else if ( Wlc_PrsStrCmp( pStart, "output" ) )
-                Type = WLC_OBJ_PO, pStart += strlen("output");
-            pStart = Wlc_PrsSkipSpaces( pStart );
-            if ( Wlc_PrsStrCmp( pStart, "wire" ) )
-                pStart += strlen("wire");
-            // read 'signed'
-            pStart = Wlc_PrsFindWord( pStart, "signed", &Signed );
-            // read range
-            pStart = Wlc_PrsFindRange( pStart, &End, &Beg );
-            if ( pStart == NULL )
-                return Wlc_PrsWriteErrorMessage( p, pStart, "Cannot read range." );
-            while ( 1 )
-            {
-                // read name
-                pStart = Wlc_PrsFindName( pStart, &pName );
-                if ( pStart == NULL )
-                    return Wlc_PrsWriteErrorMessage( p, pStart, "Cannot read name." );
-                NameId = Abc_NamStrFindOrAdd( p->pNtk->pManName, pName, &fFound );
-                if ( fFound )
-                    return Wlc_PrsWriteErrorMessage( p, pStart, "Name %s is declared more than once.", pName );
-                iObj = Wlc_ObjAlloc( p->pNtk, Type, Signed, End, Beg );
-                assert( iObj == NameId );
-                // check next definition
-                pStart = Wlc_PrsSkipSpaces( pStart );
-                if ( pStart[0] == ',' )
-                {
-                    pStart++;
-                    continue;
-                }
-                // check definition
-                Type = Wlc_PrsFindDefinition( p, pStart, p->vFanins );
-                if ( Type )
-                {
-                    Wlc_Obj_t * pObj = Wlc_NtkObj( p->pNtk, iObj );
-                    Wlc_ObjUpdateType( p->pNtk, pObj, Type );
-                    Wlc_ObjAddFanins( p->pNtk, pObj, p->vFanins );
-                }
-                break;
-            }
+            if ( !Wlc_PrsReadDeclaration( p, pStart ) )
+                return 0;
         }
         else if ( Wlc_PrsStrCmp( pStart, "assign" ) )
         {
@@ -637,16 +961,183 @@
             Type = Wlc_PrsFindDefinition( p, pStart, p->vFanins );
             if ( Type )
             {
-                Wlc_Obj_t * pObj = Wlc_NtkObj( p->pNtk, NameId );
+                pObj = Wlc_NtkObj( p->pNtk, NameId );
                 Wlc_ObjUpdateType( p->pNtk, pObj, Type );
                 Wlc_ObjAddFanins( p->pNtk, pObj, p->vFanins );
             }
             else
                 return 0;
         }
-//        else if ( Wlc_PrsStrCmp( pStart, "CPL_FF" ) )
-        else
+        else if ( Wlc_PrsStrCmp( pStart, "table" ) )
         {
+            // THIS IS A HACK to detect tables
+            int NameId, fFound, iTable = atoi( pStart + strlen("table") );
+            // find opening
+            pStart = Wlc_PrsFindSymbol( pStart, '(' );
+            if ( pStart == NULL )
+                return Wlc_PrsWriteErrorMessage( p, pStart, "Cannot read table." );
+            // read input
+            pStart = Wlc_PrsFindName( pStart+1, &pName );
+            if ( pStart == NULL )
+                return Wlc_PrsWriteErrorMessage( p, pStart, "Cannot read name after assign." );
+            NameId = Abc_NamStrFindOrAdd( p->pNtk->pManName, pName, &fFound );
+            if ( !fFound )
+                return Wlc_PrsWriteErrorMessage( p, pStart, "Name %s is not declared.", pName );
+            // save inputs
+            Vec_IntClear( p->vFanins );
+            Vec_IntPush( p->vFanins, NameId );
+            Vec_IntPush( p->vFanins, iTable );
+            // find comma
+            pStart = Wlc_PrsFindSymbol( pStart, ',' );
+            if ( pStart == NULL )
+                return Wlc_PrsWriteErrorMessage( p, pStart, "Cannot read table." );
+            // read output
+            pStart = Wlc_PrsFindName( pStart+1, &pName );
+            if ( pStart == NULL )
+                return Wlc_PrsWriteErrorMessage( p, pStart, "Cannot read name after assign." );
+            NameId = Abc_NamStrFindOrAdd( p->pNtk->pManName, pName, &fFound );
+            if ( !fFound )
+                return Wlc_PrsWriteErrorMessage( p, pStart, "Name %s is not declared.", pName );
+            pObj = Wlc_NtkObj( p->pNtk, NameId );
+            Wlc_ObjUpdateType( p->pNtk, pObj, WLC_OBJ_TABLE );
+            Wlc_ObjAddFanins( p->pNtk, pObj, p->vFanins );
+        }
+        else if ( Wlc_PrsStrCmp( pStart, "always" ) )
+        {
+            // THIS IS A HACK to detect always statement representing combinational MUX
+            int NameId, NameIdOut = -1, fFound;
+            // find control
+            pStart = Wlc_PrsFindWord( pStart, "case", &fFound );
+            if ( pStart == NULL )
+                return Wlc_PrsWriteErrorMessage( p, pStart, "Cannot read case statement." );
+            // read the name
+            pStart = Wlc_PrsFindSymbol( pStart, '(' );
+            if ( pStart == NULL )
+                return Wlc_PrsWriteErrorMessage( p, pStart, "Cannot read table." );
+            pStart = Wlc_PrsFindSymbol( pStart+1, '(' );
+            if ( pStart == NULL )
+                return Wlc_PrsWriteErrorMessage( p, pStart, "Cannot read table." );
+            pStart = Wlc_PrsFindName( pStart+1, &pName );
+            if ( pStart == NULL )
+                return Wlc_PrsWriteErrorMessage( p, pStart, "Cannot read name after case." );
+            NameId = Abc_NamStrFindOrAdd( p->pNtk->pManName, pName, &fFound );
+            if ( !fFound )
+                return Wlc_PrsWriteErrorMessage( p, pStart, "Name %s is not declared.", pName );
+            Vec_IntClear( p->vFanins );
+            Vec_IntPush( p->vFanins, NameId );
+            // read data inputs
+            while ( 1 )
+            {
+                // find opening
+                pStart = Wlc_PrsFindSymbol( pStart, ':' );
+                if ( pStart == NULL )
+                    return Wlc_PrsWriteErrorMessage( p, pStart, "Cannot find colon in the case statement." );
+                // find output name
+                pStart = Wlc_PrsFindName( pStart+1, &pName );
+                if ( pStart == NULL )
+                    return Wlc_PrsWriteErrorMessage( p, pStart, "Cannot read name after case." );
+                NameIdOut = Abc_NamStrFindOrAdd( p->pNtk->pManName, pName, &fFound );
+                if ( !fFound )
+                    return Wlc_PrsWriteErrorMessage( p, pStart, "Name %s is not declared.", pName );
+                // find equality
+                pStart = Wlc_PrsFindSymbol( pStart, '=' );
+                if ( pStart == NULL )
+                    return Wlc_PrsWriteErrorMessage( p, pStart, "Cannot find equality in the case statement." );
+                // find input name
+                pStart = Wlc_PrsSkipSpaces( pStart+1 );
+                pStart = Wlc_PrsReadName( p, pStart, p->vFanins );
+                if ( pStart == NULL )
+                    return Wlc_PrsWriteErrorMessage( p, pStart, "Cannot read name inside case statement." );
+                // get next line and check its opening character
+                pStart = Wlc_PrsStr(p, Vec_IntEntry(p->vStarts, ++i));
+                pStart = Wlc_PrsSkipSpaces( pStart );
+                if ( Wlc_PrsIsDigit(pStart) )
+                    continue;
+                if ( Wlc_PrsStrCmp( pStart, "default" ) )
+                {
+                    printf( "Ignoring default in Line %d.\n", i );
+                    pStart = Wlc_PrsStr(p, Vec_IntEntry(p->vStarts, ++i));
+                }
+                // find closing
+                pStart = Wlc_PrsFindWord( pStart, "endcase", &fFound );
+                if ( pStart == NULL )
+                    return Wlc_PrsWriteErrorMessage( p, pStart, "Cannot read case statement." );
+                // find closing
+                pStart = Wlc_PrsFindWord( pStart, "end", &fFound );
+                if ( pStart == NULL )
+                    return Wlc_PrsWriteErrorMessage( p, pStart, "Cannot read case statement." );
+                pStart = Wlc_PrsSkipSpaces( pStart );
+                break;
+            }
+            // check range of the control
+            pObj = Wlc_NtkObj( p->pNtk, Vec_IntEntry(p->vFanins, 0) );
+            if ( (1 << Wlc_ObjRange(pObj)) != Vec_IntSize(p->vFanins) - 1 )
+                return Wlc_PrsWriteErrorMessage( p, pStart, "The number of values in the case statement is wrong.", pName );
+            pObj = Wlc_NtkObj( p->pNtk, NameIdOut );
+            Wlc_ObjUpdateType( p->pNtk, pObj, WLC_OBJ_MUX );
+            Wlc_ObjAddFanins( p->pNtk, pObj, p->vFanins );
+            goto startword;
+        }
+        else if ( Wlc_PrsStrCmp( pStart, "CPL_FF" ) )
+        {
+            int NameId = -1, NameIdIn = -1, NameIdOut = -1, fFound, nBits = 1, fFlopIn, fFlopOut;
+            pStart += strlen("CPL_FF");
+            if ( pStart[0] == '#' )
+                nBits = atoi(pStart+1);
+            // read names
+            while ( 1 )
+            {
+                pStart = Wlc_PrsFindSymbol( pStart, '.' );
+                if ( pStart == NULL )
+                    break;
+                pStart = Wlc_PrsSkipSpaces( pStart+1 );
+                if ( pStart[0] != 'd' && (pStart[0] != 'q' || pStart[1] == 'b') && strncmp(pStart, "arstval", 7) )
+                    continue;
+                fFlopIn = (pStart[0] == 'd');
+                fFlopOut = (pStart[0] == 'q');
+                pStart = Wlc_PrsFindSymbol( pStart, '(' );
+                if ( pStart == NULL )
+                    return Wlc_PrsWriteErrorMessage( p, pStart, "Cannot read opening parenthesis in the flop description." );
+                pStart = Wlc_PrsFindName( pStart+1, &pName );
+                if ( pStart == NULL )
+                    return Wlc_PrsWriteErrorMessage( p, pStart, "Cannot read name inside flop description." );
+                if ( fFlopIn )
+                    NameIdIn = Abc_NamStrFindOrAdd( p->pNtk->pManName, pName, &fFound );
+                else if ( fFlopOut ) 
+                    NameIdOut = Abc_NamStrFindOrAdd( p->pNtk->pManName, pName, &fFound );
+                else
+                    NameId = Abc_NamStrFindOrAdd( p->pNtk->pManName, pName, &fFound );
+                if ( !fFound )
+                    return Wlc_PrsWriteErrorMessage( p, pStart, "Name %s is not declared.", pName );
+            }
+            if ( NameIdIn == -1 || NameIdOut == -1 )
+                return Wlc_PrsWriteErrorMessage( p, pStart, "Name of flop input or flop output is missing." );
+            // create flop output
+            pObj = Wlc_NtkObj( p->pNtk, NameIdOut );
+            Wlc_ObjUpdateType( p->pNtk, pObj, WLC_OBJ_FO );
+            Vec_IntPush( &p->pNtk->vFfs, NameIdOut );
+            if ( nBits != Wlc_ObjRange(pObj) )
+                printf( "Warning!  Flop input has bit-width (%d) that differs from the flop declaration (%d)\n", Wlc_ObjRange(pObj), nBits );
+            // create flop input
+            pObj = Wlc_NtkObj( p->pNtk, NameIdIn );
+            Vec_IntPush( &p->pNtk->vFfs, NameIdIn );
+            if ( nBits != Wlc_ObjRange(pObj) )
+                printf( "Warning!  Flop output has bit-width (%d) that differs from the flop declaration (%d)\n", Wlc_ObjRange(pObj), nBits );
+            // save flop init value
+            if ( NameId == -1 )
+                printf( "Initial value of flop \"%s\" is not specified. Zero is assumed.\n", Abc_NamStr(p->pNtk->pManName, NameIdOut) );
+            else
+            {
+                pObj = Wlc_NtkObj( p->pNtk, NameId );
+                if ( nBits != Wlc_ObjRange(pObj) )
+                    printf( "Warning!  Flop init signal bit-width (%d) is different from the flop declaration (%d)\n", Wlc_ObjRange(pObj), nBits );
+            }
+            if ( p->pNtk->vInits == NULL )
+                p->pNtk->vInits = Vec_IntAlloc( 100 );
+            Vec_IntPush( p->pNtk->vInits, NameId > 0 ? NameId : -nBits );
+        }
+        else if ( pStart[0] != '`' )
+        {
             pStart = Wlc_PrsFindName( pStart, &pName );
             return Wlc_PrsWriteErrorMessage( p, pStart, "Cannot read line beginning with %s.", pName );
         }
@@ -695,7 +1186,7 @@
         return;
     Wlc_WriteVer( pNtk, "test.v" );
 
-    pNew = Wlc_NtkBitBlast( pNtk );
+    pNew = Wlc_NtkBitBlast( pNtk, NULL );
     Gia_AigerWrite( pNew, "test.aig", 0, 0 );
     Gia_ManStop( pNew );
 
diff --git a/abc-build/src/base/wlc/wlcWriteVer.c b/abc-build/src/base/wlc/wlcWriteVer.c
--- a/abc-build/src/base/wlc/wlcWriteVer.c
+++ b/abc-build/src/base/wlc/wlcWriteVer.c
@@ -42,6 +42,85 @@
   SeeAlso     []
 
 ***********************************************************************/
+void Wlc_WriteTableOne( FILE * pFile, int nFans, int nOuts, word * pTable, int Id )
+{
+    int m, nMints = (1<<nFans);
+//    Abc_TtPrintHexArrayRev( stdout, pTable, nMints );  printf( "\n" );
+    assert( nOuts > 0 && nOuts <= 64 && (64 % nOuts) == 0 );
+    fprintf( pFile, "module table%d(ind, val);\n", Id );
+    fprintf( pFile, "  input  [%d:0] ind;\n", nFans-1 );
+    fprintf( pFile, "  output [%d:0] val;\n", nOuts-1 );
+    fprintf( pFile, "  reg    [%d:0] val;\n", nOuts-1 );
+    fprintf( pFile, "  always @(ind)\n" );
+    fprintf( pFile, "  begin\n" );
+    fprintf( pFile, "    case (ind)\n" );
+    for ( m = 0; m < nMints; m++ )
+    fprintf( pFile, "      %d\'h%x: val = %d\'h%x;\n", nFans, m, nOuts, (unsigned)((pTable[(nOuts * m) >> 6] >> ((nOuts * m) & 63)) & Abc_Tt6Mask(nOuts)) );
+    fprintf( pFile, "    endcase\n" );
+    fprintf( pFile, "  end\n" );
+    fprintf( pFile, "endmodule\n" );
+    fprintf( pFile, "\n" );
+}
+void Wlc_WriteTables( FILE * pFile, Wlc_Ntk_t * p )
+{
+    Vec_Int_t * vNodes;
+    Wlc_Obj_t * pObj, * pFanin;
+    word * pTable;
+    int i;
+    if ( p->vTables == NULL || Vec_PtrSize(p->vTables) == 0 )
+        return;
+    // map tables into their nodes
+    vNodes = Vec_IntStart( Vec_PtrSize(p->vTables) );
+    Wlc_NtkForEachObj( p, pObj, i )
+        if ( pObj->Type == WLC_OBJ_TABLE )
+            Vec_IntWriteEntry( vNodes, Wlc_ObjTableId(pObj), i );
+    // write tables
+    Vec_PtrForEachEntry( word *, p->vTables, pTable, i )
+    {
+        pObj = Wlc_NtkObj( p, Vec_IntEntry(vNodes, i) );
+        assert( pObj->Type == WLC_OBJ_TABLE );
+        pFanin = Wlc_ObjFanin0( p, pObj );
+        Wlc_WriteTableOne( pFile, Wlc_ObjRange(pFanin), Wlc_ObjRange(pObj), pTable, i );
+    }
+    Vec_IntFree( vNodes );
+}
+
+/**Function*************************************************************
+
+  Synopsis    [This was used to add POs to each node except PIs and MUXes.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Wlc_WriteAddPos( Wlc_Ntk_t * p )
+{
+    Wlc_Obj_t * pObj;
+    int i;
+    Vec_IntClear( &p->vPos );
+    Wlc_NtkForEachObj( p, pObj, i )
+        if ( pObj->Type != WLC_OBJ_PI && pObj->Type != WLC_OBJ_MUX )
+        {
+            pObj->fIsPo = 1;
+            Vec_IntPush( &p->vPos, Wlc_ObjId(p, pObj) );
+        }
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
 void Wlc_WriteVerIntVec( FILE * pFile, Wlc_Ntk_t * p, Vec_Int_t * vVec, int Start )
 {
     char * pName;
@@ -80,45 +159,119 @@
     if ( Wlc_NtkPoNum(p) > 0  )
         Wlc_WriteVerIntVec( pFile, p, &p->vPos, 3 );
     fprintf( pFile, "  );\n" );
+    // mark fanins of rotation shifts
     Wlc_NtkForEachObj( p, pObj, i )
+        if ( pObj->Type == WLC_OBJ_ROTATE_R || pObj->Type == WLC_OBJ_ROTATE_L )
+            Wlc_ObjFanin1(p, pObj)->Mark = 1;
+    Wlc_NtkForEachObj( p, pObj, i )
     {
-        char * pName  = Wlc_ObjName(p, i);
-        char * pName0 = Wlc_ObjFaninNum(pObj) ? Wlc_ObjName(p, Wlc_ObjFaninId0(pObj)) : NULL;
         int nDigits   = Abc_Base10Log(pObj->End+1) + Abc_Base10Log(pObj->Beg+1);
-        sprintf( Range, "%s[%d:%d]%*s", pObj->Signed ? "signed ":"       ", pObj->End, pObj->Beg, 8-nDigits, "" );
+        if ( pObj->Mark ) 
+        {
+            pObj->Mark = 0;
+            continue;
+        }
+        sprintf( Range, "%s[%d:%d]%*s", Wlc_ObjIsSigned(pObj) ? "signed ":"       ", pObj->End, pObj->Beg, 8-nDigits, "" );
         fprintf( pFile, "  " );
         if ( pObj->Type == WLC_OBJ_PI )
-            fprintf( pFile, "input  wire %s %-16s", Range, pName );
-        else if ( pObj->Type == WLC_OBJ_PO )
-            fprintf( pFile, "output wire %s %-16s = %s", Range, pName, pName0 );
+            fprintf( pFile, "input  " );
+        else if ( pObj->fIsPo )
+            fprintf( pFile, "output " );
+        else
+            fprintf( pFile, "       " );
+        if ( Wlc_ObjIsCi(pObj) || pObj->fIsPo )
+        {
+            fprintf( pFile, "wire %s %s ;\n", Range, Wlc_ObjName(p, i) );
+            if ( Wlc_ObjIsCi(pObj) )
+                continue;
+            Range[0] = 0;
+        }
+        if ( pObj->fIsPo )
+            fprintf( pFile, "  assign                         " );
+        else if ( pObj->Type == WLC_OBJ_MUX && Wlc_ObjFaninNum(pObj) > 3 )
+            fprintf( pFile, "reg  %s ", Range );
+        else
+            fprintf( pFile, "wire %s ", Range );
+        if ( pObj->Type == WLC_OBJ_TABLE )
+        {
+            // wire [3:0] s4972; table0 s4972_Index(s4971, s4972);
+            fprintf( pFile, "%s ;              table%d", Wlc_ObjName(p, i), Wlc_ObjTableId(pObj) );
+            fprintf( pFile, " s%d_Index(%s, ", i, Wlc_ObjName(p, Wlc_ObjFaninId0(pObj)) );
+            fprintf( pFile, "%s)",             Wlc_ObjName(p, i) );
+        }
         else if ( pObj->Type == WLC_OBJ_CONST )
         {
-            fprintf( pFile, "       wire %s %-16s = %d\'%sh", Range, pName, Wlc_ObjRange(pObj), pObj->Signed ? "s":"" );
+            fprintf( pFile, "%-16s = %d\'%sh", Wlc_ObjName(p, i), Wlc_ObjRange(pObj), Wlc_ObjIsSigned(pObj) ? "s":"" );
             Abc_TtPrintHexArrayRev( pFile, (word *)Wlc_ObjConstValue(pObj), (Wlc_ObjRange(pObj) + 3) / 4 );
         }
+        else if ( pObj->Type == WLC_OBJ_ROTATE_R || pObj->Type == WLC_OBJ_ROTATE_L )
+        {
+            //  wire [27:0] s4960 = (s57 >> 17) | (s57 << 11);
+            Wlc_Obj_t * pShift = Wlc_ObjFanin1(p, pObj);
+            int Num0 = *Wlc_ObjConstValue(pShift);
+            int Num1 = Wlc_ObjRange(pObj) - Num0;
+            assert( pShift->Type == WLC_OBJ_CONST );
+            assert( Num0 > 0 && Num0 < Wlc_ObjRange(pObj) );
+            fprintf( pFile, "%-16s = ", Wlc_ObjName(p, i) );
+            if ( pObj->Type == WLC_OBJ_ROTATE_R )
+                fprintf( pFile, "(%s >> %d) | (%s << %d)", Wlc_ObjName(p, Wlc_ObjFaninId0(pObj)), Num0, Wlc_ObjName(p, Wlc_ObjFaninId0(pObj)), Num1 );
+            else
+                fprintf( pFile, "(%s << %d) | (%s >> %d)", Wlc_ObjName(p, Wlc_ObjFaninId0(pObj)), Num0, Wlc_ObjName(p, Wlc_ObjFaninId0(pObj)), Num1 );
+        }
+        else if ( pObj->Type == WLC_OBJ_MUX && Wlc_ObjFaninNum(pObj) > 3 )
+        {
+            fprintf( pFile, "%s ;\n", Wlc_ObjName(p, i) );
+            fprintf( pFile, "         " );
+            fprintf( pFile, "always @( " );
+            Wlc_ObjForEachFanin( pObj, iFanin, k )
+                fprintf( pFile, "%s%s", k ? " or ":"", Wlc_ObjName(p, Wlc_ObjFaninId(pObj, k)) );
+            fprintf( pFile, " )\n" );
+            fprintf( pFile, "           " );
+            fprintf( pFile, "begin\n" );
+            fprintf( pFile, "             " );
+            fprintf( pFile, "case ( %s )\n", Wlc_ObjName(p, Wlc_ObjFaninId(pObj, 0)) );
+            Wlc_ObjForEachFanin( pObj, iFanin, k )
+            {
+                if ( !k ) continue;
+                fprintf( pFile, "               " );
+                fprintf( pFile, "%d : %s = ", k-1, Wlc_ObjName(p, i) );
+                fprintf( pFile, "%s ;\n", Wlc_ObjName(p, Wlc_ObjFaninId(pObj, k)) );
+            }
+            fprintf( pFile, "             " );
+            fprintf( pFile, "endcase\n" );
+            fprintf( pFile, "           " );
+            fprintf( pFile, "end\n" );
+            continue;
+        }
         else
         {
-            fprintf( pFile, "       wire %s %-16s = ", Range, Wlc_ObjName(p, i) );
+            fprintf( pFile, "%-16s = ", Wlc_ObjName(p, i) );
             if ( pObj->Type == WLC_OBJ_BUF )
-                fprintf( pFile, "%s", pName0 );
+                fprintf( pFile, "%s", Wlc_ObjName(p, Wlc_ObjFaninId0(pObj)) );
             else if ( pObj->Type == WLC_OBJ_MUX )
-                fprintf( pFile, "%s ? %s : %s", pName0, Wlc_ObjName(p, Wlc_ObjFaninId1(pObj)), Wlc_ObjName(p, Wlc_ObjFaninId2(pObj)) );
+            {
+                fprintf( pFile, "%s ? ", Wlc_ObjName(p, Wlc_ObjFaninId0(pObj)) );
+                fprintf( pFile, "%s : ", Wlc_ObjName(p, Wlc_ObjFaninId2(pObj)) );
+                fprintf( pFile, "%s",    Wlc_ObjName(p, Wlc_ObjFaninId1(pObj)) );
+            }
+            else if ( pObj->Type == WLC_OBJ_ARI_MINUS )
+                fprintf( pFile, "-%s", Wlc_ObjName(p, Wlc_ObjFaninId0(pObj)) );
             else if ( pObj->Type == WLC_OBJ_BIT_NOT )
-                fprintf( pFile, "~%s", pName0 );
+                fprintf( pFile, "~%s", Wlc_ObjName(p, Wlc_ObjFaninId0(pObj)) );
             else if ( pObj->Type == WLC_OBJ_LOGIC_NOT )
-                fprintf( pFile, "!%s", pName0 );
+                fprintf( pFile, "!%s", Wlc_ObjName(p, Wlc_ObjFaninId0(pObj)) );
             else if ( pObj->Type == WLC_OBJ_REDUCT_AND )
-                fprintf( pFile, "&%s", pName0 );
+                fprintf( pFile, "&%s", Wlc_ObjName(p, Wlc_ObjFaninId0(pObj)) );
             else if ( pObj->Type == WLC_OBJ_REDUCT_OR )
-                fprintf( pFile, "|%s", pName0 );
+                fprintf( pFile, "|%s", Wlc_ObjName(p, Wlc_ObjFaninId0(pObj)) );
             else if ( pObj->Type == WLC_OBJ_REDUCT_XOR )
-                fprintf( pFile, "^%s", pName0 );
+                fprintf( pFile, "^%s", Wlc_ObjName(p, Wlc_ObjFaninId0(pObj)) );
             else if ( pObj->Type == WLC_OBJ_BIT_SELECT )
-                fprintf( pFile, "%s [%d:%d]", pName0, Wlc_ObjRangeEnd(pObj), Wlc_ObjRangeBeg(pObj) );
+                fprintf( pFile, "%s [%d:%d]", Wlc_ObjName(p, Wlc_ObjFaninId0(pObj)), Wlc_ObjRangeEnd(pObj), Wlc_ObjRangeBeg(pObj) );
             else if ( pObj->Type == WLC_OBJ_BIT_SIGNEXT )
-                fprintf( pFile, "{ {%d{%s[%d]}}, %s }", Wlc_ObjRange(pObj) - Wlc_ObjRange(Wlc_ObjFanin0(p, pObj)), pName0, Wlc_ObjRange(Wlc_ObjFanin0(p, pObj)) - 1, pName0 );
+                fprintf( pFile, "{ {%d{%s[%d]}}, %s }", Wlc_ObjRange(pObj) - Wlc_ObjRange(Wlc_ObjFanin0(p, pObj)), Wlc_ObjName(p, Wlc_ObjFaninId0(pObj)), Wlc_ObjRange(Wlc_ObjFanin0(p, pObj)) - 1, Wlc_ObjName(p, Wlc_ObjFaninId0(pObj)) );
             else if ( pObj->Type == WLC_OBJ_BIT_ZEROPAD )
-                fprintf( pFile, "{ {%d{1\'b0}}, %s }", Wlc_ObjRange(pObj) - Wlc_ObjRange(Wlc_ObjFanin0(p, pObj)), pName0 );
+                fprintf( pFile, "{ {%d{1\'b0}}, %s }", Wlc_ObjRange(pObj) - Wlc_ObjRange(Wlc_ObjFanin0(p, pObj)), Wlc_ObjName(p, Wlc_ObjFaninId0(pObj)) );
             else if ( pObj->Type == WLC_OBJ_BIT_CONCAT )
             {
                 fprintf( pFile, "{" );
@@ -126,7 +279,7 @@
                     fprintf( pFile, " %s%s", Wlc_ObjName(p, Wlc_ObjFaninId(pObj, k)), k == Wlc_ObjFaninNum(pObj)-1 ? "":"," );
                 fprintf( pFile, " }" );
             }
-            else 
+            else
             {
                 fprintf( pFile, "%s ", Wlc_ObjName(p, Wlc_ObjFaninId(pObj, 0)) );
                 if ( pObj->Type == WLC_OBJ_SHIFT_R )
@@ -149,7 +302,7 @@
                     fprintf( pFile, "||" );
                 else if ( pObj->Type == WLC_OBJ_COMP_EQU )
                     fprintf( pFile, "==" );
-                else if ( pObj->Type == WLC_OBJ_COMP_NOT )
+                else if ( pObj->Type == WLC_OBJ_COMP_NOTEQU )
                     fprintf( pFile, "!=" );
                 else if ( pObj->Type == WLC_OBJ_COMP_LESS )
                     fprintf( pFile, "<" );
@@ -177,6 +330,56 @@
         }
         fprintf( pFile, " ;\n" );
     }
+    iFanin = 0;
+    assert( !p->vInits || Wlc_NtkFfNum(p) == Vec_IntSize(p->vInits) );
+    if ( p->vInits )
+    Wlc_NtkForEachCi( p, pObj, i )
+    {
+        int nDigits   = Abc_Base10Log(pObj->End+1) + 1;
+        char * pName  = Wlc_ObjName(p, Wlc_ObjId(p, pObj));
+        assert( i == Wlc_ObjCiId(pObj) );
+        if ( pObj->Type == WLC_OBJ_PI )
+            continue;
+        sprintf( Range, "       [%d:%d]%*s", Wlc_ObjRange(pObj) - 1, 0, 8-nDigits, "" );
+        fprintf( pFile, "         " );
+        fprintf( pFile, "wire %s ", Range );
+        fprintf( pFile, "%s_init%*s = ", pName, 11 - (int)strlen(pName), "" );
+        if ( Vec_IntEntry(p->vInits, i-Wlc_NtkPiNum(p)) > 0 )
+            fprintf( pFile, "%s", Wlc_ObjName(p, Wlc_ObjId(p, Wlc_NtkPi(p, Vec_IntEntry(p->vInits, i-Wlc_NtkPiNum(p))))));
+        else
+        {
+            fprintf( pFile, "%d\'b", Wlc_ObjRange(pObj) );
+            for ( k = 0; k < Wlc_ObjRange(pObj); k++ )
+                fprintf( pFile, "%c", p->pInits[iFanin + k] );
+        }
+        fprintf( pFile, ";\n" );
+        iFanin += Wlc_ObjRange(pObj);
+    }
+    Wlc_NtkForEachCi( p, pObj, i )
+    {
+        char * pName  = Wlc_ObjName(p, Wlc_ObjId(p, pObj));
+        assert( i == Wlc_ObjCiId(pObj) );
+        if ( pObj->Type == WLC_OBJ_PI )
+            continue;
+        fprintf( pFile, "         " );
+        fprintf( pFile, "CPL_FF" );
+        if ( Wlc_ObjRange(pObj) > 1 )
+            fprintf( pFile, "#%d%*s", Wlc_ObjRange(pObj), 4 - Abc_Base10Log(Wlc_ObjRange(pObj)+1), "" );
+        else
+            fprintf( pFile, "     " );
+        fprintf( pFile, " reg%d (",       i );
+        fprintf( pFile, " .q( %s ),",      pName );
+        fprintf( pFile, " .qbar()," );
+        fprintf( pFile, " .d( %s ),",      Wlc_ObjName(p, Wlc_ObjId(p, Wlc_ObjFoToFi(p, pObj))) );
+        fprintf( pFile, " .clk( %s ),",    "1\'b0" );
+        fprintf( pFile, " .arst( %s ),",   "1\'b0" );
+        if ( p->vInits )
+            fprintf( pFile, " .arstval( %s_init )", pName );
+        else
+            fprintf( pFile, " .arstval( %s )", "1\'b0" );
+        fprintf( pFile, " ) ;\n" );
+    }
+    assert( !p->vInits || iFanin == (int)strlen(p->pInits) );
     fprintf( pFile, "endmodule\n\n" );
 } 
 void Wlc_WriteVer( Wlc_Ntk_t * p, char * pFileName )
@@ -190,6 +393,8 @@
     }
     fprintf( pFile, "// Benchmark \"%s\" written by ABC on %s\n", p->pName, Extra_TimeStamp() );
     fprintf( pFile, "\n" );
+    Wlc_WriteTables( pFile, p );
+//    Wlc_WriteAddPos( p );
     Wlc_WriteVerInt( pFile, p );
     fprintf( pFile, "\n" );
     fclose( pFile );
diff --git a/abc-build/src/bdd/dsd/dsdTree.c b/abc-build/src/bdd/dsd/dsdTree.c
--- a/abc-build/src/bdd/dsd/dsdTree.c
+++ b/abc-build/src/bdd/dsd/dsdTree.c
@@ -18,6 +18,7 @@
 
 #include "dsdInt.h"
 #include "misc/util/utilTruth.h"
+#include "opt/dau/dau.h"
 
 ABC_NAMESPACE_IMPL_START
 
@@ -869,7 +870,6 @@
         fprintf( pFile, " " );
         if ( pNode->nDecs <= 6 )
         {
-            extern unsigned Abc_TtCanonicize( word * pTruth, int nVars, char * pCanonPerm );
             char pCanonPerm[6]; int uCanonPhase;
             // compute truth table
             DdNode * bFunc = Dsd_TreeGetPrimeFunction( dd, pNode );  
diff --git a/abc-build/src/bdd/mtr/mtr.h b/abc-build/src/bdd/mtr/mtr.h
--- a/abc-build/src/bdd/mtr/mtr.h
+++ b/abc-build/src/bdd/mtr/mtr.h
@@ -76,12 +76,12 @@
 #define SIZEOF_INT 4
 #endif
 
-#undef CONST
-#if defined(__STDC__) || defined(__cplusplus)
-#define CONST           const
-#else /* !(__STDC__ || __cplusplus) */
-#define CONST
-#endif /* !(__STDC__ || __cplusplus) */
+//#undef CONST
+//#if defined(__STDC__) || defined(__cplusplus)
+//#define CONST           const
+//#else /* !(__STDC__ || __cplusplus) */
+//#define CONST
+//#endif /* !(__STDC__ || __cplusplus) */
 
 #if defined(__GNUC__)
 #define MTR_INLINE __inline__
diff --git a/abc-build/src/bdd/parse/parseCore.c b/abc-build/src/bdd/parse/parseCore.c
--- a/abc-build/src/bdd/parse/parseCore.c
+++ b/abc-build/src/bdd/parse/parseCore.c
@@ -24,11 +24,11 @@
     and underscores: For example: 1) a&b <+> c'&d => a + b;   
     2) a1 b2 c3' dummy' + (a2+b2')c3 dummy
  2) Constant values 0 and 1 can be used just like normal variables
- 3) Any boolean operator (listed below) and parantheses can be used
+ 3) Any boolean operator (listed below) and parentheses can be used
     any number of times provided there are equal number of opening
-    and closing parantheses.
+    and closing parentheses.
  4) By default, absence of an operator between vars and before and 
-    after parantheses is taken for AND. 
+    after parentheses is taken for AND. 
  5) Both complementation prefix and complementation suffix can be 
     used at the same time (but who needs this?)
  6) Spaces (tabs, end-of-lines) may be inserted anywhere,
@@ -47,8 +47,8 @@
 
 
 // the list of operation symbols to be used in expressions
-#define PARSE_SYM_OPEN    '('   // opening paranthesis
-#define PARSE_SYM_CLOSE   ')'   // closing paranthesis
+#define PARSE_SYM_OPEN    '('   // opening parenthesis
+#define PARSE_SYM_CLOSE   ')'   // closing parenthesis
 #define PARSE_SYM_LOWER   '['   // shifts one rank down 
 #define PARSE_SYM_RAISE   ']'   // shifts one rank up
 #define PARSE_SYM_CONST0  '0'   // constant 0
@@ -81,7 +81,7 @@
 #define PARSE_OPER_EQU  6  // equvalence   (a'b'| ab )
 #define PARSE_OPER_FLR  5  // implication  ( a' | b )
 #define PARSE_OPER_FLL  4  // backward imp ( 'b | a )
-#define PARSE_OPER_MARK 1  // OpStack token standing for an opening paranthesis
+#define PARSE_OPER_MARK 1  // OpStack token standing for an opening parenthesis
 
 // these are values of the internal Flag
 #define PARSE_FLAG_START  1 // after the opening parenthesis 
@@ -133,7 +133,7 @@
         return NULL;
     }
 
-    // make sure that the number of opening and closing parantheses is the same
+    // make sure that the number of opening and closing parentheses is the same
     nParans = 0;
     for ( pTemp = pFormulaInit; *pTemp; pTemp++ )
         if ( *pTemp == '(' )
@@ -142,7 +142,7 @@
             nParans--;
     if ( nParans != 0 )
     {
-        fprintf( pOutput, "Parse_FormulaParser(): Different number of opening and closing parantheses ().\n" );
+        fprintf( pOutput, "Parse_FormulaParser(): Different number of opening and closing parentheses ().\n" );
         return NULL;
     }
 
@@ -326,7 +326,7 @@
 			    {
 				    if ( Parse_StackOpIsEmpty( pStackOp ) )
 					{
-						fprintf( pOutput, "Parse_FormulaParser(): There is no opening paranthesis\n" );
+						fprintf( pOutput, "Parse_FormulaParser(): There is no opening parenthesis\n" );
 						Flag = PARSE_FLAG_ERROR; 
                         break;
 					}
@@ -353,7 +353,7 @@
             }
 		    else
 			{
-				fprintf( pOutput, "Parse_FormulaParser(): There is no opening paranthesis\n" );
+				fprintf( pOutput, "Parse_FormulaParser(): There is no opening parenthesis\n" );
 				Flag = PARSE_FLAG_ERROR; 
                 break;
 			}
diff --git a/abc-build/src/bdd/parse/parseEqn.c b/abc-build/src/bdd/parse/parseEqn.c
--- a/abc-build/src/bdd/parse/parseEqn.c
+++ b/abc-build/src/bdd/parse/parseEqn.c
@@ -29,8 +29,8 @@
 
 
 // the list of operation symbols to be used in expressions
-#define PARSE_EQN_SYM_OPEN    '('   // opening paranthesis
-#define PARSE_EQN_SYM_CLOSE   ')'   // closing paranthesis
+#define PARSE_EQN_SYM_OPEN    '('   // opening parenthesis
+#define PARSE_EQN_SYM_CLOSE   ')'   // closing parenthesis
 #define PARSE_EQN_SYM_CONST0  '0'   // constant 0
 #define PARSE_EQN_SYM_CONST1  '1'   // constant 1
 #define PARSE_EQN_SYM_NEG     '!'   // negation before the variable
@@ -41,7 +41,7 @@
 #define PARSE_EQN_OPER_NEG    10    // negation
 #define PARSE_EQN_OPER_AND     9    // logic AND
 #define PARSE_EQN_OPER_OR      7    // logic OR
-#define PARSE_EQN_OPER_MARK    1    // OpStack token standing for an opening paranthesis
+#define PARSE_EQN_OPER_MARK    1    // OpStack token standing for an opening parenthesis
 
 // these are values of the internal Flag
 #define PARSE_EQN_FLAG_START   1    // after the opening parenthesis 
@@ -80,7 +80,7 @@
 	int Oper, Oper1, Oper2;
     int i, v;
 
-    // make sure that the number of opening and closing parantheses is the same
+    // make sure that the number of opening and closing parentheses is the same
     nParans = 0;
     for ( pTemp = pFormInit; *pTemp; pTemp++ )
         if ( *pTemp == '(' )
@@ -89,7 +89,7 @@
             nParans--;
     if ( nParans != 0 )
     {
-        fprintf( pOutput, "Parse_FormulaParserEqn(): Different number of opening and closing parantheses ().\n" );
+        fprintf( pOutput, "Parse_FormulaParserEqn(): Different number of opening and closing parentheses ().\n" );
         return NULL;
     }
 
@@ -158,7 +158,7 @@
 			if ( Flag == PARSE_EQN_FLAG_VAR )
             {
 //				Parse_StackOpPush( pStackOp, PARSE_EQN_OPER_AND );
-				fprintf( pOutput, "Parse_FormulaParserEqn(): An opening paranthesis follows a var without operation sign.\n" ); 
+				fprintf( pOutput, "Parse_FormulaParserEqn(): An opening parenthesis follows a var without operation sign.\n" ); 
 				Flag = PARSE_EQN_FLAG_ERROR; 
                 break; 
             }
@@ -173,7 +173,7 @@
 			    {
 				    if ( Parse_StackOpIsEmpty( pStackOp ) )
 					{
-						fprintf( pOutput, "Parse_FormulaParserEqn(): There is no opening paranthesis\n" );
+						fprintf( pOutput, "Parse_FormulaParserEqn(): There is no opening parenthesis\n" );
 						Flag = PARSE_EQN_FLAG_ERROR; 
                         break;
 					}
@@ -194,7 +194,7 @@
             }
 		    else
 			{
-				fprintf( pOutput, "Parse_FormulaParserEqn(): There is no opening paranthesis\n" );
+				fprintf( pOutput, "Parse_FormulaParserEqn(): There is no opening parenthesis\n" );
 				Flag = PARSE_EQN_FLAG_ERROR; 
                 break;
 			}
@@ -211,7 +211,7 @@
               {
 				    if ( pTemp[i] == PARSE_EQN_SYM_NEG || pTemp[i] == PARSE_EQN_SYM_OPEN )
 				    {
-					    fprintf( pOutput, "Parse_FormulaParserEqn(): The negation sign or an opening paranthesis inside the variable name.\n" );
+					    fprintf( pOutput, "Parse_FormulaParserEqn(): The negation sign or an opening parenthesis inside the variable name.\n" );
 					    Flag = PARSE_EQN_FLAG_ERROR; 
                         break;
 				    }
diff --git a/abc-build/src/bool/dec/decFactor.c b/abc-build/src/bool/dec/decFactor.c
--- a/abc-build/src/bool/dec/decFactor.c
+++ b/abc-build/src/bool/dec/decFactor.c
@@ -57,23 +57,20 @@
     Mvc_Cover_t * pCover;
     Dec_Graph_t * pFForm;
     Dec_Edge_t eRoot;
+    if ( Abc_SopIsConst0(pSop) )
+        return Dec_GraphCreateConst0();
+    if ( Abc_SopIsConst1(pSop) )
+        return Dec_GraphCreateConst1();
 
     // derive the cover from the SOP representation
     pCover = Dec_ConvertSopToMvc( pSop );
 
     // make sure the cover is CCS free (should be done before CST)
-    Mvc_CoverContain( pCover );
-    // check for trivial functions
-    if ( Mvc_CoverIsEmpty(pCover) )
-    {
-        Mvc_CoverFree( pCover );
-        return Dec_GraphCreateConst0();
-    }
-    if ( Mvc_CoverIsTautology(pCover) )
-    {
-        Mvc_CoverFree( pCover );
-        return Dec_GraphCreateConst1();
-    }
+    Mvc_CoverContain( pCover );
+
+    // check for trivial functions
+    assert( !Mvc_CoverIsEmpty(pCover) );
+    assert( !Mvc_CoverIsTautology(pCover) );
 
     // perform CST
     Mvc_CoverInverse( pCover ); // CST
@@ -333,7 +330,8 @@
     int nVars, Value, v;
 
     // start the cover
-    nVars = Abc_SopGetVarNum(pSop);
+    nVars = Abc_SopGetVarNum(pSop);
+    assert( nVars > 0 );
     pMvc = Mvc_CoverAlloc( pMem, nVars * 2 );
     // check the logic function of the node
     Abc_SopForEachCube( pSop, nVars, pCube )
diff --git a/abc-build/src/bool/kit/kitIsop.c b/abc-build/src/bool/kit/kitIsop.c
--- a/abc-build/src/bool/kit/kitIsop.c
+++ b/abc-build/src/bool/kit/kitIsop.c
@@ -58,7 +58,7 @@
     Kit_Sop_t cRes2, * pcRes2 = &cRes2;
     unsigned * pResult;
     int RetValue = 0;
-    assert( nVars >= 0 && nVars < 16 );
+    assert( nVars >= 0 && nVars <= 16 );
     // if nVars < 5, make sure it does not depend on those vars
 //    for ( i = nVars; i < 5; i++ )
 //        assert( !Kit_TruthVarInSupport(puTruth, 5, i) );
diff --git a/abc-build/src/bool/lucky/luckySimple.c b/abc-build/src/bool/lucky/luckySimple.c
--- a/abc-build/src/bool/lucky/luckySimple.c
+++ b/abc-build/src/bool/lucky/luckySimple.c
@@ -103,7 +103,7 @@
 	
 	
 }
-inline int factorial(int n)
+static inline int factorial(int n)
 {
 	return (n == 1 || n == 0) ? 1 : factorial(n - 1) * n;
 }
@@ -129,14 +129,14 @@
     free(x->swapArray);
     free(x);
 }
-inline void minWord(word* a, word* b, word* minimal, int nVars)
+static inline void minWord(word* a, word* b, word* minimal, int nVars)
 {
     if(memCompare(a, b, nVars) == -1)
         Kit_TruthCopy_64bit( minimal, a, nVars );
     else
         Kit_TruthCopy_64bit( minimal, b, nVars );
 }
-inline void minWord3(word* a, word* b, word* minimal, int nVars)
+static inline void minWord3(word* a, word* b, word* minimal, int nVars)
 { 
     if (memCompare(a, b, nVars) <= 0)
     {
diff --git a/abc-build/src/bool/rpo/rpo.c b/abc-build/src/bool/rpo/rpo.c
--- a/abc-build/src/bool/rpo/rpo.c
+++ b/abc-build/src/bool/rpo/rpo.c
@@ -380,4 +380,4 @@
     return result;
 }
 
-ABC_NAMESPACE_IMPL_END
+ABC_NAMESPACE_IMPL_END
diff --git a/abc-build/src/bool/rpo/rpo.h b/abc-build/src/bool/rpo/rpo.h
--- a/abc-build/src/bool/rpo/rpo.h
+++ b/abc-build/src/bool/rpo/rpo.h
@@ -54,5 +54,8 @@
 ABC_NAMESPACE_HEADER_END
         
 #endif
-
-  
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
diff --git a/abc-build/src/map/amap/amapParse.c b/abc-build/src/map/amap/amapParse.c
--- a/abc-build/src/map/amap/amapParse.c
+++ b/abc-build/src/map/amap/amapParse.c
@@ -30,8 +30,8 @@
 ////////////////////////////////////////////////////////////////////////
 
 // the list of operation symbols to be used in expressions
-#define AMAP_EQN_SYM_OPEN    '('   // opening paranthesis
-#define AMAP_EQN_SYM_CLOSE   ')'   // closing paranthesis
+#define AMAP_EQN_SYM_OPEN    '('   // opening parenthesis
+#define AMAP_EQN_SYM_CLOSE   ')'   // closing parenthesis
 #define AMAP_EQN_SYM_CONST0  '0'   // constant 0
 #define AMAP_EQN_SYM_CONST1  '1'   // constant 1
 #define AMAP_EQN_SYM_NEG     '!'   // negation before the variable
@@ -47,7 +47,7 @@
 #define AMAP_EQN_OPER_AND     9    // logic AND
 #define AMAP_EQN_OPER_XOR     8    // logic XOR
 #define AMAP_EQN_OPER_OR      7    // logic OR
-#define AMAP_EQN_OPER_MARK    1    // OpStack token standing for an opening paranthesis
+#define AMAP_EQN_OPER_MARK    1    // OpStack token standing for an opening parenthesis
 
 // these are values of the internal Flag
 #define AMAP_EQN_FLAG_START   1    // after the opening parenthesis 
@@ -114,7 +114,7 @@
 	int Oper, Oper1, Oper2;
     int i, v;
 
-    // make sure that the number of opening and closing parantheses is the same
+    // make sure that the number of opening and closing parentheses is the same
     nParans = 0;
     for ( pTemp = pFormInit; *pTemp; pTemp++ )
         if ( *pTemp == '(' )
@@ -123,7 +123,7 @@
             nParans--;
     if ( nParans != 0 )
     {
-        fprintf( pOutput, "Amap_ParseFormula(): Different number of opening and closing parantheses ().\n" );
+        fprintf( pOutput, "Amap_ParseFormula(): Different number of opening and closing parentheses ().\n" );
         return NULL;
     }
 
@@ -207,7 +207,7 @@
 			if ( Flag == AMAP_EQN_FLAG_VAR )
             {
 				Vec_IntPush( pStackOp, AMAP_EQN_OPER_AND );
-//				fprintf( pOutput, "Amap_ParseFormula(): An opening paranthesis follows a var without operation sign.\n" ); 
+//				fprintf( pOutput, "Amap_ParseFormula(): An opening parenthesis follows a var without operation sign.\n" ); 
 //				Flag = AMAP_EQN_FLAG_ERROR; 
 //              break; 
             }
@@ -222,7 +222,7 @@
 			    {
 				    if ( Vec_IntSize( pStackOp ) == 0 )
 					{
-						fprintf( pOutput, "Amap_ParseFormula(): There is no opening paranthesis\n" );
+						fprintf( pOutput, "Amap_ParseFormula(): There is no opening parenthesis\n" );
 						Flag = AMAP_EQN_FLAG_ERROR; 
                         break;
 					}
@@ -243,7 +243,7 @@
             }
 		    else
 			{
-				fprintf( pOutput, "Amap_ParseFormula(): There is no opening paranthesis\n" );
+				fprintf( pOutput, "Amap_ParseFormula(): There is no opening parenthesis\n" );
 				Flag = AMAP_EQN_FLAG_ERROR; 
                 break;
 			}
@@ -262,7 +262,7 @@
               {
 				    if ( pTemp[i] == AMAP_EQN_SYM_NEG || pTemp[i] == AMAP_EQN_SYM_OPEN )
 				    {
-					    fprintf( pOutput, "Amap_ParseFormula(): The negation sign or an opening paranthesis inside the variable name.\n" );
+					    fprintf( pOutput, "Amap_ParseFormula(): The negation sign or an opening parenthesis inside the variable name.\n" );
 					    Flag = AMAP_EQN_FLAG_ERROR; 
                         break;
 				    }
diff --git a/abc-build/src/map/if/if.h b/abc-build/src/map/if/if.h
--- a/abc-build/src/map/if/if.h
+++ b/abc-build/src/map/if/if.h
@@ -81,6 +81,7 @@
 typedef struct If_LibLut_t_  If_LibLut_t;
 typedef struct If_LibBox_t_  If_LibBox_t;
 typedef struct If_DsdMan_t_  If_DsdMan_t;
+typedef struct Ifn_Ntk_t_    Ifn_Ntk_t;
 
 typedef struct Ifif_Par_t_   Ifif_Par_t;
 struct Ifif_Par_t_
@@ -130,6 +131,9 @@
     int                fEnableCheck75;// enable additional checking
     int                fEnableCheck75u;// enable additional checking
     int                fUseDsd;       // compute DSD of the cut functions
+    int                fUseDsdTune;   // use matching based on precomputed manager
+    int                fUseCofVars;   // use cofactoring variables
+    int                fUseAndVars;   // use bi-decomposition
     int                fUseTtPerm;    // compute truth tables of the cut functions
     int                fDeriveLuts;   // enables deriving LUT structures
     int                fDoAverage;    // optimize average rather than maximum level
@@ -241,6 +245,8 @@
     Vec_Wec_t *        vTtIsops[IF_MAX_FUNC_LUTSIZE+1]; // mapping of truth table into DSD
     Vec_Int_t *        vTtDsds[IF_MAX_FUNC_LUTSIZE+1];  // mapping of truth table into DSD
     Vec_Str_t *        vTtPerms[IF_MAX_FUNC_LUTSIZE+1]; // mapping of truth table into permutations
+    Vec_Str_t *        vTtVars[IF_MAX_FUNC_LUTSIZE+1];  // mapping of truth table into selected vars
+    Vec_Int_t *        vTtDecs[IF_MAX_FUNC_LUTSIZE+1];  // mapping of truth table into decomposition pattern
     Hash_IntMan_t *    vPairHash;     // hashing pairs of truth tables
     Vec_Int_t *        vPairRes;      // resulting truth table
     Vec_Str_t *        vPairPerms;    // resulting permutation
@@ -539,17 +545,27 @@
 extern void            If_DsdManAllocIsops( If_DsdMan_t * p, int nLutSize );
 extern void            If_DsdManPrint( If_DsdMan_t * p, char * pFileName, int Number, int Support, int fOccurs, int fTtDump, int fVerbose );
 extern void            If_DsdManTune( If_DsdMan_t * p, int LutSize, int fFast, int fAdd, int fSpec, int fVerbose );
+extern void            Id_DsdManTuneStr( If_DsdMan_t * p, char * pStruct, int nConfls, int nProcs, int fVerbose );
 extern void            If_DsdManFree( If_DsdMan_t * p, int fVerbose );
 extern void            If_DsdManSave( If_DsdMan_t * p, char * pFileName );
 extern If_DsdMan_t *   If_DsdManLoad( char * pFileName );
 extern void            If_DsdManMerge( If_DsdMan_t * p, If_DsdMan_t * pNew );
-extern void            If_DsdManClean( If_DsdMan_t * p, int fVerbose );
+extern void            If_DsdManCleanOccur( If_DsdMan_t * p, int fVerbose );
+extern void            If_DsdManCleanMarks( If_DsdMan_t * p, int fVerbose );
+extern void            If_DsdManInvertMarks( If_DsdMan_t * p, int fVerbose );
+extern If_DsdMan_t *   If_DsdManFilter( If_DsdMan_t * p, int Limit );
 extern int             If_DsdManCompute( If_DsdMan_t * p, word * pTruth, int nLeaves, unsigned char * pPerm, char * pLutStruct );
 extern char *          If_DsdManFileName( If_DsdMan_t * p );
 extern int             If_DsdManVarNum( If_DsdMan_t * p );
+extern int             If_DsdManObjNum( If_DsdMan_t * p );
 extern int             If_DsdManLutSize( If_DsdMan_t * p );
+extern void            If_DsdManSetLutSize( If_DsdMan_t * p, int nLutSize );
 extern int             If_DsdManSuppSize( If_DsdMan_t * p, int iDsd );
 extern int             If_DsdManCheckDec( If_DsdMan_t * p, int iDsd );
+extern int             If_DsdManReadMark( If_DsdMan_t * p, int iDsd );
+extern void            If_DsdManSetNewAsUseless( If_DsdMan_t * p );
+extern word            If_DsdManGetFuncPerm( If_DsdMan_t * p, int iDsd );
+extern char *          If_DsdManGetCellStr( If_DsdMan_t * p );
 extern unsigned        If_DsdManCheckXY( If_DsdMan_t * p, int iDsd, int LutSize, int fDerive, unsigned uMaskNot, int fHighEffort, int fVerbose );
 extern int             If_CutDsdBalanceEval( If_Man_t * p, If_Cut_t * pCut, Vec_Int_t * vAig );
 extern int             If_CutDsdBalancePinDelays( If_Man_t * p, If_Cut_t * pCut, char * pPerm );
@@ -613,6 +629,15 @@
 extern void            If_CutRotatePins( If_Man_t * p, If_Cut_t * pCut );
 extern int             If_CutComputeTruth( If_Man_t * p, If_Cut_t * pCut, If_Cut_t * pCut0, If_Cut_t * pCut1, int fCompl0, int fCompl1 );
 extern int             If_CutComputeTruthPerm( If_Man_t * p, If_Cut_t * pCut, If_Cut_t * pCut0, If_Cut_t * pCut1, int fCompl0, int fCompl1 );
+/*=== ifTune.c ===========================================================*/
+extern Ifn_Ntk_t *     Ifn_NtkParse( char * pStr );
+extern int             Ifn_NtkMatch( Ifn_Ntk_t * p, word * pTruth, int nVars, int nConfls, int fVerbose, int fVeryVerbose, word * pPerm );
+extern void            Ifn_NtkPrint( Ifn_Ntk_t * p );
+extern int             Ifn_NtkLutSizeMax( Ifn_Ntk_t * p );
+extern int             Ifn_NtkInputNum( Ifn_Ntk_t * p );
+extern void *          If_ManSatBuildFromCell( char * pStr, Vec_Int_t ** pvPiVars, Vec_Int_t ** pvPoVars, Ifn_Ntk_t ** ppNtk );
+extern int             If_ManSatFindCofigBits( void * pSat, Vec_Int_t * vPiVars, Vec_Int_t * vPoVars, word * pTruth, int nVars, word Perm, int nInps, Vec_Int_t * vValues );
+extern int             If_ManSatDeriveGiaFromBits( void * pNew, Ifn_Ntk_t * p, Vec_Int_t * vLeaves, Vec_Int_t * vValues );
 /*=== ifUtil.c ============================================================*/
 extern void            If_ManCleanNodeCopy( If_Man_t * p );
 extern void            If_ManCleanCutData( If_Man_t * p );
diff --git a/abc-build/src/map/if/ifCount.h b/abc-build/src/map/if/ifCount.h
--- a/abc-build/src/map/if/ifCount.h
+++ b/abc-build/src/map/if/ifCount.h
@@ -85,7 +85,7 @@
         pFaninLits[i-1] = If_LogCreateAndXor( vAig, pFaninLits[i], pFaninLits[i-1], nSuppAll, fXor );
     return pFaninLits[0];
 }
-static inline int If_LogCounterAddAig( int * pTimes, int * pnTimes, int * pFaninLits, int Num, int iLit, Vec_Int_t * vAig, int nSuppAll, int fXor )
+static inline int If_LogCounterAddAig( int * pTimes, int * pnTimes, int * pFaninLits, int Num, int iLit, Vec_Int_t * vAig, int nSuppAll, int fXor, int fXorFunc )
 {
     int nTimes = *pnTimes;
     if ( vAig )
@@ -107,7 +107,7 @@
             }
             pTimes[k-1] += 1 + fXor;
             if ( vAig )
-                pFaninLits[k-1] = If_LogCreateAndXor( vAig, pFaninLits[k], pFaninLits[k-1], nSuppAll, fXor );
+                pFaninLits[k-1] = If_LogCreateAndXor( vAig, pFaninLits[k], pFaninLits[k-1], nSuppAll, fXorFunc );
             for ( nTimes--, i = k; i < nTimes; i++ )
             {
                 pTimes[i] = pTimes[i+1];
diff --git a/abc-build/src/map/if/ifCut.c b/abc-build/src/map/if/ifCut.c
--- a/abc-build/src/map/if/ifCut.c
+++ b/abc-build/src/map/if/ifCut.c
@@ -754,9 +754,8 @@
     if ( !pCut->fUseless && 
          (p->pPars->fUseDsd || p->pPars->fUseBat || 
           p->pPars->pLutStruct || p->pPars->fUserRecLib || 
-          p->pPars->fEnableCheck07 || p->pPars->fEnableCheck08 || 
-          p->pPars->fEnableCheck10 || p->pPars->fEnableCheck75 || 
-          p->pPars->fEnableCheck75u) )
+          p->pPars->fEnableCheck07 || p->pPars->fUseCofVars || p->pPars->fUseAndVars || 
+          p->pPars->fUseDsdTune || p->pPars->fEnableCheck75 || p->pPars->fEnableCheck75u) )
     {
         If_Cut_t * pFirst = pCutSet->ppCuts[0];
         if ( pFirst->fUseless || If_ManSortCompare(p, pFirst, pCut) == 1 )
diff --git a/abc-build/src/map/if/ifDelay.c b/abc-build/src/map/if/ifDelay.c
--- a/abc-build/src/map/if/ifDelay.c
+++ b/abc-build/src/map/if/ifDelay.c
@@ -204,9 +204,9 @@
         {
             Literal = 3 & (Entry >> (k << 1));
             if ( Literal == 1 ) // neg literal
-                nLits++, Delay = If_LogCounterAddAig( pCounterAnd, &nCounterAnd, pFaninLitsAnd, pTimes[k], Abc_LitNot(pFaninLits[k]), vAig, nSuppAll, 0 );
+                nLits++, Delay = If_LogCounterAddAig( pCounterAnd, &nCounterAnd, pFaninLitsAnd, pTimes[k], vAig ? Abc_LitNot(pFaninLits[k]) : -1, vAig, nSuppAll, 0, 0 );
             else if ( Literal == 2 ) // pos literal
-                nLits++, Delay = If_LogCounterAddAig( pCounterAnd, &nCounterAnd, pFaninLitsAnd, pTimes[k], pFaninLits[k], vAig, nSuppAll, 0 );
+                nLits++, Delay = If_LogCounterAddAig( pCounterAnd, &nCounterAnd, pFaninLitsAnd, pTimes[k], vAig ? pFaninLits[k] : -1, vAig, nSuppAll, 0, 0 );
             else if ( Literal != 0 ) 
                 assert( 0 );
         }
@@ -216,7 +216,7 @@
             iRes = If_LogCreateAndXorMulti( vAig, pFaninLitsAnd, nCounterAnd, nSuppAll, 0 );
         else
             *pArea += nLits == 1 ? 0 : nLits - 1;
-        Delay = If_LogCounterAddAig( pCounterOr, &nCounterOr, pFaninLitsOr, Delay, Abc_LitNot(iRes), vAig, nSuppAll, 0 );
+        Delay = If_LogCounterAddAig( pCounterOr, &nCounterOr, pFaninLitsOr, Delay, vAig ? Abc_LitNot(iRes) : -1, vAig, nSuppAll, 0, 0 );
     }
     assert( nCounterOr > 0 );
     if ( vAig )
diff --git a/abc-build/src/map/if/ifDsd.c b/abc-build/src/map/if/ifDsd.c
--- a/abc-build/src/map/if/ifDsd.c
+++ b/abc-build/src/map/if/ifDsd.c
@@ -25,6 +25,17 @@
 #include "sat/bsat/satSolver.h"
 #include "aig/gia/gia.h"
 #include "bool/kit/kit.h"
+
+#ifdef ABC_USE_PTHREADS
+
+#ifdef _WIN32
+#include "../lib/pthread.h"
+#else
+#include <pthread.h>
+#include <unistd.h>
+#endif
+
+#endif
 
 ABC_NAMESPACE_IMPL_START
 
@@ -75,9 +86,13 @@
     Vec_Ptr_t *    vTtDecs[IF_MAX_FUNC_LUTSIZE+1]; // truth table decompositions
     Vec_Wec_t *    vIsops[IF_MAX_FUNC_LUTSIZE+1];  // ISOP for each function
     int *          pSched[IF_MAX_FUNC_LUTSIZE];    // grey code schedules
+    Vec_Wrd_t *    vPerms;         // permutations
     Gia_Man_t *    pTtGia;         // GIA to represent truth tables
     Vec_Int_t *    vCover;         // temporary memory
     void *         pSat;           // SAT solver
+    char *         pCellStr;       // symbolic cell description
+    int            nObjsPrev;      // previous number of objects
+    int            fNewAsUseless;  // set new as useless
     int            nUniqueHits;    // statistics
     int            nUniqueMisses;  // statistics
     abctime        timeDsd;        // statistics
@@ -115,13 +130,15 @@
 
 #define If_DsdVecForEachObj( vVec, pObj, i )                \
     Vec_PtrForEachEntry( If_DsdObj_t *, vVec, pObj, i )
-#define If_DsdVecForEachObjVec( vNodes, vVec, pObj, i )      \
+#define If_DsdVecForEachObjStart( vVec, pObj, i, Start )    \
+    Vec_PtrForEachEntryStart( If_DsdObj_t *, vVec, pObj, i, Start )
+#define If_DsdVecForEachObjVec( vNodes, vVec, pObj, i )     \
     for ( i = 0; (i < Vec_IntSize(vNodes)) && ((pObj) = If_DsdVecObj(vVec, Vec_IntEntry(vNodes,i))); i++ )
 #define If_DsdVecForEachNode( vVec, pObj, i )               \
     Vec_PtrForEachEntryStart( If_DsdObj_t *, vVec, pObj, i, 2 )
 #define If_DsdObjForEachFanin( vVec, pObj, pFanin, i )      \
     for ( i = 0; (i < If_DsdObjFaninNum(pObj)) && ((pFanin) = If_DsdObjFanin(vVec, pObj, i)); i++ )
-#define If_DsdObjForEachFaninLit( vVec, pObj, iLit, i )      \
+#define If_DsdObjForEachFaninLit( vVec, pObj, iLit, i )     \
     for ( i = 0; (i < If_DsdObjFaninNum(pObj)) && ((iLit) = If_DsdObjFaninLit(pObj, i)); i++ )
 
 extern int Kit_TruthToGia( Gia_Man_t * pMan, unsigned * pTruth, int nVars, Vec_Int_t * vMemory, Vec_Int_t * vLeaves, int fHash );
@@ -149,10 +166,18 @@
 {
     return p->nVars;
 }
+int If_DsdManObjNum( If_DsdMan_t * p )
+{
+    return Vec_PtrSize( &p->vObjs );
+}
 int If_DsdManLutSize( If_DsdMan_t * p )
 {
     return p->LutSize;
 }
+void If_DsdManSetLutSize( If_DsdMan_t * p, int nLutSize )
+{
+    p->LutSize = nLutSize;
+}
 int If_DsdManSuppSize( If_DsdMan_t * p, int iDsd )
 {
     return If_DsdVecLitSuppSize( &p->vObjs, iDsd );
@@ -161,6 +186,24 @@
 {
     return If_DsdVecObjMark( &p->vObjs, Abc_Lit2Var(iDsd) );
 }
+int If_DsdManReadMark( If_DsdMan_t * p, int iDsd )
+{
+    return If_DsdVecObjMark( &p->vObjs, Abc_Lit2Var(iDsd) );
+}
+void If_DsdManSetNewAsUseless( If_DsdMan_t * p )
+{
+    if ( p->nObjsPrev == 0 )
+        p->nObjsPrev = If_DsdManObjNum(p);
+    p->fNewAsUseless = 1;
+}
+word If_DsdManGetFuncPerm( If_DsdMan_t * p, int iDsd )
+{
+    return p->vPerms ? Vec_WrdEntry(p->vPerms, Abc_Lit2Var(iDsd)) : 0;
+}
+char * If_DsdManGetCellStr( If_DsdMan_t * p )
+{
+    return p->pCellStr;
+}
 
 /**Function*************************************************************
 
@@ -193,7 +236,7 @@
     pObj->Type   = Type;
     pObj->nFans  = nFans;
     pObj->Id     = Vec_PtrSize( &p->vObjs );
-    pObj->fMark  = 0;
+    pObj->fMark  = p->fNewAsUseless;
     pObj->Count  = 0;
     Vec_PtrPush( &p->vObjs, pObj );
     Vec_IntPush( &p->vNexts, 0 );
@@ -206,6 +249,7 @@
 {
     If_DsdMan_t * p; int v;
     char pFileName[10];
+    assert( nVars <= DAU_MAX_VAR );
     sprintf( pFileName, "%02d.dsd", nVars );
     p = ABC_CALLOC( If_DsdMan_t, 1 );
     p->pStore  = Abc_UtilStrsav( pFileName );
@@ -294,6 +338,7 @@
         if ( p->vIsops[v] )
             Vec_WecFree( p->vIsops[v] );
     }
+    Vec_WrdFreeP( &p->vPerms );
     Vec_IntFreeP( &p->vTemp1 );
     Vec_IntFreeP( &p->vTemp2 );
     ABC_FREE( p->vObjs.pArray );
@@ -303,6 +348,7 @@
     Gia_ManStopP( &p->pTtGia );
     Vec_IntFreeP( &p->vCover );
     If_ManSatUnbuild( p->pSat );
+    ABC_FREE( p->pCellStr );
     ABC_FREE( p->pStore );
     ABC_FREE( p->pBins );
     ABC_FREE( p );
@@ -366,6 +412,15 @@
     }
     fclose( pFile );
 }
+int If_DsdManHasMarks( If_DsdMan_t * p )
+{
+    If_DsdObj_t * pObj;
+    int i;
+    If_DsdVecForEachObj( &p->vObjs, pObj, i )
+        if ( pObj->fMark )
+            return 1;
+    return 0;
+}
 
 /**Function*************************************************************
 
@@ -639,6 +694,24 @@
         printf( "cannot open output file\n" );
         return;
     }
+    if ( fVerbose )
+    {
+        fprintf( pFile, "*****  NOTATIONS USED BELOW  *****\n" );
+        fprintf( pFile, "Support -- the support size\n" );
+        fprintf( pFile, "Obj     -- the number of nodes in the DSD manager for each support size\n" );
+        fprintf( pFile, "           (the constant node and the primary input node have no support)\n" );
+        fprintf( pFile, "ObjNDSD -- the number of prime nodes (that is, nodes whose function has no DSD)\n" );
+        fprintf( pFile, "           (percentage is relative to the number of all nodes of that size)\n" );
+        fprintf( pFile, "NPNNDSD -- the number of different NPN classes of prime nodes\n" );
+        fprintf( pFile, "           (Each NPN class may appear more than once. For example: F1 = 17(ab(cd))\n" ); 
+        fprintf( pFile, "           and F2 = 17(ab[cd]) both have prime majority node (hex TT is 17),\n" ); 
+        fprintf( pFile, "           but in one case the majority node is fed by AND, and in another by XOR.\n" );
+        fprintf( pFile, "           These two majority nodes are different nodes in the DSD manager\n" );
+        fprintf( pFile, "Str     -- the number of structures for each support size\n" );
+        fprintf( pFile, "           (each structure is composed of one or more nodes)\n" );
+        fprintf( pFile, "StrNDSD -- the number of DSD structures containing at least one prime node\n" );
+        fprintf( pFile, "Marked  -- the number of DSD structures matchable with the LUT structure (say, \"44\")\n" );
+    }
     If_DsdVecForEachObj( &p->vObjs, pObj, i )
     {
         if ( If_DsdObjType(pObj) == IF_DSD_PRIME )
@@ -655,6 +728,10 @@
         MemSizeDecs += (int)Vec_VecMemoryInt((Vec_Vec_t *)(p->vTtDecs[v]));
     }
     If_DsdManPrintDistrib( p );
+    printf( "Number of inputs = %d.  LUT size = %d.  Marks = %s.  NewAsUseless = %s.  Bookmark = %d.\n", 
+        p->nVars, p->LutSize, If_DsdManHasMarks(p)? "yes" : "no", p->fNewAsUseless? "yes" : "no", p->nObjsPrev );
+    if ( p->pCellStr )
+        printf( "Symbolic cell description: %s\n", p->pCellStr );
     if ( p->pTtGia )
     fprintf( pFile, "Non-DSD AIG nodes          = %8d\n", Gia_ManAndNum(p->pTtGia) );
     fprintf( pFile, "Unique table misses        = %8d\n", p->nUniqueMisses );
@@ -996,6 +1073,14 @@
             fwrite( Vec_IntArray(vSets), sizeof(int)*Num, 1, pFile );
         }
     }
+    Num = p->vPerms ? Vec_WrdSize(p->vPerms) : 0;
+    fwrite( &Num, 4, 1, pFile );
+    if ( Num )
+        fwrite( Vec_WrdArray(p->vPerms), sizeof(word)*Num, 1, pFile );
+    Num = p->pCellStr ? strlen(p->pCellStr) : 0;
+    fwrite( &Num, 4, 1, pFile );
+    if ( Num )
+        fwrite( p->pCellStr, sizeof(char)*Num, 1, pFile );
     fclose( pFile );
 }
 If_DsdMan_t * If_DsdManLoad( char * pFileName )
@@ -1074,6 +1159,18 @@
         assert( Num2 == Vec_PtrSize(p->vTtDecs[v]) ); 
     }
     ABC_FREE( pTruth );
+    RetValue = fread( &Num, 4, 1, pFile );
+    if ( RetValue && Num )
+    {
+        p->vPerms = Vec_WrdStart( Num );
+        RetValue = fread( Vec_WrdArray(p->vPerms), sizeof(word)*Num, 1, pFile );
+    }
+    RetValue = fread( &Num, 4, 1, pFile );
+    if ( RetValue && Num )
+    {
+        p->pCellStr = ABC_CALLOC( char, Num + 1 );
+        RetValue = fread( p->pCellStr, sizeof(char)*Num, 1, pFile );
+    }
     fclose( pFile );
     return p;
 }
@@ -1093,26 +1190,91 @@
         printf( "LUT size should be the same.\n" );
         return;
     }
+    if ( If_DsdManHasMarks(p) != If_DsdManHasMarks(pNew) )
+        printf( "Warning! Old manager has %smarks while new manager has %smarks.\n", 
+            If_DsdManHasMarks(p) ? "" : "no ", If_DsdManHasMarks(pNew) ? "" : "no " );
     vMap = Vec_IntAlloc( Vec_PtrSize(&pNew->vObjs) );
     Vec_IntPush( vMap, 0 );
     Vec_IntPush( vMap, 1 );
+    if ( p->vPerms && pNew->vPerms )
+        Vec_WrdFillExtra( p->vPerms, Vec_PtrSize(&p->vObjs) + Vec_PtrSize(&pNew->vObjs), 0 );
     If_DsdVecForEachNode( &pNew->vObjs, pObj, i )
     {
         If_DsdObjForEachFaninLit( &pNew->vObjs, pObj, iFanin, k )
             pFanins[k] = Abc_Lit2LitV( Vec_IntArray(vMap), iFanin );
         Id = If_DsdObjFindOrAdd( p, pObj->Type, pFanins, pObj->nFans, pObj->Type == IF_DSD_PRIME ? If_DsdObjTruth(pNew, pObj) : NULL );
+        if ( pObj->fMark )
+            If_DsdVecObjSetMark( &p->vObjs, Id );
+        if ( p->vPerms && pNew->vPerms && i < Vec_WrdSize(pNew->vPerms) )
+            Vec_WrdFillExtra( p->vPerms, Id, Vec_WrdEntry(pNew->vPerms, i) );
         Vec_IntPush( vMap, Id );
     }
     assert( Vec_IntSize(vMap) == Vec_PtrSize(&pNew->vObjs) );
     Vec_IntFree( vMap );
+    if ( p->vPerms && pNew->vPerms )
+        Vec_WrdShrink( p->vPerms, Vec_PtrSize(&p->vObjs) );
 }
-void If_DsdManClean( If_DsdMan_t * p, int fVerbose )
+void If_DsdManCleanOccur( If_DsdMan_t * p, int fVerbose )
 {
     If_DsdObj_t * pObj; 
     int i;
     If_DsdVecForEachObj( &p->vObjs, pObj, i )
         pObj->Count = 0;
 }
+void If_DsdManCleanMarks( If_DsdMan_t * p, int fVerbose )
+{
+    If_DsdObj_t * pObj; 
+    int i;
+    ABC_FREE( p->pCellStr );
+    Vec_WrdFreeP( &p->vPerms );
+    If_DsdVecForEachObj( &p->vObjs, pObj, i )
+        pObj->fMark = 0;
+}
+void If_DsdManInvertMarks( If_DsdMan_t * p, int fVerbose )
+{
+    If_DsdObj_t * pObj; 
+    int i;
+    ABC_FREE( p->pCellStr );
+    Vec_WrdFreeP( &p->vPerms );
+    If_DsdVecForEachObj( &p->vObjs, pObj, i )
+        pObj->fMark = !pObj->fMark;
+}
+void If_DsdManFilter_rec( If_DsdMan_t * pNew, If_DsdMan_t * p, int i, Vec_Int_t * vMap )
+{
+    If_DsdObj_t * pObj;
+    int pFanins[DAU_MAX_VAR];
+    int k, iFanin, Id;
+    if ( Vec_IntEntry(vMap, i) >= 0 )
+        return;
+    // call recursively
+    pObj = If_DsdVecObj( &p->vObjs, i );
+    If_DsdObjForEachFaninLit( &p->vObjs, pObj, iFanin, k )
+        If_DsdManFilter_rec( pNew, p, Abc_Lit2Var(iFanin), vMap );
+    // duplicate this one
+    If_DsdObjForEachFaninLit( &p->vObjs, pObj, iFanin, k )
+        pFanins[k] = Abc_Lit2LitV( Vec_IntArray(vMap), iFanin );
+    Id = If_DsdObjFindOrAdd( pNew, pObj->Type, pFanins, pObj->nFans, pObj->Type == IF_DSD_PRIME ? If_DsdObjTruth(p, pObj) : NULL );
+    if ( pObj->fMark )
+        If_DsdVecObjSetMark( &pNew->vObjs, Id );
+    If_DsdVecObj( &pNew->vObjs, Id )->Count = pObj->Count;
+    // save the result
+    Vec_IntWriteEntry( vMap, i, Id );
+}
+If_DsdMan_t * If_DsdManFilter( If_DsdMan_t * p, int Limit )
+{
+    If_DsdMan_t * pNew = If_DsdManAlloc( p->nVars, p->LutSize );
+    If_DsdObj_t * pObj; 
+    Vec_Int_t * vMap;
+    int i;
+    vMap = Vec_IntStartFull( Vec_PtrSize(&p->vObjs) );
+    Vec_IntWriteEntry( vMap, 0, 0 );
+    Vec_IntWriteEntry( vMap, 1, 1 );
+    If_DsdVecForEachNode( &p->vObjs, pObj, i )
+        if ( (int)pObj->Count >= Limit )
+            If_DsdManFilter_rec( pNew, p, i, vMap );
+    Vec_IntFree( vMap );
+    return pNew;
+}
 
 /**Function*************************************************************
 
@@ -1213,10 +1375,9 @@
     assert( 0 );
 
 }
-word * If_DsdManComputeTruth( If_DsdMan_t * p, int iDsd, unsigned char * pPermLits )
+void If_DsdManComputeTruthPtr( If_DsdMan_t * p, int iDsd, unsigned char * pPermLits, word * pRes )
 {
     int nSupp = 0;
-    word * pRes = p->pTtElems[DAU_MAX_VAR];
     If_DsdObj_t * pObj = If_DsdVecObj( &p->vObjs, Abc_Lit2Var(iDsd) );
     if ( iDsd == 0 )
         Abc_TtConst0( pRes, p->nWords );
@@ -1231,6 +1392,11 @@
     else
         If_DsdManComputeTruth_rec( p, iDsd, pRes, pPermLits, &nSupp );
     assert( nSupp == If_DsdVecLitSuppSize(&p->vObjs, iDsd) );
+}
+word * If_DsdManComputeTruth( If_DsdMan_t * p, int iDsd, unsigned char * pPermLits )
+{
+    word * pRes = p->pTtElems[DAU_MAX_VAR];
+    If_DsdManComputeTruthPtr( p, iDsd, pPermLits, pRes );
     return pRes;
 }
 
@@ -1969,7 +2135,7 @@
     {
         word pFaninRes[IF_MAX_FUNC_LUTSIZE];
         int i, iFanin, Delay, Result = 0;
-        int fXor = (If_DsdObjType(pObj) == IF_DSD_XOR);
+        int fXor = 0;//(If_DsdObjType(pObj) == IF_DSD_XOR);
         int nCounter = 0, pCounter[IF_MAX_FUNC_LUTSIZE];
         If_DsdObjForEachFaninLit( &p->vObjs, pObj, iFanin, i )
         {
@@ -2045,7 +2211,7 @@
     if ( If_DsdObjType(pObj) == IF_DSD_VAR )
     {
         int iCutVar = Abc_Lit2Var( pPermLits[*pnSupp] );
-        if ( vAig )
+        if ( vAig ) 
             *piLit = Abc_Var2Lit( iCutVar, Abc_LitIsCompl(pPermLits[*pnSupp]) );
         (*pnSupp)++;
         return pTimes[iCutVar];
@@ -2058,7 +2224,8 @@
             Delays[i] = If_CutDsdBalanceEval_rec( p, Abc_Lit2Var(iFanin), pTimes, pnSupp, vAig, pFaninLits+i, nSuppAll, pArea, pPermLits );
             if ( Delays[i] == -1 )
                 return -1;
-            pFaninLits[i] = Abc_LitNotCond( pFaninLits[i], Abc_LitIsCompl(iFanin) );
+            if ( vAig ) 
+                pFaninLits[i] = Abc_LitNotCond( pFaninLits[i], Abc_LitIsCompl(iFanin) );
         }
         if ( vAig )
             *piLit = If_LogCreateMux( vAig, pFaninLits[0], pFaninLits[1], pFaninLits[2], nSuppAll );
@@ -2077,28 +2244,31 @@
             Delays[i] = If_CutDsdBalanceEval_rec( p, Abc_Lit2Var(iFanin), pTimes, pnSupp, vAig, pFaninLits+i, nSuppAll, pArea, pPermLits );
             if ( Delays[i] == -1 )
                 return -1;
-            pFaninLits[i] = Abc_LitNotCond( pFaninLits[i], Abc_LitIsCompl(iFanin) );
+            if ( vAig ) 
+                pFaninLits[i] = Abc_LitNotCond( pFaninLits[i], Abc_LitIsCompl(iFanin) );
         }
         return If_CutSopBalanceEvalInt( vCover, Delays, pFaninLits, vAig, piLit, nSuppAll, pArea );
     }
     assert( If_DsdObjType(pObj) == IF_DSD_AND || If_DsdObjType(pObj) == IF_DSD_XOR );
     {
         int i, iFanin, Delay, Result = 0;
-        int fXor = (If_DsdObjType(pObj) == IF_DSD_XOR);
+        int fXor = 0;//(If_DsdObjType(pObj) == IF_DSD_XOR);
+        int fXorFunc = (If_DsdObjType(pObj) == IF_DSD_XOR);
         int nCounter = 0, pCounter[IF_MAX_FUNC_LUTSIZE], pFaninLits[IF_MAX_FUNC_LUTSIZE];
         If_DsdObjForEachFaninLit( &p->vObjs, pObj, iFanin, i )
         {
             Delay = If_CutDsdBalanceEval_rec( p, Abc_Lit2Var(iFanin), pTimes, pnSupp, vAig, pFaninLits+i, nSuppAll, pArea, pPermLits );
             if ( Delay == -1 )
                 return -1;
-            pFaninLits[i] = Abc_LitNotCond( pFaninLits[i], Abc_LitIsCompl(iFanin) );
-            Result = If_LogCounterAddAig( pCounter, &nCounter, pFaninLits, Delay, pFaninLits[i], vAig, nSuppAll, fXor );
+            if ( vAig ) 
+                pFaninLits[i] = Abc_LitNotCond( pFaninLits[i], Abc_LitIsCompl(iFanin) );
+            Result = If_LogCounterAddAig( pCounter, &nCounter, pFaninLits, Delay, vAig ? pFaninLits[i] : -1, vAig, nSuppAll, fXor, fXorFunc );
         }
         assert( nCounter > 0 );
         if ( fXor )
             Result = If_LogCounterDelayXor( pCounter, nCounter ); // estimation
         if ( vAig )
-            *piLit = If_LogCreateAndXorMulti( vAig, pFaninLits, nCounter, nSuppAll, fXor );
+            *piLit = If_LogCreateAndXorMulti( vAig, pFaninLits, nCounter, nSuppAll, fXorFunc );
         else
             *pArea += (pObj->nFans - 1) * (1 + 2 * fXor);
         return Result;
@@ -2252,6 +2422,361 @@
         If_DsdManPrintDistrib( p );
 }
 
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Id_DsdManTuneStr1( If_DsdMan_t * p, char * pStruct, int nConfls, int fVerbose )
+{
+    int fVeryVerbose = 0;
+    ProgressBar * pProgress = NULL;
+    If_DsdObj_t * pObj;
+    word * pTruth, Perm;
+    int i, nVars, Value, LutSize;
+    abctime clk = Abc_Clock();
+    // parse the structure
+    Ifn_Ntk_t * pNtk = Ifn_NtkParse( pStruct );
+    if ( pNtk == NULL )
+        return;
+    if ( If_DsdManVarNum(p) > Ifn_NtkInputNum(pNtk) )
+    {
+        printf( "The support of DSD manager (%d) exceeds the support of the structure (%d).\n", If_DsdManVarNum(p), Ifn_NtkInputNum(pNtk) );
+        ABC_FREE( pNtk );
+        return;
+    }
+    ABC_FREE( p->pCellStr );
+    p->pCellStr = Abc_UtilStrsav( pStruct );
+    if ( If_DsdManVarNum(p) < Ifn_NtkInputNum(pNtk) )
+        printf( "Warning: The support of DSD manager (%d) is less than the support of the structure (%d).\n", If_DsdManVarNum(p), Ifn_NtkInputNum(pNtk) );
+    LutSize = Ifn_NtkLutSizeMax(pNtk);
+    // print
+    if ( fVerbose )
+    {
+        printf( "Considering programmable cell: " );
+        Ifn_NtkPrint( pNtk );
+        printf( "Largest LUT size = %d.\n", LutSize );
+    }
+    if ( p->nObjsPrev > 0 )
+        printf( "Starting the tuning process from object %d (out of %d).\n", p->nObjsPrev, Vec_PtrSize(&p->vObjs) );
+    // clean the attributes
+    If_DsdVecForEachObj( &p->vObjs, pObj, i )
+        if ( i >= p->nObjsPrev )
+            pObj->fMark = 0;
+    if ( p->vPerms == NULL )
+        p->vPerms = Vec_WrdStart( Vec_PtrSize(&p->vObjs) );
+    else
+        Vec_WrdFillExtra( p->vPerms, Vec_PtrSize(&p->vObjs), 0 );
+    pProgress = Extra_ProgressBarStart( stdout, Vec_PtrSize(&p->vObjs) );
+    If_DsdVecForEachObjStart( &p->vObjs, pObj, i, p->nObjsPrev )
+    {
+        if ( (i & 0xFF) == 0 )
+            Extra_ProgressBarUpdate( pProgress, i, NULL );
+        nVars = If_DsdObjSuppSize(pObj);
+        if ( nVars <= LutSize )
+            continue;
+        pTruth = If_DsdManComputeTruth( p, Abc_Var2Lit(i, 0), NULL );
+        if ( fVeryVerbose )
+            Dau_DsdPrintFromTruth( pTruth, nVars );
+        if ( fVerbose )
+            printf( "%6d : %2d ", i, nVars );
+        Value = Ifn_NtkMatch( pNtk, pTruth, nVars, nConfls, fVerbose, fVeryVerbose, &Perm );
+        if ( fVeryVerbose )
+            printf( "\n" );
+        if ( Value == 0 )
+            If_DsdVecObjSetMark( &p->vObjs, i );
+        else
+            Vec_WrdWriteEntry( p->vPerms, i, Perm );
+    }
+    p->nObjsPrev = 0;
+    p->LutSize = 0;
+    Extra_ProgressBarStop( pProgress );
+    printf( "Finished matching %d functions. ", Vec_PtrSize(&p->vObjs) );
+    Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
+    if ( fVeryVerbose )
+        If_DsdManPrintDistrib( p );
+    ABC_FREE( pNtk );
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+#ifndef ABC_USE_PTHREADS
+void Id_DsdManTuneStr( If_DsdMan_t * p, char * pStruct, int nConfls, int nProcs, int fVerbose )
+{
+    Id_DsdManTuneStr1( p, pStruct, nConfls, fVerbose );
+}
+#else // pthreads are used
+
+
+#define PAR_THR_MAX 100
+typedef struct Ifn_ThData_t_
+{
+    Ifn_Ntk_t * pNtk;    // network
+    word        pTruth[DAU_MAX_WORD];
+    int         nVars;   // support
+    int         Id;      // object
+    int         nConfls; // conflicts
+    int         Result;  // result
+    int         Status;  // state
+    word        Perm;    // permutation
+    abctime     clkUsed; // total runtime
+} Ifn_ThData_t;
+void * Ifn_WorkerThread( void * pArg )
+{
+    Ifn_ThData_t * pThData = (Ifn_ThData_t *)pArg;
+    volatile int * pPlace = &pThData->Status;
+    abctime clk;
+    while ( 1 )
+    {
+        while ( *pPlace == 0 );
+        assert( pThData->Status == 1 );
+        if ( pThData->Id == -1 )
+        {
+	        pthread_exit( NULL );
+            assert( 0 );
+            return NULL;
+        }
+        clk = Abc_Clock();
+        pThData->Result = Ifn_NtkMatch( pThData->pNtk, pThData->pTruth, pThData->nVars, pThData->nConfls, 0, 0, &pThData->Perm );
+        pThData->clkUsed += Abc_Clock() - clk;
+        pThData->Status = 0;
+//        printf( "Finished object %d\n", pThData->Id );
+    }
+	assert( 0 );
+	return NULL;
+}
+void Id_DsdManTuneStr( If_DsdMan_t * p, char * pStruct, int nConfls, int nProcs, int fVerbose )
+{
+    int fVeryVerbose = 0;
+    ProgressBar * pProgress = NULL;
+    int i, k, nVars, LutSize;
+    abctime clk = Abc_Clock();
+    Ifn_Ntk_t * pNtk;
+    If_DsdObj_t * pObj;
+    if ( nProcs == 1 )
+    {
+        Id_DsdManTuneStr1( p, pStruct, nConfls, fVerbose );
+        return;
+    }
+    if ( nProcs > PAR_THR_MAX )
+    {
+        printf( "The number of processes (%d) exceeds the precompiled limit (%d).\n", nProcs, PAR_THR_MAX );
+        return;
+    }
+    // parse the structure
+    pNtk = Ifn_NtkParse( pStruct );
+    if ( pNtk == NULL )
+        return;
+    if ( If_DsdManVarNum(p) > Ifn_NtkInputNum(pNtk) )
+    {
+        printf( "The support of DSD manager (%d) exceeds the support of the structure (%d).\n", If_DsdManVarNum(p), Ifn_NtkInputNum(pNtk) );
+        ABC_FREE( pNtk );
+        return;
+    }
+    ABC_FREE( p->pCellStr );
+    p->pCellStr = Abc_UtilStrsav( pStruct );
+    if ( If_DsdManVarNum(p) < Ifn_NtkInputNum(pNtk) )
+        printf( "Warning: The support of DSD manager (%d) is less than the support of the structure (%d).\n", If_DsdManVarNum(p), Ifn_NtkInputNum(pNtk) );
+    // check the largest LUT
+    LutSize = Ifn_NtkLutSizeMax(pNtk);
+    if ( fVerbose )
+    {
+        printf( "Considering programmable cell: " );
+        Ifn_NtkPrint( pNtk );
+        printf( "Largest LUT size = %d.\n", LutSize );
+    }
+    ABC_FREE( pNtk );
+    if ( p->nObjsPrev > 0 )
+        printf( "Starting the tuning process from object %d (out of %d).\n", p->nObjsPrev, Vec_PtrSize(&p->vObjs) );
+    // clean the attributes
+    If_DsdVecForEachObj( &p->vObjs, pObj, i )
+        if ( i >= p->nObjsPrev )
+            pObj->fMark = 0;
+    if ( p->vPerms == NULL )
+        p->vPerms = Vec_WrdStart( Vec_PtrSize(&p->vObjs) );
+    else
+        Vec_WrdFillExtra( p->vPerms, Vec_PtrSize(&p->vObjs), 0 );
+    pProgress = Extra_ProgressBarStart( stdout, Vec_PtrSize(&p->vObjs) );
+
+    // perform concurrent solving
+    {
+	    pthread_t WorkerThread[PAR_THR_MAX];
+        Ifn_ThData_t ThData[PAR_THR_MAX];
+        abctime clk, clkUsed = 0;
+        int status, fRunning = 1, iCurrentObj = p->nObjsPrev;
+        // start the threads
+        for ( i = 0; i < nProcs; i++ )
+        {
+            ThData[i].pNtk    = Ifn_NtkParse( pStruct );
+            ThData[i].nVars   = -1;      // support
+            ThData[i].Id      = -1;      // object
+            ThData[i].nConfls = nConfls; // conflicts
+            ThData[i].Result  = -1;      // result
+            ThData[i].Status  =  0;      // state
+            ThData[i].clkUsed =  0;      // total runtime
+            status = pthread_create( WorkerThread + i, NULL, Ifn_WorkerThread, (void *)(ThData + i) );  assert( status == 0 );
+        }
+        // run the threads
+        while ( fRunning || iCurrentObj < Vec_PtrSize(&p->vObjs) )
+        {
+            for ( i = 0; i < nProcs; i++ )
+            {
+                if ( ThData[i].Status )
+                    continue;
+                assert( ThData[i].Status == 0 );
+                if ( ThData[i].Id >= 0 )
+                {
+                    //printf( "Closing obj %d with Thread %d:\n", ThData[i].Id, i );
+                    assert( ThData[i].Result == 0 || ThData[i].Result == 1 );
+                    if ( ThData[i].Result == 0 )
+                        If_DsdVecObjSetMark( &p->vObjs, ThData[i].Id );
+                    else
+                        Vec_WrdWriteEntry( p->vPerms, ThData[i].Id, ThData[i].Perm );
+                    ThData[i].Id     = -1;
+                    ThData[i].Result = -1;
+                }
+                for ( k = iCurrentObj; k < Vec_PtrSize(&p->vObjs); k++ )
+                {
+                    if ( (k & 0xFF) == 0 )
+                        Extra_ProgressBarUpdate( pProgress, k, NULL );
+                    pObj  = If_DsdVecObj( &p->vObjs, k );
+                    nVars = If_DsdObjSuppSize(pObj);
+                    if ( nVars <= LutSize )
+                        continue;
+                    clk = Abc_Clock();
+                    If_DsdManComputeTruthPtr( p, Abc_Var2Lit(k, 0), NULL, ThData[i].pTruth );
+                    clkUsed += Abc_Clock() - clk;
+                    ThData[i].nVars  = nVars;
+                    ThData[i].Id     =  k;
+                    ThData[i].Result = -1;
+                    ThData[i].Status =  1;
+                    //printf( "Scheduling %d for Thread %d\n", ThData[i].Id, i );
+                    iCurrentObj = k+1;
+                    break;
+                }
+            }
+            fRunning = 0;
+            for ( i = 0; i < nProcs; i++ )
+                if ( ThData[i].Status == 1 || (ThData[i].Status == 0 && ThData[i].Id >= 0) )
+                    fRunning = 1;
+            //printf( "fRunning %d\n", fRunning );
+        }
+        // stop the threads
+        for ( i = 0; i < nProcs; i++ )
+        {
+            assert( ThData[i].Status == 0 );
+            ThData[i].Id = -1;
+            ThData[i].Status = 1;
+            ABC_FREE( ThData[i].pNtk );
+        }
+        if ( fVerbose )
+        {
+            printf( "Main     : " );
+            Abc_PrintTime( 1, "Time", clkUsed );
+            for ( i = 0; i < nProcs; i++ )
+            {
+                printf( "Thread %d : ", i );
+                Abc_PrintTime( 1, "Time", ThData[i].clkUsed );
+            }
+        }
+    }
+
+    p->nObjsPrev = 0;
+    p->LutSize = 0;
+    Extra_ProgressBarStop( pProgress );
+    printf( "Finished matching %d functions. ", Vec_PtrSize(&p->vObjs) );
+    Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
+    if ( fVeryVerbose )
+        If_DsdManPrintDistrib( p );
+}
+
+#endif // pthreads are used
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Id_DsdManTuneThresh( If_DsdMan_t * p, int fUnate, int fThresh, int fVerbose )
+{
+    extern int Extra_ThreshCheck( word * t, int nVars, int * pW );
+    int fVeryVerbose = 0;
+    int pW[16];
+    ProgressBar * pProgress = NULL;
+    If_DsdObj_t * pObj;
+    word * pTruth, Perm;
+    int i, nVars, Value;
+    abctime clk = Abc_Clock();
+    assert( fUnate != fThresh );
+    if ( p->nObjsPrev > 0 )
+        printf( "Starting the tuning process from object %d (out of %d).\n", p->nObjsPrev, Vec_PtrSize(&p->vObjs) );
+    // clean the attributes
+    If_DsdVecForEachObj( &p->vObjs, pObj, i )
+        if ( i >= p->nObjsPrev )
+            pObj->fMark = 0;
+    if ( p->vPerms == NULL )
+        p->vPerms = Vec_WrdStart( Vec_PtrSize(&p->vObjs) );
+    else
+        Vec_WrdFillExtra( p->vPerms, Vec_PtrSize(&p->vObjs), 0 );
+    pProgress = Extra_ProgressBarStart( stdout, Vec_PtrSize(&p->vObjs) );
+    If_DsdVecForEachObjStart( &p->vObjs, pObj, i, p->nObjsPrev )
+    {
+        if ( (i & 0xFF) == 0 )
+            Extra_ProgressBarUpdate( pProgress, i, NULL );
+        nVars = If_DsdObjSuppSize(pObj);
+        if ( nVars > 8 )
+            continue;
+        pTruth = If_DsdManComputeTruth( p, Abc_Var2Lit(i, 0), NULL );
+        if ( fVeryVerbose )
+            Dau_DsdPrintFromTruth( pTruth, nVars );
+        if ( fVerbose )
+            printf( "%6d : %2d ", i, nVars );
+        if ( fUnate )
+            Value = Abc_TtIsUnate( pTruth, nVars );
+        else if ( fThresh )
+            Value = Extra_ThreshCheck( pTruth, nVars, pW );
+        else 
+            Value = 0;
+        Perm = 0;
+        if ( fVeryVerbose )
+            printf( "\n" );
+        if ( Value )
+            If_DsdVecObjSetMark( &p->vObjs, i );
+        else
+            Vec_WrdWriteEntry( p->vPerms, i, Perm );
+    }
+    p->nObjsPrev = 0;
+    p->LutSize = 0;
+    Extra_ProgressBarStop( pProgress );
+    printf( "Finished matching %d functions. ", Vec_PtrSize(&p->vObjs) );
+    Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
+    if ( fVeryVerbose )
+        If_DsdManPrintDistrib( p );
+}
 
 ////////////////////////////////////////////////////////////////////////
 ///                       END OF FILE                                ///
diff --git a/abc-build/src/map/if/ifLibBox.c b/abc-build/src/map/if/ifLibBox.c
--- a/abc-build/src/map/if/ifLibBox.c
+++ b/abc-build/src/map/if/ifLibBox.c
@@ -250,7 +250,7 @@
 char * If_LibBoxGetToken( FILE * pFile )
 {
     static char pBuffer[1000];
-    char c, * pTemp = pBuffer;
+    int c; char * pTemp = pBuffer;
     while ( (c = fgetc(pFile)) != EOF )
     {
         if ( c == '#' )
diff --git a/abc-build/src/map/if/ifMan.c b/abc-build/src/map/if/ifMan.c
--- a/abc-build/src/map/if/ifMan.c
+++ b/abc-build/src/map/if/ifMan.c
@@ -124,7 +124,29 @@
         Vec_StrFill( p->vPairPerms, p->pPars->nLutSize, 0 );
         p->vPairRes = Vec_IntAlloc( 1000 );
         Vec_IntPush( p->vPairRes, -1 );
+    }
+    if ( pPars->fUseCofVars )
+    {
+        for ( v = 6; v <= Abc_MaxInt(6,p->pPars->nLutSize); v++ )
+        {
+            p->vTtVars[v] = Vec_StrAlloc( 1000 );
+            Vec_StrPush( p->vTtVars[v], 0 );
+            Vec_StrPush( p->vTtVars[v], 0 );
+        }
+        for ( v = 0; v < 6; v++ )
+            p->vTtVars[v]  = p->vTtVars[6];
     }
+    if ( pPars->fUseAndVars )
+    {
+        for ( v = 6; v <= Abc_MaxInt(6,p->pPars->nLutSize); v++ )
+        {
+            p->vTtDecs[v] = Vec_IntAlloc( 1000 );
+            Vec_IntPush( p->vTtDecs[v], 0 );
+            Vec_IntPush( p->vTtDecs[v], 0 );
+        }
+        for ( v = 0; v < 6; v++ )
+            p->vTtDecs[v]  = p->vTtDecs[6];
+    }
     if ( pPars->fUseBat )
     {
 //        abctime clk = Abc_Clock();
@@ -209,8 +231,8 @@
     {
         for ( i = 0; i <= 16; i++ )
             if ( p->nCutsUseless[i] )
-                Abc_Print( 1, "Useless cuts %2d  = %9d  (out of %9d)  (%6.2f %%)\n", i, p->nCutsUseless[i], p->nCutsCount[i], 100.0*p->nCutsUseless[i]/(p->nCutsCount[i]+1) );
-        Abc_Print( 1, "Useless cuts all = %9d  (out of %9d)  (%6.2f %%)\n", p->nCutsUselessAll, p->nCutsCountAll, 100.0*p->nCutsUselessAll/(p->nCutsCountAll+1) );
+                Abc_Print( 1, "Useless cuts %2d  = %9d  (out of %9d)  (%6.2f %%)\n", i, p->nCutsUseless[i], p->nCutsCount[i], 100.0*p->nCutsUseless[i]/Abc_MaxInt(p->nCutsCount[i],1) );
+        Abc_Print( 1, "Useless cuts all = %9d  (out of %9d)  (%6.2f %%)\n", p->nCutsUselessAll, p->nCutsCountAll, 100.0*p->nCutsUselessAll/Abc_MaxInt(p->nCutsCountAll,1) );
     }
 //    if ( p->pPars->fVerbose && p->nCuts5 )
 //        Abc_Print( 1, "Statistics about 5-cuts: Total = %d  Non-decomposable = %d (%.2f %%)\n", p->nCuts5, p->nCuts5-p->nCuts5a, 100.0*(p->nCuts5-p->nCuts5a)/p->nCuts5 );
@@ -235,6 +257,10 @@
         Vec_IntFreeP( &p->vTtDsds[i] );
     for ( i = 6; i <= Abc_MaxInt(6,p->pPars->nLutSize); i++ )
         Vec_StrFreeP( &p->vTtPerms[i] );
+    for ( i = 6; i <= Abc_MaxInt(6,p->pPars->nLutSize); i++ )
+        Vec_StrFreeP( &p->vTtVars[i] );
+    for ( i = 6; i <= Abc_MaxInt(6,p->pPars->nLutSize); i++ )
+        Vec_IntFreeP( &p->vTtDecs[i] );
     Vec_IntFreeP( &p->vCutData );
     Vec_IntFreeP( &p->vPairRes );
     Vec_StrFreeP( &p->vPairPerms );
diff --git a/abc-build/src/map/if/ifMap.c b/abc-build/src/map/if/ifMap.c
--- a/abc-build/src/map/if/ifMap.c
+++ b/abc-build/src/map/if/ifMap.c
@@ -99,7 +99,7 @@
     If_Cut_t * pCut0R, * pCut1R;
     int fFunc0R, fFunc1R;
     int i, k, v, iCutDsd, fChange;
-    int fSave0 = p->pPars->fDelayOpt || p->pPars->fDelayOptLut || p->pPars->fDsdBalance || p->pPars->fUserRecLib || p->pPars->pLutStruct != NULL;
+    int fSave0 = p->pPars->fDelayOpt || p->pPars->fDelayOptLut || p->pPars->fDsdBalance || p->pPars->fUserRecLib || p->pPars->fUseDsdTune || p->pPars->fUseCofVars || p->pPars->fUseAndVars || p->pPars->pLutStruct != NULL;
     assert( !If_ObjIsAnd(pObj->pFanin0) || pObj->pFanin0->pCutSet->nCuts > 0 );
     assert( !If_ObjIsAnd(pObj->pFanin1) || pObj->pFanin1->pCutSet->nCuts > 0 );
 
@@ -261,6 +261,57 @@
                     if ( If_CluCheckDecInAny( Truth, 5 ) || If_CluCheckDecOut( Truth, 5 ) )
                         p->nCuts5a++;
                 }
+            }
+            else if ( p->pPars->fUseDsdTune )
+            {
+                pCut->fUseless = If_DsdManReadMark( p->pIfDsdMan, If_CutDsdLit(p, pCut) );
+                p->nCutsUselessAll += pCut->fUseless;
+                p->nCutsUseless[pCut->nLeaves] += pCut->fUseless;
+                p->nCutsCountAll++;
+                p->nCutsCount[pCut->nLeaves]++;
+            }
+            else 
+            {
+                if ( p->pPars->fUseAndVars )
+                {
+                    int iDecMask = -1, truthId = Abc_Lit2Var(pCut->iCutFunc);
+                    assert( p->pPars->nLutSize <= 13 );
+                    if ( truthId >= Vec_IntSize(p->vTtDecs[pCut->nLeaves]) || Vec_IntEntry(p->vTtDecs[pCut->nLeaves], truthId) == -1 )
+                    {
+                        while ( truthId >= Vec_IntSize(p->vTtDecs[pCut->nLeaves]) )
+                            Vec_IntPush( p->vTtDecs[pCut->nLeaves], -1 );
+                        if ( (int)pCut->nLeaves > p->pPars->nLutSize / 2 && (int)pCut->nLeaves <= 2 * (p->pPars->nLutSize / 2) )
+                            iDecMask = Abc_TtProcessBiDec( If_CutTruthWR(p, pCut), (int)pCut->nLeaves, p->pPars->nLutSize / 2 );
+                        else
+                            iDecMask = 0;
+                        Vec_IntWriteEntry( p->vTtDecs[pCut->nLeaves], truthId, iDecMask );
+                    }
+                    iDecMask = Vec_IntEntry(p->vTtDecs[pCut->nLeaves], truthId);
+                    assert( iDecMask >= 0 );
+                    pCut->fUseless = (int)(iDecMask == 0 && (int)pCut->nLeaves > p->pPars->nLutSize / 2);
+                    p->nCutsUselessAll += pCut->fUseless;
+                    p->nCutsUseless[pCut->nLeaves] += pCut->fUseless;
+                    p->nCutsCountAll++;
+                    p->nCutsCount[pCut->nLeaves]++;
+                }
+                if ( p->pPars->fUseCofVars && (!p->pPars->fUseAndVars || pCut->fUseless) )
+                {
+                    int iCofVar = -1, truthId = Abc_Lit2Var(pCut->iCutFunc);
+                    if ( truthId >= Vec_StrSize(p->vTtVars[pCut->nLeaves]) || Vec_StrEntry(p->vTtVars[pCut->nLeaves], truthId) == (char)-1 )
+                    {
+                        while ( truthId >= Vec_StrSize(p->vTtVars[pCut->nLeaves]) )
+                            Vec_StrPush( p->vTtVars[pCut->nLeaves], (char)-1 );
+                        iCofVar = Abc_TtCheckCondDep( If_CutTruthWR(p, pCut), pCut->nLeaves, p->pPars->nLutSize / 2 );
+                        Vec_StrWriteEntry( p->vTtVars[pCut->nLeaves], truthId, (char)iCofVar );
+                    }
+                    iCofVar = Vec_StrEntry(p->vTtVars[pCut->nLeaves], truthId);
+                    assert( iCofVar >= 0 && iCofVar <= (int)pCut->nLeaves );
+                    pCut->fUseless = (int)(iCofVar == (int)pCut->nLeaves && pCut->nLeaves > 0);
+                    p->nCutsUselessAll += pCut->fUseless;
+                    p->nCutsUseless[pCut->nLeaves] += pCut->fUseless;
+                    p->nCutsCountAll++;
+                    p->nCutsCount[pCut->nLeaves]++;
+                }
             }
         }
         
diff --git a/abc-build/src/map/if/ifTest.c b/abc-build/src/map/if/ifTest.c
--- a/abc-build/src/map/if/ifTest.c
+++ b/abc-build/src/map/if/ifTest.c
@@ -38,6 +38,12 @@
 ///                        DECLARATIONS                              ///
 ////////////////////////////////////////////////////////////////////////
 
+#ifndef ABC_USE_PTHREADS
+
+// do nothing
+
+#else // pthreads are used
+
 static inline word * Gia_ParTestObj( Gia_Man_t * p, int Id )         { return (word *)p->pData + Id * p->iData; }
 static inline void   Gia_ParTestAlloc( Gia_Man_t * p, int nWords )   { assert( !p->pData ); p->pData = (unsigned *)ABC_ALLOC(word, Gia_ManObjNum(p) * nWords); p->iData = nWords; }
 static inline void   Gia_ParTestFree( Gia_Man_t * p )                { ABC_FREE( p->pData ); p->iData = 0; }
@@ -340,6 +346,8 @@
 ////////////////////////////////////////////////////////////////////////
 ///                       END OF FILE                                ///
 ////////////////////////////////////////////////////////////////////////
+
+#endif // pthreads are used
 
 
 ABC_NAMESPACE_IMPL_END
diff --git a/abc-build/src/map/if/ifTruth.c b/abc-build/src/map/if/ifTruth.c
--- a/abc-build/src/map/if/ifTruth.c
+++ b/abc-build/src/map/if/ifTruth.c
@@ -97,21 +97,20 @@
 ***********************************************************************/
 int If_CutComputeTruth( If_Man_t * p, If_Cut_t * pCut, If_Cut_t * pCut0, If_Cut_t * pCut1, int fCompl0, int fCompl1 )
 {
-    int fCompl, truthId, nLeavesNew, RetValue = 0;
-    int PrevSize, nWords = Abc_TtWordNum( pCut->nLeaves );
+    int fCompl, truthId, nLeavesNew, PrevSize, RetValue = 0;
     word * pTruth0s = Vec_MemReadEntry( p->vTtMem[pCut0->nLeaves], Abc_Lit2Var(pCut0->iCutFunc) );
     word * pTruth1s = Vec_MemReadEntry( p->vTtMem[pCut1->nLeaves], Abc_Lit2Var(pCut1->iCutFunc) );
     word * pTruth0  = (word *)p->puTemp[0];
     word * pTruth1  = (word *)p->puTemp[1];
     word * pTruth   = (word *)p->puTemp[2];
-    Abc_TtCopy( pTruth0, pTruth0s, nWords, fCompl0 ^ pCut0->fCompl ^ Abc_LitIsCompl(pCut0->iCutFunc) );
-    Abc_TtCopy( pTruth1, pTruth1s, nWords, fCompl1 ^ pCut1->fCompl ^ Abc_LitIsCompl(pCut1->iCutFunc) );
+    Abc_TtCopy( pTruth0, pTruth0s, p->nTruth6Words[pCut0->nLeaves], fCompl0 ^ pCut0->fCompl ^ Abc_LitIsCompl(pCut0->iCutFunc) );
+    Abc_TtCopy( pTruth1, pTruth1s, p->nTruth6Words[pCut1->nLeaves], fCompl1 ^ pCut1->fCompl ^ Abc_LitIsCompl(pCut1->iCutFunc) );
     Abc_TtStretch6( pTruth0, pCut0->nLeaves, pCut->nLeaves );
     Abc_TtStretch6( pTruth1, pCut1->nLeaves, pCut->nLeaves );
     Abc_TtExpand( pTruth0, pCut->nLeaves, pCut0->pLeaves, pCut0->nLeaves, pCut->pLeaves, pCut->nLeaves );
     Abc_TtExpand( pTruth1, pCut->nLeaves, pCut1->pLeaves, pCut1->nLeaves, pCut->pLeaves, pCut->nLeaves );
     fCompl         = (pTruth0[0] & pTruth1[0] & 1);
-    Abc_TtAnd( pTruth, pTruth0, pTruth1, nWords, fCompl );
+    Abc_TtAnd( pTruth, pTruth0, pTruth1, p->nTruth6Words[pCut->nLeaves], fCompl );
     if ( p->pPars->fCutMin && (pCut0->nLeaves + pCut1->nLeaves > pCut->nLeaves || pCut0->nLeaves == 0 || pCut1->nLeaves == 0) )
     {
         nLeavesNew = Abc_TtMinBase( pTruth, pCut->pLeaves, pCut->nLeaves, pCut->nLeaves );
@@ -130,7 +129,7 @@
     {
         word pCopy[1024];
         char pCanonPerm[16];
-        memcpy( pCopy, If_CutTruthW(pCut), sizeof(word) * nWords );
+        memcpy( pCopy, If_CutTruthW(pCut), sizeof(word) * p->nTruth6Words[pCut->nLeaves] );
         Abc_TtCanonicize( pCopy, pCut->nLeaves, pCanonPerm );
     }
 #endif
@@ -167,7 +166,6 @@
     abctime clk = 0;
     int pPerm[IF_MAX_LUTSIZE];
     int v, Place, fCompl, truthId, nLeavesNew, RetValue = 0;
-    int nWords      = Abc_TtWordNum( pCut->nLeaves );
     word * pTruth0s = Vec_MemReadEntry( p->vTtMem[pCut0->nLeaves], Abc_Lit2Var(iCutFunc0) );
     word * pTruth1s = Vec_MemReadEntry( p->vTtMem[pCut1->nLeaves], Abc_Lit2Var(iCutFunc1) );
     word * pTruth0  = (word *)p->puTemp[0];
@@ -175,8 +173,8 @@
     word * pTruth   = (word *)p->puTemp[2];
     assert( pCut0->uMaskFunc >= 0 );
     assert( pCut1->uMaskFunc >= 0 );
-    Abc_TtCopy( pTruth0, pTruth0s, nWords, Abc_LitIsCompl(iCutFunc0) );
-    Abc_TtCopy( pTruth1, pTruth1s, nWords, Abc_LitIsCompl(iCutFunc1) );
+    Abc_TtCopy( pTruth0, pTruth0s, p->nTruth6Words[pCut0->nLeaves], Abc_LitIsCompl(iCutFunc0) );
+    Abc_TtCopy( pTruth1, pTruth1s, p->nTruth6Words[pCut1->nLeaves], Abc_LitIsCompl(iCutFunc1) );
     Abc_TtStretch6( pTruth0, pCut0->nLeaves, pCut->nLeaves );
     Abc_TtStretch6( pTruth1, pCut1->nLeaves, pCut->nLeaves );
 
@@ -192,7 +190,7 @@
         if ( p->pPerm[1][v] >= (int)pCut0->nLeaves )
             pCut->pLeaves[p->pPerm[1][v]] = Abc_Var2Lit( pCut1->pLeaves[v], If_CutLeafBit(pCut1, v) );
         else if ( If_CutLeafBit(pCut0, p->pPerm[1][v]) != If_CutLeafBit(pCut1, v) )
-            Abc_TtFlip( pTruth1, nWords, v );  
+            Abc_TtFlip( pTruth1, p->nTruth6Words[pCut1->nLeaves], v );  
     // permute variables
     for ( v = (int)pCut1->nLeaves; v < (int)pCut->nLeaves; v++ )
         p->pPerm[1][v] = -1;
@@ -214,7 +212,7 @@
 }
 
     // perform operation
-    Abc_TtAnd( pTruth, pTruth0, pTruth1, nWords, 0 );
+    Abc_TtAnd( pTruth, pTruth0, pTruth1, p->nTruth6Words[pCut->nLeaves], 0 );
     // minimize support
     if ( p->pPars->fCutMin && (pCut0->nLeaves + pCut1->nLeaves > pCut->nLeaves || pCut0->nLeaves == 0 || pCut1->nLeaves == 0) )
     {
diff --git a/abc-build/src/map/if/ifTune.c b/abc-build/src/map/if/ifTune.c
--- a/abc-build/src/map/if/ifTune.c
+++ b/abc-build/src/map/if/ifTune.c
@@ -37,14 +37,14 @@
 
 // network types
 typedef enum { 
-    IF_DSD_NONE = 0,               // 0:  unknown
-    IF_DSD_CONST0,                 // 1:  constant
-    IF_DSD_VAR,                    // 2:  variable
-    IF_DSD_AND,                    // 3:  AND
-    IF_DSD_XOR,                    // 4:  XOR
-    IF_DSD_MUX,                    // 5:  MUX
-    IF_DSD_PRIME                   // 6:  PRIME
-} If_DsdType_t;
+    IFN_DSD_NONE = 0,              // 0:  unknown
+    IFN_DSD_CONST0,                // 1:  constant
+    IFN_DSD_VAR,                   // 2:  variable
+    IFN_DSD_AND,                   // 3:  AND
+    IFN_DSD_XOR,                   // 4:  XOR
+    IFN_DSD_MUX,                   // 5:  MUX
+    IFN_DSD_PRIME                  // 6:  PRIME
+} Ifn_DsdType_t;
 
 // object types
 static char * Ifn_Symbs[16] = { 
@@ -57,10 +57,8 @@
     "{}"                           // 6:  PRIME
 };
 
-typedef struct Ift_Obj_t_  Ift_Obj_t;
-typedef struct Ift_Ntk_t_  Ift_Ntk_t;
-
-struct Ift_Obj_t_
+typedef struct Ifn_Obj_t_  Ifn_Obj_t;
+struct Ifn_Obj_t_
 {
     unsigned               Type    :  3;      // node type
     unsigned               nFanins :  5;      // fanin counter
@@ -68,12 +66,12 @@
     unsigned               Var     : 16;      // current variable
     int                    Fanins[IFN_INS];   // fanin IDs
 };
-struct Ift_Ntk_t_ 
+struct Ifn_Ntk_t_ 
 {
     // cell structure
     int                    nInps;             // inputs
     int                    nObjs;             // objects
-    Ift_Obj_t              Nodes[2*IFN_INS];  // nodes
+    Ifn_Obj_t              Nodes[2*IFN_INS];  // nodes
     // constraints
     int                    pConstr[IFN_INS];  // constraint pairs
     int                    nConstr;           // number of pairs
@@ -90,8 +88,8 @@
     word                   pTtObjs[2*IFN_INS*IFN_WRD]; // object truth tables
 };
 
-static inline word *       Ift_ElemTruth( Ift_Ntk_t * p, int i ) { return p->pTtElems + i * Abc_TtWordNum(p->nInps); }
-static inline word *       Ift_ObjTruth( Ift_Ntk_t * p, int i )  { return p->pTtObjs + i * p->nWords;                }
+static inline word *       Ifn_ElemTruth( Ifn_Ntk_t * p, int i ) { return p->pTtElems + i * Abc_TtWordNum(p->nInps); }
+static inline word *       Ifn_ObjTruth( Ifn_Ntk_t * p, int i )  { return p->pTtObjs + i * p->nWords;                }
  
 // variable ordering
 // - primary inputs            [0;            p->nInps)
@@ -114,7 +112,7 @@
   SeeAlso     []
 
 ***********************************************************************/
-int Ifn_Prepare( Ift_Ntk_t * p, word * pTruth, int nVars )
+int Ifn_Prepare( Ifn_Ntk_t * p, word * pTruth, int nVars )
 {
     int i, fVerbose = 0;
     assert( nVars <= p->nInps );
@@ -124,7 +122,7 @@
     p->nPars  = p->nObjs;
     for ( i = p->nInps; i < p->nObjs; i++ )
     {
-        if ( p->Nodes[i].Type != IF_DSD_PRIME )
+        if ( p->Nodes[i].Type != IFN_DSD_PRIME )
             continue;
         p->Nodes[i].iFirst = p->nPars;
         p->nPars += (1 << p->Nodes[i].nFanins);
@@ -140,7 +138,7 @@
     memset( p->Values, 0xFF, sizeof(int) * p->nPars );
     return p->nPars;
 }
-void Ifn_NtkPrint( Ift_Ntk_t * p )
+void Ifn_NtkPrint( Ifn_Ntk_t * p )
 {
     int i, k; 
     if ( p == NULL )
@@ -158,6 +156,18 @@
     }
     printf( "\n" );
 }
+int Ifn_NtkLutSizeMax( Ifn_Ntk_t * p )
+{
+    int i, LutSize = 0;
+    for ( i = p->nInps; i < p->nObjs; i++ )
+        if ( p->Nodes[i].Type == IFN_DSD_PRIME )
+            LutSize = Abc_MaxInt( LutSize, (int)p->Nodes[i].nFanins );
+    return LutSize;
+}
+int Ifn_NtkInputNum( Ifn_Ntk_t * p )
+{
+    return p->nInps;
+}
 
 /**Function*************************************************************
 
@@ -170,28 +180,168 @@
   SeeAlso     []
 
 ***********************************************************************/
+int Ifn_ErrorMessage( const char * format, ...  )
+{
+    char * pMessage;
+    va_list args;
+    va_start( args, format );
+    pMessage = vnsprintf( format, args );
+    va_end( args );
+    printf( "%s", pMessage );
+    ABC_FREE( pMessage );
+    return 0;
+}
+int Inf_ManOpenSymb( char * pStr )
+{
+    if ( pStr[0] == '(' )
+        return 3;
+    if ( pStr[0] == '[' )
+        return 4;
+    if ( pStr[0] == '<' )
+        return 5;
+    if ( pStr[0] == '{' )
+        return 6;
+    return 0;
+}
 int Ifn_ManStrCheck( char * pStr, int * pnInps, int * pnObjs )
 {
-    int i, Marks[32] = {0}, MaxVar = 0, MaxDef = 0, RetValue = 1;
+    int i, nNodes = 0, Marks[32] = {0}, MaxVar = -1;
     for ( i = 0; pStr[i]; i++ )
     {
+        if ( Inf_ManOpenSymb(pStr+i) )
+            nNodes++;
+        if ( pStr[i] == ';' || 
+             pStr[i] == '(' || pStr[i] == ')' || 
+             pStr[i] == '[' || pStr[i] == ']' || 
+             pStr[i] == '<' || pStr[i] == '>' || 
+             pStr[i] == '{' || pStr[i] == '}' )
+            continue;
+        if ( pStr[i] >= 'A' && pStr[i] <= 'Z' )
+            continue;
+        if ( pStr[i] >= 'a' && pStr[i] <= 'z' )
+        {
+            MaxVar = Abc_MaxInt( MaxVar, (int)(pStr[i] - 'a') );
+            Marks[pStr[i] - 'a'] = 1;
+            continue;
+        }
+        return Ifn_ErrorMessage( "String \"%s\" contains unrecognized symbol \'%c\'.\n", pStr, pStr[i] );
+    }
+    for ( i = 0; i <= MaxVar; i++ )
+        if ( Marks[i] == 0 )
+            return Ifn_ErrorMessage( "String \"%s\" has no symbol \'%c\'.\n", pStr, 'a' + i );
+    *pnInps = MaxVar + 1;
+    *pnObjs = MaxVar + 1 + nNodes;
+    return 1;
+}
+static inline char * Ifn_NtkParseFindClosingParenthesis( char * pStr, char Open, char Close )
+{
+    int Counter = 0;
+    assert( *pStr == Open );
+    for ( ; *pStr; pStr++ )
+    {
+        if ( *pStr == Open )
+            Counter++;
+        if ( *pStr == Close )
+            Counter--;
+        if ( Counter == 0 )
+            return pStr;
+    }
+    return NULL;
+}
+int Ifn_NtkParseInt_rec( char * pStr, Ifn_Ntk_t * p, char ** ppFinal, int * piNode )
+{
+    Ifn_Obj_t * pObj;
+    int nFanins = 0, pFanins[IFN_INS];
+    int Type = Inf_ManOpenSymb( pStr );
+    char * pLim = Ifn_NtkParseFindClosingParenthesis( pStr++, Ifn_Symbs[Type][0], Ifn_Symbs[Type][1] );
+    *ppFinal = NULL;
+    if ( pLim == NULL )
+        return Ifn_ErrorMessage( "For symbol \'%c\' cannot find matching symbol \'%c\'.\n", Ifn_Symbs[Type][0], Ifn_Symbs[Type][1] );
+    while ( pStr < pLim )
+    {
+        assert( nFanins < IFN_INS );
+        if ( pStr[0] >= 'a' && pStr[0] <= 'z' )
+            pFanins[nFanins++] = pStr[0] - 'a', pStr++; 
+        else if ( Inf_ManOpenSymb(pStr) )
+        {
+            if ( !Ifn_NtkParseInt_rec( pStr, p, &pStr, piNode ) )
+                return 0;
+            pFanins[nFanins++] = *piNode - 1;
+        }
+        else
+            return Ifn_ErrorMessage( "Substring \"%s\" contans unrecognized symbol \'%c\'.\n", pStr, pStr[0] );
+    }
+    assert( pStr == pLim );
+    pObj = p->Nodes + (*piNode)++;
+    pObj->Type = Type;
+    assert( pObj->nFanins == 0 );
+    pObj->nFanins = nFanins;
+    memcpy( pObj->Fanins, pFanins, sizeof(int) * nFanins );
+    *ppFinal = pLim + 1;
+    if ( Type == IFN_DSD_MUX && nFanins != 3 )
+        return Ifn_ErrorMessage( "MUX should have exactly three fanins.\n" );
+    return 1;
+}
+int Ifn_NtkParseInt( char * pStr, Ifn_Ntk_t * p )
+{
+    char * pFinal; int iNode;
+    if ( !Ifn_ManStrCheck(pStr, &p->nInps, &p->nObjs) )
+        return 0;
+    if ( p->nInps > IFN_INS )
+        return Ifn_ErrorMessage( "The number of variables (%d) exceeds predefined limit (%d). Recompile with different value of IFN_INS.\n", p->nInps, IFN_INS );
+    assert( p->nInps > 1 && p->nInps < p->nObjs && p->nInps <= IFN_INS && p->nObjs < 2*IFN_INS );
+    if ( !Inf_ManOpenSymb(pStr) )
+        return Ifn_ErrorMessage( "The first symbol should be one of the symbols: (, [, <, {.\n" );
+    iNode = p->nInps;
+    if ( !Ifn_NtkParseInt_rec( pStr, p, &pFinal, &iNode ) )
+        return 0;
+    if ( pFinal[0] && pFinal[0] != ';' )
+        return Ifn_ErrorMessage( "The last symbol should be \';\'.\n" );
+    if ( iNode != p->nObjs )
+        return Ifn_ErrorMessage( "Mismatch in the number of nodes.\n" );
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Ifn_ManStrType2( char * pStr )
+{
+    int i;
+    for ( i = 0; pStr[i]; i++ )
+        if ( pStr[i] == '=' )
+            return 1;
+    return 0;
+}
+int Ifn_ManStrCheck2( char * pStr, int * pnInps, int * pnObjs )
+{
+    int i, Marks[32] = {0}, MaxVar = 0, MaxDef = 0;
+    for ( i = 0; pStr[i]; i++ )
+    {
         if ( pStr[i] == '=' || pStr[i] == ';' || 
              pStr[i] == '(' || pStr[i] == ')' || 
              pStr[i] == '[' || pStr[i] == ']' || 
              pStr[i] == '<' || pStr[i] == '>' || 
              pStr[i] == '{' || pStr[i] == '}' )
             continue;
+        if ( pStr[i] >= 'A' && pStr[i] <= 'Z' )
+            continue;
         if ( pStr[i] >= 'a' && pStr[i] <= 'z' )
         {
             if ( pStr[i+1] == '=' )
                 Marks[pStr[i] - 'a'] = 2, MaxDef = Abc_MaxInt(MaxDef, pStr[i] - 'a');
             continue;
         }
-        printf( "String \"%s\" contains unrecognized symbol (%c).\n", pStr, pStr[i] );
-        RetValue = 0;
+        return Ifn_ErrorMessage( "String \"%s\" contains unrecognized symbol \'%c\'.\n", pStr, pStr[i] );
     }
-    if ( !RetValue )
-        return 0;
     for ( i = 0; pStr[i]; i++ )
     {
         if ( pStr[i] == '=' || pStr[i] == ';' || 
@@ -200,46 +350,38 @@
              pStr[i] == '<' || pStr[i] == '>' || 
              pStr[i] == '{' || pStr[i] == '}' )
             continue;
+        if ( pStr[i] >= 'A' && pStr[i] <= 'Z' )
+            continue;
         if ( pStr[i] >= 'a' && pStr[i] <= 'z' )
         {
             if ( pStr[i+1] != '=' && Marks[pStr[i] - 'a'] != 2 )
                 Marks[pStr[i] - 'a'] = 1, MaxVar = Abc_MaxInt(MaxVar, pStr[i] - 'a');
             continue;
         }
-        printf( "String \"%s\" contains unrecognized symbol (%c).\n", pStr, pStr[i] );
-        RetValue = 0;
+        return Ifn_ErrorMessage( "String \"%s\" contains unrecognized symbol \'%c\'.\n", pStr, pStr[i] );
     }
-    if ( !RetValue )
-        return 0;
     MaxVar++;
     MaxDef++;
     for ( i = 0; i < MaxDef; i++ )
         if ( Marks[i] == 0 )
-            printf( "String \"%s\" has no symbol (%c).\n", pStr, 'a' + i ), RetValue = 0;
+            return Ifn_ErrorMessage( "String \"%s\" has no symbol \'%c\'.\n", pStr, 'a' + i );
     for ( i = 0; i < MaxVar; i++ )
         if ( Marks[i] == 2 )
-            printf( "String \"%s\" has definition of input variable (%c).\n", pStr, 'a' + i ), RetValue = 0;
+            return Ifn_ErrorMessage( "String \"%s\" has definition of input variable \'%c\'.\n", pStr, 'a' + i );
     for ( i = MaxVar; i < MaxDef; i++ )
         if ( Marks[i] == 1 )
-            printf( "String \"%s\" has no definition for internal variable (%c).\n", pStr, 'a' + i ), RetValue = 0;
-    if ( !RetValue )
-        return 0;
+            return Ifn_ErrorMessage( "String \"%s\" has no definition for internal variable \'%c\'.\n", pStr, 'a' + i );
     *pnInps = MaxVar;
     *pnObjs = MaxDef;
     return 1;
 }
-Ift_Ntk_t * Ifn_ManStrParse( char * pStr )
+int Ifn_NtkParseInt2( char * pStr, Ifn_Ntk_t * p )
 {
     int i, k, n, f, nFans, iFan;
-    static Ift_Ntk_t P, * p = &P;
-    memset( p, 0, sizeof(Ift_Ntk_t) );
-    if ( !Ifn_ManStrCheck(pStr, &p->nInps, &p->nObjs) )
-        return NULL;
+    if ( !Ifn_ManStrCheck2(pStr, &p->nInps, &p->nObjs) )
+        return 0;
     if ( p->nInps > IFN_INS )
-    {
-        printf( "The number of variables (%d) exceeds predefined limit (%d). Recompile with different value of IFN_INS.\n", p->nInps, IFN_INS );
-        return NULL;
-    }
+        return Ifn_ErrorMessage( "The number of variables (%d) exceeds predefined limit (%d). Recompile with different value of IFN_INS.\n", p->nInps, IFN_INS );
     assert( p->nInps > 1 && p->nInps < p->nObjs && p->nInps <= IFN_INS && p->nObjs < 2*IFN_INS );
     for ( i = p->nInps; i < p->nObjs; i++ )
     {
@@ -248,67 +390,409 @@
             if ( pStr[k] == 'a' + i && pStr[k+1] == '=' )
                 break;
         if ( pStr[k] == 0 )
-        {
-            printf( "Cannot find definition of signal %c.\n", 'a' + i );
-            return NULL;
-        }
+            return Ifn_ErrorMessage( "Cannot find definition of signal \'%c\'.\n", 'a' + i );
         if ( pStr[k+2] == '(' )
-            p->Nodes[i].Type = IF_DSD_AND, Next = ')';
+            p->Nodes[i].Type = IFN_DSD_AND, Next = ')';
         else if ( pStr[k+2] == '[' )
-            p->Nodes[i].Type = IF_DSD_XOR, Next = ']';
+            p->Nodes[i].Type = IFN_DSD_XOR, Next = ']';
         else if ( pStr[k+2] == '<' )
-            p->Nodes[i].Type = IF_DSD_MUX, Next = '>';
+            p->Nodes[i].Type = IFN_DSD_MUX, Next = '>';
         else if ( pStr[k+2] == '{' )
-            p->Nodes[i].Type = IF_DSD_PRIME, Next = '}';
+            p->Nodes[i].Type = IFN_DSD_PRIME, Next = '}';
         else 
-        {
-            printf( "Cannot find openning operation symbol in the defition of of signal %c.\n", 'a' + i );
-            return NULL;
-        }
+            return Ifn_ErrorMessage( "Cannot find openning operation symbol in the defition of of signal \'%c\'.\n", 'a' + i );
         for ( n = k + 3; pStr[n]; n++ )
             if ( pStr[n] == Next )
                 break;
         if ( pStr[n] == 0 )
-        {
-            printf( "Cannot find closing operation symbol in the defition of of signal %c.\n", 'a' + i );
-            return NULL;
-        }
+            return Ifn_ErrorMessage( "Cannot find closing operation symbol in the defition of of signal \'%c\'.\n", 'a' + i );
         nFans = n - k - 3;
         if ( nFans < 1 || nFans > 8 )
-        {
-            printf( "Cannot find matching operation symbol in the defition of of signal %c.\n", 'a' + i );
-            return NULL;
-        }
+            return Ifn_ErrorMessage( "Cannot find matching operation symbol in the defition of of signal \'%c\'.\n", 'a' + i );
         for ( f = 0; f < nFans; f++ )
         {
             iFan = pStr[k + 3 + f] - 'a';
             if ( iFan < 0 || iFan >= i )
-            {
-                printf( "Fanin number %d is signal %d is out of range.\n", f, 'a' + i );
-                return NULL;
-            }
+                return Ifn_ErrorMessage( "Fanin number %d is signal %d is out of range.\n", f, 'a' + i );
             p->Nodes[i].Fanins[f] = iFan;
         }
         p->Nodes[i].nFanins = nFans;
     }
-    // truth tables
+    return 1;
+}
+void Ifn_NtkParseConstraints( char * pStr, Ifn_Ntk_t * p )
+{
+    int i, k;
+    // parse constraints
+    p->nConstr = 0;
+    for ( i = 0; i < p->nInps; i++ )
+        for ( k = 0; pStr[k]; k++ )
+            if ( pStr[k] == 'A' + i && pStr[k-1] == ';' )
+            {
+                p->pConstr[p->nConstr++] = ((int)(pStr[k] - 'A') << 16) | (int)(pStr[k+1] - 'A');
+//                printf( "Added constraint (%c < %c)\n", pStr[k], pStr[k+1] );
+            }
+//    if ( p->nConstr )
+//        printf( "Total constraints = %d\n", p->nConstr );
+}
+
+Ifn_Ntk_t * Ifn_NtkParse( char * pStr )
+{
+    Ifn_Ntk_t * p = ABC_CALLOC( Ifn_Ntk_t, 1 );
+    if ( Ifn_ManStrType2(pStr) )
+    {
+        if ( !Ifn_NtkParseInt2( pStr, p ) )
+        {
+            ABC_FREE( p );
+            return NULL;
+        }
+    }
+    else
+    {
+        if ( !Ifn_NtkParseInt( pStr, p ) )
+        {
+            ABC_FREE( p );
+            return NULL;
+        }
+    }
+    Ifn_NtkParseConstraints( pStr, p );
     Abc_TtElemInit2( p->pTtElems, p->nInps );
-/*
-    // constraints
-    p->nConstr = 5;
-    p->pConstr[0] = (0 << 16) | 1;
+//    printf( "Finished parsing: " ); Ifn_NtkPrint(p);
+    return p;
+}
 
-    p->pConstr[1] = (2 << 16) | 3;
-    p->pConstr[2] = (3 << 16) | 4;
 
-    p->pConstr[3] = (6 << 16) | 7;
-    p->pConstr[4] = (7 << 16) | 8;
-*/
-    return p;
+
+/**Function*************************************************************
+
+  Synopsis    [Derive AIG.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Gia_Man_t * Ifn_ManStrFindModel( Ifn_Ntk_t * p )
+{
+    Gia_Man_t * pNew, * pTemp;
+    int i, k, iLit, * pVarMap = ABC_FALLOC( int, p->nParsVIni );
+    pNew = Gia_ManStart( 1000 );
+    pNew->pName = Abc_UtilStrsav( "model" );
+    Gia_ManHashStart( pNew );
+    for ( i = 0; i < p->nInps; i++ )
+        pVarMap[i] = Gia_ManAppendCi(pNew);
+    for ( i = p->nObjs; i < p->nParsVIni; i++ )
+        pVarMap[i] = Gia_ManAppendCi(pNew);
+    for ( i = p->nInps; i < p->nObjs; i++ )
+    {
+        int Type = p->Nodes[i].Type;
+        int nFans = p->Nodes[i].nFanins;
+        int * pFans = p->Nodes[i].Fanins;
+        int iFanin = p->Nodes[i].iFirst;
+        if ( Type == IFN_DSD_AND )
+        {
+            iLit = 1;
+            for ( k = 0; k < nFans; k++ )
+                iLit = Gia_ManHashAnd( pNew, iLit, pVarMap[pFans[k]] );
+            pVarMap[i] = iLit;
+        }
+        else if ( Type == IFN_DSD_XOR )
+        {
+            iLit = 0;
+            for ( k = 0; k < nFans; k++ )
+                iLit = Gia_ManHashXor( pNew, iLit, pVarMap[pFans[k]] );
+            pVarMap[i] = iLit;
+        }
+        else if ( Type == IFN_DSD_MUX )
+        {
+            assert( nFans == 3 );
+            pVarMap[i] = Gia_ManHashMux( pNew, pVarMap[pFans[0]], pVarMap[pFans[1]], pVarMap[pFans[2]] );
+        }
+        else if ( Type == IFN_DSD_PRIME )
+        {
+            int n, Step, pVarsData[256];
+            int nMints = (1 << nFans);
+            assert( nFans >= 1 && nFans <= 8 );
+            for ( k = 0; k < nMints; k++ )
+                pVarsData[k] = pVarMap[iFanin + k];
+            for ( Step = 1, k = 0; k < nFans; k++, Step <<= 1 )
+                for ( n = 0; n < nMints; n += Step << 1 )
+                    pVarsData[n] = Gia_ManHashMux( pNew, pVarMap[pFans[k]], pVarsData[n+Step], pVarsData[n] );
+            assert( Step == nMints );
+            pVarMap[i] = pVarsData[0];
+        }
+        else assert( 0 );
+    }
+    Gia_ManAppendCo( pNew, pVarMap[p->nObjs-1] );
+    ABC_FREE( pVarMap );
+    pNew = Gia_ManCleanup( pTemp = pNew );
+    Gia_ManStop( pTemp );
+    assert( Gia_ManPiNum(pNew) == p->nParsVIni - (p->nObjs - p->nInps) );
+    assert( Gia_ManPoNum(pNew) == 1 );
+    return pNew;
 }
+// compute cofactors w.r.t. the first nIns variables
+Gia_Man_t * Ifn_ManStrFindCofactors( int nIns, Gia_Man_t * p )
+{
+    Gia_Man_t * pNew, * pTemp; 
+    Gia_Obj_t * pObj;
+    int i, m, nMints = 1 << nIns;
+    pNew = Gia_ManStart( Gia_ManObjNum(p) );
+    pNew->pName = Abc_UtilStrsav( p->pName );
+    Gia_ManHashAlloc( pNew );
+    Gia_ManConst0(p)->Value = 0;
+    Gia_ManForEachCi( p, pObj, i )
+        if ( i >= nIns )
+            pObj->Value = Gia_ManAppendCi( pNew );
+    for ( m = 0; m < nMints; m++ )
+    {
+        Gia_ManForEachCi( p, pObj, i )
+            if ( i < nIns )
+                pObj->Value = ((m >> i) & 1);
+        Gia_ManForEachAnd( p, pObj, i )
+            pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+        Gia_ManForEachPo( p, pObj, i )
+            pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+    }
+    pNew = Gia_ManCleanup( pTemp = pNew );
+    Gia_ManStop( pTemp );
+    return pNew;
+}
 
 /**Function*************************************************************
 
+  Synopsis    [Derive SAT solver.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline Cnf_Dat_t * Cnf_DeriveGiaRemapped( Gia_Man_t * p )
+{
+    Cnf_Dat_t * pCnf;
+    Aig_Man_t * pAig = Gia_ManToAigSimple( p );
+    pAig->nRegs = 0;
+    pCnf = Cnf_Derive( pAig, Aig_ManCoNum(pAig) );
+    Aig_ManStop( pAig );
+    return pCnf;
+}
+sat_solver * Ifn_ManStrFindSolver( Gia_Man_t * p, Vec_Int_t ** pvPiVars, Vec_Int_t ** pvPoVars )
+{
+    sat_solver * pSat;
+    Gia_Obj_t * pObj;
+    Cnf_Dat_t * pCnf;
+    int i;    
+    pCnf = Cnf_DeriveGiaRemapped( p );
+    // start the SAT solver
+    pSat = sat_solver_new();
+    sat_solver_setnvars( pSat, pCnf->nVars );
+    // add timeframe clauses
+    for ( i = 0; i < pCnf->nClauses; i++ )
+        if ( !sat_solver_addclause( pSat, pCnf->pClauses[i], pCnf->pClauses[i+1] ) )
+            assert( 0 );
+    // inputs/outputs
+    *pvPiVars = Vec_IntAlloc( Gia_ManPiNum(p) );
+    Gia_ManForEachCi( p, pObj, i )
+        Vec_IntPush( *pvPiVars, pCnf->pVarNums[Gia_ObjId(p, pObj)] );
+    *pvPoVars = Vec_IntAlloc( Gia_ManPoNum(p) );
+    Gia_ManForEachCo( p, pObj, i )
+        Vec_IntPush( *pvPoVars, pCnf->pVarNums[Gia_ObjId(p, pObj)] );
+    Cnf_DataFree( pCnf );
+    return pSat;
+}
+sat_solver * Ifn_ManSatBuild( Ifn_Ntk_t * p, Vec_Int_t ** pvPiVars, Vec_Int_t ** pvPoVars )
+{
+    Gia_Man_t * p1, * p2;
+    sat_solver * pSat = NULL;
+    *pvPiVars = *pvPoVars = NULL;
+    p1 = Ifn_ManStrFindModel( p );
+//    Gia_AigerWrite( p1, "satbuild.aig", 0, 0 );
+    p2 = Ifn_ManStrFindCofactors( p->nInps, p1 );
+    Gia_ManStop( p1 );
+//    Gia_AigerWrite( p2, "satbuild2.aig", 0, 0 );
+    pSat = Ifn_ManStrFindSolver( p2, pvPiVars, pvPoVars );
+    Gia_ManStop( p2 );
+    return pSat;
+}
+void * If_ManSatBuildFromCell( char * pStr, Vec_Int_t ** pvPiVars, Vec_Int_t ** pvPoVars, Ifn_Ntk_t ** ppNtk )
+{
+    Ifn_Ntk_t * p = Ifn_NtkParse( pStr );
+    Ifn_Prepare( p, NULL, p->nInps );
+    *ppNtk = p;
+    if ( p == NULL )
+        return NULL;
+//    Ifn_NtkPrint( p );
+    return Ifn_ManSatBuild( p, pvPiVars, pvPoVars );
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Ifn_ManSatPrintPerm( char * pPerms, int nVars )
+{
+    int i;
+    for ( i = 0; i < nVars; i++ )
+        printf( "%c", 'a' + pPerms[i] );
+    printf( "\n" );
+}
+int Ifn_ManSatCheckOne( sat_solver * pSat, Vec_Int_t * vPoVars, word * pTruth, int nVars, int * pPerm, int nInps, Vec_Int_t * vLits )
+{
+    int v, Value, m, mNew, nMints = (1 << nVars); // (1 << nInps);
+    assert( (1 << nInps) == Vec_IntSize(vPoVars) );
+    assert( nVars <= nInps );
+    // remap minterms
+    Vec_IntFill( vLits, Vec_IntSize(vPoVars), -1 );
+    for ( m = 0; m < nMints; m++ )
+    {
+        mNew = 0;
+        for ( v = 0; v < nInps; v++ )
+        {
+            assert( pPerm[v] < nVars );
+            if ( ((m >> pPerm[v]) & 1) )
+                mNew |= (1 << v);
+        }
+        assert( Vec_IntEntry(vLits, mNew) == -1 );
+        Vec_IntWriteEntry( vLits, mNew, Abc_TtGetBit(pTruth, m) );
+    }
+    // find assumptions
+    v = 0;
+    Vec_IntForEachEntry( vLits, Value, m )
+        if ( Value >= 0 )
+            Vec_IntWriteEntry( vLits, v++, Abc_Var2Lit(Vec_IntEntry(vPoVars, m), !Value) );
+    Vec_IntShrink( vLits, v );
+    // run SAT solver
+    Value = sat_solver_solve( pSat, Vec_IntArray(vLits), Vec_IntArray(vLits) + Vec_IntSize(vLits), 0, 0, 0, 0 );
+    return (int)(Value == l_True);
+}
+void Ifn_ManSatDeriveOne( sat_solver * pSat, Vec_Int_t * vPiVars, Vec_Int_t * vValues )
+{
+    int i, iVar;
+    Vec_IntClear( vValues );
+    Vec_IntForEachEntry( vPiVars, iVar, i )
+        Vec_IntPush( vValues, sat_solver_var_value(pSat, iVar) );
+}
+int If_ManSatFindCofigBits( void * pSat, Vec_Int_t * vPiVars, Vec_Int_t * vPoVars, word * pTruth, int nVars, word Perm, int nInps, Vec_Int_t * vValues )
+{
+    // extract permutation
+    int RetValue, i, pPerm[IF_MAX_FUNC_LUTSIZE];
+    assert( nInps <= IF_MAX_FUNC_LUTSIZE );
+    for ( i = 0; i < nInps; i++ )
+    {
+        pPerm[i] = Abc_TtGetHex( &Perm, i );
+        assert( pPerm[i] < nVars );
+    }
+    // perform SAT check 
+    RetValue = Ifn_ManSatCheckOne( (sat_solver *)pSat, vPoVars, pTruth, nVars, pPerm, nInps, vValues );
+    Vec_IntClear( vValues );
+    if ( RetValue == 0 )
+        return 0;
+    Ifn_ManSatDeriveOne( pSat, vPiVars, vValues );
+    return 1;
+}
+int Ifn_ManSatFindCofigBitsTest( Ifn_Ntk_t * p, word * pTruth, int nVars, word Perm )
+{
+    Vec_Int_t * vValues = Vec_IntAlloc( 100 );
+    Vec_Int_t * vPiVars, * vPoVars;
+    sat_solver * pSat = Ifn_ManSatBuild( p, &vPiVars, &vPoVars );
+    int RetValue = If_ManSatFindCofigBits( pSat, vPiVars, vPoVars, pTruth, nVars, Perm, p->nInps, vValues );
+    Vec_IntPrint( vValues );
+    // cleanup
+    sat_solver_delete( pSat );
+    Vec_IntFreeP( &vPiVars );
+    Vec_IntFreeP( &vPoVars );
+    Vec_IntFreeP( &vValues );
+    return RetValue;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Derive GIA using programmable bits.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int If_ManSatDeriveGiaFromBits( void * pGia, Ifn_Ntk_t * p, Vec_Int_t * vValues, Vec_Int_t * vCover )
+{
+    Gia_Man_t * pNew = (Gia_Man_t *)pGia;
+    int i, Id, k, iLit, iVar = 0, nVarsNew, pVarMap[1000];
+    assert( Gia_ManCiNum(pNew) == p->nInps && p->nParsVIni < 1000 );
+    Gia_ManForEachCiId( pNew, Id, i )
+        pVarMap[i] = Abc_Var2Lit( Id, 0 );
+    for ( i = p->nInps; i < p->nObjs; i++ )
+    {
+        int Type = p->Nodes[i].Type;
+        int nFans = p->Nodes[i].nFanins;
+        int * pFans = p->Nodes[i].Fanins;
+        //int iFanin = p->Nodes[i].iFirst;
+        assert( nFans <= 6 );
+        if ( Type == IFN_DSD_AND )
+        {
+            iLit = 1;
+            for ( k = 0; k < nFans; k++ )
+                iLit = Gia_ManHashAnd( pNew, iLit, pVarMap[pFans[k]] );
+            pVarMap[i] = iLit;
+        }
+        else if ( Type == IFN_DSD_XOR )
+        {
+            iLit = 0;
+            for ( k = 0; k < nFans; k++ )
+                iLit = Gia_ManHashXor( pNew, iLit, pVarMap[pFans[k]] );
+            pVarMap[i] = iLit;
+        }
+        else if ( Type == IFN_DSD_MUX )
+        {
+            assert( nFans == 3 );
+            pVarMap[i] = Gia_ManHashMux( pNew, pVarMap[pFans[0]], pVarMap[pFans[1]], pVarMap[pFans[2]] );
+        }
+        else if ( Type == IFN_DSD_PRIME )
+        {
+            int pFaninLits[16];
+            // collect truth table
+            word uTruth = 0;
+            int nMints = (1 << nFans);
+            for ( k = 0; k < nMints; k++ )
+                if ( Vec_IntEntry( vValues, iVar++ ) )
+                    uTruth |= ((word)1 << k);
+            uTruth = Abc_Tt6Stretch( uTruth, nFans );
+            // collect function
+            for ( k = 0; k < nFans; k++ )
+                pFaninLits[k] = pVarMap[pFans[k]];
+            // implement the function
+            nVarsNew = Abc_TtMinBase( &uTruth, pFaninLits, nFans, 6 );
+            if ( nVarsNew == 0 )
+                pVarMap[i] = (int)(uTruth & 1);
+            else
+            {
+                extern int Kit_TruthToGia( Gia_Man_t * pMan, unsigned * pTruth, int nVars, Vec_Int_t * vMemory, Vec_Int_t * vLeaves, int fHash );
+                Vec_Int_t Leaves = { nVarsNew, nVarsNew, pFaninLits };
+                pVarMap[i] = Kit_TruthToGia( pNew, (unsigned *)&uTruth, nVarsNew, vCover, &Leaves, 1 ); // hashing enabled!!!
+            }
+        }
+        else assert( 0 );
+    }
+    assert( iVar == Vec_IntSize(vValues) );
+    return pVarMap[p->nObjs - 1];
+}
+
+/**Function*************************************************************
+
   Synopsis    [Derive truth table given the configulation values.]
 
   Description []
@@ -318,7 +802,7 @@
   SeeAlso     []
 
 ***********************************************************************/
-word * Ift_NtkDeriveTruth( Ift_Ntk_t * p, int * pValues )
+word * Ifn_NtkDeriveTruth( Ifn_Ntk_t * p, int * pValues )
 {
     int i, v, f, iVar, iStart;
     // elementary variables
@@ -330,35 +814,35 @@
             if ( p->Values[iStart+v] )
                 iVar += (1 << v);
         // assign variable
-        Abc_TtCopy( Ift_ObjTruth(p, i), Ift_ElemTruth(p, iVar), p->nWords, 0 );
+        Abc_TtCopy( Ifn_ObjTruth(p, i), Ifn_ElemTruth(p, iVar), p->nWords, 0 );
     }
     // internal variables
     for ( i = p->nInps; i < p->nObjs; i++ )
     {
         int nFans = p->Nodes[i].nFanins;
         int * pFans = p->Nodes[i].Fanins;
-        word * pTruth = Ift_ObjTruth( p, i );
-        if ( p->Nodes[i].Type == IF_DSD_AND )
+        word * pTruth = Ifn_ObjTruth( p, i );
+        if ( p->Nodes[i].Type == IFN_DSD_AND )
         {
             Abc_TtFill( pTruth, p->nWords );
             for ( f = 0; f < nFans; f++ )
-                Abc_TtAnd( pTruth, pTruth, Ift_ObjTruth(p, pFans[f]), p->nWords, 0 );
+                Abc_TtAnd( pTruth, pTruth, Ifn_ObjTruth(p, pFans[f]), p->nWords, 0 );
         }
-        else if ( p->Nodes[i].Type == IF_DSD_XOR )
+        else if ( p->Nodes[i].Type == IFN_DSD_XOR )
         {
             Abc_TtClear( pTruth, p->nWords );
             for ( f = 0; f < nFans; f++ )
-                Abc_TtXor( pTruth, pTruth, Ift_ObjTruth(p, pFans[f]), p->nWords, 0 );
+                Abc_TtXor( pTruth, pTruth, Ifn_ObjTruth(p, pFans[f]), p->nWords, 0 );
         }
-        else if ( p->Nodes[i].Type == IF_DSD_MUX )
+        else if ( p->Nodes[i].Type == IFN_DSD_MUX )
         {
             assert( nFans == 3 );
-            Abc_TtMux( pTruth, Ift_ObjTruth(p, pFans[0]), Ift_ObjTruth(p, pFans[1]), Ift_ObjTruth(p, pFans[2]), p->nWords );
+            Abc_TtMux( pTruth, Ifn_ObjTruth(p, pFans[0]), Ifn_ObjTruth(p, pFans[1]), Ifn_ObjTruth(p, pFans[2]), p->nWords );
         }
-        else if ( p->Nodes[i].Type == IF_DSD_PRIME )
+        else if ( p->Nodes[i].Type == IFN_DSD_PRIME )
         {
             int nValues = (1 << nFans);
-            word * pTemp = Ift_ObjTruth(p, p->nObjs);
+            word * pTemp = Ifn_ObjTruth(p, p->nObjs);
             Abc_TtClear( pTruth, p->nWords );
             for ( v = 0; v < nValues; v++ )
             {
@@ -367,16 +851,16 @@
                 Abc_TtFill( pTemp, p->nWords );
                 for ( f = 0; f < nFans; f++ )
                     if ( (v >> f) & 1 )
-                        Abc_TtAnd( pTemp, pTemp, Ift_ObjTruth(p, pFans[f]), p->nWords, 0 );
+                        Abc_TtAnd( pTemp, pTemp, Ifn_ObjTruth(p, pFans[f]), p->nWords, 0 );
                     else
-                        Abc_TtSharp( pTemp, pTemp, Ift_ObjTruth(p, pFans[f]), p->nWords );
+                        Abc_TtSharp( pTemp, pTemp, Ifn_ObjTruth(p, pFans[f]), p->nWords );
                 Abc_TtOr( pTruth, pTruth, pTemp, p->nWords );
             }
         }
         else assert( 0 );
 //Dau_DsdPrintFromTruth( pTruth, p->nVars );
     }
-    return Ift_ObjTruth(p, p->nObjs-1);
+    return Ifn_ObjTruth(p, p->nObjs-1);
 }
 
 /**Function*************************************************************
@@ -390,18 +874,18 @@
   SeeAlso     []
 
 ***********************************************************************/
-void Ift_TtComparisonConstr( word * pTruth, int nVars, int fMore, int fEqual )
+void Ifn_TtComparisonConstr( word * pTruth, int nVars, int fMore, int fEqual )
 {
     word Cond[4], Equa[4], Temp[4];
     word s_TtElems[8][4] = {
-        ABC_CONST(0xAAAAAAAAAAAAAAAA),ABC_CONST(0xAAAAAAAAAAAAAAAA),ABC_CONST(0xAAAAAAAAAAAAAAAA),ABC_CONST(0xAAAAAAAAAAAAAAAA),
-        ABC_CONST(0xCCCCCCCCCCCCCCCC),ABC_CONST(0xCCCCCCCCCCCCCCCC),ABC_CONST(0xCCCCCCCCCCCCCCCC),ABC_CONST(0xCCCCCCCCCCCCCCCC),
-        ABC_CONST(0xF0F0F0F0F0F0F0F0),ABC_CONST(0xF0F0F0F0F0F0F0F0),ABC_CONST(0xF0F0F0F0F0F0F0F0),ABC_CONST(0xF0F0F0F0F0F0F0F0),
-        ABC_CONST(0xFF00FF00FF00FF00),ABC_CONST(0xFF00FF00FF00FF00),ABC_CONST(0xFF00FF00FF00FF00),ABC_CONST(0xFF00FF00FF00FF00),
-        ABC_CONST(0xFFFF0000FFFF0000),ABC_CONST(0xFFFF0000FFFF0000),ABC_CONST(0xFFFF0000FFFF0000),ABC_CONST(0xFFFF0000FFFF0000),
-        ABC_CONST(0xFFFFFFFF00000000),ABC_CONST(0xFFFFFFFF00000000),ABC_CONST(0xFFFFFFFF00000000),ABC_CONST(0xFFFFFFFF00000000),
-        ABC_CONST(0x0000000000000000),ABC_CONST(0xFFFFFFFFFFFFFFFF),ABC_CONST(0x0000000000000000),ABC_CONST(0xFFFFFFFFFFFFFFFF),
-        ABC_CONST(0x0000000000000000),ABC_CONST(0x0000000000000000),ABC_CONST(0xFFFFFFFFFFFFFFFF),ABC_CONST(0xFFFFFFFFFFFFFFFF)
+        { ABC_CONST(0xAAAAAAAAAAAAAAAA),ABC_CONST(0xAAAAAAAAAAAAAAAA),ABC_CONST(0xAAAAAAAAAAAAAAAA),ABC_CONST(0xAAAAAAAAAAAAAAAA) },
+        { ABC_CONST(0xCCCCCCCCCCCCCCCC),ABC_CONST(0xCCCCCCCCCCCCCCCC),ABC_CONST(0xCCCCCCCCCCCCCCCC),ABC_CONST(0xCCCCCCCCCCCCCCCC) },
+        { ABC_CONST(0xF0F0F0F0F0F0F0F0),ABC_CONST(0xF0F0F0F0F0F0F0F0),ABC_CONST(0xF0F0F0F0F0F0F0F0),ABC_CONST(0xF0F0F0F0F0F0F0F0) },
+        { ABC_CONST(0xFF00FF00FF00FF00),ABC_CONST(0xFF00FF00FF00FF00),ABC_CONST(0xFF00FF00FF00FF00),ABC_CONST(0xFF00FF00FF00FF00) },
+        { ABC_CONST(0xFFFF0000FFFF0000),ABC_CONST(0xFFFF0000FFFF0000),ABC_CONST(0xFFFF0000FFFF0000),ABC_CONST(0xFFFF0000FFFF0000) },
+        { ABC_CONST(0xFFFFFFFF00000000),ABC_CONST(0xFFFFFFFF00000000),ABC_CONST(0xFFFFFFFF00000000),ABC_CONST(0xFFFFFFFF00000000) },
+        { ABC_CONST(0x0000000000000000),ABC_CONST(0xFFFFFFFFFFFFFFFF),ABC_CONST(0x0000000000000000),ABC_CONST(0xFFFFFFFFFFFFFFFF) },
+        { ABC_CONST(0x0000000000000000),ABC_CONST(0x0000000000000000),ABC_CONST(0xFFFFFFFFFFFFFFFF),ABC_CONST(0xFFFFFFFFFFFFFFFF) }
     };
     int i, nWords = Abc_TtWordNum(2*nVars);
     assert( nVars > 0 && nVars <= 4 );
@@ -433,7 +917,7 @@
   SeeAlso     []
 
 ***********************************************************************/
-void Ift_AddClause( sat_solver * pSat, int * pBeg, int * pEnd )
+int Ifn_AddClause( sat_solver * pSat, int * pBeg, int * pEnd )
 {
     int fVerbose = 0;
     int RetValue = sat_solver_addclause( pSat, pBeg, pEnd );
@@ -443,11 +927,11 @@
             printf( "%c%d ", Abc_LitIsCompl(*pBeg) ? '-':'+', Abc_Lit2Var(*pBeg) );
         printf( "\n" );
     }
-    assert( RetValue );
+    return RetValue;
 }
-void Ift_NtkAddConstrOne( sat_solver * pSat, Vec_Int_t * vCover, int * pVars, int nVars )
+void Ifn_NtkAddConstrOne( sat_solver * pSat, Vec_Int_t * vCover, int * pVars, int nVars )
 {
-    int k, c, Cube, Literal, nLits, pLits[IFN_INS];
+    int RetValue, k, c, Cube, Literal, nLits, pLits[IFN_INS];
     Vec_IntForEachEntry( vCover, Cube, c )
     {
         nLits = 0;
@@ -461,12 +945,13 @@
             else if ( Literal != 0 )
                 assert( 0 );
         }
-        Ift_AddClause( pSat, pLits, pLits + nLits );
+        RetValue = Ifn_AddClause( pSat, pLits, pLits + nLits );
+        assert( RetValue );
     }
 }
-void Ift_NtkAddConstraints( Ift_Ntk_t * p, sat_solver * pSat )
+void Ifn_NtkAddConstraints( Ifn_Ntk_t * p, sat_solver * pSat )
 {
-    int fAddConstr = 0;
+    int fAddConstr = 1;
     Vec_Int_t * vCover = Vec_IntAlloc( 0 );
     word uTruth = Abc_Tt6Stretch( ~Abc_Tt6Mask(p->nVars), p->nParsVNum );
     assert( p->nParsVNum <= 4 );
@@ -481,7 +966,7 @@
         {
             for ( k = 0; k < p->nParsVNum; k++ )
                 pVars[k] = p->nParsVIni + i * p->nParsVNum + k;
-            Ift_NtkAddConstrOne( pSat, vCover, pVars, p->nParsVNum );
+            Ifn_NtkAddConstrOne( pSat, vCover, pVars, p->nParsVNum );
         }
     }
     // ordering constraints
@@ -490,7 +975,7 @@
         word pTruth[4];
         int i, k, RetValue, pVars[2*IFN_INS];
         int fForceDiff = (p->nVars == p->nInps);
-        Ift_TtComparisonConstr( pTruth, p->nParsVNum, fForceDiff, fForceDiff );
+        Ifn_TtComparisonConstr( pTruth, p->nParsVNum, fForceDiff, fForceDiff );
         RetValue = Kit_TruthIsop( (unsigned *)pTruth, 2*p->nParsVNum, vCover, 0 );
         assert( RetValue == 0 );
 //        Kit_TruthIsopPrintCover( vCover, 2*p->nParsVNum, 0 );
@@ -503,7 +988,7 @@
                 pVars[2*k+0] = p->nParsVIni + iVar1 * p->nParsVNum + k;
                 pVars[2*k+1] = p->nParsVIni + iVar2 * p->nParsVNum + k;
             }
-            Ift_NtkAddConstrOne( pSat, vCover, pVars, 2*p->nParsVNum );
+            Ifn_NtkAddConstrOne( pSat, vCover, pVars, 2*p->nParsVNum );
 //            printf( "added constraint with %d clauses for %d and %d\n", Vec_IntSize(vCover), iVar1, iVar2 );
         }
     }
@@ -521,14 +1006,14 @@
   SeeAlso     []
 
 ***********************************************************************/
-int Ift_NtkAddClauses( Ift_Ntk_t * p, int * pValues, sat_solver * pSat )
+int Ifn_NtkAddClauses( Ifn_Ntk_t * p, int * pValues, sat_solver * pSat )
 {
     int i, f, v, nLits, pLits[IFN_INS+2], pLits2[IFN_INS+2];
     // assign new variables
     int nSatVars = sat_solver_nvars(pSat);
     for ( i = 0; i < p->nObjs-1; i++ )
         p->Nodes[i].Var = nSatVars++;
-    p->Nodes[p->nObjs-1].Var = -ABC_INFINITY;
+    p->Nodes[p->nObjs-1].Var = 0xFFFF;
     sat_solver_setnvars( pSat, nSatVars );
     // verify variable values
     for ( i = 0; i < p->nVars; i++ )
@@ -548,7 +1033,8 @@
             // add clause literals
             for ( f = 0; f < p->nParsVNum; f++ )
                 pLits[f+1] = Abc_Var2Lit( iParStart + f, (v >> f) & 1 ); 
-            Ift_AddClause( pSat, pLits, pLits+p->nParsVNum+1 );
+            if ( !Ifn_AddClause( pSat, pLits, pLits+p->nParsVNum+1 ) )
+                return 0;
         }
     }
 //printf( "\n" );
@@ -556,7 +1042,7 @@
     {
         int nFans = p->Nodes[i].nFanins;
         int * pFans = p->Nodes[i].Fanins;
-        if ( p->Nodes[i].Type == IF_DSD_AND )
+        if ( p->Nodes[i].Type == IFN_DSD_AND )
         {
             nLits = 0;
             pLits[nLits++] = Abc_Var2Lit( p->Nodes[i].Var, 0 );
@@ -566,20 +1052,59 @@
                 // add small clause
                 pLits2[0] = Abc_Var2Lit( p->Nodes[i].Var, 1 );
                 pLits2[1] = Abc_Var2Lit( p->Nodes[pFans[f]].Var, 0 );
-                Ift_AddClause( pSat, pLits2, pLits2 + 2 );
+                if ( !Ifn_AddClause( pSat, pLits2, pLits2 + 2 ) )
+                    return 0;
             }
             // add big clause
-            Ift_AddClause( pSat, pLits, pLits + nLits );
+            if ( !Ifn_AddClause( pSat, pLits, pLits + nLits ) )
+                return 0;
         }
-        else if ( p->Nodes[i].Type == IF_DSD_XOR )
+        else if ( p->Nodes[i].Type == IFN_DSD_XOR )
         {
-            assert( 0 );
+            int m, nMints = (1 << (nFans+1));
+            for ( m = 0; m < nMints; m++ )
+            {
+                // skip even 
+                int Count = 0;
+                for ( v = 0; v <= nFans; v++ )
+                    Count += ((m >> v) & 1);
+                if ( (Count & 1) == 0 )
+                    continue;
+                // generate minterm
+                pLits[0] = Abc_Var2Lit( p->Nodes[i].Var, (m >> nFans) & 1 );
+                for ( v = 0; v < nFans; v++ )
+                    pLits[v+1] = Abc_Var2Lit( p->Nodes[pFans[v]].Var, (m >> v) & 1 );
+                if ( !Ifn_AddClause( pSat, pLits, pLits + nFans + 1 ) )
+                    return 0;
+            }
         }
-        else if ( p->Nodes[i].Type == IF_DSD_MUX )
+        else if ( p->Nodes[i].Type == IFN_DSD_MUX )
         {
-            assert( 0 );
+            pLits[0] = Abc_Var2Lit( p->Nodes[i].Var, 0 );
+            pLits[1] = Abc_Var2Lit( p->Nodes[pFans[0]].Var, 1 ); // ctrl
+            pLits[2] = Abc_Var2Lit( p->Nodes[pFans[1]].Var, 1 );
+            if ( !Ifn_AddClause( pSat, pLits, pLits + 3 ) )
+                return 0;
+
+            pLits[0] = Abc_Var2Lit( p->Nodes[i].Var, 1 );
+            pLits[1] = Abc_Var2Lit( p->Nodes[pFans[0]].Var, 1 ); // ctrl
+            pLits[2] = Abc_Var2Lit( p->Nodes[pFans[1]].Var, 0 );
+            if ( !Ifn_AddClause( pSat, pLits, pLits + 3 ) )
+                return 0;
+
+            pLits[0] = Abc_Var2Lit( p->Nodes[i].Var, 0 );
+            pLits[1] = Abc_Var2Lit( p->Nodes[pFans[0]].Var, 0 ); // ctrl
+            pLits[2] = Abc_Var2Lit( p->Nodes[pFans[2]].Var, 1 );
+            if ( !Ifn_AddClause( pSat, pLits, pLits + 3 ) )
+                return 0;
+
+            pLits[0] = Abc_Var2Lit( p->Nodes[i].Var, 1 );
+            pLits[1] = Abc_Var2Lit( p->Nodes[pFans[0]].Var, 0 ); // ctrl
+            pLits[2] = Abc_Var2Lit( p->Nodes[pFans[2]].Var, 0 );
+            if ( !Ifn_AddClause( pSat, pLits, pLits + 3 ) )
+                return 0;
         }
-        else if ( p->Nodes[i].Type == IF_DSD_PRIME )
+        else if ( p->Nodes[i].Type == IFN_DSD_PRIME )
         {
             int nValues = (1 << nFans);
             int iParStart = p->Nodes[i].iFirst;
@@ -598,9 +1123,15 @@
                 pLits2[nLits] = Abc_Var2Lit( iParStart + v, 0 ); 
                 nLits++;
                 if ( pValues[i] != 0 )
-                    Ift_AddClause( pSat, pLits2, pLits2 + nLits );
+                {
+                    if ( !Ifn_AddClause( pSat, pLits2, pLits2 + nLits ) )
+                        return 0;
+                }
                 if ( pValues[i] != 1 )
-                    Ift_AddClause( pSat, pLits,  pLits + nLits );
+                {
+                    if ( !Ifn_AddClause( pSat, pLits,  pLits + nLits ) )
+                        return 0;
+                }
             }
         }
         else assert( 0 );
@@ -620,7 +1151,7 @@
   SeeAlso     []
 
 ***********************************************************************/
-void Ift_SatPrintStatus( sat_solver * p, int Iter, int status, int iMint, int Value, abctime clk )
+void Ifn_NtkMatchPrintStatus( sat_solver * p, int Iter, int status, int iMint, int Value, abctime clk )
 {
     printf( "Iter = %5d  ",  Iter );
     printf( "Mint = %5d  ",  iMint );
@@ -634,21 +1165,46 @@
         printf( "status = sat  " );
     else 
         printf( "status = undec" );
-    Abc_PrintTime( 1, "", clk );
+    Abc_PrintTime( 1, "Time", clk );
 }
-void Ift_SatPrintConfig( Ift_Ntk_t * p, sat_solver * pSat )
+void Ifn_NtkMatchPrintConfig( Ifn_Ntk_t * p, sat_solver * pSat )
 {
-    int v;
+    int v, i;
     for ( v = p->nObjs; v < p->nPars; v++ )
     {
-        if ( v >= p->nParsVIni && (v - p->nParsVIni) % p->nParsVNum == 0 )
+        for ( i = p->nInps; i < p->nObjs; i++ )
+            if ( p->Nodes[i].Type == IFN_DSD_PRIME && (int)p->Nodes[i].iFirst == v )
+                break;
+        if ( i < p->nObjs )
+            printf( " " );
+        else if ( v >= p->nParsVIni && (v - p->nParsVIni) % p->nParsVNum == 0 )
             printf( " %d=", (v - p->nParsVIni) / p->nParsVNum );
         printf( "%d", sat_solver_var_value(pSat, v) );
     }
+}
+word Ifn_NtkMatchCollectPerm( Ifn_Ntk_t * p, sat_solver * pSat )
+{
+    word Perm = 0;
+    int i, v, Mint;
+    assert( p->nParsVNum <= 4 );
+    for ( i = 0; i < p->nInps; i++ )
+    {
+        for ( Mint = v = 0; v < p->nParsVNum; v++ )
+            if ( sat_solver_var_value(pSat, p->nParsVIni + i * p->nParsVNum + v) )
+                Mint |= (1 << v);
+        Abc_TtSetHex( &Perm, i, Mint );
+    }
+    return Perm;
+}
+void Ifn_NtkMatchPrintPerm( word Perm, int nInps )
+{
+    int i;
+    assert( nInps <= 16 );
+    for ( i = 0; i < nInps; i++ )
+        printf( "%c", 'a' + Abc_TtGetHex(&Perm, i) );
     printf( "\n" );
 }
-
-int Ift_NtkMatch( Ift_Ntk_t * p, word * pTruth, int nVars, int fVerbose )
+int Ifn_NtkMatch( Ifn_Ntk_t * p, word * pTruth, int nVars, int nConfls, int fVerbose, int fVeryVerbose, word * pPerm )
 {
     word * pTruth1;
     int RetValue = 0;
@@ -659,9 +1215,10 @@
     sat_solver * pSat = sat_solver_new();
     Ifn_Prepare( p, pTruth, nVars );
     sat_solver_setnvars( pSat, p->nPars );
-    Ift_NtkAddConstraints( p, pSat );
-    if ( fVerbose )
-        Ift_SatPrintStatus( pSat, 0, l_True, -1, -1, Abc_Clock() - clk );
+    Ifn_NtkAddConstraints( p, pSat );
+    if ( fVeryVerbose )
+        Ifn_NtkMatchPrintStatus( pSat, 0, l_True, -1, -1, Abc_Clock() - clk );
+    if ( pPerm ) *pPerm = 0;
     for ( i = 0; i < nIterMax; i++ )
     {
         // get variable assignment
@@ -669,37 +1226,52 @@
             p->Values[v] = v < p->nVars ? (iMint >> v) & 1 :  -1;
         p->Values[p->nObjs-1] = Abc_TtGetBit( pTruth, iMint );
         // derive clauses
-        if ( !Ift_NtkAddClauses( p, p->Values, pSat ) )
+        if ( !Ifn_NtkAddClauses( p, p->Values, pSat ) )
             break;
         // find assignment of parameters
 //        clk2 = Abc_Clock();
-        status = sat_solver_solve( pSat, NULL, NULL, 0, 0, 0, 0 );
+        status = sat_solver_solve( pSat, NULL, NULL, nConfls, 0, 0, 0 );
 //        clkSat += Abc_Clock() - clk2;
-        if ( fVerbose )
-            Ift_SatPrintStatus( pSat, i+1, status, iMint, p->Values[p->nObjs-1], Abc_Clock() - clk );
-        if ( status == l_False )
+        if ( fVeryVerbose )
+            Ifn_NtkMatchPrintStatus( pSat, i+1, status, iMint, p->Values[p->nObjs-1], Abc_Clock() - clk );
+        if ( status != l_True )
             break;
-        assert( status == l_True );
         // collect assignment
         for ( v = p->nObjs; v < p->nPars; v++ )
             p->Values[v] = sat_solver_var_value(pSat, v);
         // find truth table
 //        clk2 = Abc_Clock();
-        pTruth1 = Ift_NtkDeriveTruth( p, p->Values );
+        pTruth1 = Ifn_NtkDeriveTruth( p, p->Values );
 //        clkTru += Abc_Clock() - clk2;
         Abc_TtXor( pTruth1, pTruth1, p->pTruth, p->nWords, 0 );
         // find mismatch if present
         iMint = Abc_TtFindFirstBit( pTruth1, p->nVars );
         if ( iMint == -1 )
         {
-            Ift_SatPrintConfig( p, pSat );
+            if ( pPerm ) 
+                *pPerm = Ifn_NtkMatchCollectPerm( p, pSat );
+/*
+            if ( pPerm )
+            {
+                int RetValue = Ifn_ManSatFindCofigBitsTest( p, pTruth, nVars, *pPerm );
+                Ifn_NtkMatchPrintPerm( *pPerm, p->nInps );
+                if ( RetValue == 0 )
+                    printf( "Verification failed.\n" );
+            }
+*/
             RetValue = 1;
             break;
         }
     }
     assert( i < nIterMax );
+    if ( fVerbose )
+    {
+        printf( "%s  Iter =%4d. Confl = %6d.  ", RetValue ? "yes":"no ", i, sat_solver_nconflicts(pSat) );
+        if ( RetValue )
+            Ifn_NtkMatchPrintConfig( p, pSat );
+        printf( "\n" );
+    }
     sat_solver_delete( pSat );
-    printf( "Matching = %d  Iters = %d. ", RetValue, i );
 //    Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
 //    Abc_PrintTime( 1, "Sat", clkSat );
 //    Abc_PrintTime( 1, "Tru", clkTru );
@@ -720,26 +1292,31 @@
 void Ifn_NtkRead()
 {
     int RetValue;
-    int nVars = 9;
-//    int nVars = 8;
-//    int nVars = 3;
+    int nVars = 8;
 //    word * pTruth = Dau_DsdToTruth( "(abcdefghi)", nVars );
     word * pTruth = Dau_DsdToTruth( "1008{(1008{(ab)cde}f)ghi}", nVars );
 //    word * pTruth = Dau_DsdToTruth( "18{(1008{(ab)cde}f)gh}", nVars );
 //    word * pTruth = Dau_DsdToTruth( "1008{(1008{[ab]cde}f)ghi}", nVars );
 //    word * pTruth = Dau_DsdToTruth( "(abcd)", nVars );
 //    word * pTruth = Dau_DsdToTruth( "(abc)", nVars );
+//    word * pTruth = Dau_DsdToTruth( "18{(1008{(ab)cde}f)gh}", nVars );
 //    char * pStr = "e={abc};f={ed};";
 //    char * pStr = "d={ab};e={cd};";
-    char * pStr = "j=(ab);k={jcde};l=(kf);m={lghi};";
+//    char * pStr = "j=(ab);k={jcde};l=(kf);m={lghi};";
 //    char * pStr = "i={abc};j={ide};k={ifg};l={jkh};";
 //    char * pStr = "h={abcde};i={abcdf};j=<ghi>;";
 //    char * pStr = "g=<abc>;h=<ade>;i={fgh};";
-    Ift_Ntk_t * p = Ifn_ManStrParse( pStr );
+//    char * pStr = "i=<abc>;j=(def);k=[gh];l={ijk};";
+    char * pStr = "{({(ab)cde}f)ghi};AB;CD;DE;GH;HI";
+    Ifn_Ntk_t * p = Ifn_NtkParse( pStr );
+    word Perm = 0;
+    if ( p == NULL )
+        return;
     Ifn_NtkPrint( p );
     Dau_DsdPrintFromTruth( pTruth, nVars );
     // get the given function
-    RetValue = Ift_NtkMatch( p, pTruth, nVars, 1 );
+    RetValue = Ifn_NtkMatch( p, pTruth, nVars, 0, 1, 1, &Perm );
+    ABC_FREE( p );
 }
 
 ////////////////////////////////////////////////////////////////////////
diff --git a/abc-build/src/map/mapper/mapperSuper.c b/abc-build/src/map/mapper/mapperSuper.c
--- a/abc-build/src/map/mapper/mapperSuper.c
+++ b/abc-build/src/map/mapper/mapperSuper.c
@@ -149,7 +149,7 @@
         // get the gate
         pGate = Map_LibraryReadGate( pLib, pTemp, pLib->nVarsMax );
         assert( pGate->Num == nCounter + 1 );
-        // count the number of parantheses in the formula - this is the number of gates
+        // count the number of parentheses in the formula - this is the number of gates
         for ( pTemp = pGate->pFormula; *pTemp; pTemp++ )
             pGate->nGates += (*pTemp == '(');
         // verify the truth table
@@ -261,7 +261,7 @@
     // skip leading spaces
     for ( pName = pFormula; *pName && *pName == ' '; pName++ );
     assert( *pName );
-    // find the first opening paranthesis
+    // find the first opening parenthesis
     for ( pPar1 = pName; *pPar1 && *pPar1 != '('; pPar1++ );
     if ( *pPar1 == 0 )
     {
@@ -271,7 +271,7 @@
     // overwrite it with space
     assert( *pPar1 == '(' );
     *pPar1 = 0;
-    // find the corresponding closing paranthesis
+    // find the corresponding closing parenthesis
     for ( CountPars = 1, pPar2 = pPar1 + 1; *pPar2 && CountPars; pPar2++ )
         if ( *pPar2 == '(' )
             CountPars++;
diff --git a/abc-build/src/map/mio/mio.h b/abc-build/src/map/mio/mio.h
--- a/abc-build/src/map/mio/mio.h
+++ b/abc-build/src/map/mio/mio.h
@@ -98,6 +98,7 @@
 extern Mio_Gate_t **     Mio_LibraryReadGateArray  ( Mio_Library_t * pLib );
 extern Mio_Gate_t *      Mio_LibraryReadGateByName ( Mio_Library_t * pLib, char * pName, char * pOutName );
 extern char *            Mio_LibraryReadSopByName  ( Mio_Library_t * pLib, char * pName );    
+extern Mio_Gate_t *      Mio_LibraryReadGateByTruth( Mio_Library_t * pLib, word t );
 extern Mio_Gate_t *      Mio_LibraryReadConst0     ( Mio_Library_t * pLib );
 extern Mio_Gate_t *      Mio_LibraryReadConst1     ( Mio_Library_t * pLib );
 extern Mio_Gate_t *      Mio_LibraryReadNand2      ( Mio_Library_t * pLib );
diff --git a/abc-build/src/map/mio/mioApi.c b/abc-build/src/map/mio/mioApi.c
--- a/abc-build/src/map/mio/mioApi.c
+++ b/abc-build/src/map/mio/mioApi.c
@@ -109,6 +109,26 @@
         return pGate->pTwin;
     return NULL;
 }
+
+/**Function*************************************************************
+
+  Synopsis    [Returns the first gate in the library with the given TT.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Mio_Gate_t * Mio_LibraryReadGateByTruth( Mio_Library_t * pLib, word t )
+{
+    Mio_Gate_t * pGate;
+    Mio_LibraryForEachGate( pLib, pGate )
+        if ( pGate->nInputs <= 6 && pGate->uTruth == t )
+            return pGate;
+    return NULL;
+}
 
 /**Function*************************************************************
 
diff --git a/abc-build/src/map/mio/mioParse.c b/abc-build/src/map/mio/mioParse.c
--- a/abc-build/src/map/mio/mioParse.c
+++ b/abc-build/src/map/mio/mioParse.c
@@ -27,8 +27,8 @@
 ////////////////////////////////////////////////////////////////////////
 
 // the list of operation symbols to be used in expressions
-#define MIO_EQN_SYM_OPEN    '('   // opening paranthesis
-#define MIO_EQN_SYM_CLOSE   ')'   // closing paranthesis
+#define MIO_EQN_SYM_OPEN    '('   // opening parenthesis
+#define MIO_EQN_SYM_CLOSE   ')'   // closing parenthesis
 #define MIO_EQN_SYM_CONST0  '0'   // constant 0
 #define MIO_EQN_SYM_CONST1  '1'   // constant 1
 #define MIO_EQN_SYM_NEG     '!'   // negation before the variable
@@ -44,7 +44,7 @@
 #define MIO_EQN_OPER_AND     9    // logic AND
 #define MIO_EQN_OPER_XOR     8    // logic XOR
 #define MIO_EQN_OPER_OR      7    // logic OR
-#define MIO_EQN_OPER_MARK    1    // OpStack token standing for an opening paranthesis
+#define MIO_EQN_OPER_MARK    1    // OpStack token standing for an opening parenthesis
 
 // these are values of the internal Flag
 #define MIO_EQN_FLAG_START   1    // after the opening parenthesis 
@@ -114,7 +114,7 @@
 	int Oper, Oper1, Oper2;
     int i, v;
 
-    // make sure that the number of opening and closing parantheses is the same
+    // make sure that the number of opening and closing parentheses is the same
     nParans = 0;
     for ( pTemp = pFormInit; *pTemp; pTemp++ )
         if ( *pTemp == '(' )
@@ -123,7 +123,7 @@
             nParans--;
     if ( nParans != 0 )
     {
-        fprintf( stdout, "Mio_ParseFormula(): Different number of opening and closing parantheses ().\n" );
+        fprintf( stdout, "Mio_ParseFormula(): Different number of opening and closing parentheses ().\n" );
         return NULL;
     }
 
@@ -207,7 +207,7 @@
 			if ( Flag == MIO_EQN_FLAG_VAR )
             {
 				Vec_IntPush( pStackOp, MIO_EQN_OPER_AND );
-//				fprintf( stdout, "Mio_ParseFormula(): An opening paranthesis follows a var without operation sign.\n" ); 
+//				fprintf( stdout, "Mio_ParseFormula(): An opening parenthesis follows a var without operation sign.\n" ); 
 //				Flag = MIO_EQN_FLAG_ERROR; 
 //              break; 
             }
@@ -222,7 +222,7 @@
 			    {
 				    if ( Vec_IntSize( pStackOp ) == 0 )
 					{
-						fprintf( stdout, "Mio_ParseFormula(): There is no opening paranthesis\n" );
+						fprintf( stdout, "Mio_ParseFormula(): There is no opening parenthesis\n" );
 						Flag = MIO_EQN_FLAG_ERROR; 
                         break;
 					}
@@ -243,7 +243,7 @@
             }
 		    else
 			{
-				fprintf( stdout, "Mio_ParseFormula(): There is no opening paranthesis\n" );
+				fprintf( stdout, "Mio_ParseFormula(): There is no opening parenthesis\n" );
 				Flag = MIO_EQN_FLAG_ERROR; 
                 break;
 			}
@@ -262,7 +262,7 @@
               {
 				    if ( pTemp[i] == MIO_EQN_SYM_NEG || pTemp[i] == MIO_EQN_SYM_OPEN )
 				    {
-					    fprintf( stdout, "Mio_ParseFormula(): The negation sign or an opening paranthesis inside the variable name.\n" );
+					    fprintf( stdout, "Mio_ParseFormula(): The negation sign or an opening parenthesis inside the variable name.\n" );
 					    Flag = MIO_EQN_FLAG_ERROR; 
                         break;
 				    }
diff --git a/abc-build/src/map/mio/mioUtils.c b/abc-build/src/map/mio/mioUtils.c
--- a/abc-build/src/map/mio/mioUtils.c
+++ b/abc-build/src/map/mio/mioUtils.c
@@ -21,6 +21,7 @@
 #include "base/main/main.h"
 #include "exp.h"
 #include "misc/util/utilTruth.h"
+#include "opt/dau/dau.h"
 
 ABC_NAMESPACE_IMPL_START
 
@@ -442,6 +443,14 @@
         }
         Mio_CollectCopy( ppCells + iCell++, pGate );
     }
+    if ( ppCells[0].pName == NULL )
+        { printf( "Error: Cannot find constant 0 gate in the library.\n" ); return NULL; }
+    if ( ppCells[1].pName == NULL )
+        { printf( "Error: Cannot find constant 1 gate in the library.\n" ); return NULL; }
+    if ( ppCells[2].pName == NULL )
+        { printf( "Error: Cannot find buffer gate in the library.\n" );     return NULL; }
+    if ( ppCells[3].pName == NULL )
+        { printf( "Error: Cannot find inverter gate in the library.\n" );   return NULL; }
     // sort by delay
     if ( iCell > 1 ) 
     {
@@ -512,10 +521,13 @@
         { 0xFFFF0000, 0xFFFF0000 },
         { 0x00000000, 0xFFFFFFFF }
     };
-    unsigned uTruthRes[2];
+    union {
+      unsigned u[2];
+      word w;
+    } uTruthRes;
     assert( pGate->nInputs <= 6 );
-    Mio_DeriveTruthTable( pGate, uTruths6, pGate->nInputs, 6, uTruthRes );
-    return *((word *)uTruthRes);
+    Mio_DeriveTruthTable( pGate, uTruths6, pGate->nInputs, 6, uTruthRes.u );
+    return uTruthRes.w;
 }
 
 #if 0
@@ -963,7 +975,6 @@
 
 void Nf_ManPrepareLibrary( Mio_Library_t * pLib )
 {
-    extern void Dau_DsdPrintFromTruth( word * pTruth, int nVarsInit );
 //    char Lines[2*720*64][8];
 //    Nf_ManPreparePrint( 6, pComp, pPerm, Lines );
     int * pComp[7];
diff --git a/abc-build/src/map/scl/scl.c b/abc-build/src/map/scl/scl.c
--- a/abc-build/src/map/scl/scl.c
+++ b/abc-build/src/map/scl/scl.c
@@ -33,6 +33,7 @@
 static int Scl_CommandReadScl    ( Abc_Frame_t * pAbc, int argc, char ** argv );
 static int Scl_CommandWriteScl   ( Abc_Frame_t * pAbc, int argc, char ** argv );
 static int Scl_CommandPrintLib   ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Scl_CommandLeak2Area  ( Abc_Frame_t * pAbc, int argc, char ** argv );
 static int Scl_CommandDumpGen    ( Abc_Frame_t * pAbc, int argc, char ** argv );
 static int Scl_CommandPrintGS    ( Abc_Frame_t * pAbc, int argc, char ** argv );
 static int Scl_CommandStime      ( Abc_Frame_t * pAbc, int argc, char ** argv );
@@ -92,6 +93,7 @@
     Cmd_CommandAdd( pAbc, "SCL mapping",  "read_lib",      Scl_CommandReadLib,     0 ); 
     Cmd_CommandAdd( pAbc, "SCL mapping",  "write_lib",     Scl_CommandWriteLib,    0 ); 
     Cmd_CommandAdd( pAbc, "SCL mapping",  "print_lib",     Scl_CommandPrintLib,    0 ); 
+    Cmd_CommandAdd( pAbc, "SCL mapping",  "leak2area",     Scl_CommandLeak2Area,   0 ); 
     Cmd_CommandAdd( pAbc, "SCL mapping",  "read_scl",      Scl_CommandReadScl,     0 ); 
     Cmd_CommandAdd( pAbc, "SCL mapping",  "write_scl",     Scl_CommandWriteScl,    0 ); 
     Cmd_CommandAdd( pAbc, "SCL mapping",  "dump_genlib",   Scl_CommandDumpGen,     0 ); 
@@ -372,6 +374,77 @@
     fprintf( pAbc->Err, "\t-h       : print the help massage\n" );
     return 1;
 }
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Scl_CommandLeak2Area( Abc_Frame_t * pAbc, int argc, char **argv )
+{
+    float A = 1, B = 1;
+    int c, fVerbose = 0;
+    Extra_UtilGetoptReset();
+    while ( ( c = Extra_UtilGetopt( argc, argv, "ABvh" ) ) != EOF )
+    {
+        switch ( c )
+        {
+        case 'A':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-A\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            A = (float)atof(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( A <= 0.0 )
+                goto usage;
+            break;
+        case 'B':
+            if ( globalUtilOptind >= argc )
+            {
+                Abc_Print( -1, "Command line switch \"-B\" should be followed by a floating point number.\n" );
+                goto usage;
+            }
+            B = (float)atof(argv[globalUtilOptind]);
+            globalUtilOptind++;
+            if ( B <= 0.0 )
+                goto usage;
+            break;
+        case 'v':
+            fVerbose ^= 1;
+            break;
+        case 'h':
+            goto usage;
+        default:
+            goto usage;
+        }
+    }
+    if ( pAbc->pLibScl == NULL )
+    {
+        fprintf( pAbc->Err, "There is no Liberty library available.\n" );
+        return 1;
+    }
+    // update the current library
+    Abc_SclConvertLeakageIntoArea( (SC_Lib *)pAbc->pLibScl, A, B );
+    return 0;
+
+usage:
+    fprintf( pAbc->Err, "usage: leak2area [-AB float] [-v]\n" );
+    fprintf( pAbc->Err, "\t           converts leakage into area: Area = A * Area + B * Leakage\n" );
+    fprintf( pAbc->Err, "\t-A float : the multiplicative coefficient to transform area [default = %.2f]\n", A );
+    fprintf( pAbc->Err, "\t-B float : the multiplicative coefficient to transform leakage [default = %.2f]\n", B );
+    fprintf( pAbc->Err, "\t-v       : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+    fprintf( pAbc->Err, "\t-h       : print the help massage\n" );
+    return 1;
+}
+
 
 
 /**Function*************************************************************
diff --git a/abc-build/src/map/scl/sclBufSize.c b/abc-build/src/map/scl/sclBufSize.c
--- a/abc-build/src/map/scl/sclBufSize.c
+++ b/abc-build/src/map/scl/sclBufSize.c
@@ -172,8 +172,6 @@
     float Load = Bus_SclObjLoad( pFanout );
     float Dept = Bus_SclObjDept( pFanout );
     float Edge = Scl_LibPinArrivalEstimate( Abc_SclObjCell(pFanout), iFanin, Slew, Load );
-//if ( Abc_ObjFaninNum(pFanout) == 0 )
-//printf( "Edge = %.2f\n", Edge );
     assert( Edge > 0 );
     return Dept + Edge;
 }
@@ -183,8 +181,12 @@
     int i;
     assert( Bus_SclObjDept(pObj) == 0 );
     Abc_ObjForEachFanout( pObj, pFanout, i )
-        if ( !Abc_ObjIsCo(pFanout) ) // add required times here
+    {
+        if ( Abc_ObjIsBarBuf(pFanout) )
+            Bus_SclObjUpdateDept( pObj, Bus_SclObjDept(pFanout) );
+        else if ( !Abc_ObjIsCo(pFanout) ) // add required times here
             Bus_SclObjUpdateDept( pObj, Abc_NtkComputeEdgeDept(pFanout, Abc_NodeFindFanin(pFanout, pObj), Slew) );
+    }
     return Bus_SclObjDept( pObj );
 }
 void Abc_NtkComputeFanoutInfo( Abc_Obj_t * pObj, float Slew )
@@ -192,12 +194,19 @@
     Abc_Obj_t * pFanout;
     int i;
     Abc_ObjForEachFanout( pObj, pFanout, i )
-        if ( !Abc_ObjIsCo(pFanout) )
+    {
+        if ( Abc_ObjIsBarBuf(pFanout) )
         {
+            Bus_SclObjSetETime( pFanout, Bus_SclObjDept(pFanout) );
+            Bus_SclObjSetCin( pFanout, Bus_SclObjLoad(pFanout) );
+        }
+        else if ( !Abc_ObjIsCo(pFanout) )
+        {
             int iFanin = Abc_NodeFindFanin(pFanout, pObj);
             Bus_SclObjSetETime( pFanout, Abc_NtkComputeEdgeDept(pFanout, iFanin, Slew) );
             Bus_SclObjSetCin( pFanout, SC_CellPinCap( Abc_SclObjCell(pFanout), iFanin ) );
         }
+    }
 }
 float Abc_NtkComputeNodeLoad( Bus_Man_t * p, Abc_Obj_t * pObj )
 {
@@ -407,10 +416,12 @@
         Abc_NtkComputeFanoutInfo( pObj, p->pPars->Slew );
         Load = Abc_NtkComputeNodeLoad( p, pObj );
         // consider the gate
-        if ( Abc_ObjIsCi(pObj) )
+        if ( Abc_ObjIsCi(pObj) || Abc_ObjIsBarBuf(pObj) )
         {
             pCell = p->pPiDrive;
-            Cin = SC_CellPinCapAve( pCell );
+            // if PI driver is not given, assume Cin to be equal to Load
+            // this way, buffering of the PIs is performed
+            Cin = pCell ? SC_CellPinCapAve(pCell) : Load;
         }
         else
         {
@@ -418,7 +429,7 @@
             Cin = SC_CellPinCapAve( pCell->pAve );
 //        Cin = SC_CellPinCapAve( pCell->pRepr->pNext );
         }
-        // consider upsizing the gate
+        // consider buffering this gate
         if ( !p->pPars->fSizeOnly && (Abc_ObjFanoutNum(pObj) > p->pPars->nDegree || Load > GainGate * Cin) )
         {
             // add one or more inverters
@@ -448,6 +459,8 @@
         if ( Abc_ObjIsCi(pObj) )
             continue;
         Abc_NtkComputeNodeDeparture( pObj, p->pPars->Slew );
+        if ( Abc_ObjIsBarBuf(pObj) )
+            continue;
         // create cell
         pCellNew = Abc_SclFindSmallestGate( pCell, Load / GainGate );
         Abc_SclObjSetCell( pObj, pCellNew );
diff --git a/abc-build/src/map/scl/sclBuffer.c b/abc-build/src/map/scl/sclBuffer.c
--- a/abc-build/src/map/scl/sclBuffer.c
+++ b/abc-build/src/map/scl/sclBuffer.c
@@ -296,6 +296,8 @@
             if ( !Abc_NodeIsTravIdCurrent( pFanin ) )
                 printf( "obj %d and its fanin %d are not in the topo order\n", Abc_ObjId(pObj), Abc_ObjId(pFanin) ), fFlag = 0;
         Abc_NodeSetTravIdCurrent( pObj );
+        if ( Abc_ObjIsBarBuf(pObj) )
+            continue;
         if ( Abc_ObjFanoutNum(pObj) == 0 )
             printf( "node %d has no fanout\n", Abc_ObjId(pObj) ), fFlag = 0;
         if ( !fFlag )
diff --git a/abc-build/src/map/scl/sclDnsize.c b/abc-build/src/map/scl/sclDnsize.c
--- a/abc-build/src/map/scl/sclDnsize.c
+++ b/abc-build/src/map/scl/sclDnsize.c
@@ -239,7 +239,7 @@
   SeeAlso     []
 
 ***********************************************************************/
-void Abc_SclDnsizePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, SC_SizePars * pPars )
+void Abc_SclDnsizePerformInt( SC_Lib * pLib, Abc_Ntk_t * pNtk, SC_SizePars * pPars )
 {
     SC_Man * p;
     Abc_Obj_t * pObj;
@@ -322,7 +322,7 @@
     Vec_IntFree( vEvals );
     Vec_IntFree( vTryLater );
     if ( !pPars->fVerbose )
-        printf( "                                                                                                                               \r" );
+        printf( "                                                                                                                                                  \r" );
 
     // report runtime
     p->timeTotal = Abc_Clock() - p->timeTotal;
@@ -344,6 +344,29 @@
     Abc_SclSclGates2MioGates( pLib, pNtk ); // updates gate pointers
     Abc_SclManFree( p );
 //    Abc_NtkCleanMarkAB( pNtk );
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Abc_SclDnsizePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, SC_SizePars * pPars )
+{
+    Abc_Ntk_t * pNtkNew = pNtk;
+    if ( pNtk->nBarBufs2 > 0 )
+        pNtkNew = Abc_NtkDupDfsNoBarBufs( pNtk );
+    Abc_SclDnsizePerformInt( pLib, pNtkNew, pPars );
+    if ( pNtk->nBarBufs2 > 0 )
+        Abc_SclTransferGates( pNtk, pNtkNew );
+    if ( pNtk->nBarBufs2 > 0 )
+        Abc_NtkDelete( pNtkNew );
 }
 
 ////////////////////////////////////////////////////////////////////////
diff --git a/abc-build/src/map/scl/sclLib.h b/abc-build/src/map/scl/sclLib.h
--- a/abc-build/src/map/scl/sclLib.h
+++ b/abc-build/src/map/scl/sclLib.h
@@ -40,7 +40,7 @@
 ///                         PARAMETERS                               ///
 ////////////////////////////////////////////////////////////////////////
 
-#define ABC_SCL_CUR_VERSION 7
+#define ABC_SCL_CUR_VERSION 8
 
 typedef enum  
 {
@@ -186,6 +186,7 @@
     int            seq;            // -- set to TRUE by parser if a sequential element
     int            unsupp;         // -- set to TRUE by parser if cell contains information we cannot handle
     float          area;
+    float          leakage;
     int            drive_strength; // -- some library files provide this field (currently unused, but may be a good hint for sizing) (not used)
     Vec_Ptr_t *    vPins;          // NamedSet<SC_Pin> 
     int            n_inputs;       // -- 'pins[0 .. n_inputs-1]' are input pins
@@ -231,6 +232,7 @@
 static inline float       SC_PairAve( SC_Pair * d )                 { return 0.5 * d->rise + 0.5 * d->fall;  }
 static inline void        SC_PairDup( SC_Pair * d, SC_Pair * s )    { *d = *s;                               }
 static inline void        SC_PairMove( SC_Pair * d, SC_Pair * s )   { *d = *s; s->rise = s->fall = 0;        }
+static inline void        SC_PairAdd( SC_Pair * d, SC_Pair * s )    { d->rise += s->rise; d->fall += s->fall;}
 static inline int         SC_PairEqual( SC_Pair * d, SC_Pair * s )  { return d->rise == s->rise && d->fall == s->fall;                }
 static inline int         SC_PairEqualE( SC_Pair * d, SC_Pair * s, float E )  { return d->rise - s->rise < E && s->rise - d->rise < E &&  d->fall - s->fall < E && s->fall - d->fall < E;    }
 
@@ -616,6 +618,7 @@
 extern int           Abc_SclLibClassNum( SC_Lib * pLib );
 extern void          Abc_SclLinkCells( SC_Lib * p );
 extern void          Abc_SclPrintCells( SC_Lib * p, float Slew, float Gain, int fInvOnly, int fShort );
+extern void          Abc_SclConvertLeakageIntoArea( SC_Lib * p, float A, float B );
 extern void          Abc_SclLibNormalize( SC_Lib * p );
 extern SC_Cell *     Abc_SclFindInvertor( SC_Lib * p, int fFindBuff );
 extern SC_Cell *     Abc_SclFindSmallestGate( SC_Cell * p, float CinMin );
diff --git a/abc-build/src/map/scl/sclLibScl.c b/abc-build/src/map/scl/sclLibScl.c
--- a/abc-build/src/map/scl/sclLibScl.c
+++ b/abc-build/src/map/scl/sclLibScl.c
@@ -132,6 +132,7 @@
 
         pCell->pName           = Vec_StrGetS(vOut, pPos);     
         pCell->area           = Vec_StrGetF(vOut, pPos);
+        pCell->leakage        = Vec_StrGetF(vOut, pPos);
         pCell->drive_strength = Vec_StrGetI(vOut, pPos);
 
         pCell->n_inputs       = Vec_StrGetI(vOut, pPos);
@@ -380,6 +381,7 @@
 
         Vec_StrPutS( vOut, pCell->pName );
         Vec_StrPutF( vOut, pCell->area );
+        Vec_StrPutF( vOut, pCell->leakage );
         Vec_StrPutI( vOut, pCell->drive_strength );
 
         // Write 'pins': (sorted at this point; first inputs, then outputs)
@@ -582,10 +584,11 @@
             continue;
 
         fprintf( s, "\n" );
-        fprintf( s, "  cell(%s) {\n", pCell->pName );
+        fprintf( s, "  cell(%s) {\n",                             pCell->pName );
         fprintf( s, "    /*  n_inputs = %d  n_outputs = %d */\n", pCell->n_inputs, pCell->n_outputs );
-        fprintf( s, "    area : %f;\n", pCell->area );
-        fprintf( s, "    drive_strength : %d;\n", pCell->drive_strength );
+        fprintf( s, "    area : %f;\n",                           pCell->area );
+        fprintf( s, "    cell_leakage_power : %f;\n",             pCell->leakage );
+        fprintf( s, "    drive_strength : %d;\n",                 pCell->drive_strength );
 
         SC_CellForEachPinIn( pCell, pPin, j )
         {
diff --git a/abc-build/src/map/scl/sclLibUtil.c b/abc-build/src/map/scl/sclLibUtil.c
--- a/abc-build/src/map/scl/sclLibUtil.c
+++ b/abc-build/src/map/scl/sclLibUtil.c
@@ -549,7 +549,8 @@
                 printf( " : " );
                 printf( "%-*s  ",           nLength, pCell->pName );
                 printf( "%2d   ",           pCell->drive_strength );
-                printf( "A =%8.2f    ",     pCell->area );
+                printf( "A =%8.2f  ",       pCell->area );
+                printf( "L =%8.2f  ",       pCell->leakage );
                 if ( pCell->n_outputs == 1 )
                 {
                     if ( Abc_SclComputeParametersCell( p, pCell, Slew, &LD, &PD ) )
@@ -568,6 +569,25 @@
         }
     }
 }
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Abc_SclConvertLeakageIntoArea( SC_Lib * p, float A, float B )
+{
+    SC_Cell * pCell; int i;
+    SC_LibForEachCell( p, pCell, i )
+        pCell->area = A * pCell->area + B * pCell->leakage;
+}
+
 
 /**Function*************************************************************
 
diff --git a/abc-build/src/map/scl/sclLiberty.c b/abc-build/src/map/scl/sclLiberty.c
--- a/abc-build/src/map/scl/sclLiberty.c
+++ b/abc-build/src/map/scl/sclLiberty.c
@@ -619,6 +619,23 @@
         return Scl_LibertyReadString(p, pArea->Head);
     return 0;
 }
+char * Scl_LibertyReadCellLeakage( Scl_Tree_t * p, Scl_Item_t * pCell )
+{
+    Scl_Item_t * pItem, * pChild;
+    Scl_ItemForEachChildName( p, pCell, pItem, "cell_leakage_power" )
+        return Scl_LibertyReadString(p, pItem->Head);
+    // look for another type
+    Scl_ItemForEachChildName( p, pCell, pItem, "leakage_power" )
+    {
+        Scl_ItemForEachChildName( p, pItem, pChild, "when" )
+            break;
+        if ( pChild && !Scl_LibertyCompare(p, pChild->Key, "when") )
+            continue;
+        Scl_ItemForEachChildName( p, pItem, pChild, "value" )
+            return Scl_LibertyReadString(p, pChild->Head);
+    }
+    return 0;
+}
 char * Scl_LibertyReadPinFormula( Scl_Tree_t * p, Scl_Item_t * pPin )
 {
     Scl_Item_t * pFunc;
@@ -1447,6 +1464,8 @@
         Vec_StrPutS_( vOut, Scl_LibertyReadString(p, pCell->Head) );
         pName = Scl_LibertyReadCellArea(p, pCell);
         Vec_StrPutF_( vOut, pName ? atof(pName) : 1 );
+        pName = Scl_LibertyReadCellLeakage(p, pCell);
+        Vec_StrPutF_( vOut, pName ? atof(pName) : 0 );
         Vec_StrPutI_( vOut, Scl_LibertyReadDeriveStrength(p, pCell) );
         // pin count
         nOutputs = Scl_LibertyReadCellOutputNum( p, pCell );
diff --git a/abc-build/src/map/scl/sclLoad.c b/abc-build/src/map/scl/sclLoad.c
--- a/abc-build/src/map/scl/sclLoad.c
+++ b/abc-build/src/map/scl/sclLoad.c
@@ -154,6 +154,15 @@
                 printf( "Maximum input drive strength is exceeded at primary input %d.\n", i );
         }
     }
+/*
+    // transfer load from barbufs
+    Abc_NtkForEachBarBuf( p->pNtk, pObj, i )
+    {
+        SC_Pair * pLoad = Abc_SclObjLoad( p, pObj );
+        SC_Pair * pLoadF = Abc_SclObjLoad( p, Abc_ObjFanin(pObj, 0) );
+        SC_PairAdd( pLoadF, pLoad );
+    }
+*/
     // calculate average load
 //    if ( p->EstLoadMax )
     {
diff --git a/abc-build/src/map/scl/sclSize.c b/abc-build/src/map/scl/sclSize.c
--- a/abc-build/src/map/scl/sclSize.c
+++ b/abc-build/src/map/scl/sclSize.c
@@ -668,7 +668,7 @@
   SeeAlso     []
 
 ***********************************************************************/
-void Abc_SclTimePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, int nTreeCRatio, int fUseWireLoads, int fShowAll, int fPrintPath, int fDumpStats )
+void Abc_SclTimePerformInt( SC_Lib * pLib, Abc_Ntk_t * pNtk, int nTreeCRatio, int fUseWireLoads, int fShowAll, int fPrintPath, int fDumpStats )
 {
     SC_Man * p;
     p = Abc_SclManStart( pLib, pNtk, fUseWireLoads, 1, 0, nTreeCRatio );
@@ -676,6 +676,27 @@
     if ( fDumpStats )
         Abc_SclDumpStats( p, "stats.txt", 0 );
     Abc_SclManFree( p );
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Abc_SclTimePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, int nTreeCRatio, int fUseWireLoads, int fShowAll, int fPrintPath, int fDumpStats )
+{
+    Abc_Ntk_t * pNtkNew = pNtk;
+    if ( pNtk->nBarBufs2 > 0 )
+        pNtkNew = Abc_NtkDupDfsNoBarBufs( pNtk );
+    Abc_SclTimePerformInt( pLib, pNtkNew, nTreeCRatio, fUseWireLoads, fShowAll, fPrintPath, fDumpStats );
+    if ( pNtk->nBarBufs2 > 0 )
+        Abc_NtkDelete( pNtkNew );
 }
 
 
diff --git a/abc-build/src/map/scl/sclSize.h b/abc-build/src/map/scl/sclSize.h
--- a/abc-build/src/map/scl/sclSize.h
+++ b/abc-build/src/map/scl/sclSize.h
@@ -106,7 +106,8 @@
 ////////////////////////////////////////////////////////////////////////
 
 static inline SC_Lib  * Abc_SclObjLib( Abc_Obj_t * p )                              { return (SC_Lib *)p->pNtk->pSCLib;    }
-static inline SC_Cell * Abc_SclObjCell( Abc_Obj_t * p )                             { return SC_LibCell( Abc_SclObjLib(p), Vec_IntEntry(p->pNtk->vGates, Abc_ObjId(p)) ); }
+static inline int       Abc_SclObjCellId( Abc_Obj_t * p )                           { return Vec_IntEntry( p->pNtk->vGates, Abc_ObjId(p) );                               }
+static inline SC_Cell * Abc_SclObjCell( Abc_Obj_t * p )                             { int c = Abc_SclObjCellId(p); return c == -1 ? NULL:SC_LibCell(Abc_SclObjLib(p), c); }
 static inline void      Abc_SclObjSetCell( Abc_Obj_t * p, SC_Cell * pCell )         { Vec_IntWriteEntry( p->pNtk->vGates, Abc_ObjId(p), pCell->Id );                      }
 
 static inline SC_Pair * Abc_SclObjLoad( SC_Man * p, Abc_Obj_t * pObj )              { return p->pLoads + Abc_ObjId(pObj);  }
@@ -429,7 +430,7 @@
 {
     Abc_Obj_t * pObj;
     int i, Count = 0;
-    Abc_NtkForEachNode( pNtk, pObj, i )
+    Abc_NtkForEachNodeNotBarBuf1( pNtk, pObj, i )
         Count += (Abc_ObjFaninNum(pObj) == 1);
     return Count;
 }
@@ -438,7 +439,7 @@
     Abc_Obj_t * pObj;
     double Total = 0;
     int i, Count = 0;
-    Abc_NtkForEachNode1( pNtk, pObj, i )
+    Abc_NtkForEachNodeNotBarBuf1( pNtk, pObj, i )
         Count++, Total += 100.0*Abc_SclObjCell(pObj)->Order/Abc_SclObjCell(pObj)->nGates;
     return (float)(Total / Count);
 }
@@ -447,7 +448,7 @@
     double Area = 0;
     Abc_Obj_t * pObj;
     int i;
-    Abc_NtkForEachNode1( pNtk, pObj, i )
+    Abc_NtkForEachNodeNotBarBuf1( pNtk, pObj, i )
         Area += Abc_SclObjCell(pObj)->area;
     return Area;
 }
@@ -576,9 +577,12 @@
 /*=== sclUtil.c ===============================================================*/
 extern void          Abc_SclMioGates2SclGates( SC_Lib * pLib, Abc_Ntk_t * p );
 extern void          Abc_SclSclGates2MioGates( SC_Lib * pLib, Abc_Ntk_t * p );
+extern void          Abc_SclTransferGates( Abc_Ntk_t * pOld, Abc_Ntk_t * pNew );
 extern void          Abc_SclPrintGateSizes( SC_Lib * pLib, Abc_Ntk_t * p );
 extern void          Abc_SclMinsizePerform( SC_Lib * pLib, Abc_Ntk_t * p, int fUseMax, int fVerbose );
 extern int           Abc_SclCountMinSize( SC_Lib * pLib, Abc_Ntk_t * p, int fUseMax );
+extern Vec_Int_t *   Abc_SclExtractBarBufs( Abc_Ntk_t * pNtk );
+extern void          Abc_SclInsertBarBufs( Abc_Ntk_t * pNtk, Vec_Int_t * vBufs );
 
 
 ABC_NAMESPACE_HEADER_END
diff --git a/abc-build/src/map/scl/sclUpsize.c b/abc-build/src/map/scl/sclUpsize.c
--- a/abc-build/src/map/scl/sclUpsize.c
+++ b/abc-build/src/map/scl/sclUpsize.c
@@ -844,7 +844,7 @@
     SC_Cell * pCell;
     Abc_Obj_t * pObj;
     int i;
-    Abc_NtkForEachNode( pNtk, pObj, i )
+    Abc_NtkForEachNodeNotBarBuf( pNtk, pObj, i )
         if ( Abc_ObjFanoutNum(pObj) == 0 )
         {
             pCell = Abc_SclObjCell( pObj );
@@ -865,7 +865,7 @@
   SeeAlso     []
 
 ***********************************************************************/
-void Abc_SclUpsizePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, SC_SizePars * pPars )
+void Abc_SclUpsizePerformInt( SC_Lib * pLib, Abc_Ntk_t * pNtk, SC_SizePars * pPars )
 {
     SC_Man * p;
     Vec_Int_t * vPathPos = NULL;    // critical POs
@@ -1011,6 +1011,29 @@
     Abc_SclSclGates2MioGates( pLib, pNtk ); // updates gate pointers
     Abc_SclManFree( p );
 //    Abc_NtkCleanMarkAB( pNtk );
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Abc_SclUpsizePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, SC_SizePars * pPars )
+{
+    Abc_Ntk_t * pNtkNew = pNtk;
+    if ( pNtk->nBarBufs2 > 0 )
+        pNtkNew = Abc_NtkDupDfsNoBarBufs( pNtk );
+    Abc_SclUpsizePerformInt( pLib, pNtkNew, pPars );
+    if ( pNtk->nBarBufs2 > 0 )
+        Abc_SclTransferGates( pNtk, pNtkNew );
+    if ( pNtk->nBarBufs2 > 0 )
+        Abc_NtkDelete( pNtkNew );
 }
 
 ////////////////////////////////////////////////////////////////////////
diff --git a/abc-build/src/map/scl/sclUtil.c b/abc-build/src/map/scl/sclUtil.c
--- a/abc-build/src/map/scl/sclUtil.c
+++ b/abc-build/src/map/scl/sclUtil.c
@@ -47,33 +47,40 @@
 void Abc_SclMioGates2SclGates( SC_Lib * pLib, Abc_Ntk_t * p )
 {
     Abc_Obj_t * pObj;
-    int i;
+    int i, gateId, bufferId;
+    // find buffer
+    if ( Mio_LibraryReadBuf((Mio_Library_t *)p->pManFunc) == NULL )
+    {
+        printf( "Cannot find buffer in the current library. Quitting.\n" );
+        return;
+    }
+    bufferId = Abc_SclCellFind( pLib, Mio_GateReadName(Mio_LibraryReadBuf((Mio_Library_t *)p->pManFunc)) );
+    assert( bufferId >= 0 );
+    // remap cells
     assert( p->vGates == NULL );
     p->vGates = Vec_IntStartFull( Abc_NtkObjNumMax(p) );
-    Abc_NtkForEachNode1( p, pObj, i )
+    Abc_NtkForEachNodeNotBarBuf1( p, pObj, i )
     {
-        char * pName = Mio_GateReadName((Mio_Gate_t *)pObj->pData);
-        int gateId = Abc_SclCellFind( pLib, pName );
+        gateId = Abc_SclCellFind( pLib, Mio_GateReadName((Mio_Gate_t *)pObj->pData) );
         assert( gateId >= 0 );
         Vec_IntWriteEntry( p->vGates, i, gateId );
-//printf( "Found gate %s\n", pName );
     }
     p->pSCLib = pLib;
 }
 void Abc_SclSclGates2MioGates( SC_Lib * pLib, Abc_Ntk_t * p )
 {
     Abc_Obj_t * pObj;
+    SC_Cell * pCell;
     int i, Counter = 0, CounterAll = 0;
     assert( p->vGates != NULL );
-    Abc_NtkForEachNode1( p, pObj, i )
+    Abc_NtkForEachNodeNotBarBuf1( p, pObj, i )
     {
-        SC_Cell * pCell = Abc_SclObjCell(pObj);
+        pCell = Abc_SclObjCell(pObj);
         assert( pCell->n_inputs == Abc_ObjFaninNum(pObj) );
         pObj->pData = Mio_LibraryReadGateByName( (Mio_Library_t *)p->pManFunc, pCell->pName, NULL );
         Counter += (pObj->pData == NULL);
         assert( pObj->fMarkA == 0 && pObj->fMarkB == 0 );
         CounterAll++;
-//printf( "Found gate %s\n", pCell->name );
     }
     if ( Counter )
         printf( "Could not find %d (out of %d) gates in the current library.\n", Counter, CounterAll );
@@ -83,6 +90,31 @@
 
 /**Function*************************************************************
 
+  Synopsis    [Transfer gate sizes from AIG without barbufs.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Abc_SclTransferGates( Abc_Ntk_t * pOld, Abc_Ntk_t * pNew )
+{
+    Abc_Obj_t * pObj; int i;
+    assert( pOld->nBarBufs2 > 0 );
+    assert( pNew->nBarBufs2 == 0 );
+    Abc_NtkForEachNodeNotBarBuf( pOld, pObj, i )
+    {
+        if ( pObj->pCopy == NULL )
+            continue;
+        assert( Abc_ObjNtk(pObj->pCopy) == pNew );
+        pObj->pData = pObj->pCopy->pData;
+    }
+}
+
+/**Function*************************************************************
+
   Synopsis    [Reports percentage of gates of each size.]
 
   Description []
@@ -96,11 +128,12 @@
 void Abc_SclManPrintGateSizes( SC_Lib * pLib, Abc_Ntk_t * p, Vec_Int_t * vGates )
 {
     Abc_Obj_t * pObj;
+    SC_Cell * pCell;
     int i, nGates = 0, Counters[ABC_SCL_MAX_SIZE] = {0};
     double TotArea = 0, Areas[ABC_SCL_MAX_SIZE] = {0};
-    Abc_NtkForEachNode1( p, pObj, i )
+    Abc_NtkForEachNodeNotBarBuf1( p, pObj, i )
     {
-        SC_Cell * pCell = SC_LibCell( pLib, Vec_IntEntry(vGates, Abc_ObjId(pObj)) );
+        pCell = SC_LibCell( pLib, Vec_IntEntry(vGates, Abc_ObjId(pObj)) );
         assert( pCell->Order < ABC_SCL_MAX_SIZE );
         Counters[pCell->Order]++;
         Areas[pCell->Order] += pCell->area;
@@ -124,6 +157,7 @@
 {
     Abc_SclMioGates2SclGates( pLib, p );
     Abc_SclManPrintGateSizes( pLib, p, p->vGates );
+    Abc_SclSclGates2MioGates( pLib, p );
     Vec_IntFreeP( &p->vGates );
     p->pSCLib = NULL;
 }
@@ -174,7 +208,7 @@
     int i, gateId;
     vMinCells = Abc_SclFindMinAreas( pLib, fUseMax );
     Abc_SclMioGates2SclGates( pLib, p );
-    Abc_NtkForEachNode1( p, pObj, i )
+    Abc_NtkForEachNodeNotBarBuf1( p, pObj, i )
     {
         gateId = Vec_IntEntry( p->vGates, i );
         assert( gateId >= 0 && gateId < Vec_PtrSize(pLib->vCells) );
@@ -191,7 +225,7 @@
     Abc_Obj_t * pObj;
     int i, gateId, Counter = 0;
     vMinCells = Abc_SclFindMinAreas( pLib, fUseMax );
-    Abc_NtkForEachNode1( p, pObj, i )
+    Abc_NtkForEachNodeNotBarBuf1( p, pObj, i )
     {
         gateId = Vec_IntEntry( p->vGates, i );
         Counter += ( gateId == Vec_IntEntry(vMinCells, gateId) );
@@ -236,6 +270,44 @@
             printf( "Unrecognized token \"%s\".\n", pToken );
     }
     fclose( pFile );
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Vec_Int_t * Abc_SclExtractBarBufs( Abc_Ntk_t * pNtk )
+{
+    Vec_Int_t * vBufs;
+    Mio_Gate_t * pBuffer;
+    Abc_Obj_t * pObj; int i;
+    pBuffer = Mio_LibraryReadBuf( (Mio_Library_t *)pNtk->pManFunc );
+    if ( pBuffer == NULL )
+    {
+        printf( "Cannot find buffer in the current library. Quitting.\n" );
+        return NULL;
+    }
+    vBufs = Vec_IntAlloc( 100 );
+    Abc_NtkForEachBarBuf( pNtk, pObj, i )
+    {
+        assert( pObj->pData == NULL );
+        pObj->pData = pBuffer;
+        Vec_IntPush( vBufs, i );
+    }
+    return vBufs;
+}
+void Abc_SclInsertBarBufs( Abc_Ntk_t * pNtk, Vec_Int_t * vBufs )
+{
+    Abc_Obj_t * pObj; int i;
+    Abc_NtkForEachObjVec( vBufs, pNtk, pObj, i )
+        pObj->pData = NULL;
 }
 
 ////////////////////////////////////////////////////////////////////////
diff --git a/abc-build/src/map/super/superWrite.c b/abc-build/src/map/super/superWrite.c
--- a/abc-build/src/map/super/superWrite.c
+++ b/abc-build/src/map/super/superWrite.c
@@ -35,7 +35,7 @@
 		GATENAME1( GATENAME2( a, c ), GATENAME3( a, d ), ... )
 		The gate names (GATENAME1, etc) are the names as they appear in the .genlib library.
 		The primary inputs of the gates are denoted by lowercase chars 'a', 'b', etc.
-		The parantheses are mandatory for each gate, except for the wire. 
+		The parentheses are mandatory for each gate, except for the wire. 
 		The wire name can be omitted, so that "a" can be used instead of "**wire**( a )".
 		The spaces are optional in any position of this string.
 
diff --git a/abc-build/src/misc/ext/ext.h b/abc-build/src/misc/ext/ext.h
deleted file mode 100644
--- a/abc-build/src/misc/ext/ext.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/**CFile****************************************************************
-
-  FileName    [ext.h]
-
-  SystemName  [ABC: Logic synthesis and verification system.]
-
-  PackageName []
-
-  Synopsis    [plugin for external functionality]
-
-  Author      [Alan Mishchenko]
-  
-  Affiliation [UC Berkeley]
-
-  Date        [Ver. 1.0. Started - June 20, 2005.]
-
-  Revision    [$Id: ext.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#ifndef ABC__misc__ext__ext_h
-#define ABC__misc__ext__ext_h
-
-#define EXT_ABC_FRAME
-#define EXT_ABC_INIT(pAbc)
-#define EXT_ABC_END(pAbc)
-    
-////////////////////////////////////////////////////////////////////////
-///                          INCLUDES                                ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-///                         PARAMETERS                               ///
-////////////////////////////////////////////////////////////////////////
-
-ABC_NAMESPACE_HEADER_START
-
-////////////////////////////////////////////////////////////////////////
-///                         BASIC TYPES                              ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-///                      MACRO DEFINITIONS                           ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-///                    FUNCTION DECLARATIONS                         ///
-////////////////////////////////////////////////////////////////////////
-
-ABC_NAMESPACE_HEADER_END
-
-#endif
-
-////////////////////////////////////////////////////////////////////////
-///                       END OF FILE                                ///
-////////////////////////////////////////////////////////////////////////
-
diff --git a/abc-build/src/misc/ext/module.make b/abc-build/src/misc/ext/module.make
deleted file mode 100644
--- a/abc-build/src/misc/ext/module.make
+++ /dev/null
diff --git a/abc-build/src/misc/extra/extra.h b/abc-build/src/misc/extra/extra.h
--- a/abc-build/src/misc/extra/extra.h
+++ b/abc-build/src/misc/extra/extra.h
@@ -103,7 +103,10 @@
 extern char *       Extra_FileNameAppend( char * pBase, char * pSuffix );
 extern char *       Extra_FileNameGeneric( char * FileName );
 extern char *       Extra_FileNameGenericAppend( char * pBase, char * pSuffix );
+extern void         Extra_FileNameCorrectPath( char * FileName );
 extern char *       Extra_FileNameWithoutPath( char * FileName );
+extern char *       Extra_FilePathWithoutName( char * FileName );
+extern char *       Extra_FileDesignName( char * pFileName );
 extern int          Extra_FileCheck( char * pFileName );
 extern int          Extra_FileSize( char * pFileName );
 extern char *       Extra_FileRead( FILE * pFile );
diff --git a/abc-build/src/misc/extra/extraBddKmap.c b/abc-build/src/misc/extra/extraBddKmap.c
--- a/abc-build/src/misc/extra/extraBddKmap.c
+++ b/abc-build/src/misc/extra/extraBddKmap.c
@@ -222,6 +222,8 @@
         fprintf( Output, "PrintKMap(): The on-set and the off-set overlap\n" );
         return;
     }
+    if ( nVars == 0 )
+        { printf( "Function is constant %d.\n", !Cudd_IsComplement(OnSet) ); return; }
 
     // print truth table for debugging
     if ( fPrintTruth )
diff --git a/abc-build/src/misc/extra/extraUtilFile.c b/abc-build/src/misc/extra/extraUtilFile.c
--- a/abc-build/src/misc/extra/extraUtilFile.c
+++ b/abc-build/src/misc/extra/extraUtilFile.c
@@ -192,8 +192,28 @@
         *pDot = 0;
     strcat( Buffer, pSuffix );
     return Buffer;
-}
+}
+
+/**Function*************************************************************
 
+  Synopsis    []
+
+  Description []
+
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Extra_FileNameCorrectPath( char * FileName )
+{
+    char * pStart;
+    if ( FileName )
+        for ( pStart = FileName; *pStart; pStart++ )
+            if ( *pStart == '>' || *pStart == '\\' )
+                *pStart = '/';
+}
+
 /**Function*************************************************************
 
   Synopsis    []
@@ -212,6 +232,39 @@
         if ( *pRes == '\\' || *pRes == '/' )
             return pRes + 1;
     return FileName;
+}
+char * Extra_FilePathWithoutName( char * FileName )
+{
+    char * pRes;
+    FileName = Abc_UtilStrsav( FileName );
+    for ( pRes = FileName + strlen(FileName) - 1; pRes >= FileName; pRes-- )
+        if ( *pRes == '\\' || *pRes == '/' )
+        {
+           *pRes = 0;
+           Extra_FileNameCorrectPath( FileName );
+           return FileName;
+        }
+    ABC_FREE( FileName );
+    return NULL;
+}
+char * Extra_FileDesignName( char * pFileName )
+{
+    char * pBeg, * pEnd, * pStore, * pCur;
+    // find the first dot
+    for ( pEnd = pFileName; *pEnd; pEnd++ )
+        if ( *pEnd == '.' )
+            break;
+    // find the first char
+    for ( pBeg = pEnd - 1; pBeg >= pFileName; pBeg-- )
+        if ( !((*pBeg >= 'a' && *pBeg <= 'z') || (*pBeg >= 'A' && *pBeg <= 'Z') || (*pBeg >= '0' && *pBeg <= '9') || *pBeg == '_') )
+            break;
+    pBeg++;
+    // fill up storage
+    pStore = ABC_ALLOC( char, pEnd - pBeg + 1 );
+    for ( pCur = pStore; pBeg < pEnd; pBeg++, pCur++ )
+        *pCur = *pBeg;
+    *pCur = 0;
+    return pStore;
 }
 
 /**Function*************************************************************
diff --git a/abc-build/src/misc/extra/extraUtilPrime.c b/abc-build/src/misc/extra/extraUtilPrime.c
new file mode 100644
--- /dev/null
+++ b/abc-build/src/misc/extra/extraUtilPrime.c
@@ -0,0 +1,124 @@
+/**CFile****************************************************************
+
+  FileName    [extraUtilPrime.c]
+
+  SystemName  [ABC: Logic synthesis and verification system.]
+
+  PackageName [extra]
+
+  Synopsis    [Function enumeration.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - June 20, 2005.]
+
+  Revision    [$Id: extraUtilPrime.c,v 1.0 2003/02/01 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include "misc/vec/vec.h"
+#include "misc/vec/vecHsh.h"
+#include "bool/kit/kit.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Abc_GenCountDump( Vec_Int_t * vPrimes, int nVars, char * pFileName )
+{
+    FILE * pFile;
+    int i, k, Prime;
+    pFile = fopen( pFileName, "wb" );
+    fprintf( pFile, "# %d prime numbers up to 2^%d generated by ABC on %s\n", Vec_IntSize(vPrimes), nVars, Extra_TimeStamp() );
+    fprintf( pFile, ".i %d\n", nVars );
+    fprintf( pFile, ".o %d\n", 1 );
+    fprintf( pFile, ".p %d\n", Vec_IntSize(vPrimes) );
+    Vec_IntForEachEntry( vPrimes, Prime, i )
+        for ( k = nVars-1; k >= 0; k-- )
+            fprintf( pFile, "%d%s", (Prime >> k)&1, k ? "" : " 1\n" );
+    fprintf( pFile, ".e\n\n" );
+    fclose( pFile );
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Abc_GenCountHits1( Vec_Bit_t * vMap, Vec_Int_t * vPrimes, int nVars )
+{
+    abctime clk = Abc_Clock();
+    int i, k, Prime, Count = 0;
+    Vec_IntForEachEntry( vPrimes, Prime, i )
+    {
+        for ( k = 0; k < nVars; k++ )
+            if ( !Vec_BitEntry(vMap, Prime ^ (1<<k)) )
+                Count++;
+    }
+    printf( "Dist1 pairs = %d. ", Count );
+    Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
+}
+Vec_Int_t * Abc_GenPrimes( int nVars )
+{
+    int i, n, nBits = ( 1 << nVars );
+    Vec_Bit_t * vMap = Vec_BitStart( nBits );
+    Vec_Int_t * vPrimes = Vec_IntAlloc( 1000 );
+    for ( n = 2; n < nBits; n++ )
+        if ( !Vec_BitEntry(vMap, n) )
+            for ( i = 2*n; i < nBits; i += n )
+                Vec_BitWriteEntry(vMap, i, 1);
+    for ( n = 2; n < nBits; n++ )
+        if ( !Vec_BitEntry(vMap, n) )
+            Vec_IntPush( vPrimes, n );
+    Abc_GenCountHits1( vMap, vPrimes, nVars );
+    Vec_BitFree( vMap );
+    return vPrimes;
+}
+void Abc_GenPrimesTest()
+{
+    // 54,400,028 primes up to 2^30 can be computed in 22 sec
+    int nVars = 18;
+    Vec_Int_t * vPrimes = Abc_GenPrimes( nVars );
+    Abc_GenCountDump( vPrimes, nVars, "primes18.pla" );
+    //Vec_IntPrint( vPrimes );
+    printf( "Primes up to 2^%d = %d\n", nVars, Vec_IntSize(vPrimes) );
+
+    Vec_IntFree( vPrimes );
+}
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/abc-build/src/misc/extra/extraUtilSupp.c b/abc-build/src/misc/extra/extraUtilSupp.c
--- a/abc-build/src/misc/extra/extraUtilSupp.c
+++ b/abc-build/src/misc/extra/extraUtilSupp.c
@@ -24,6 +24,7 @@
 #include <assert.h>
 #include "misc/vec/vec.h"
 #include "misc/vec/vecWec.h"
+#include "extra.h"
 
 ABC_NAMESPACE_IMPL_START
 
@@ -302,7 +303,6 @@
 ***********************************************************************/
 Vec_Wrd_t * Abc_SuppReadMin( char * pFileName, int * pnVars )
 {
-    extern char * Extra_FileReadContents( char * pFileName );
     Vec_Wrd_t * vRes; word uCube;
     int nCubes = 0, nVars = -1, iVar;
     char * pCur, * pToken, * pStart = "INPUT F-COVER";
@@ -402,7 +402,7 @@
 }
 int Abc_SuppFindVar( Vec_Wec_t * pS, Vec_Wec_t * pD, int nVars )
 {
-    int v, vBest = -1, dBest;
+    int v, vBest = -1, dBest = -1;
     for ( v = 0; v < nVars; v++ )
     {
         if ( Vec_WecLevelSize(pS, v) )
diff --git a/abc-build/src/misc/extra/extraUtilThresh.c b/abc-build/src/misc/extra/extraUtilThresh.c
new file mode 100644
--- /dev/null
+++ b/abc-build/src/misc/extra/extraUtilThresh.c
@@ -0,0 +1,333 @@
+/**CFile****************************************************************
+
+  FileName    [extraUtilThresh.c]
+
+  SystemName  [ABC: Logic synthesis and verification system.]
+
+  PackageName [extra]
+
+  Synopsis    [Dealing with threshold functions.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - October 7, 2014.]
+
+  Revision    [$Id: extraUtilThresh.c,v 1.0 2014/10/07 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "misc/vec/vec.h"
+#include "misc/util/utilTruth.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    [Checks thresholdness of the function.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Extra_ThreshPrintChow( int Chow0, int * pChow, int nVars )
+{
+    int i;
+    for ( i = 0; i < nVars; i++ )
+        printf( "%d ", pChow[i] );
+    printf( "  %d\n", Chow0 );
+}
+int Extra_ThreshComputeChow( word * t, int nVars, int * pChow )
+{
+    int i, k, Chow0 = 0, nMints = (1 << nVars);
+    memset( pChow, 0, sizeof(int) * nVars );
+    // compute Chow coefs
+    for ( i = 0; i < nMints; i++ )
+        if ( Abc_TtGetBit(t, i) )
+            for ( Chow0++, k = 0; k < nVars; k++ )
+                if ( (i >> k) & 1 )
+                    pChow[k]++;
+    // compute modified Chow coefs
+    for ( k = 0; k < nVars; k++ )
+        pChow[k] = 2 * pChow[k] - Chow0;
+    return Chow0 - (1 << (nVars-1));
+}
+void Extra_ThreshSortByChow( word * t, int nVars, int * pChow )
+{
+    int i, nWords = Abc_TtWordNum(nVars);
+    while ( 1 )
+    {
+        int fChange = 0;
+        for ( i = 0; i < nVars - 1; i++ )
+        {
+            if ( pChow[i] >= pChow[i+1] )
+                continue;
+            ABC_SWAP( int, pChow[i], pChow[i+1] );
+            Abc_TtSwapAdjacent( t, nWords, i );
+            fChange = 1;
+        }
+        if ( !fChange )
+            return;
+    }
+}
+static inline int Extra_ThreshWeightedSum( int * pW, int nVars, int m )
+{
+    int i, Cost = 0;
+    for ( i = 0; i < nVars; i++ )
+        if ( (m >> i) & 1 )
+            Cost += pW[i];
+    return Cost;
+}
+int Extra_ThreshSelectWeights3( word * t, int nVars, int * pW )
+{
+    int m, Lmin, Lmax, nMints = (1 << nVars);
+    assert( nVars == 3 );
+    for ( pW[2] = 1;     pW[2] <= nVars; pW[2]++ )
+    for ( pW[1] = pW[2]; pW[1] <= nVars; pW[1]++ )
+    for ( pW[0] = pW[1]; pW[0] <= nVars; pW[0]++ )
+    {
+        Lmin = 10000; Lmax = 0;
+        for ( m = 0; m < nMints; m++ )
+        {
+            if ( Abc_TtGetBit(t, m) )
+                Lmin = Abc_MinInt( Lmin, Extra_ThreshWeightedSum(pW, nVars, m) );
+            else
+                Lmax = Abc_MaxInt( Lmax, Extra_ThreshWeightedSum(pW, nVars, m) );
+            if ( Lmax >= Lmin )
+                break;
+//            printf( "%c%d ", Abc_TtGetBit(t, m) ? '+' : '-', Extra_ThreshWeightedSum(pW, nVars, m) );
+        }
+//        printf( "  -%d +%d\n", Lmax, Lmin );
+        if ( m < nMints )
+            continue;
+        assert( Lmax < Lmin );
+        return Lmin;
+    }
+    return 0;
+}
+int Extra_ThreshSelectWeights4( word * t, int nVars, int * pW )
+{
+    int m, Lmin, Lmax, nMints = (1 << nVars);
+    assert( nVars == 4 );
+    for ( pW[3] = 1;     pW[3] <= nVars; pW[3]++ )
+    for ( pW[2] = pW[3]; pW[2] <= nVars; pW[2]++ )
+    for ( pW[1] = pW[2]; pW[1] <= nVars; pW[1]++ )
+    for ( pW[0] = pW[1]; pW[0] <= nVars; pW[0]++ )
+    {
+        Lmin = 10000; Lmax = 0;
+        for ( m = 0; m < nMints; m++ )
+        {
+            if ( Abc_TtGetBit(t, m) )
+                Lmin = Abc_MinInt( Lmin, Extra_ThreshWeightedSum(pW, nVars, m) );
+            else
+                Lmax = Abc_MaxInt( Lmax, Extra_ThreshWeightedSum(pW, nVars, m) );
+            if ( Lmax >= Lmin )
+                break;
+        }
+        if ( m < nMints )
+            continue;
+        assert( Lmax < Lmin );
+        return Lmin;
+    }
+    return 0;
+}
+int Extra_ThreshSelectWeights5( word * t, int nVars, int * pW )
+{
+    int m, Lmin, Lmax, nMints = (1 << nVars), Limit = nVars + 0;
+    assert( nVars == 5 );
+    for ( pW[4] = 1;     pW[4] <= Limit; pW[4]++ )
+    for ( pW[3] = pW[4]; pW[3] <= Limit; pW[3]++ )
+    for ( pW[2] = pW[3]; pW[2] <= Limit; pW[2]++ )
+    for ( pW[1] = pW[2]; pW[1] <= Limit; pW[1]++ )
+    for ( pW[0] = pW[1]; pW[0] <= Limit; pW[0]++ )
+    {
+        Lmin = 10000; Lmax = 0;
+        for ( m = 0; m < nMints; m++ )
+        {
+            if ( Abc_TtGetBit(t, m) )
+                Lmin = Abc_MinInt( Lmin, Extra_ThreshWeightedSum(pW, nVars, m) );
+            else
+                Lmax = Abc_MaxInt( Lmax, Extra_ThreshWeightedSum(pW, nVars, m) );
+            if ( Lmax >= Lmin )
+                break;
+        }
+        if ( m < nMints )
+            continue;
+        assert( Lmax < Lmin );
+        return Lmin;
+    }
+    return 0;
+}
+int Extra_ThreshSelectWeights6( word * t, int nVars, int * pW )
+{
+    int m, Lmin, Lmax, nMints = (1 << nVars), Limit = nVars + 3;
+    assert( nVars == 6 );
+    for ( pW[5] = 1;     pW[5] <= Limit; pW[5]++ )
+    for ( pW[4] = pW[5]; pW[4] <= Limit; pW[4]++ )
+    for ( pW[3] = pW[4]; pW[3] <= Limit; pW[3]++ )
+    for ( pW[2] = pW[3]; pW[2] <= Limit; pW[2]++ )
+    for ( pW[1] = pW[2]; pW[1] <= Limit; pW[1]++ )
+    for ( pW[0] = pW[1]; pW[0] <= Limit; pW[0]++ )
+    {
+        Lmin = 10000; Lmax = 0;
+        for ( m = 0; m < nMints; m++ )
+        {
+            if ( Abc_TtGetBit(t, m) )
+                Lmin = Abc_MinInt( Lmin, Extra_ThreshWeightedSum(pW, nVars, m) );
+            else
+                Lmax = Abc_MaxInt( Lmax, Extra_ThreshWeightedSum(pW, nVars, m) );
+            if ( Lmax >= Lmin )
+                break;
+        }
+        if ( m < nMints )
+            continue;
+        assert( Lmax < Lmin );
+        return Lmin;
+    }
+    return 0;
+}
+int Extra_ThreshSelectWeights7( word * t, int nVars, int * pW )
+{
+    int m, Lmin, Lmax, nMints = (1 << nVars), Limit = nVars + 6;
+    assert( nVars == 7 );
+    for ( pW[6] = 1;     pW[6] <= Limit; pW[6]++ )
+    for ( pW[5] = pW[6]; pW[5] <= Limit; pW[5]++ )
+    for ( pW[4] = pW[5]; pW[4] <= Limit; pW[4]++ )
+    for ( pW[3] = pW[4]; pW[3] <= Limit; pW[3]++ )
+    for ( pW[2] = pW[3]; pW[2] <= Limit; pW[2]++ )
+    for ( pW[1] = pW[2]; pW[1] <= Limit; pW[1]++ )
+    for ( pW[0] = pW[1]; pW[0] <= Limit; pW[0]++ )
+    {
+        Lmin = 10000; Lmax = 0;
+        for ( m = 0; m < nMints; m++ )
+        {
+            if ( Abc_TtGetBit(t, m) )
+                Lmin = Abc_MinInt( Lmin, Extra_ThreshWeightedSum(pW, nVars, m) );
+            else
+                Lmax = Abc_MaxInt( Lmax, Extra_ThreshWeightedSum(pW, nVars, m) );
+            if ( Lmax >= Lmin )
+                break;
+        }
+        if ( m < nMints )
+            continue;
+        assert( Lmax < Lmin );
+        return Lmin;
+    }
+    return 0;
+}
+int Extra_ThreshSelectWeights8( word * t, int nVars, int * pW )
+{
+    int m, Lmin, Lmax, nMints = (1 << nVars), Limit = nVars + 1; // <<-- incomplete detection to save runtime!
+    assert( nVars == 8 );
+    for ( pW[7] = 1;     pW[7] <= Limit; pW[7]++ )
+    for ( pW[6] = pW[7]; pW[6] <= Limit; pW[6]++ )
+    for ( pW[5] = pW[6]; pW[5] <= Limit; pW[5]++ )
+    for ( pW[4] = pW[5]; pW[4] <= Limit; pW[4]++ )
+    for ( pW[3] = pW[4]; pW[3] <= Limit; pW[3]++ )
+    for ( pW[2] = pW[3]; pW[2] <= Limit; pW[2]++ )
+    for ( pW[1] = pW[2]; pW[1] <= Limit; pW[1]++ )
+    for ( pW[0] = pW[1]; pW[0] <= Limit; pW[0]++ )
+    {
+        Lmin = 10000; Lmax = 0;
+        for ( m = 0; m < nMints; m++ )
+        {
+            if ( Abc_TtGetBit(t, m) )
+                Lmin = Abc_MinInt( Lmin, Extra_ThreshWeightedSum(pW, nVars, m) );
+            else
+                Lmax = Abc_MaxInt( Lmax, Extra_ThreshWeightedSum(pW, nVars, m) );
+            if ( Lmax >= Lmin )
+                break;
+        }
+        if ( m < nMints )
+            continue;
+        assert( Lmax < Lmin );
+        return Lmin;
+    }
+    return 0;
+}
+int Extra_ThreshSelectWeights( word * t, int nVars, int * pW )
+{
+    if ( nVars <= 2 )
+        return (t[0] & 0xF) != 6 && (t[0] & 0xF) != 9;
+    if ( nVars == 3 )
+        return Extra_ThreshSelectWeights3( t, nVars, pW );
+    if ( nVars == 4 )
+        return Extra_ThreshSelectWeights4( t, nVars, pW );
+    if ( nVars == 5 )
+        return Extra_ThreshSelectWeights5( t, nVars, pW );
+    if ( nVars == 6 )
+        return Extra_ThreshSelectWeights6( t, nVars, pW );
+    if ( nVars == 7 )
+        return Extra_ThreshSelectWeights7( t, nVars, pW );
+    if ( nVars == 8 )
+        return Extra_ThreshSelectWeights8( t, nVars, pW );
+    return 0;
+}
+int Extra_ThreshCheck( word * t, int nVars, int * pW )
+{
+    int Chow0, Chow[16];
+    if ( !Abc_TtIsUnate(t, nVars) )
+        return 0;
+    Abc_TtMakePosUnate( t, nVars );
+    Chow0 = Extra_ThreshComputeChow( t, nVars, Chow );
+    Extra_ThreshSortByChow( t, nVars, Chow );
+    return Extra_ThreshSelectWeights( t, nVars, pW );
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Checks unateness of a function.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Extra_ThreshCheckTest()
+{
+    int nVars = 5;
+    int T, Chow0, Chow[16], Weights[16];
+//    word t =  s_Truths6[0] & s_Truths6[1] & s_Truths6[2] & s_Truths6[3] & s_Truths6[4];
+//    word t =  (s_Truths6[0] & s_Truths6[1]) | (s_Truths6[0] & s_Truths6[2] & s_Truths6[3]) | (s_Truths6[0] & s_Truths6[2] & s_Truths6[4]);
+    word t =  (s_Truths6[2] & s_Truths6[1]) | (s_Truths6[2] & s_Truths6[0] & s_Truths6[3]) | (s_Truths6[2] & s_Truths6[0] & ~s_Truths6[4]);
+//    word t =  (s_Truths6[0] & s_Truths6[1]) | (s_Truths6[0] & s_Truths6[2] & s_Truths6[3]) | (s_Truths6[0] & s_Truths6[2] & s_Truths6[4]) | (s_Truths6[1] & s_Truths6[2] & s_Truths6[3]);
+//    word t =  (s_Truths6[0] & s_Truths6[1]) | (s_Truths6[0] & s_Truths6[2]) | (s_Truths6[0] & s_Truths6[3] & s_Truths6[4] & s_Truths6[5]) | 
+//        (s_Truths6[1] & s_Truths6[2] & s_Truths6[3]) | (s_Truths6[1] & s_Truths6[2] & s_Truths6[4]) | (s_Truths6[1] & s_Truths6[2] & s_Truths6[5]);
+    int i;
+    assert( nVars <= 8 );
+    for ( i = 0; i < nVars; i++ )
+        printf( "%d %d %d\n", i, Abc_TtPosVar(&t, nVars, i), Abc_TtNegVar(&t, nVars, i) );
+//    word t = s_Truths6[0] & s_Truths6[1] & s_Truths6[2];
+    Chow0 = Extra_ThreshComputeChow( &t, nVars, Chow );
+    if ( (T = Extra_ThreshCheck(&t, nVars, Weights)) )
+        Extra_ThreshPrintChow( T, Weights, nVars );
+    else
+        printf( "No threshold\n" );
+}
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/abc-build/src/misc/extra/module.make b/abc-build/src/misc/extra/module.make
--- a/abc-build/src/misc/extra/module.make
+++ b/abc-build/src/misc/extra/module.make
@@ -18,5 +18,6 @@
 	src/misc/extra/extraUtilProgress.c \
 	src/misc/extra/extraUtilReader.c \
 	src/misc/extra/extraUtilSupp.c \
+	src/misc/extra/extraUtilThresh.c \
 	src/misc/extra/extraUtilTruth.c \
 	src/misc/extra/extraUtilUtil.c
diff --git a/abc-build/src/misc/tim/tim.h b/abc-build/src/misc/tim/tim.h
--- a/abc-build/src/misc/tim/tim.h
+++ b/abc-build/src/misc/tim/tim.h
@@ -114,7 +114,9 @@
 extern int             Tim_ManBoxForCi( Tim_Man_t * p, int iCo );
 extern int             Tim_ManBoxForCo( Tim_Man_t * p, int iCi );
 extern int             Tim_ManBoxInputFirst( Tim_Man_t * p, int iBox );
+extern int             Tim_ManBoxInputLast( Tim_Man_t * p, int iBox );
 extern int             Tim_ManBoxOutputFirst( Tim_Man_t * p, int iBox );
+extern int             Tim_ManBoxOutputLast( Tim_Man_t * p, int iBox );
 extern int             Tim_ManBoxInputNum( Tim_Man_t * p, int iBox );
 extern int             Tim_ManBoxOutputNum( Tim_Man_t * p, int iBox );
 extern int             Tim_ManBoxDelayTableId( Tim_Man_t * p, int iBox );
@@ -130,6 +132,7 @@
 extern Tim_Man_t *     Tim_ManStart( int nCis, int nCos );
 extern Tim_Man_t *     Tim_ManDup( Tim_Man_t * p, int fUnitDelay );
 extern Tim_Man_t *     Tim_ManTrim( Tim_Man_t * p, Vec_Int_t * vBoxPres );
+extern Tim_Man_t *     Tim_ManReduce( Tim_Man_t * p, Vec_Int_t * vBoxesLeft, int nTermsDiff );
 extern Vec_Int_t *     Tim_ManAlignTwo( Tim_Man_t * pSpec, Tim_Man_t * pImpl );
 extern void            Tim_ManCreate( Tim_Man_t * p, void * pLib, Vec_Flt_t * vInArrs, Vec_Flt_t * vOutReqs );
 extern float *         Tim_ManGetArrTimes( Tim_Man_t * p );
diff --git a/abc-build/src/misc/tim/timBox.c b/abc-build/src/misc/tim/timBox.c
--- a/abc-build/src/misc/tim/timBox.c
+++ b/abc-build/src/misc/tim/timBox.c
@@ -126,6 +126,22 @@
 
 /**Function*************************************************************
 
+  Synopsis    [Returns the last input of the box.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Tim_ManBoxInputLast( Tim_Man_t * p, int iBox )
+{
+    return Tim_ManBox(p, iBox)->Inouts[0] + Tim_ManBoxInputNum(p, iBox) - 1;
+}
+
+/**Function*************************************************************
+
   Synopsis    [Returns the first output of the box.]
 
   Description []
@@ -138,6 +154,22 @@
 int Tim_ManBoxOutputFirst( Tim_Man_t * p, int iBox )
 {
     return Tim_ManBox(p, iBox)->Inouts[Tim_ManBox(p, iBox)->nInputs];
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Returns the last output of the box.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Tim_ManBoxOutputLast( Tim_Man_t * p, int iBox )
+{
+    return Tim_ManBox(p, iBox)->Inouts[Tim_ManBox(p, iBox)->nInputs] + Tim_ManBoxOutputNum(p, iBox) - 1;
 }
 
 /**Function*************************************************************
diff --git a/abc-build/src/misc/tim/timMan.c b/abc-build/src/misc/tim/timMan.c
--- a/abc-build/src/misc/tim/timMan.c
+++ b/abc-build/src/misc/tim/timMan.c
@@ -239,6 +239,99 @@
 
 /**Function*************************************************************
 
+  Synopsis    [Reduces the timing manager.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Tim_Man_t * Tim_ManReduce( Tim_Man_t * p, Vec_Int_t * vBoxesLeft, int nTermsDiff )
+{
+    Tim_Man_t * pNew;
+    Tim_Box_t * pBox;
+    Tim_Obj_t * pObj;
+    float * pDelayTable, * pDelayTableNew;
+    int i, k, iBox, nNewCis, nNewCos, nInputs, nOutputs;
+    int nNewPiNum = Tim_ManPiNum(p) - nTermsDiff;
+    int nNewPoNum = Tim_ManPoNum(p) - nTermsDiff;
+    assert( Vec_IntSize(vBoxesLeft) <= Tim_ManBoxNum(p) );
+    // count the number of CIs and COs in the trimmed manager
+    nNewCis = nNewPiNum;
+    nNewCos = nNewPoNum;
+    Vec_IntForEachEntry( vBoxesLeft, iBox, i )
+    {
+        pBox = Tim_ManBox( p, iBox );
+        nNewCis += pBox->nOutputs;
+        nNewCos += pBox->nInputs;
+    }
+    assert( nNewCis <= Tim_ManCiNum(p) - nTermsDiff );
+    assert( nNewCos <= Tim_ManCoNum(p) - nTermsDiff );
+    // clear traversal IDs
+    Tim_ManForEachCi( p, pObj, i ) 
+        pObj->TravId = 0;          
+    Tim_ManForEachCo( p, pObj, i ) 
+        pObj->TravId = 0;          
+    // create new manager
+    pNew = Tim_ManStart( nNewCis, nNewCos );
+    // copy box connectivity information
+    memcpy( pNew->pCis, p->pCis, sizeof(Tim_Obj_t) * nNewPiNum );
+    memcpy( pNew->pCos + nNewCos - nNewPoNum, 
+            p->pCos + Tim_ManCoNum(p) - Tim_ManPoNum(p), 
+            sizeof(Tim_Obj_t) * nNewPoNum );
+    // duplicate delay tables
+    if ( Tim_ManDelayTableNum(p) > 0 )
+    {
+        int fWarning = 0;
+        pNew->vDelayTables = Vec_PtrStart( Vec_PtrSize(p->vDelayTables) );
+        Tim_ManForEachTable( p, pDelayTable, i )
+        {
+            if ( pDelayTable == NULL )
+                continue;
+            if ( i != (int)pDelayTable[0] && fWarning == 0 )
+            {
+                printf( "Warning: Mismatch in delay-table number between the manager and the box.\n" );
+                fWarning = 1;
+            }
+            //assert( i == (int)pDelayTable[0] );
+            nInputs   = (int)pDelayTable[1];
+            nOutputs  = (int)pDelayTable[2];
+            pDelayTableNew = ABC_ALLOC( float, 3 + nInputs * nOutputs );
+            pDelayTableNew[0] = i;//(int)pDelayTable[0];
+            pDelayTableNew[1] = (int)pDelayTable[1];
+            pDelayTableNew[2] = (int)pDelayTable[2];
+            for ( k = 0; k < nInputs * nOutputs; k++ )
+                pDelayTableNew[3+k] = pDelayTable[3+k];
+//            assert( (int)pDelayTableNew[0] == Vec_PtrSize(pNew->vDelayTables) );
+            assert( Vec_PtrEntry(pNew->vDelayTables, i) == NULL );
+            Vec_PtrWriteEntry( pNew->vDelayTables, i, pDelayTableNew );
+        }
+    }
+    // duplicate boxes
+    if ( Tim_ManBoxNum(p) > 0 )
+    {
+        int curPi = nNewPiNum;
+        int curPo = 0;
+        pNew->vBoxes = Vec_PtrAlloc( Tim_ManBoxNum(p) );
+        Vec_IntForEachEntry( vBoxesLeft, iBox, i )
+        {
+            pBox = Tim_ManBox( p, iBox );
+            Tim_ManCreateBox( pNew, curPo, pBox->nInputs, curPi, pBox->nOutputs, pBox->iDelayTable );
+            Tim_ManBoxSetCopy( pNew, Tim_ManBoxNum(pNew) - 1, iBox );
+            curPi += pBox->nOutputs;
+            curPo += pBox->nInputs;
+        }
+        curPo += nNewPoNum;
+        assert( curPi == Tim_ManCiNum(pNew) );
+        assert( curPo == Tim_ManCoNum(pNew) );
+    }
+    return pNew;
+}
+
+/**Function*************************************************************
+
   Synopsis    [Aligns two sets of boxes using the copy field.]
 
   Description []
@@ -316,11 +409,11 @@
     float * pTable;
     int i, k;
     assert( p->vDelayTables == NULL );
-    p->vDelayTables = Vec_PtrStart( Vec_PtrSize(pLibBox->vBoxes) );
+    p->vDelayTables = pLibBox ? Vec_PtrStart( Vec_PtrSize(pLibBox->vBoxes) ) : Vec_PtrAlloc( 100 );
     if ( p->vBoxes )
     Tim_ManForEachBox( p, pBox, i )
     {
-        if ( pBox->iDelayTable == -1 )
+        if ( pBox->iDelayTable == -1 || pLibBox == NULL )
         {
             // create table with constants
             pTable = ABC_ALLOC( float, 3 + pBox->nInputs * pBox->nOutputs );
@@ -445,10 +538,10 @@
         if ( pPrev->timeArr != pObj->timeArr || pPrev->timeReq != pObj->timeReq )
             break;
     if ( i == Tim_ManCiNum(p) )
-        printf( "All PIs :  arr = %5.3f  req = %5.3f\n", pPrev->timeArr, pPrev->timeReq );
+        printf( "All PIs     :  arrival = %5.3f  required = %5.3f\n", pPrev->timeArr, pPrev->timeReq );
     else
         Tim_ManForEachPi( p, pObj, i )
-            printf( "PI%5d :  arr = %5.3f  req = %5.3f\n", i, pObj->timeArr, pObj->timeReq );
+            printf( "PI%5d     :  arrival = %5.3f  required = %5.3f\n", i, pObj->timeArr, pObj->timeReq );
 
     // print CO info
     pPrev = p->pCos;
@@ -456,12 +549,12 @@
         if ( pPrev->timeArr != pObj->timeArr || pPrev->timeReq != pObj->timeReq )
             break;
     if ( i == Tim_ManCoNum(p) )
-        printf( "All POs :  arr = %5.3f  req = %5.3f\n", pPrev->timeArr, pPrev->timeReq );
+        printf( "All POs     :  arrival = %5.3f  required = %5.3f\n", pPrev->timeArr, pPrev->timeReq );
     else
     {
         int k = 0;
         Tim_ManForEachPo( p, pObj, i )
-            printf( "PO%5d :  arr = %5.3f  req = %5.3f\n", k++, pObj->timeArr, pObj->timeReq );
+            printf( "PO%5d     :  arrival = %5.3f  required = %5.3f\n", k++, pObj->timeArr, pObj->timeReq );
     }
 
     // print box info
@@ -479,10 +572,10 @@
             if ( pPrev->timeArr != pObj->timeArr || pPrev->timeReq != pObj->timeReq )
                 break;
         if ( k == Tim_ManBoxInputNum(p, pBox->iBox) )
-            printf( "Box inputs  :  arr = %5.3f  req = %5.3f\n", pPrev->timeArr, pPrev->timeReq );
+            printf( "Box inputs  :  arrival = %5.3f  required = %5.3f\n", pPrev->timeArr, pPrev->timeReq );
         else
             Tim_ManBoxForEachInput( p, pBox, pObj, k )
-                printf( "box-in%4d :  arr = %5.3f  req = %5.3f\n", k, pObj->timeArr, pObj->timeReq );
+                printf( "box-in%4d :  arrival = %5.3f  required = %5.3f\n", k, pObj->timeArr, pObj->timeReq );
 
         // print box outputs
         pPrev = Tim_ManBoxOutput( p, pBox, 0 );
@@ -490,10 +583,10 @@
             if ( pPrev->timeArr != pObj->timeArr || pPrev->timeReq != pObj->timeReq )
                 break;
         if ( k == Tim_ManBoxOutputNum(p, pBox->iBox) )
-            printf( "Box outputs :  arr = %5.3f  req = %5.3f\n", pPrev->timeArr, pPrev->timeReq );
+            printf( "Box outputs :  arrival = %5.3f  required = %5.3f\n", pPrev->timeArr, pPrev->timeReq );
         else
             Tim_ManBoxForEachOutput( p, pBox, pObj, k )
-                printf( "box-out%3d :  arr = %5.3f  req = %5.3f\n", k, pObj->timeArr, pObj->timeReq );
+                printf( "box-out%3d :  arrival = %5.3f  required = %5.3f\n", k, pObj->timeArr, pObj->timeReq );
 
         if ( i > 2 )
             break;
diff --git a/abc-build/src/misc/util/abc_global.h b/abc-build/src/misc/util/abc_global.h
--- a/abc-build/src/misc/util/abc_global.h
+++ b/abc-build/src/misc/util/abc_global.h
@@ -80,6 +80,7 @@
 #include <time.h>
 #include <stdarg.h>
 #include <stdlib.h>
+#include <assert.h>
 
 ////////////////////////////////////////////////////////////////////////
 ///                         NAMESPACES                               ///
@@ -253,6 +254,7 @@
 static inline int      Abc_Base16Log( unsigned n )            { int r; if ( n < 2 ) return n; for ( r = 0, n--; n; n /= 16, r++ ) {}; return r; }
 static inline char *   Abc_UtilStrsav( char * s )             { return s ? strcpy(ABC_ALLOC(char, strlen(s)+1), s) : NULL;  }
 static inline int      Abc_BitWordNum( int nBits )            { return (nBits>>5) + ((nBits&31) > 0);                       }
+static inline int      Abc_Bit6WordNum( int nBits )           { return (nBits>>6) + ((nBits&63) > 0);                       }
 static inline int      Abc_TruthWordNum( int nVars )          { return nVars <= 5 ? 1 : (1 << (nVars - 5));                 }
 static inline int      Abc_Truth6WordNum( int nVars )         { return nVars <= 6 ? 1 : (1 << (nVars - 6));                 }
 static inline int      Abc_InfoHasBit( unsigned * p, int i )  { return (p[(i)>>5] & (1<<((i) & 31))) > 0;                   }
@@ -260,15 +262,29 @@
 static inline void     Abc_InfoXorBit( unsigned * p, int i )  { p[(i)>>5] ^= (1<<((i) & 31));                               }
 static inline unsigned Abc_InfoMask( int nVar )               { return (~(unsigned)0) >> (32-nVar);                         }
 
-static inline int      Abc_Var2Lit( int Var, int fCompl )     { return Var + Var + fCompl; }
-static inline int      Abc_Lit2Var( int Lit )                 { return Lit >> 1;           }
-static inline int      Abc_LitIsCompl( int Lit )              { return Lit & 1;            }
-static inline int      Abc_LitNot( int Lit )                  { return Lit ^ 1;            }
-static inline int      Abc_LitNotCond( int Lit, int c )       { return Lit ^ (int)(c > 0); }
-static inline int      Abc_LitRegular( int Lit )              { return Lit & ~01;          }
-static inline int      Abc_Lit2LitV( int * pMap, int Lit )    { return Abc_Var2Lit( pMap[Abc_Lit2Var(Lit)], Abc_LitIsCompl(Lit) );   }
-static inline int      Abc_Lit2LitL( int * pMap, int Lit )    { return Abc_LitNotCond( pMap[Abc_Lit2Var(Lit)], Abc_LitIsCompl(Lit) );   }
-
+static inline int      Abc_Var2Lit( int Var, int c )          { assert(Var >= 0 && !(c >> 1)); return Var + Var + c;        }
+static inline int      Abc_Lit2Var( int Lit )                 { assert(Lit >= 0); return Lit >> 1;                          }
+static inline int      Abc_LitIsCompl( int Lit )              { assert(Lit >= 0); return Lit & 1;                           }
+static inline int      Abc_LitNot( int Lit )                  { assert(Lit >= 0); return Lit ^ 1;                           }
+static inline int      Abc_LitNotCond( int Lit, int c )       { assert(Lit >= 0); return Lit ^ (int)(c > 0);                }
+static inline int      Abc_LitRegular( int Lit )              { assert(Lit >= 0); return Lit & ~01;                         }
+static inline int      Abc_Lit2LitV( int * pMap, int Lit )    { assert(Lit >= 0); return Abc_Var2Lit( pMap[Abc_Lit2Var(Lit)], Abc_LitIsCompl(Lit) );      }
+static inline int      Abc_Lit2LitL( int * pMap, int Lit )    { assert(Lit >= 0); return Abc_LitNotCond( pMap[Abc_Lit2Var(Lit)], Abc_LitIsCompl(Lit) );   }
+
+static inline int      Abc_Ptr2Int( void * p )                { return (int)(ABC_PTRINT_T)p;      }
+static inline void *   Abc_Int2Ptr( int i )                   { return (void *)(ABC_PTRINT_T)i;   }
+static inline word     Abc_Ptr2Wrd( void * p )                { return (word)(ABC_PTRUINT_T)p;    }
+static inline void *   Abc_Wrd2Ptr( word i )                  { return (void *)(ABC_PTRUINT_T)i;  }
+
+static inline int      Abc_Var2Lit2( int Var, int Att )       { assert(!(Att >> 2)); return (Var << 2) + Att; }
+static inline int      Abc_Lit2Var2( int Lit )                { assert(Lit >= 0);    return Lit >> 2;         }
+static inline int      Abc_Lit2Att2( int Lit )                { assert(Lit >= 0);    return Lit & 3;          }
+static inline int      Abc_Var2Lit3( int Var, int Att )       { assert(!(Att >> 3)); return (Var << 3) + Att; }
+static inline int      Abc_Lit2Var3( int Lit )                { assert(Lit >= 0);    return Lit >> 3;         }
+static inline int      Abc_Lit2Att3( int Lit )                { assert(Lit >= 0);    return Lit & 7;          }
+static inline int      Abc_Var2Lit4( int Var, int Att )       { assert(!(Att >> 4)); return (Var << 4) + Att; }
+static inline int      Abc_Lit2Var4( int Lit )                { assert(Lit >= 0);    return Lit >> 4;         }
+static inline int      Abc_Lit2Att4( int Lit )                { assert(Lit >= 0);    return Lit & 15;         }
 
 // time counting
 typedef ABC_INT64_T abctime;
diff --git a/abc-build/src/misc/util/module.make b/abc-build/src/misc/util/module.make
--- a/abc-build/src/misc/util/module.make
+++ b/abc-build/src/misc/util/module.make
@@ -2,6 +2,7 @@
 	src/misc/util/utilCex.c \
 	src/misc/util/utilColor.c \
 	src/misc/util/utilFile.c \
+	src/misc/util/utilIsop.c \
 	src/misc/util/utilNam.c \
 	src/misc/util/utilSignal.c \
 	src/misc/util/utilSort.c
diff --git a/abc-build/src/misc/util/utilFile.c b/abc-build/src/misc/util/utilFile.c
--- a/abc-build/src/misc/util/utilFile.c
+++ b/abc-build/src/misc/util/utilFile.c
@@ -26,7 +26,7 @@
 #include <sys/stat.h>
 
 #if defined(_MSC_VER) || defined(__MINGW32__)
-#include <Windows.h>
+#include <windows.h>
 #include <process.h>
 #include <io.h>
 #else
diff --git a/abc-build/src/misc/util/utilIsop.c b/abc-build/src/misc/util/utilIsop.c
new file mode 100644
--- /dev/null
+++ b/abc-build/src/misc/util/utilIsop.c
@@ -0,0 +1,1139 @@
+/**CFile****************************************************************
+
+  FileName    [utilIsop.c]
+
+  SystemName  [ABC: Logic synthesis and verification system.]
+
+  PackageName [ISOP computation.]
+
+  Synopsis    [ISOP computation.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - October 4, 2014.]
+
+  Revision    [$Id: utilIsop.c,v 1.00 2014/10/04 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "misc/vec/vec.h"
+#include "misc/util/utilTruth.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+#define ABC_ISOP_MAX_VAR  16
+#define ABC_ISOP_MAX_WORD (ABC_ISOP_MAX_VAR > 6 ? (1 << (ABC_ISOP_MAX_VAR-6)) : 1)
+#define ABC_ISOP_MAX_CUBE  0xFFFF
+
+typedef word FUNC_ISOP( word *, word *, word *, word, int * );
+
+static FUNC_ISOP Abc_Isop7Cover; 
+static FUNC_ISOP Abc_Isop8Cover;
+static FUNC_ISOP Abc_Isop9Cover; 
+static FUNC_ISOP Abc_Isop10Cover;
+static FUNC_ISOP Abc_Isop11Cover;
+static FUNC_ISOP Abc_Isop12Cover;
+static FUNC_ISOP Abc_Isop13Cover;
+static FUNC_ISOP Abc_Isop14Cover;
+static FUNC_ISOP Abc_Isop15Cover;
+static FUNC_ISOP Abc_Isop16Cover;
+
+static FUNC_ISOP * s_pFuncIsopCover[17] =
+{
+    NULL, // 0
+    NULL, // 1
+    NULL, // 2
+    NULL, // 3
+    NULL, // 4
+    NULL, // 5
+    NULL, // 6
+    Abc_Isop7Cover,  // 7
+    Abc_Isop8Cover,  // 8
+    Abc_Isop9Cover,  // 9
+    Abc_Isop10Cover, // 10
+    Abc_Isop11Cover, // 11
+    Abc_Isop12Cover, // 12
+    Abc_Isop13Cover, // 13
+    Abc_Isop14Cover, // 14
+    Abc_Isop15Cover, // 15
+    Abc_Isop16Cover  // 16
+};
+
+extern word Abc_IsopCheck( word * pOn, word * pOnDc, word * pRes, int nVars, word CostLim, int * pCover );
+extern word Abc_EsopCheck( word * pOn,                            int nVars, word CostLim, int * pCover );
+
+static inline word Abc_Cube2Cost( int nCubes )    { return (word)nCubes << 32;       }
+static inline int  Abc_CostCubes( word Cost )     { return (int)(Cost >> 32);        }
+static inline int  Abc_CostLits( word Cost )      { return (int)(Cost & 0xFFFFFFFF); }
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    [These procedures assume that function has exact support.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline void Abc_IsopAddLits( int * pCover, word Cost0, word Cost1, int Var )
+{
+    if ( pCover ) 
+    {
+        int c, nCubes0, nCubes1;
+        nCubes0 = Abc_CostCubes( Cost0 );
+        nCubes1 = Abc_CostCubes( Cost1 );
+        for ( c = 0; c < nCubes0; c++ )
+            pCover[c] |= (1 << Abc_Var2Lit(Var,0));
+        for ( c = 0; c < nCubes1; c++ )
+            pCover[nCubes0+c] |= (1 << Abc_Var2Lit(Var,1));
+    }
+}
+word Abc_Isop6Cover( word uOn, word uOnDc, word * pRes, int nVars, word CostLim, int * pCover )
+{
+    word uOn0, uOn1, uOnDc0, uOnDc1, uRes0, uRes1, uRes2;
+    word Cost0, Cost1, Cost2;  int Var; 
+    assert( nVars <= 6 );
+    assert( (uOn & ~uOnDc) == 0 );
+    if ( uOn == 0 )
+    {
+        pRes[0] = 0;
+        return 0;
+    }
+    if ( uOnDc == ~(word)0 )
+    {
+        pRes[0] = ~(word)0;
+        if ( pCover ) pCover[0] = 0;
+        return Abc_Cube2Cost(1);
+    }
+    assert( nVars > 0 );
+    // find the topmost var
+    for ( Var = nVars-1; Var >= 0; Var-- )
+        if ( Abc_Tt6HasVar( uOn, Var ) || Abc_Tt6HasVar( uOnDc, Var ) )
+             break;
+    assert( Var >= 0 );
+    // cofactor
+    uOn0   = Abc_Tt6Cofactor0( uOn,   Var );
+    uOn1   = Abc_Tt6Cofactor1( uOn  , Var );
+    uOnDc0 = Abc_Tt6Cofactor0( uOnDc, Var );
+    uOnDc1 = Abc_Tt6Cofactor1( uOnDc, Var );
+    // solve for cofactors
+    Cost0 = Abc_Isop6Cover( uOn0 & ~uOnDc1, uOnDc0, &uRes0, Var, CostLim, pCover );
+    if ( Cost0 >= CostLim ) return CostLim;
+    Cost1 = Abc_Isop6Cover( uOn1 & ~uOnDc0, uOnDc1, &uRes1, Var, CostLim, pCover ? pCover + Abc_CostCubes(Cost0) : NULL );
+    if ( Cost0 + Cost1 >= CostLim ) return CostLim;
+    Cost2 = Abc_Isop6Cover( (uOn0 & ~uRes0) | (uOn1 & ~uRes1), uOnDc0 & uOnDc1, &uRes2, Var, CostLim, pCover ? pCover + Abc_CostCubes(Cost0) + Abc_CostCubes(Cost1) : NULL );
+    if ( Cost0 + Cost1 + Cost2 >= CostLim ) return CostLim;
+    // derive the final truth table
+    *pRes = uRes2 | (uRes0 & s_Truths6Neg[Var]) | (uRes1 & s_Truths6[Var]);
+    assert( (uOn & ~*pRes) == 0 && (*pRes & ~uOnDc) == 0 );
+    Abc_IsopAddLits( pCover, Cost0, Cost1, Var );
+    return Cost0 + Cost1 + Cost2 + Abc_CostCubes(Cost0) + Abc_CostCubes(Cost1);
+}
+word Abc_Isop7Cover( word * pOn, word * pOnDc, word * pRes, word CostLim, int * pCover )
+{
+    word uOn0, uOn1, uOn2, uOnDc2, uRes0, uRes1, uRes2;
+    word Cost0, Cost1, Cost2;  int nVars = 6; 
+    assert( (pOn[0] & ~pOnDc[0]) == 0 );
+    assert( (pOn[1] & ~pOnDc[1]) == 0 );
+    // cofactor
+    uOn0 = pOn[0] & ~pOnDc[1];
+    uOn1 = pOn[1] & ~pOnDc[0];
+    // solve for cofactors
+    Cost0 = Abc_IsopCheck( &uOn0, pOnDc,   &uRes0, nVars, CostLim, pCover );
+    if ( Cost0 >= CostLim ) return CostLim;
+    Cost1 = Abc_IsopCheck( &uOn1, pOnDc+1, &uRes1, nVars, CostLim, pCover ? pCover + Abc_CostCubes(Cost0) : NULL );
+    if ( Cost0 + Cost1 >= CostLim ) return CostLim;
+    uOn2 = (pOn[0] & ~uRes0) | (pOn[1] & ~uRes1);
+    uOnDc2 = pOnDc[0] & pOnDc[1];
+    Cost2 = Abc_IsopCheck( &uOn2, &uOnDc2,  &uRes2, nVars, CostLim, pCover ? pCover + Abc_CostCubes(Cost0) + Abc_CostCubes(Cost1) : NULL );
+    if ( Cost0 + Cost1 + Cost2 >= CostLim ) return CostLim;
+    // derive the final truth table
+    pRes[0] = uRes2 | uRes0;
+    pRes[1] = uRes2 | uRes1;
+    assert( (pOn[0] & ~pRes[0]) == 0 && (pRes[0] & ~pOnDc[0]) == 0 );
+    assert( (pOn[1] & ~pRes[1]) == 0 && (pRes[1] & ~pOnDc[1]) == 0 );
+    Abc_IsopAddLits( pCover, Cost0, Cost1, nVars );
+    return Cost0 + Cost1 + Cost2 + Abc_CostCubes(Cost0) + Abc_CostCubes(Cost1);
+}
+word Abc_Isop8Cover( word * pOn, word * pOnDc, word * pRes, word CostLim, int * pCover )
+{
+    word uOn2[2], uOnDc2[2], uRes0[2], uRes1[2], uRes2[2];
+    word Cost0, Cost1, Cost2;  int nVars = 7;
+    // negative cofactor
+    uOn2[0] = pOn[0] & ~pOnDc[2];
+    uOn2[1] = pOn[1] & ~pOnDc[3];
+    Cost0 = Abc_IsopCheck( uOn2, pOnDc,   uRes0, nVars, CostLim, pCover );
+    if ( Cost0 >= CostLim ) return CostLim;
+    // positive cofactor
+    uOn2[0] = pOn[2] & ~pOnDc[0];
+    uOn2[1] = pOn[3] & ~pOnDc[1];
+    Cost1 = Abc_IsopCheck( uOn2, pOnDc+2, uRes1, nVars, CostLim, pCover ? pCover + Abc_CostCubes(Cost0) : NULL );
+    if ( Cost0 + Cost1 >= CostLim ) return CostLim;
+    // middle cofactor
+    uOn2[0] = (pOn[0] & ~uRes0[0]) | (pOn[2] & ~uRes1[0]); uOnDc2[0] = pOnDc[0] & pOnDc[2];
+    uOn2[1] = (pOn[1] & ~uRes0[1]) | (pOn[3] & ~uRes1[1]); uOnDc2[1] = pOnDc[1] & pOnDc[3];
+    Cost2 = Abc_IsopCheck( uOn2, uOnDc2,  uRes2, nVars, CostLim, pCover ? pCover + Abc_CostCubes(Cost0) + Abc_CostCubes(Cost1) : NULL );
+    if ( Cost0 + Cost1 + Cost2 >= CostLim ) return CostLim;
+    // derive the final truth table
+    pRes[0] = uRes2[0] | uRes0[0];
+    pRes[1] = uRes2[1] | uRes0[1];
+    pRes[2] = uRes2[0] | uRes1[0];
+    pRes[3] = uRes2[1] | uRes1[1];
+    assert( (pOn[0] & ~pRes[0]) == 0 && (pOn[1] & ~pRes[1]) == 0 && (pOn[2] & ~pRes[2]) == 0 && (pOn[3] & ~pRes[3]) == 0 );
+    assert( (pRes[0] & ~pOnDc[0])==0 && (pRes[1] & ~pOnDc[1])==0 && (pRes[2] & ~pOnDc[2])==0 && (pRes[3] & ~pOnDc[3])==0 );
+    Abc_IsopAddLits( pCover, Cost0, Cost1, nVars );
+    return Cost0 + Cost1 + Cost2 + Abc_CostCubes(Cost0) + Abc_CostCubes(Cost1);
+}
+word Abc_Isop9Cover( word * pOn, word * pOnDc, word * pRes, word CostLim, int * pCover )
+{
+    word uOn2[4], uOnDc2[4], uRes0[4], uRes1[4], uRes2[4];
+    word Cost0, Cost1, Cost2; int c, nVars = 8, nWords = 4;
+    // negative cofactor
+    for ( c = 0; c < nWords; c++ )
+        uOn2[c] = pOn[c] & ~pOnDc[c+nWords];
+    Cost0 = Abc_IsopCheck( uOn2, pOnDc,        uRes0, nVars, CostLim, pCover );
+    if ( Cost0 >= CostLim ) return CostLim;
+    // positive cofactor
+    for ( c = 0; c < nWords; c++ )
+        uOn2[c] = pOn[c+nWords] & ~pOnDc[c];
+    Cost1 = Abc_IsopCheck( uOn2, pOnDc+nWords, uRes1, nVars, CostLim, pCover ? pCover + Abc_CostCubes(Cost0) : NULL );
+    if ( Cost0 + Cost1 >= CostLim ) return CostLim;
+    // middle cofactor
+    for ( c = 0; c < nWords; c++ )
+        uOn2[c] = (pOn[c] & ~uRes0[c]) | (pOn[c+nWords] & ~uRes1[c]), uOnDc2[c] = pOnDc[c] & pOnDc[c+nWords];
+    Cost2 = Abc_IsopCheck( uOn2, uOnDc2,       uRes2, nVars, CostLim, pCover ? pCover + Abc_CostCubes(Cost0) + Abc_CostCubes(Cost1) : NULL );
+    if ( Cost0 + Cost1 + Cost2 >= CostLim ) return CostLim;
+    // derive the final truth table
+    for ( c = 0; c < nWords; c++ )
+        pRes[c] = uRes2[c] | uRes0[c], pRes[c+nWords] = uRes2[c] | uRes1[c];
+    // verify
+    for ( c = 0; c < (nWords<<1); c++ )
+        assert( (pOn[c]  & ~pRes[c] ) == 0 && (pRes[c] & ~pOnDc[c]) == 0 );
+    Abc_IsopAddLits( pCover, Cost0, Cost1, nVars );
+    return Cost0 + Cost1 + Cost2 + Abc_CostCubes(Cost0) + Abc_CostCubes(Cost1);
+}
+word Abc_Isop10Cover( word * pOn, word * pOnDc, word * pRes, word CostLim, int * pCover )
+{
+    word uOn2[8], uOnDc2[8], uRes0[8], uRes1[8], uRes2[8];
+    word Cost0, Cost1, Cost2; int c, nVars = 9, nWords = 8;
+    // negative cofactor
+    for ( c = 0; c < nWords; c++ )
+        uOn2[c] = pOn[c] & ~pOnDc[c+nWords];
+    Cost0 = Abc_IsopCheck( uOn2, pOnDc,        uRes0, nVars, CostLim, pCover );
+    if ( Cost0 >= CostLim ) return CostLim;
+    // positive cofactor
+    for ( c = 0; c < nWords; c++ )
+        uOn2[c] = pOn[c+nWords] & ~pOnDc[c];
+    Cost1 = Abc_IsopCheck( uOn2, pOnDc+nWords, uRes1, nVars, CostLim, pCover ? pCover + Abc_CostCubes(Cost0) : NULL );
+    if ( Cost0 + Cost1 >= CostLim ) return CostLim;
+    // middle cofactor
+    for ( c = 0; c < nWords; c++ )
+        uOn2[c] = (pOn[c] & ~uRes0[c]) | (pOn[c+nWords] & ~uRes1[c]), uOnDc2[c] = pOnDc[c] & pOnDc[c+nWords];
+    Cost2 = Abc_IsopCheck( uOn2, uOnDc2,       uRes2, nVars, CostLim, pCover ? pCover + Abc_CostCubes(Cost0) + Abc_CostCubes(Cost1) : NULL );
+    if ( Cost0 + Cost1 + Cost2 >= CostLim ) return CostLim;
+    // derive the final truth table
+    for ( c = 0; c < nWords; c++ )
+        pRes[c] = uRes2[c] | uRes0[c], pRes[c+nWords] = uRes2[c] | uRes1[c];
+    // verify
+    for ( c = 0; c < (nWords<<1); c++ )
+        assert( (pOn[c]  & ~pRes[c] ) == 0 && (pRes[c] & ~pOnDc[c]) == 0 );
+    Abc_IsopAddLits( pCover, Cost0, Cost1, nVars );
+    return Cost0 + Cost1 + Cost2 + Abc_CostCubes(Cost0) + Abc_CostCubes(Cost1);
+}
+word Abc_Isop11Cover( word * pOn, word * pOnDc, word * pRes, word CostLim, int * pCover )
+{
+    word uOn2[16], uOnDc2[16], uRes0[16], uRes1[16], uRes2[16];
+    word Cost0, Cost1, Cost2; int c, nVars = 10, nWords = 16;
+    // negative cofactor
+    for ( c = 0; c < nWords; c++ )
+        uOn2[c] = pOn[c] & ~pOnDc[c+nWords];
+    Cost0 = Abc_IsopCheck( uOn2, pOnDc,        uRes0, nVars, CostLim, pCover );
+    if ( Cost0 >= CostLim ) return CostLim;
+    // positive cofactor
+    for ( c = 0; c < nWords; c++ )
+        uOn2[c] = pOn[c+nWords] & ~pOnDc[c];
+    Cost1 = Abc_IsopCheck( uOn2, pOnDc+nWords, uRes1, nVars, CostLim, pCover ? pCover + Abc_CostCubes(Cost0) : NULL );
+    if ( Cost0 + Cost1 >= CostLim ) return CostLim;
+    // middle cofactor
+    for ( c = 0; c < nWords; c++ )
+        uOn2[c] = (pOn[c] & ~uRes0[c]) | (pOn[c+nWords] & ~uRes1[c]), uOnDc2[c] = pOnDc[c] & pOnDc[c+nWords];
+    Cost2 = Abc_IsopCheck( uOn2, uOnDc2,       uRes2, nVars, CostLim, pCover ? pCover + Abc_CostCubes(Cost0) + Abc_CostCubes(Cost1) : NULL );
+    if ( Cost0 + Cost1 + Cost2 >= CostLim ) return CostLim;
+    // derive the final truth table
+    for ( c = 0; c < nWords; c++ )
+        pRes[c] = uRes2[c] | uRes0[c], pRes[c+nWords] = uRes2[c] | uRes1[c];
+    // verify
+    for ( c = 0; c < (nWords<<1); c++ )
+        assert( (pOn[c]  & ~pRes[c] ) == 0 && (pRes[c] & ~pOnDc[c]) == 0 );
+    Abc_IsopAddLits( pCover, Cost0, Cost1, nVars );
+    return Cost0 + Cost1 + Cost2 + Abc_CostCubes(Cost0) + Abc_CostCubes(Cost1);
+}
+word Abc_Isop12Cover( word * pOn, word * pOnDc, word * pRes, word CostLim, int * pCover )
+{
+    word uOn2[32], uOnDc2[32], uRes0[32], uRes1[32], uRes2[32];
+    word Cost0, Cost1, Cost2; int c, nVars = 11, nWords = 32;
+    // negative cofactor
+    for ( c = 0; c < nWords; c++ )
+        uOn2[c] = pOn[c] & ~pOnDc[c+nWords];
+    Cost0 = Abc_IsopCheck( uOn2, pOnDc,        uRes0, nVars, CostLim, pCover );
+    if ( Cost0 >= CostLim ) return CostLim;
+    // positive cofactor
+    for ( c = 0; c < nWords; c++ )
+        uOn2[c] = pOn[c+nWords] & ~pOnDc[c];
+    Cost1 = Abc_IsopCheck( uOn2, pOnDc+nWords, uRes1, nVars, CostLim, pCover ? pCover + Abc_CostCubes(Cost0) : NULL );
+    if ( Cost0 + Cost1 >= CostLim ) return CostLim;
+    // middle cofactor
+    for ( c = 0; c < nWords; c++ )
+        uOn2[c] = (pOn[c] & ~uRes0[c]) | (pOn[c+nWords] & ~uRes1[c]), uOnDc2[c] = pOnDc[c] & pOnDc[c+nWords];
+    Cost2 = Abc_IsopCheck( uOn2, uOnDc2,       uRes2, nVars, CostLim, pCover ? pCover + Abc_CostCubes(Cost0) + Abc_CostCubes(Cost1) : NULL );
+    if ( Cost0 + Cost1 + Cost2 >= CostLim ) return CostLim;
+    // derive the final truth table
+    for ( c = 0; c < nWords; c++ )
+        pRes[c] = uRes2[c] | uRes0[c], pRes[c+nWords] = uRes2[c] | uRes1[c];
+    // verify
+    for ( c = 0; c < (nWords<<1); c++ )
+        assert( (pOn[c]  & ~pRes[c] ) == 0 && (pRes[c] & ~pOnDc[c]) == 0 );
+    Abc_IsopAddLits( pCover, Cost0, Cost1, nVars );
+    return Cost0 + Cost1 + Cost2 + Abc_CostCubes(Cost0) + Abc_CostCubes(Cost1);
+}
+word Abc_Isop13Cover( word * pOn, word * pOnDc, word * pRes, word CostLim, int * pCover )
+{
+    word uOn2[64], uOnDc2[64], uRes0[64], uRes1[64], uRes2[64];
+    word Cost0, Cost1, Cost2; int c, nVars = 12, nWords = 64;
+    // negative cofactor
+    for ( c = 0; c < nWords; c++ )
+        uOn2[c] = pOn[c] & ~pOnDc[c+nWords];
+    Cost0 = Abc_IsopCheck( uOn2, pOnDc,        uRes0, nVars, CostLim, pCover );
+    if ( Cost0 >= CostLim ) return CostLim;
+    // positive cofactor
+    for ( c = 0; c < nWords; c++ )
+        uOn2[c] = pOn[c+nWords] & ~pOnDc[c];
+    Cost1 = Abc_IsopCheck( uOn2, pOnDc+nWords, uRes1, nVars, CostLim, pCover ? pCover + Abc_CostCubes(Cost0) : NULL );
+    if ( Cost0 + Cost1 >= CostLim ) return CostLim;
+    // middle cofactor
+    for ( c = 0; c < nWords; c++ )
+        uOn2[c] = (pOn[c] & ~uRes0[c]) | (pOn[c+nWords] & ~uRes1[c]), uOnDc2[c] = pOnDc[c] & pOnDc[c+nWords];
+    Cost2 = Abc_IsopCheck( uOn2, uOnDc2,       uRes2, nVars, CostLim, pCover ? pCover + Abc_CostCubes(Cost0) + Abc_CostCubes(Cost1) : NULL );
+    if ( Cost0 + Cost1 + Cost2 >= CostLim ) return CostLim;
+    // derive the final truth table
+    for ( c = 0; c < nWords; c++ )
+        pRes[c] = uRes2[c] | uRes0[c], pRes[c+nWords] = uRes2[c] | uRes1[c];
+    // verify
+    for ( c = 0; c < (nWords<<1); c++ )
+        assert( (pOn[c]  & ~pRes[c] ) == 0 && (pRes[c] & ~pOnDc[c]) == 0 );
+    Abc_IsopAddLits( pCover, Cost0, Cost1, nVars );
+    return Cost0 + Cost1 + Cost2 + Abc_CostCubes(Cost0) + Abc_CostCubes(Cost1);
+}
+word Abc_Isop14Cover( word * pOn, word * pOnDc, word * pRes, word CostLim, int * pCover )
+{
+    word uOn2[128], uOnDc2[128], uRes0[128], uRes1[128], uRes2[128];
+    word Cost0, Cost1, Cost2; int c, nVars = 13, nWords = 128;
+    // negative cofactor
+    for ( c = 0; c < nWords; c++ )
+        uOn2[c] = pOn[c] & ~pOnDc[c+nWords];
+    Cost0 = Abc_IsopCheck( uOn2, pOnDc,        uRes0, nVars, CostLim, pCover );
+    if ( Cost0 >= CostLim ) return CostLim;
+    // positive cofactor
+    for ( c = 0; c < nWords; c++ )
+        uOn2[c] = pOn[c+nWords] & ~pOnDc[c];
+    Cost1 = Abc_IsopCheck( uOn2, pOnDc+nWords, uRes1, nVars, CostLim, pCover ? pCover + Abc_CostCubes(Cost0) : NULL );
+    if ( Cost0 + Cost1 >= CostLim ) return CostLim;
+    // middle cofactor
+    for ( c = 0; c < nWords; c++ )
+        uOn2[c] = (pOn[c] & ~uRes0[c]) | (pOn[c+nWords] & ~uRes1[c]), uOnDc2[c] = pOnDc[c] & pOnDc[c+nWords];
+    Cost2 = Abc_IsopCheck( uOn2, uOnDc2,       uRes2, nVars, CostLim, pCover ? pCover + Abc_CostCubes(Cost0) + Abc_CostCubes(Cost1) : NULL );
+    if ( Cost0 + Cost1 + Cost2 >= CostLim ) return CostLim;
+    // derive the final truth table
+    for ( c = 0; c < nWords; c++ )
+        pRes[c] = uRes2[c] | uRes0[c], pRes[c+nWords] = uRes2[c] | uRes1[c];
+    // verify
+    for ( c = 0; c < (nWords<<1); c++ )
+        assert( (pOn[c]  & ~pRes[c] ) == 0 && (pRes[c] & ~pOnDc[c]) == 0 );
+    Abc_IsopAddLits( pCover, Cost0, Cost1, nVars );
+    return Cost0 + Cost1 + Cost2 + Abc_CostCubes(Cost0) + Abc_CostCubes(Cost1);
+}
+word Abc_Isop15Cover( word * pOn, word * pOnDc, word * pRes, word CostLim, int * pCover )
+{
+    word uOn2[256], uOnDc2[256], uRes0[256], uRes1[256], uRes2[256];
+    word Cost0, Cost1, Cost2; int c, nVars = 14, nWords = 256;
+    // negative cofactor
+    for ( c = 0; c < nWords; c++ )
+        uOn2[c] = pOn[c] & ~pOnDc[c+nWords];
+    Cost0 = Abc_IsopCheck( uOn2, pOnDc,        uRes0, nVars, CostLim, pCover );
+    if ( Cost0 >= CostLim ) return CostLim;
+    // positive cofactor
+    for ( c = 0; c < nWords; c++ )
+        uOn2[c] = pOn[c+nWords] & ~pOnDc[c];
+    Cost1 = Abc_IsopCheck( uOn2, pOnDc+nWords, uRes1, nVars, CostLim, pCover ? pCover + Abc_CostCubes(Cost0) : NULL );
+    if ( Cost0 + Cost1 >= CostLim ) return CostLim;
+    // middle cofactor
+    for ( c = 0; c < nWords; c++ )
+        uOn2[c] = (pOn[c] & ~uRes0[c]) | (pOn[c+nWords] & ~uRes1[c]), uOnDc2[c] = pOnDc[c] & pOnDc[c+nWords];
+    Cost2 = Abc_IsopCheck( uOn2, uOnDc2,       uRes2, nVars, CostLim, pCover ? pCover + Abc_CostCubes(Cost0) + Abc_CostCubes(Cost1) : NULL );
+    if ( Cost0 + Cost1 + Cost2 >= CostLim ) return CostLim;
+    // derive the final truth table
+    for ( c = 0; c < nWords; c++ )
+        pRes[c] = uRes2[c] | uRes0[c], pRes[c+nWords] = uRes2[c] | uRes1[c];
+    // verify
+    for ( c = 0; c < (nWords<<1); c++ )
+        assert( (pOn[c]  & ~pRes[c] ) == 0 && (pRes[c] & ~pOnDc[c]) == 0 );
+    Abc_IsopAddLits( pCover, Cost0, Cost1, nVars );
+    return Cost0 + Cost1 + Cost2 + Abc_CostCubes(Cost0) + Abc_CostCubes(Cost1);
+}
+word Abc_Isop16Cover( word * pOn, word * pOnDc, word * pRes, word CostLim, int * pCover )
+{
+    word uOn2[512], uOnDc2[512], uRes0[512], uRes1[512], uRes2[512];
+    word Cost0, Cost1, Cost2; int c, nVars = 15, nWords = 512;
+    // negative cofactor
+    for ( c = 0; c < nWords; c++ )
+        uOn2[c] = pOn[c] & ~pOnDc[c+nWords];
+    Cost0 = Abc_IsopCheck( uOn2, pOnDc,        uRes0, nVars, CostLim, pCover );
+    if ( Cost0 >= CostLim ) return CostLim;
+    // positive cofactor
+    for ( c = 0; c < nWords; c++ )
+        uOn2[c] = pOn[c+nWords] & ~pOnDc[c];
+    Cost1 = Abc_IsopCheck( uOn2, pOnDc+nWords, uRes1, nVars, CostLim, pCover ? pCover + Abc_CostCubes(Cost0) : NULL );
+    if ( Cost0 + Cost1 >= CostLim ) return CostLim;
+    // middle cofactor
+    for ( c = 0; c < nWords; c++ )
+        uOn2[c] = (pOn[c] & ~uRes0[c]) | (pOn[c+nWords] & ~uRes1[c]), uOnDc2[c] = pOnDc[c] & pOnDc[c+nWords];
+    Cost2 = Abc_IsopCheck( uOn2, uOnDc2,       uRes2, nVars, CostLim, pCover ? pCover + Abc_CostCubes(Cost0) + Abc_CostCubes(Cost1) : NULL );
+    if ( Cost0 + Cost1 + Cost2 >= CostLim ) return CostLim;
+    // derive the final truth table
+    for ( c = 0; c < nWords; c++ )
+        pRes[c] = uRes2[c] | uRes0[c], pRes[c+nWords] = uRes2[c] | uRes1[c];
+    // verify
+    for ( c = 0; c < (nWords<<1); c++ )
+        assert( (pOn[c]  & ~pRes[c] ) == 0 && (pRes[c] & ~pOnDc[c]) == 0 );
+    Abc_IsopAddLits( pCover, Cost0, Cost1, nVars );
+    return Cost0 + Cost1 + Cost2 + Abc_CostCubes(Cost0) + Abc_CostCubes(Cost1);
+}
+word Abc_IsopCheck( word * pOn, word * pOnDc, word * pRes, int nVars, word CostLim, int * pCover )
+{
+    int nVarsNew; word Cost;
+    if ( nVars <= 6 )
+        return Abc_Isop6Cover( *pOn, *pOnDc, pRes, nVars, CostLim, pCover );
+    for ( nVarsNew = nVars; nVarsNew > 6; nVarsNew-- )
+        if ( Abc_TtHasVar( pOn, nVars, nVarsNew-1 ) || Abc_TtHasVar( pOnDc, nVars, nVarsNew-1 ) )
+            break;
+    if ( nVarsNew == 6 )
+        Cost = Abc_Isop6Cover( *pOn, *pOnDc, pRes, nVarsNew, CostLim, pCover );
+    else
+        Cost = s_pFuncIsopCover[nVarsNew]( pOn, pOnDc, pRes, CostLim, pCover );
+    Abc_TtStretch6( pRes, nVarsNew, nVars );
+    return Cost;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Create truth table for the given cover.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline word ** Abc_IsopTtElems()
+{
+    static word TtElems[ABC_ISOP_MAX_VAR+1][ABC_ISOP_MAX_WORD], * pTtElems[ABC_ISOP_MAX_VAR+1] = {NULL};
+    if ( pTtElems[0] == NULL )
+    {
+        int v;
+        for ( v = 0; v <= ABC_ISOP_MAX_VAR; v++ )
+            pTtElems[v] = TtElems[v];
+        Abc_TtElemInit( pTtElems, ABC_ISOP_MAX_VAR );
+    }
+    return pTtElems;
+}
+void Abc_IsopBuildTruth( Vec_Int_t * vCover, int nVars, word * pRes, int fXor, int fCompl )
+{
+    word ** pTtElems = Abc_IsopTtElems();
+    word pCube[ABC_ISOP_MAX_WORD];
+    int nWords = Abc_TtWordNum( nVars );
+    int c, v, Cube;
+    assert( nVars <= ABC_ISOP_MAX_VAR );
+    Abc_TtClear( pRes, nWords );
+    Vec_IntForEachEntry( vCover, Cube, c )
+    {
+        Abc_TtFill( pCube, nWords );
+        for ( v = 0; v < nVars; v++ )
+            if ( ((Cube >> (v << 1)) & 3) == 1 )
+                Abc_TtSharp( pCube, pCube, pTtElems[v], nWords );
+            else if ( ((Cube >> (v << 1)) & 3) == 2 )
+                Abc_TtAnd( pCube, pCube, pTtElems[v], nWords, 0 );
+        if ( fXor )
+            Abc_TtXor( pRes, pRes, pCube, nWords, 0 );
+        else
+            Abc_TtOr( pRes, pRes, pCube, nWords );
+    }
+    if ( fCompl )
+        Abc_TtNot( pRes, nWords );
+}
+static inline void Abc_IsopVerify( word * pFunc, int nVars, word * pRes, Vec_Int_t * vCover, int fXor, int fCompl )
+{
+    Abc_IsopBuildTruth( vCover, nVars, pRes, fXor, fCompl );
+    if ( !Abc_TtEqual( pFunc, pRes, Abc_TtWordNum(nVars) ) )
+        printf( "Verification failed.\n" );
+//    else
+//        printf( "Verification succeeded.\n" );
+}
+
+/**Function*************************************************************
+
+  Synopsis    [This procedure assumes that function has exact support.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_Isop( word * pFunc, int nVars, int nCubeLim, Vec_Int_t * vCover, int fTryBoth )
+{
+    word pRes[ABC_ISOP_MAX_WORD];
+    word Cost0, Cost1, Cost, CostInit = Abc_Cube2Cost(nCubeLim);
+    assert( nVars <= ABC_ISOP_MAX_VAR );
+    Vec_IntGrow( vCover, 1 << (nVars-1) );
+    if ( fTryBoth )
+    {
+        Cost0 = Abc_IsopCheck( pFunc, pFunc, pRes, nVars, CostInit, NULL );
+        Abc_TtNot( pFunc, Abc_TtWordNum(nVars) );
+        Cost1 = Abc_IsopCheck( pFunc, pFunc, pRes, nVars, Cost0, NULL );
+        Cost = Abc_MinWord( Cost0, Cost1 );
+        if ( Cost == CostInit )
+        {
+            Abc_TtNot( pFunc, Abc_TtWordNum(nVars) );
+            return -1;
+        }
+        if ( Cost == Cost0 )
+        {
+            Abc_TtNot( pFunc, Abc_TtWordNum(nVars) );
+            Abc_IsopCheck( pFunc, pFunc, pRes, nVars, CostInit, Vec_IntArray(vCover) );
+        }
+        else // if ( Cost == Cost1 )
+        {
+            Abc_IsopCheck( pFunc, pFunc, pRes, nVars, CostInit, Vec_IntArray(vCover) );
+            Abc_TtNot( pFunc, Abc_TtWordNum(nVars) );
+        }
+    }
+    else
+    {
+        Cost = Cost0 = Abc_IsopCheck( pFunc, pFunc, pRes, nVars, CostInit, Vec_IntArray(vCover) );
+        if ( Cost == CostInit )
+            return -1;
+    }
+    vCover->nSize = Abc_CostCubes(Cost);
+    assert( vCover->nSize <= vCover->nCap );
+//    Abc_IsopVerify( pFunc, nVars, pRes, vCover, 0, Cost != Cost0 );
+    return Cost != Cost0;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Compute CNF assuming it does not exceed the limit.]
+
+  Description [Please note that pCover should have at least 32 extra entries!]
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_IsopCnf( word * pFunc, int nVars, int nCubeLim, int * pCover )
+{
+    word pRes[ABC_ISOP_MAX_WORD];
+    word Cost0, Cost1, CostInit = Abc_Cube2Cost(nCubeLim);
+    int c, nCubes0, nCubes1;
+    assert( nVars <= ABC_ISOP_MAX_VAR );
+    assert( Abc_TtHasVar( pFunc, nVars, nVars - 1 ) );
+    if ( nVars > 6 )
+        Cost0 = s_pFuncIsopCover[nVars]( pFunc, pFunc, pRes, CostInit, pCover );
+    else
+        Cost0 = Abc_Isop6Cover( *pFunc, *pFunc, pRes, nVars, CostInit, pCover );
+    if ( Cost0 >= CostInit )
+        return CostInit;
+    Abc_TtNot( pFunc, Abc_TtWordNum(nVars) );
+    if ( nVars > 6 )
+        Cost1 = s_pFuncIsopCover[nVars]( pFunc, pFunc, pRes, CostInit, pCover ? pCover + Abc_CostCubes(Cost0) : NULL );
+    else
+        Cost1 = Abc_Isop6Cover( *pFunc, *pFunc, pRes, nVars, CostInit, pCover ? pCover + Abc_CostCubes(Cost0) : NULL );
+    Abc_TtNot( pFunc, Abc_TtWordNum(nVars) );
+    if ( Cost0 + Cost1 >= CostInit )
+        return CostInit;
+    nCubes0 = Abc_CostCubes(Cost0);
+    nCubes1 = Abc_CostCubes(Cost1);
+    if ( pCover )
+    {
+        for ( c = 0; c < nCubes0; c++ )
+            pCover[c] |= (1 << Abc_Var2Lit(nVars, 0));
+        for ( c = 0; c < nCubes1; c++ )
+            pCover[c+nCubes0] |= (1 << Abc_Var2Lit(nVars, 1));
+    }
+    return nCubes0 + nCubes1;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_IsopCountLits( Vec_Int_t * vCover, int nVars )
+{
+    int i, k, Entry, Literal, nLits = 0;
+    if ( Vec_IntSize(vCover) == 0 || (Vec_IntSize(vCover) == 1 && Vec_IntEntry(vCover, 0) == 0) )
+        return 0;
+    Vec_IntForEachEntry( vCover, Entry, i )
+    { 
+        for ( k = 0; k < nVars; k++ )
+        {
+            Literal = 3 & (Entry >> (k << 1));
+            if ( Literal == 1 ) // neg literal
+                nLits++;
+            else if ( Literal == 2 ) // pos literal
+                nLits++;
+            else if ( Literal != 0 ) 
+                assert( 0 );
+        }
+    }
+    return nLits;
+}
+void Abc_IsopPrintCover( Vec_Int_t * vCover, int nVars, int fCompl )
+{
+    int i, k, Entry, Literal;
+    if ( Vec_IntSize(vCover) == 0 || (Vec_IntSize(vCover) == 1 && Vec_IntEntry(vCover, 0) == 0) )
+    {
+        printf( "Constant %d\n", Vec_IntSize(vCover) );
+        return;
+    }
+    Vec_IntForEachEntry( vCover, Entry, i )
+    { 
+        for ( k = 0; k < nVars; k++ )
+        {
+            Literal = 3 & (Entry >> (k << 1));
+            if ( Literal == 1 ) // neg literal
+                printf( "0" );
+            else if ( Literal == 2 ) // pos literal
+                printf( "1" );
+            else if ( Literal == 0 ) 
+                printf( "-" );
+            else assert( 0 );
+        }
+        printf( " %d\n", !fCompl );
+    }
+}
+void Abc_IsopPrint( word * t, int nVars, Vec_Int_t * vCover, int fTryBoth )
+{
+    int fCompl = Abc_Isop( t, nVars, ABC_ISOP_MAX_CUBE, vCover, fTryBoth );
+    Abc_IsopPrintCover( vCover, nVars, fCompl );
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    [These procedures assume that function has exact support.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Abc_EsopAddLits( int * pCover, word r0, word r1, word r2, word Max, int Var )
+{
+    int i, c0, c1, c2;
+    if ( Max == r0 )
+    {
+        c2 = Abc_CostCubes(r2);
+        if ( pCover )
+        {
+            c0 = Abc_CostCubes(r0);
+            c1 = Abc_CostCubes(r1);
+            for ( i = 0; i < c1; i++ )
+                pCover[i] = pCover[c0+i];
+            for ( i = 0; i < c2; i++ )
+                pCover[c1+i] = pCover[c0+c1+i] | (1 << Abc_Var2Lit(Var,0));
+        }
+        return c2;
+    }
+    else if ( Max == r1 )
+    {
+        c2 = Abc_CostCubes(r2);
+        if ( pCover )
+        {
+            c0 = Abc_CostCubes(r0);
+            c1 = Abc_CostCubes(r1);
+            for ( i = 0; i < c2; i++ )
+                pCover[c0+i] = pCover[c0+c1+i] | (1 << Abc_Var2Lit(Var,1));
+        }
+        return c2;
+    }
+    else
+    {
+        c0 = Abc_CostCubes(r0);
+        c1 = Abc_CostCubes(r1);
+        if ( pCover )
+        {
+            c2 = Abc_CostCubes(r2);
+            for ( i = 0; i < c0; i++ )
+                pCover[i] |= (1 << Abc_Var2Lit(Var,0));
+            for ( i = 0; i < c1; i++ )
+                pCover[c0+i] |= (1 << Abc_Var2Lit(Var,1));
+        }
+        return c0 + c1;
+    }
+}
+word Abc_Esop6Cover( word t, int nVars, word CostLim, int * pCover )
+{
+    word c0, c1;
+    word r0, r1, r2, Max;
+    int Var;
+    assert( nVars <= 6 );
+    if ( t == 0 )
+        return 0;
+    if ( t == ~(word)0 )
+    {
+        if ( pCover ) *pCover = 0;
+        return Abc_Cube2Cost(1);
+    }
+    assert( nVars > 0 );
+    // find the topmost var
+    for ( Var = nVars-1; Var >= 0; Var-- )
+        if ( Abc_Tt6HasVar( t, Var ) )
+             break;
+    assert( Var >= 0 );
+    // cofactor
+    c0 = Abc_Tt6Cofactor0( t, Var );
+    c1 = Abc_Tt6Cofactor1( t, Var );
+    // call recursively
+    r0 = Abc_Esop6Cover( c0,      Var, CostLim, pCover ? pCover : NULL );
+    if ( r0 >= CostLim ) return CostLim;
+    r1 = Abc_Esop6Cover( c1,      Var, CostLim, pCover ? pCover + Abc_CostCubes(r0) : NULL );
+    if ( r1 >= CostLim ) return CostLim;
+    r2 = Abc_Esop6Cover( c0 ^ c1, Var, CostLim, pCover ? pCover + Abc_CostCubes(r0) + Abc_CostCubes(r1) : NULL );
+    if ( r2 >= CostLim ) return CostLim;
+    Max = Abc_MaxWord( r0, Abc_MaxWord(r1, r2) );
+    if ( r0 + r1 + r2 - Max >= CostLim ) return CostLim;
+    return r0 + r1 + r2 - Max + Abc_EsopAddLits( pCover, r0, r1, r2, Max, Var );
+}
+word Abc_EsopCover( word * pOn, int nVars, word CostLim, int * pCover )
+{
+    word r0, r1, r2, Max;
+    int c, nWords = (1 << (nVars - 7));
+    assert( nVars > 6 );
+    assert( Abc_TtHasVar( pOn, nVars, nVars - 1 ) );
+    r0 = Abc_EsopCheck( pOn,        nVars-1, CostLim, pCover );
+    if ( r0 >= CostLim ) return CostLim;
+    r1 = Abc_EsopCheck( pOn+nWords, nVars-1, CostLim, pCover ? pCover + Abc_CostCubes(r0) : NULL );
+    if ( r1 >= CostLim ) return CostLim;
+    for ( c = 0; c < nWords; c++ )
+        pOn[c] ^= pOn[nWords+c];
+    r2 = Abc_EsopCheck( pOn, nVars-1, CostLim, pCover ? pCover + Abc_CostCubes(r0) + Abc_CostCubes(r1) : NULL );
+    for ( c = 0; c < nWords; c++ )
+        pOn[c] ^= pOn[nWords+c];
+    if ( r2 >= CostLim ) return CostLim;
+    Max = Abc_MaxWord( r0, Abc_MaxWord(r1, r2) );
+    if ( r0 + r1 + r2 - Max >= CostLim ) return CostLim;
+    return r0 + r1 + r2 - Max + Abc_EsopAddLits( pCover, r0, r1, r2, Max, nVars-1 );
+}
+word Abc_EsopCheck( word * pOn, int nVars, word CostLim, int * pCover )
+{
+    int nVarsNew; word Cost;
+    if ( nVars <= 6 )
+        return Abc_Esop6Cover( *pOn, nVars, CostLim, pCover );
+    for ( nVarsNew = nVars; nVarsNew > 6; nVarsNew-- )
+        if ( Abc_TtHasVar( pOn, nVars, nVarsNew-1 ) )
+            break;
+    if ( nVarsNew == 6 )
+        Cost = Abc_Esop6Cover( *pOn, nVarsNew, CostLim, pCover );
+    else
+        Cost = Abc_EsopCover( pOn, nVarsNew, CostLim, pCover );
+    return Cost;
+}
+
+
+/**Function*************************************************************
+
+  Synopsis    [Perform ISOP computation by subtracting cubes.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Abc_TtIntersect( word * pIn1, word * pIn2, int nWords )
+{
+    int w;
+    for ( w = 0; w < nWords; w++ )
+        if ( pIn1[w] & pIn2[w] )
+            return 1;
+    return 0;
+}
+static inline int Abc_TtCheckWithCubePos2Neg( word * t, word * c, int nWords, int iVar )
+{
+    if ( iVar < 6 )
+    {
+        int i, Shift = (1 << iVar);
+        for ( i = 0; i < nWords; i++ )
+            if ( t[i] & (c[i] >> Shift) )
+                return 0;
+        return 1;
+    }
+    else
+    {
+        int i, Step = (1 << (iVar - 6));
+        word * tLimit = t + nWords;
+        for ( ; t < tLimit; t += 2*Step )
+            for ( i = 0; i < Step; i++ )
+                if ( t[Step+i] & c[i] )
+                    return 0;
+        return 1;
+    }
+}
+static inline int Abc_TtCheckWithCubeNeg2Pos( word * t, word * c, int nWords, int iVar )
+{
+    if ( iVar < 6 )
+    {
+        int i, Shift = (1 << iVar);
+        for ( i = 0; i < nWords; i++ )
+            if ( t[i] & (c[i] << Shift) )
+                return 0;
+        return 1;
+    }
+    else
+    {
+        int i, Step = (1 << (iVar - 6));
+        word * tLimit = t + nWords;
+        for ( ; t < tLimit; t += 2*Step )
+            for ( i = 0; i < Step; i++ )
+                if ( t[i] & c[Step+i] )
+                    return 0;
+        return 1;
+    }
+}
+static inline void Abc_TtExpandCubePos2Neg( word * t, int nWords, int iVar )
+{
+    if ( iVar < 6 )
+    {
+        int i, Shift = (1 << iVar);
+        for ( i = 0; i < nWords; i++ )
+            t[i] |= (t[i] >> Shift);
+    }
+    else
+    {
+        int i, Step = (1 << (iVar - 6));
+        word * tLimit = t + nWords;
+        for ( ; t < tLimit; t += 2*Step )
+            for ( i = 0; i < Step; i++ )
+                t[i] = t[Step+i];
+    }
+}
+static inline void Abc_TtExpandCubeNeg2Pos( word * t, int nWords, int iVar )
+{
+    if ( iVar < 6 )
+    {
+        int i, Shift = (1 << iVar);
+        for ( i = 0; i < nWords; i++ )
+            t[i] |= (t[i] << Shift);
+    }
+    else
+    {
+        int i, Step = (1 << (iVar - 6));
+        word * tLimit = t + nWords;
+        for ( ; t < tLimit; t += 2*Step )
+            for ( i = 0; i < Step; i++ )
+                t[Step+i] = t[i];
+    }
+}
+word Abc_IsopNew( word * pOn, word * pOnDc, word * pRes, int nVars, word CostLim, int * pCover )
+{
+    word pCube[ABC_ISOP_MAX_WORD];
+    word pOnset[ABC_ISOP_MAX_WORD];
+    word pOffset[ABC_ISOP_MAX_WORD];
+    int pBlocks[16], nBlocks, vTwo, uTwo;
+    int nWords = Abc_TtWordNum(nVars);
+    int c, v, u, iMint, Cube, nLits = 0;
+    assert( nVars <= ABC_ISOP_MAX_VAR );
+    Abc_TtClear( pRes, nWords );
+    Abc_TtCopy( pOnset, pOn, nWords, 0 ); 
+    Abc_TtCopy( pOffset, pOnDc, nWords, 1 ); 
+    if ( nVars < 6 )
+        pOnset[0] >>= (64 - (1 << nVars));
+    for ( c = 0; !Abc_TtIsConst0(pOnset, nWords); c++ )
+    {
+        // pick one minterm
+        iMint = Abc_TtFindFirstBit(pOnset, nVars);
+        for ( Cube = v = 0; v < nVars; v++ )
+            Cube |= (1 << Abc_Var2Lit(v, (iMint >> v) & 1));
+        // check expansion for the minterm
+        nBlocks = 0;
+        for ( v = 0; v < nVars; v++ )
+            if ( (pBlocks[v] = Abc_TtGetBit(pOffset, iMint ^ (1 << v))) )
+                nBlocks++;
+        // check second step
+        if ( nBlocks == nVars ) // cannot expand
+        {
+            Abc_TtSetBit( pRes, iMint );
+            Abc_TtXorBit( pOnset, iMint );
+            pCover[c] = Cube;
+            nLits += nVars;
+            continue;
+        }
+        // check dual expansion
+        vTwo = uTwo = -1;
+        if ( nBlocks < nVars - 1 )
+        {
+            for ( v = 0; v < nVars && vTwo == -1; v++ )
+            if ( !pBlocks[v] )
+            for ( u = v + 1; u < nVars; u++ )
+            if ( !pBlocks[u] )
+            {
+                if ( Abc_TtGetBit( pOffset, iMint ^ (1 << v) ^ (1 << u) ) )
+                    continue;
+                // can expand both directions
+                vTwo = v;
+                uTwo = u;
+                break;
+            }
+        }
+        if ( vTwo == -1 ) // can expand only one
+        {
+            for ( v = 0; v < nVars; v++ )
+                if ( !pBlocks[v] )
+                    break;
+            Abc_TtSetBit( pRes, iMint );
+            Abc_TtSetBit( pRes, iMint ^ (1 << v) );
+            Abc_TtXorBit( pOnset, iMint );
+            if ( Abc_TtGetBit(pOnset, iMint ^ (1 << v)) )
+                Abc_TtXorBit( pOnset, iMint ^ (1 << v) );
+            pCover[c] = Cube & ~(3 << Abc_Var2Lit(v, 0));
+            nLits += nVars - 1;
+            continue;
+        }
+        if ( nBlocks == nVars - 2 && vTwo >= 0 ) // can expand only these two
+        {
+            Abc_TtSetBit( pRes, iMint );
+            Abc_TtSetBit( pRes, iMint ^ (1 << vTwo) );
+            Abc_TtSetBit( pRes, iMint ^ (1 << uTwo) );
+            Abc_TtSetBit( pRes, iMint ^ (1 << vTwo) ^ (1 << uTwo) );
+            Abc_TtXorBit( pOnset, iMint );
+            if ( Abc_TtGetBit(pOnset, iMint ^ (1 << vTwo)) )
+                Abc_TtXorBit( pOnset, iMint ^ (1 << vTwo) );
+            if ( Abc_TtGetBit(pOnset, iMint ^ (1 << uTwo)) )
+                Abc_TtXorBit( pOnset, iMint ^ (1 << uTwo) );
+            if ( Abc_TtGetBit(pOnset, iMint ^ (1 << vTwo) ^ (1 << uTwo)) )
+                Abc_TtXorBit( pOnset, iMint ^ (1 << vTwo) ^ (1 << uTwo) );
+            pCover[c] = Cube & ~(3 << Abc_Var2Lit(vTwo, 0)) & ~(3 << Abc_Var2Lit(uTwo, 0));
+            nLits += nVars - 2;
+            continue;
+        }
+        // can expand others as well
+        Abc_TtClear( pCube, nWords );
+        Abc_TtSetBit( pCube, iMint );
+        Abc_TtSetBit( pCube, iMint ^ (1 << vTwo) );
+        Abc_TtSetBit( pCube, iMint ^ (1 << uTwo) );
+        Abc_TtSetBit( pCube, iMint ^ (1 << vTwo) ^ (1 << uTwo) );
+        Cube &= ~(3 << Abc_Var2Lit(vTwo, 0)) & ~(3 << Abc_Var2Lit(uTwo, 0));
+        assert( !Abc_TtIntersect(pCube, pOffset, nWords) );        
+        // expand against offset
+        for ( v = 0; v < nVars; v++ )
+        if ( v != vTwo && v != uTwo )
+        {
+            int Shift = Abc_Var2Lit( v, 0 );
+            if ( (Cube >> Shift) == 2 && Abc_TtCheckWithCubePos2Neg(pOffset, pCube, nWords, v) ) // pos literal
+            {
+                Abc_TtExpandCubePos2Neg( pCube, nWords, v );
+                Cube &= ~(3 << Shift);
+            }
+            else if ( (Cube >> Shift) == 1 && Abc_TtCheckWithCubeNeg2Pos(pOffset, pCube, nWords, v) ) // neg literal
+            {
+                Abc_TtExpandCubeNeg2Pos( pCube, nWords, v );
+                Cube &= ~(3 << Shift);
+            }
+            else 
+                nLits++;
+        }
+        // add cube to solution
+        Abc_TtOr( pRes, pRes, pCube, nWords );
+        Abc_TtSharp( pOnset, pOnset, pCube, nWords );
+        pCover[c] = Cube;
+    }
+    pRes[0] = Abc_Tt6Stretch( pRes[0], nVars );
+    return Abc_Cube2Cost(c) | nLits;
+}
+void Abc_IsopTestNew()
+{
+    int nVars = 4;
+    Vec_Int_t * vCover = Vec_IntAlloc( 1000 );
+    word r, t = (s_Truths6[0] & s_Truths6[1]) ^ (s_Truths6[2] & s_Truths6[3]), copy = t;
+//    word r, t = ~s_Truths6[0] | (s_Truths6[1] & s_Truths6[2] & s_Truths6[3]), copy = t;
+//    word r, t = 0xABCDABCDABCDABCD, copy = t;
+//    word r, t = 0x6996000000006996, copy = t;
+//    word Cost = Abc_IsopNew( &t, &t, &r, nVars, Abc_Cube2Cost(ABC_ISOP_MAX_CUBE), Vec_IntArray(vCover) );
+    word Cost = Abc_EsopCheck( &t, nVars, Abc_Cube2Cost(ABC_ISOP_MAX_CUBE), Vec_IntArray(vCover) );
+    vCover->nSize = Abc_CostCubes(Cost);
+    assert( vCover->nSize <= vCover->nCap );
+    printf( "Cubes = %d.  Lits = %d.\n", Abc_CostCubes(Cost), Abc_CostLits(Cost) );
+    Abc_IsopPrintCover( vCover, nVars, 0 );
+    Abc_IsopVerify( &copy, nVars, &r, vCover, 1, 0 );
+    Vec_IntFree( vCover );
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Compute CNF assuming it does not exceed the limit.]
+
+  Description [Please note that pCover should have at least 32 extra entries!]
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_IsopTest( word * pFunc, int nVars, Vec_Int_t * vCover )
+{
+    int fVerbose = 0;    
+    static word TotalCost[6] = {0};
+    static abctime TotalTime[6] = {0};
+    static int Counter;
+    word pRes[ABC_ISOP_MAX_WORD];
+    word Cost;
+    abctime clk;
+    Counter++;
+    if ( Counter == 9999 )
+    {
+        Abc_PrintTime( 1, "0", TotalTime[0] );
+        Abc_PrintTime( 1, "1", TotalTime[1] );
+        Abc_PrintTime( 1, "2", TotalTime[2] );
+        Abc_PrintTime( 1, "3", TotalTime[3] );
+        Abc_PrintTime( 1, "4", TotalTime[4] );
+        Abc_PrintTime( 1, "5", TotalTime[5] );
+    }
+    assert( nVars <= ABC_ISOP_MAX_VAR );
+//    if ( fVerbose )
+//    Dau_DsdPrintFromTruth( pFunc, nVars ), printf( "         " );
+
+    clk = Abc_Clock();
+    Cost = Abc_IsopCheck( pFunc, pFunc, pRes, nVars, Abc_Cube2Cost(ABC_ISOP_MAX_CUBE), Vec_IntArray(vCover) );
+    vCover->nSize = Abc_CostCubes(Cost);
+    assert( vCover->nSize <= vCover->nCap );
+    if ( fVerbose )
+    printf( "%5d %7d  ", Abc_CostCubes(Cost), Abc_CostLits(Cost) );
+//    Abc_IsopVerify( pFunc, nVars, pRes, vCover, 0, 0 );
+    TotalCost[0] += Abc_CostCubes(Cost);
+    TotalTime[0] += Abc_Clock() - clk;
+
+
+    clk = Abc_Clock();
+    Abc_TtNot( pFunc, Abc_TtWordNum(nVars) );
+    Cost = Abc_IsopCheck( pFunc, pFunc, pRes, nVars, Abc_Cube2Cost(ABC_ISOP_MAX_CUBE), Vec_IntArray(vCover) );
+    Abc_TtNot( pFunc, Abc_TtWordNum(nVars) );
+    vCover->nSize = Abc_CostCubes(Cost);
+    assert( vCover->nSize <= vCover->nCap );
+    if ( fVerbose )
+    printf( "%5d %7d  ", Abc_CostCubes(Cost), Abc_CostLits(Cost) );
+//    Abc_IsopVerify( pFunc, nVars, pRes, vCover, 0, 1 );
+    TotalCost[1] += Abc_CostCubes(Cost);
+    TotalTime[1] += Abc_Clock() - clk;
+
+/*
+    clk = Abc_Clock();
+    Cost = Abc_EsopCheck( pFunc, nVars, Abc_Cube2Cost(ABC_ISOP_MAX_CUBE), Vec_IntArray(vCover) );
+    vCover->nSize = Abc_CostCubes(Cost);
+    assert( vCover->nSize <= vCover->nCap );
+    if ( fVerbose )
+    printf( "%5d %7d   ", Abc_CostCubes(Cost), Abc_CostLits(Cost) );
+//    Abc_IsopVerify( pFunc, nVars, pRes, vCover, 1, 0 );
+    TotalCost[2] += Abc_CostCubes(Cost);
+    TotalTime[2] += Abc_Clock() - clk;
+
+
+    clk = Abc_Clock();
+    Abc_TtNot( pFunc, Abc_TtWordNum(nVars) );
+    Cost = Abc_EsopCheck( pFunc, nVars, Abc_Cube2Cost(ABC_ISOP_MAX_CUBE), Vec_IntArray(vCover) );
+    Abc_TtNot( pFunc, Abc_TtWordNum(nVars) );
+    vCover->nSize = Abc_CostCubes(Cost);
+    assert( vCover->nSize <= vCover->nCap );
+    if ( fVerbose )
+    printf( "%5d %7d   ", Abc_CostCubes(Cost), Abc_CostLits(Cost) );
+//    Abc_IsopVerify( pFunc, nVars, pRes, vCover, 1, 1 );
+    TotalCost[3] += Abc_CostCubes(Cost);
+    TotalTime[3] += Abc_Clock() - clk;
+*/
+
+/*
+    // try new computation
+    clk = Abc_Clock();
+    Cost = Abc_IsopNew( pFunc, pFunc, pRes, nVars, Abc_Cube2Cost(ABC_ISOP_MAX_CUBE), Vec_IntArray(vCover) );
+    vCover->nSize = Abc_CostCubes(Cost);
+    assert( vCover->nSize <= vCover->nCap );
+    if ( fVerbose )
+    printf( "%5d %7d   ", Abc_CostCubes(Cost), Abc_CostLits(Cost) );
+    Abc_IsopVerify( pFunc, nVars, pRes, vCover, 0, 0 );
+    TotalCost[4] += Abc_CostCubes(Cost);
+    TotalTime[4] += Abc_Clock() - clk;
+*/
+/*
+    // try old computation
+    clk = Abc_Clock();
+    Cost = Kit_TruthIsop( (unsigned *)pFunc, nVars, vCover, 1 );
+    vCover->nSize = Vec_IntSize(vCover);
+    assert( vCover->nSize <= vCover->nCap );
+    if ( fVerbose )
+    printf( "%5d %7d   ", Vec_IntSize(vCover), Abc_IsopCountLits(vCover, nVars) );
+    TotalCost[4] += Vec_IntSize(vCover);
+    TotalTime[4] += Abc_Clock() - clk;
+*/
+
+    clk = Abc_Clock();
+    Cost = Abc_Isop( pFunc, nVars, ABC_ISOP_MAX_CUBE, vCover, 1 );
+    if ( fVerbose )
+    printf( "%5d %7d   ", Vec_IntSize(vCover), Abc_IsopCountLits(vCover, nVars) );
+    TotalCost[5] += Vec_IntSize(vCover);
+    TotalTime[5] += Abc_Clock() - clk;
+
+    if ( fVerbose )
+    printf( "  | %8d %8d %8d %8d %8d %8d", (int)TotalCost[0], (int)TotalCost[1], (int)TotalCost[2], (int)TotalCost[3], (int)TotalCost[4], (int)TotalCost[5] );
+    if ( fVerbose )
+    printf( "\n" );
+//Abc_IsopPrintCover( vCover, nVars, 0 );
+    return 1; 
+}
+
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/abc-build/src/misc/util/utilNam.c b/abc-build/src/misc/util/utilNam.c
--- a/abc-build/src/misc/util/utilNam.c
+++ b/abc-build/src/misc/util/utilNam.c
@@ -237,7 +237,7 @@
   SeeAlso     []
 
 ***********************************************************************/
-int Abc_NamStrHash( const char * pStr, int nTableSize )
+int Abc_NamStrHash( const char * pStr, const char * pLim, int nTableSize )
 {
     static int s_FPrimes[128] = { 
         1009, 1049, 1093, 1151, 1201, 1249, 1297, 1361, 1427, 1459, 
@@ -254,12 +254,23 @@
         7393, 7477, 7523, 7561, 7607, 7681, 7727, 7817, 7877, 7933, 
         8011, 8039, 8059, 8081, 8093, 8111, 8123, 8147
     };
-    unsigned i, uHash;
-    for ( uHash = 0, i = 0; pStr[i]; i++ )
-        if ( i & 1 ) 
-            uHash *= pStr[i] * s_FPrimes[i & 0x7F];
-        else
-            uHash ^= pStr[i] * s_FPrimes[i & 0x7F];
+    unsigned i, uHash;
+    if ( pLim )
+    {
+        for ( uHash = 0, i = 0; pStr+i < pLim; i++ )
+            if ( i & 1 ) 
+                uHash *= pStr[i] * s_FPrimes[i & 0x7F];
+            else
+                uHash ^= pStr[i] * s_FPrimes[i & 0x7F];
+    }
+    else
+    {
+        for ( uHash = 0, i = 0; pStr[i]; i++ )
+            if ( i & 1 ) 
+                uHash *= pStr[i] * s_FPrimes[i & 0x7F];
+            else
+                uHash ^= pStr[i] * s_FPrimes[i & 0x7F];
+    }
     return uHash % nTableSize;
 }
 
@@ -273,16 +284,33 @@
 
   SeeAlso     []
 
-***********************************************************************/
-static inline int * Abc_NamStrHashFind( Abc_Nam_t * p, const char * pStr )
+***********************************************************************/
+static inline int Abc_NamStrcmp( char * pStr, char * pLim, char * pThis )
+{
+    if ( pLim )
+    {
+        while ( pStr < pLim )
+            if ( *pStr++ != *pThis++ )
+                return 1;
+        return *pThis != '\0';
+    }
+    else
+    {
+        while ( *pStr )
+            if ( *pStr++ != *pThis++ )
+                return 1;
+        return *pThis != '\0';
+    }
+}
+static inline int * Abc_NamStrHashFind( Abc_Nam_t * p, const char * pStr, const char * pLim )
 {
     char * pThis;
-    int * pPlace = (int *)(p->pBins + Abc_NamStrHash( pStr, p->nBins ));
+    int * pPlace = (int *)(p->pBins + Abc_NamStrHash( pStr, pLim, p->nBins ));
     assert( *pStr );
     for ( pThis = (*pPlace)? Abc_NamIntToStr(p, *pPlace) : NULL; 
           pThis;    pPlace = Abc_NamIntToNextP(p, *pPlace), 
           pThis = (*pPlace)? Abc_NamIntToStr(p, *pPlace) : NULL )
-              if ( !strcmp( pStr, pThis ) )
+              if ( !Abc_NamStrcmp( (char *)pStr, (char *)pLim, pThis ) )
                   break;
     return pPlace;
 }
@@ -318,7 +346,7 @@
     Vec_IntForEachEntryStart( vInt2HandleOld, iHandleOld, i, 1 )
     {
         pThis   = Abc_NamHandleToStr( p, iHandleOld );
-        piPlace = Abc_NamStrHashFind( p, pThis );
+        piPlace = Abc_NamStrHashFind( p, pThis, NULL );
         assert( *piPlace == 0 );
         *piPlace = Vec_IntSize( p->vInt2Handle );
         assert( Vec_IntSize( p->vInt2Handle ) == i );
@@ -341,10 +369,14 @@
   SeeAlso     []
 
 ***********************************************************************/
-int Abc_NamStrFind( Abc_Nam_t * p, char * pStr )
-{
-    return *Abc_NamStrHashFind( p, pStr );
-}
+int Abc_NamStrFind( Abc_Nam_t * p, char * pStr )
+{
+    return *Abc_NamStrHashFind( p, pStr, NULL );
+}
+int Abc_NamStrFindLim( Abc_Nam_t * p, char * pStr, char * pLim )
+{
+    return *Abc_NamStrHashFind( p, pStr, pLim );
+}
 
 /**Function*************************************************************
 
@@ -368,7 +400,7 @@
                 break;
         assert( i < (int)strlen(pStr) );
     }
-    piPlace = Abc_NamStrHashFind( p, pStr );
+    piPlace = Abc_NamStrHashFind( p, pStr, NULL );
     if ( *piPlace )
     {
         if ( pfFound )
@@ -396,6 +428,42 @@
         Abc_NamStrHashResize( p );
     return Vec_IntSize(p->vInt2Handle) - 1;
 }
+int Abc_NamStrFindOrAddLim( Abc_Nam_t * p, char * pStr, char * pLim, int * pfFound )
+{
+    int iHandleNew;
+    int *piPlace;
+    char * pStore;
+    assert( pStr < pLim );
+    piPlace = Abc_NamStrHashFind( p, pStr, pLim );
+    if ( *piPlace )
+    {
+        if ( pfFound )
+            *pfFound = 1;
+        return *piPlace;
+    }
+    if ( pfFound )
+        *pfFound = 0;
+    iHandleNew = p->iHandle + (pLim - pStr) + 1;
+    while ( p->nStore < iHandleNew )
+    {
+        p->nStore *= 3;
+        p->nStore /= 2;
+        p->pStore  = ABC_REALLOC( char, p->pStore, p->nStore );
+    }
+    assert( p->nStore >= iHandleNew );
+    // create new handle
+    *piPlace = Vec_IntSize( p->vInt2Handle );
+    pStore = Abc_NamHandleToStr( p, p->iHandle );
+    strncpy( pStore, pStr, pLim - pStr );
+    pStore[pLim - pStr] = 0;
+    Vec_IntPush( p->vInt2Handle, p->iHandle );
+    Vec_IntPush( p->vInt2Next, 0 );
+    p->iHandle = iHandleNew;
+    // extend the hash table
+    if ( Vec_IntSize(p->vInt2Handle) > 2 * p->nBins )
+        Abc_NamStrHashResize( p );
+    return Vec_IntSize(p->vInt2Handle) - 1;
+}
 
 /**Function*************************************************************
 
@@ -410,7 +478,7 @@
 ***********************************************************************/
 char * Abc_NamStr( Abc_Nam_t * p, int NameId )
 {
-    return NameId? Abc_NamIntToStr(p, NameId) : NULL;
+    return NameId > 0 ? Abc_NamIntToStr(p, NameId) : NULL;
 }
 
 /**Function*************************************************************
@@ -435,7 +503,7 @@
     Vec_IntForEachEntryStart( p1->vInt2Handle, iHandle1, i, 1 )
     {
         pThis = Abc_NamHandleToStr( p1, iHandle1 );
-        piPlace = Abc_NamStrHashFind( p2, pThis );
+        piPlace = Abc_NamStrHashFind( p2, pThis, NULL );
         Vec_IntWriteEntry( vMap, i, *piPlace );
 //        Abc_Print( 1, "%d->%d  ", i, *piPlace );
     }
diff --git a/abc-build/src/misc/util/utilNam.h b/abc-build/src/misc/util/utilNam.h
--- a/abc-build/src/misc/util/utilNam.h
+++ b/abc-build/src/misc/util/utilNam.h
@@ -59,7 +59,9 @@
 extern int             Abc_NamMemUsed( Abc_Nam_t * p );
 extern int             Abc_NamMemAlloc( Abc_Nam_t * p );
 extern int             Abc_NamStrFind( Abc_Nam_t * p, char * pStr );
+extern int             Abc_NamStrFindLim( Abc_Nam_t * p, char * pStr, char * pLim );
 extern int             Abc_NamStrFindOrAdd( Abc_Nam_t * p, char * pStr, int * pfFound );
+extern int             Abc_NamStrFindOrAddLim( Abc_Nam_t * p, char * pStr, char * pLim, int * pfFound );
 extern char *          Abc_NamStr( Abc_Nam_t * p, int id );
 extern Vec_Int_t *     Abc_NamComputeIdMap( Abc_Nam_t * p1, Abc_Nam_t * p2 );
 extern int             Abc_NamReportCommon( Vec_Int_t * vNameIds1, Abc_Nam_t * p1, Abc_Nam_t * p2 );
diff --git a/abc-build/src/misc/util/utilTruth.h b/abc-build/src/misc/util/utilTruth.h
--- a/abc-build/src/misc/util/utilTruth.h
+++ b/abc-build/src/misc/util/utilTruth.h
@@ -150,11 +150,21 @@
 static inline void    Abc_TtSetBit( word * p, int i )         { p[i>>6] |= (((word)1)<<(i & 63));             }
 static inline void    Abc_TtXorBit( word * p, int i )         { p[i>>6] ^= (((word)1)<<(i & 63));             }
 
+// read/write k-th digit d of a quaternary number:
+static inline int     Abc_TtGetQua( word * p, int k )         { return (int)(p[k>>5] >> ((k<<1) & 63)) & 3;   }
+static inline void    Abc_TtSetQua( word * p, int k, int d )  { p[k>>5] |= (((word)d)<<((k<<1) & 63));        }
+static inline void    Abc_TtXorQua( word * p, int k, int d )  { p[k>>5] ^= (((word)d)<<((k<<1) & 63));        }
+
 // read/write k-th digit d of a hexadecimal number:
 static inline int     Abc_TtGetHex( word * p, int k )         { return (int)(p[k>>4] >> ((k<<2) & 63)) & 15;  }
 static inline void    Abc_TtSetHex( word * p, int k, int d )  { p[k>>4] |= (((word)d)<<((k<<2) & 63));        }
 static inline void    Abc_TtXorHex( word * p, int k, int d )  { p[k>>4] ^= (((word)d)<<((k<<2) & 63));        }
 
+// read/write k-th digit d of a 256-base number:
+static inline int     Abc_TtGet256( word * p, int k )         { return (int)(p[k>>3] >> ((k<<3) & 63)) & 255; }
+static inline void    Abc_TtSet256( word * p, int k, int d )  { p[k>>3] |= (((word)d)<<((k<<3) & 63));        }
+static inline void    Abc_TtXor256( word * p, int k, int d )  { p[k>>3] ^= (((word)d)<<((k<<3) & 63));        }
+
 /**Function*************************************************************
 
   Synopsis    []
@@ -274,6 +284,14 @@
             return 0;
     return 1;
 }
+static inline int Abc_TtImply( word * pIn1, word * pIn2, int nWords )
+{
+    int w;
+    for ( w = 0; w < nWords; w++ )
+        if ( (pIn1[w] & pIn2[w]) != pIn1[w] )
+            return 0;
+    return 1;
+}
 static inline int Abc_TtCompare( word * pIn1, word * pIn2, int nWords )
 {
     int w;
@@ -1011,7 +1029,76 @@
     return Supp;
 }
 
+/**Function*************************************************************
 
+  Synopsis    [Checks if there is a var whose both cofs have supp <= nSuppLim.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Abc_TtCheckCondDep2( word * pTruth, int nVars, int nSuppLim )
+{
+    int v, d, nWords = Abc_TtWordNum(nVars);
+    if ( nVars <= nSuppLim + 1 )
+        return 0;
+    for ( v = 0; v < nVars; v++ )
+    {
+        int nDep0 = 0, nDep1 = 0;
+        for ( d = 0; d < nVars; d++ )
+        {
+            if ( v == d )
+                continue;
+            if ( v < d )
+            {
+                nDep0 += !Abc_TtCheckEqualCofs( pTruth, nWords, v, d, 0, 2 );
+                nDep1 += !Abc_TtCheckEqualCofs( pTruth, nWords, v, d, 1, 3 );
+            }
+            else // if ( v > d )
+            {
+                nDep0 += !Abc_TtCheckEqualCofs( pTruth, nWords, d, v, 0, 1 );
+                nDep1 += !Abc_TtCheckEqualCofs( pTruth, nWords, d, v, 2, 3 );
+            }
+            if ( nDep0 > nSuppLim || nDep1 > nSuppLim )
+                break;
+        }
+        if ( d == nVars )
+            return v;
+    }
+    return nVars;
+}
+static inline int Abc_TtCheckCondDep( word * pTruth, int nVars, int nSuppLim )
+{
+    int nVarsMax = 13;
+    word Cof0[128], Cof1[128]; // pow( 2, nVarsMax-6 )
+    int v, d, nWords = Abc_TtWordNum(nVars);
+    assert( nVars <= nVarsMax );
+    if ( nVars <= nSuppLim + 1 )
+        return 0;
+    for ( v = 0; v < nVars; v++ )
+    {
+        int nDep0 = 0, nDep1 = 0;
+        Abc_TtCofactor0p( Cof0, pTruth, nWords, v );
+        Abc_TtCofactor1p( Cof1, pTruth, nWords, v );
+        for ( d = 0; d < nVars; d++ )
+        {
+            if ( v == d )
+                continue;
+            nDep0 += Abc_TtHasVar( Cof0, nVars, d );
+            nDep1 += Abc_TtHasVar( Cof1, nVars, d );
+            if ( nDep0 > nSuppLim || nDep1 > nSuppLim )
+                break;
+        }
+        if ( d == nVars )
+            return v;
+    }
+    return nVars;
+}
+
+
 /**Function*************************************************************
 
   Synopsis    [Detecting elementary functions.]
@@ -1528,6 +1615,101 @@
 
 /**Function*************************************************************
 
+  Synopsis    [Checks unateness of a function.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Abc_Tt6PosVar( word t, int iVar )
+{
+    return ((t >> (1<<iVar)) & t & s_Truths6Neg[iVar]) == (t & s_Truths6Neg[iVar]);
+}
+static inline int Abc_Tt6NegVar( word t, int iVar )
+{
+    return ((t << (1<<iVar)) & t & s_Truths6[iVar]) == (t & s_Truths6[iVar]);
+}
+static inline int Abc_TtPosVar( word * t, int nVars, int iVar )
+{
+    assert( iVar < nVars );
+    if ( nVars <= 6 )
+        return Abc_Tt6PosVar( t[0], iVar );
+    if ( iVar < 6 )
+    {
+        int i, Shift = (1 << iVar);
+        int nWords = Abc_TtWordNum( nVars );
+        for ( i = 0; i < nWords; i++ )
+            if ( ((t[i] >> Shift) & t[i] & s_Truths6Neg[iVar]) != (t[i] & s_Truths6Neg[iVar]) )
+                return 0;
+        return 1;
+    }
+    else
+    {
+        int i, Step = (1 << (iVar - 6));
+        word * tLimit = t + Abc_TtWordNum( nVars );
+        for ( ; t < tLimit; t += 2*Step )
+            for ( i = 0; i < Step; i++ )
+                if ( t[i] != (t[i] & t[Step+i]) )
+                    return 0;
+        return 1;
+    }
+}
+static inline int Abc_TtNegVar( word * t, int nVars, int iVar )
+{
+    assert( iVar < nVars );
+    if ( nVars <= 6 )
+        return Abc_Tt6NegVar( t[0], iVar );
+    if ( iVar < 6 )
+    {
+        int i, Shift = (1 << iVar);
+        int nWords = Abc_TtWordNum( nVars );
+        for ( i = 0; i < nWords; i++ )
+            if ( ((t[i] << Shift) & t[i] & s_Truths6[iVar]) != (t[i] & s_Truths6[iVar]) )
+                return 0;
+        return 1;
+    }
+    else
+    {
+        int i, Step = (1 << (iVar - 6));
+        word * tLimit = t + Abc_TtWordNum( nVars );
+        for ( ; t < tLimit; t += 2*Step )
+            for ( i = 0; i < Step; i++ )
+                if ( (t[i] & t[Step+i]) != t[Step+i] )
+                    return 0;
+        return 1;
+    }
+}
+static inline int Abc_TtIsUnate( word * t, int nVars )
+{
+    int i;
+    for ( i = 0; i < nVars; i++ )
+        if ( !Abc_TtNegVar(t, nVars, i) && !Abc_TtPosVar(t, nVars, i) )
+            return 0;
+    return 1;
+}
+static inline int Abc_TtIsPosUnate( word * t, int nVars )
+{
+    int i;
+    for ( i = 0; i < nVars; i++ )
+        if ( !Abc_TtPosVar(t, nVars, i) )
+            return 0;
+    return 1;
+}
+static inline void Abc_TtMakePosUnate( word * t, int nVars )
+{
+    int i, nWords = Abc_TtWordNum(nVars);
+    for ( i = 0; i < nVars; i++ )
+        if ( Abc_TtNegVar(t, nVars, i) )
+            Abc_TtFlip( t, nWords, i );
+        else assert( Abc_TtPosVar(t, nVars, i) );
+}
+
+
+/**Function*************************************************************
+
   Synopsis    [Computes ISOP for 6 variables or less.]
 
   Description []
@@ -2104,6 +2286,286 @@
     }
 }
 
+
+
+/**Function*************************************************************
+
+  Synopsis    [Checks existence of bi-decomposition.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline void Abc_TtComputeGraph( word * pTruth, int v, int nVars, int * pGraph )
+{
+    word Cof0[64], Cof1[64]; // pow( 2, nVarsMax-6 )
+    word Cof00[64], Cof01[64], Cof10[64], Cof11[64];
+    word CofXor, CofAndTest; 
+    int i, w, nWords = Abc_TtWordNum(nVars);
+    pGraph[v] |= (1 << v);
+    if ( v == nVars - 1 )
+        return;
+    assert( v < nVars - 1 );
+    Abc_TtCofactor0p( Cof0, pTruth, nWords, v );
+    Abc_TtCofactor1p( Cof1, pTruth, nWords, v );
+    for ( i = v + 1; i < nVars; i++ )
+    {
+        Abc_TtCofactor0p( Cof00, Cof0, nWords, i );
+        Abc_TtCofactor1p( Cof01, Cof0, nWords, i );
+        Abc_TtCofactor0p( Cof10, Cof1, nWords, i );
+        Abc_TtCofactor1p( Cof11, Cof1, nWords, i );
+        for ( w = 0; w < nWords; w++ )
+        {
+            CofXor     =  Cof00[w] ^ Cof01[w]  ^  Cof10[w] ^ Cof11[w];
+            CofAndTest = (Cof00[w] & Cof01[w]) | (Cof10[w] & Cof11[w]);
+            if ( CofXor & CofAndTest )
+            {
+                pGraph[v] |= (1 << i);
+                pGraph[i] |= (1 << v);
+            }
+            else if ( CofXor & ~CofAndTest )
+            {
+                pGraph[v] |= (1 << (16+i));
+                pGraph[i] |= (1 << (16+v));
+            }
+        }
+    }
+}
+static inline void Abc_TtPrintVarSet( int Mask, int nVars )
+{
+    int i;
+    for ( i = 0; i < nVars; i++ )
+        if ( (Mask >> i) & 1 )
+            printf( "1" );
+        else
+            printf( "." );
+}
+static inline void Abc_TtPrintBiDec( word * pTruth, int nVars )
+{
+    int v, pGraph[12] = {0};
+    assert( nVars <= 12 );
+    for ( v = 0; v < nVars; v++ )
+    {
+        Abc_TtComputeGraph( pTruth, v, nVars, pGraph );
+        Abc_TtPrintVarSet( pGraph[v], nVars );
+        printf( "    " );
+        Abc_TtPrintVarSet( pGraph[v] >> 16, nVars );
+        printf( "\n" );
+    }
+}
+static inline int Abc_TtVerifyBiDec( word * pTruth, int nVars, int This, int That, int nSuppLim, word wThis, word wThat )
+{
+    int pVarsThis[12], pVarsThat[12], pVarsAll[12];
+    int nThis = Abc_TtBitCount16(This);
+    int nThat = Abc_TtBitCount16(That);
+    int i, k, nWords = Abc_TtWordNum(nVars);
+    word pThis[64] = {wThis}, pThat[64] = {wThat};
+    assert( nVars <= 12 );
+    for ( i = 0; i < nVars; i++ )
+        pVarsAll[i] = i;
+    for ( i = k = 0; i < nVars; i++ )
+        if ( (This >> i) & 1 )
+            pVarsThis[k++] = i;
+    assert( k == nThis );
+    for ( i = k = 0; i < nVars; i++ )
+        if ( (That >> i) & 1 )
+            pVarsThat[k++] = i;
+    assert( k == nThat );
+    Abc_TtStretch6( pThis, nThis, nVars );
+    Abc_TtStretch6( pThat, nThat, nVars );
+    Abc_TtExpand( pThis, nVars, pVarsThis, nThis, pVarsAll, nVars );
+    Abc_TtExpand( pThat, nVars, pVarsThat, nThat, pVarsAll, nVars );
+    for ( k = 0; k < nWords; k++ )
+        if ( pTruth[k] != (pThis[k] & pThat[k]) )
+            return 0;
+    return 1;
+}
+static inline void Abc_TtExist( word * pTruth, int iVar, int nWords )
+{
+    word Cof0[64], Cof1[64]; 
+    Abc_TtCofactor0p( Cof0, pTruth, nWords, iVar );
+    Abc_TtCofactor1p( Cof1, pTruth, nWords, iVar );
+    Abc_TtOr( pTruth, Cof0, Cof1, nWords );
+}
+static inline int Abc_TtCheckBiDec( word * pTruth, int nVars, int This, int That )
+{
+    int VarMask[2] = {This & ~That, That & ~This};
+    int v, c, nWords = Abc_TtWordNum(nVars);
+    word pTempR[2][64]; 
+    for ( c = 0; c < 2; c++ )
+    {
+        Abc_TtCopy( pTempR[c], pTruth, nWords, 0 );
+        for ( v = 0; v < nVars; v++ )
+            if ( ((VarMask[c] >> v) & 1) )
+                Abc_TtExist( pTempR[c], v, nWords );
+    }
+    for ( v = 0; v < nWords; v++ )
+        if ( ~pTruth[v] & pTempR[0][v] & pTempR[1][v] )
+            return 0;
+    return 1;
+}
+static inline word Abc_TtDeriveBiDecOne( word * pTruth, int nVars, int This )
+{
+    word pTemp[64]; 
+    int nThis = Abc_TtBitCount16(This);
+    int v, nWords = Abc_TtWordNum(nVars);
+    Abc_TtCopy( pTemp, pTruth, nWords, 0 );
+    for ( v = 0; v < nVars; v++ )
+        if ( !((This >> v) & 1) )
+            Abc_TtExist( pTemp, v, nWords );
+    Abc_TtShrink( pTemp, nThis, nVars, This );
+    return Abc_Tt6Stretch( pTemp[0], nThis );
+}
+static inline void Abc_TtDeriveBiDec( word * pTruth, int nVars, int This, int That, int nSuppLim, word * pThis, word * pThat )
+{
+    assert( Abc_TtBitCount16(This) <= nSuppLim );
+    assert( Abc_TtBitCount16(That) <= nSuppLim );
+    pThis[0] = Abc_TtDeriveBiDecOne( pTruth, nVars, This );
+    pThat[0] = Abc_TtDeriveBiDecOne( pTruth, nVars, That );
+    if ( !Abc_TtVerifyBiDec(pTruth, nVars, This, That, nSuppLim, pThis[0], pThat[0] ) )
+        printf( "Bi-decomposition verification failed.\n" );
+}
+// detect simple case of decomposition with topmost AND gate
+static inline int Abc_TtCheckBiDecSimple( word * pTruth, int nVars, int nSuppLim )
+{
+    word Cof0[64], Cof1[64]; 
+    int v, Res = 0, nDecVars = 0, nWords = Abc_TtWordNum(nVars);
+    for ( v = 0; v < nVars; v++ )
+    {
+        Abc_TtCofactor0p( Cof0, pTruth, nWords, v );
+        Abc_TtCofactor1p( Cof1, pTruth, nWords, v );
+        if ( !Abc_TtIsConst0(Cof0, nWords) && !Abc_TtIsConst0(Cof1, nWords) )
+            continue;
+        nDecVars++;
+        Res |= 1 << v;
+        if ( nDecVars >= nVars - nSuppLim )
+            return ((Res ^ (int)Abc_Tt6Mask(nVars)) << 16) | Res;
+    }
+    return 0;
+}
+static inline int Abc_TtProcessBiDecInt( word * pTruth, int nVars, int nSuppLim )
+{
+    int i, v, Res, nSupp, CountShared = 0, pGraph[12] = {0};
+    assert( nSuppLim < nVars && nVars <= 2 * nSuppLim && nVars <= 12 );
+    assert( 2 <= nSuppLim && nSuppLim <= 6 );
+    Res = Abc_TtCheckBiDecSimple( pTruth, nVars, nSuppLim );
+    if ( Res )
+        return Res;
+    for ( v = 0; v < nVars; v++ )
+    {
+        Abc_TtComputeGraph( pTruth, v, nVars, pGraph );
+        nSupp = Abc_TtBitCount16(pGraph[v] & 0xFFFF);
+        if ( nSupp > nSuppLim ) 
+        {
+            // this variable is shared - check if the limit is exceeded
+            if ( ++CountShared > 2*nSuppLim - nVars )
+                return 0;
+        }
+        else if ( nVars - nSupp <= nSuppLim )
+        {
+            int This = pGraph[v] & 0xFFFF;
+            int That = This ^ (int)Abc_Tt6Mask(nVars);
+            // find the other component
+            int Graph = That;
+            for ( i = 0; i < nVars; i++ )
+                if ( (That >> i) & 1 )
+                    Graph |= pGraph[i] & 0xFFFF;
+            // check if this can be done
+            if ( Abc_TtBitCount16(Graph) > nSuppLim )
+                continue;
+            // try decomposition
+            if ( Abc_TtCheckBiDec(pTruth, nVars, This, Graph) )
+                return (Graph << 16) | This;
+        }
+    }
+    return 0;
+}
+static inline int Abc_TtProcessBiDec( word * pTruth, int nVars, int nSuppLim )
+{
+    word pFunc[64];
+    int Res, nWords = Abc_TtWordNum(nVars);
+    Abc_TtCopy( pFunc, pTruth, nWords, 0 );
+    Res = Abc_TtProcessBiDecInt( pFunc, nVars, nSuppLim );
+    if ( Res )
+        return Res;
+    Abc_TtCopy( pFunc, pTruth, nWords, 1 );
+    Res = Abc_TtProcessBiDecInt( pFunc, nVars, nSuppLim );
+    if ( Res )
+        return Res | (1 << 30);
+    return 0;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Tests decomposition procedures.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     [] 
+
+***********************************************************************/
+static inline void Abc_TtProcessBiDecTest( word * pTruth, int nVars, int nSuppLim )
+{
+    word This, That, pTemp[64];
+    int Res, resThis, resThat, nThis, nThat;
+    int nWords = Abc_TtWordNum(nVars);
+    Abc_TtCopy( pTemp, pTruth, nWords, 0 );
+    Res = Abc_TtProcessBiDec( pTemp, nVars, nSuppLim );
+    if ( Res == 0 )
+    {
+        //Dau_DsdPrintFromTruth( pTemp, nVars );
+        //printf( "Non_dec\n\n" );
+        return;
+    }
+
+    resThis = Res & 0xFFFF;
+    resThat = Res >> 16;
+
+    Abc_TtDeriveBiDec( pTemp, nVars, resThis, resThat, nSuppLim, &This, &That );
+    return;
+
+    //if ( !(resThis & resThat) )
+    //    return;
+
+//    Dau_DsdPrintFromTruth( pTemp, nVars );
+
+    nThis = Abc_TtBitCount16(resThis);
+    nThat = Abc_TtBitCount16(resThat);
+
+    printf( "Variable sets:    " );
+    Abc_TtPrintVarSet( resThis, nVars );
+    printf( "    " );
+    Abc_TtPrintVarSet( resThat, nVars );
+    printf( "\n" );
+    Abc_TtDeriveBiDec( pTemp, nVars, resThis, resThat, nSuppLim, &This, &That );
+//    Dau_DsdPrintFromTruth( &This, nThis );
+//    Dau_DsdPrintFromTruth( &That, nThat );
+    printf( "\n" );
+}
+static inline void Abc_TtProcessBiDecExperiment()
+{
+    int nVars = 3;
+    int nSuppLim = 2;
+    int Res, resThis, resThat;
+    word This, That;
+//    word t = ABC_CONST(0x8000000000000000);
+//    word t = (s_Truths6[0] | s_Truths6[1]) & (s_Truths6[2] | s_Truths6[3] | s_Truths6[4] | s_Truths6[5]);
+//    word t = ((s_Truths6[0] & s_Truths6[1]) | (~s_Truths6[1] & s_Truths6[2]));
+    word t = ((s_Truths6[0] | s_Truths6[1]) & (s_Truths6[1] | s_Truths6[2]));
+    Abc_TtPrintBiDec( &t, nVars );
+    Res = Abc_TtProcessBiDec( &t, nVars, nSuppLim );
+    resThis = Res & 0xFFFF;
+    resThat = Res >> 16;
+    Abc_TtDeriveBiDec( &t, nVars, resThis, resThat, nSuppLim, &This, &That );
+//    Dau_DsdPrintFromTruth( &This, Abc_TtBitCount16(resThis) );
+//    Dau_DsdPrintFromTruth( &That, Abc_TtBitCount16(resThat) );
+    nVars = nSuppLim;
+}
 
 /*=== utilTruth.c ===========================================================*/
 
diff --git a/abc-build/src/misc/vec/vecFlt.h b/abc-build/src/misc/vec/vecFlt.h
--- a/abc-build/src/misc/vec/vecFlt.h
+++ b/abc-build/src/misc/vec/vecFlt.h
@@ -86,6 +86,16 @@
     p->pArray = p->nCap? ABC_ALLOC( float, p->nCap ) : NULL;
     return p;
 }
+static inline Vec_Flt_t * Vec_FltAllocExact( int nCap )
+{
+    Vec_Flt_t * p;
+    assert( nCap >= 0 );
+    p = ABC_ALLOC( Vec_Flt_t, 1 );
+    p->nSize  = 0;
+    p->nCap   = nCap;
+    p->pArray = p->nCap? ABC_ALLOC( float, p->nCap ) : NULL;
+    return p;
+}
 
 /**Function*************************************************************
 
diff --git a/abc-build/src/misc/vec/vecHsh.h b/abc-build/src/misc/vec/vecHsh.h
--- a/abc-build/src/misc/vec/vecHsh.h
+++ b/abc-build/src/misc/vec/vecHsh.h
@@ -46,6 +46,13 @@
     int          iNext;
 };
 
+typedef union Hsh_IntObjWord_t_ Hsh_IntObjWord_t;
+union Hsh_IntObjWord_t_
+{
+    Hsh_IntObj_t wObj;
+    word         wWord;
+};
+
 typedef struct Hsh_IntMan_t_ Hsh_IntMan_t;
 struct Hsh_IntMan_t_
 {
@@ -80,7 +87,7 @@
 
 static inline unsigned *      Hsh_IntData( Hsh_IntMan_t * p, int iData )  { return (unsigned *)Vec_IntEntryP( p->vData, p->nSize * iData );             }
 static inline Hsh_IntObj_t *  Hsh_IntObj( Hsh_IntMan_t * p, int iObj )    { return iObj == -1 ? NULL : (Hsh_IntObj_t *)Vec_WrdEntryP( p->vObjs, iObj ); }
-static inline word            Hsh_IntWord( int iData, int iNext )         { Hsh_IntObj_t Obj = {iData, iNext}; return *((word *)&Obj);                  }
+static inline word            Hsh_IntWord( int iData, int iNext )         { Hsh_IntObjWord_t Obj = { {iData, iNext} }; return Obj.wWord;                }
 
 static inline Hsh_VecObj_t *  Hsh_VecObj( Hsh_VecMan_t * p, int i )  { return i == -1 ? NULL : (Hsh_VecObj_t *)Vec_IntEntryP(p->vData, Vec_IntEntry(p->vMap, i));  }
 
diff --git a/abc-build/src/misc/vec/vecInt.h b/abc-build/src/misc/vec/vecInt.h
--- a/abc-build/src/misc/vec/vecInt.h
+++ b/abc-build/src/misc/vec/vecInt.h
@@ -65,6 +65,10 @@
     for ( i = 0; (i < Vec_IntSize(vVec1)) && (((Entry1) = Vec_IntEntry(vVec1, i)), 1) && (((Entry2) = Vec_IntEntry(vVec2, i)), 1); i++ )
 #define Vec_IntForEachEntryDouble( vVec, Entry1, Entry2, i )                                \
     for ( i = 0; (i+1 < Vec_IntSize(vVec)) && (((Entry1) = Vec_IntEntry(vVec, i)), 1) && (((Entry2) = Vec_IntEntry(vVec, i+1)), 1); i += 2 )
+#define Vec_IntForEachEntryDoubleStart( vVec, Entry1, Entry2, i, Start )                    \
+    for ( i = Start; (i+1 < Vec_IntSize(vVec)) && (((Entry1) = Vec_IntEntry(vVec, i)), 1) && (((Entry2) = Vec_IntEntry(vVec, i+1)), 1); i += 2 )
+#define Vec_IntForEachEntryTriple( vVec, Entry1, Entry2, Entry3, i )                        \
+    for ( i = 0; (i+2 < Vec_IntSize(vVec)) && (((Entry1) = Vec_IntEntry(vVec, i)), 1) && (((Entry2) = Vec_IntEntry(vVec, i+1)), 1) && (((Entry3) = Vec_IntEntry(vVec, i+2)), 1); i += 3 )
 #define Vec_IntForEachEntryThisNext( vVec, This, Next, i )                                  \
     for ( i = 0, (This) = (Next) = (Vec_IntSize(vVec) ? Vec_IntEntry(vVec, 0) : -1); (i+1 < Vec_IntSize(vVec)) && (((Next) = Vec_IntEntry(vVec, i+1)), 1); i += 2, (This) = (Next) )
 
@@ -94,6 +98,16 @@
     p->pArray = p->nCap? ABC_ALLOC( int, p->nCap ) : NULL;
     return p;
 }
+static inline Vec_Int_t * Vec_IntAllocExact( int nCap )
+{
+    Vec_Int_t * p;
+    assert( nCap >= 0 );
+    p = ABC_ALLOC( Vec_Int_t, 1 );
+    p->nSize  = 0;
+    p->nCap   = nCap;
+    p->pArray = p->nCap? ABC_ALLOC( int, p->nCap ) : NULL;
+    return p;
+}
 
 /**Function*************************************************************
 
@@ -551,6 +565,14 @@
         p->pArray[i] = Fill;
     p->nSize = nSize;
 }
+static inline void Vec_IntFillTwo( Vec_Int_t * p, int nSize, int FillEven, int FillOdd )
+{
+    int i;
+    Vec_IntGrow( p, nSize );
+    for ( i = 0; i < nSize; i++ )
+        p->pArray[i] = (i & 1) ? FillOdd : FillEven;
+    p->nSize = nSize;
+}
 
 /**Function*************************************************************
 
@@ -593,6 +615,11 @@
     Vec_IntFillExtra( p, i + 1, 0 );
     return Vec_IntEntry( p, i );
 }
+static inline int Vec_IntGetEntryFull( Vec_Int_t * p, int i )
+{
+    Vec_IntFillExtra( p, i + 1, -1 );
+    return Vec_IntEntry( p, i );
+}
 
 /**Function*************************************************************
 
@@ -688,6 +715,11 @@
     }
     p->pArray[p->nSize++] = Entry;
 }
+static inline void Vec_IntPushTwo( Vec_Int_t * p, int Entry1, int Entry2 )
+{
+    Vec_IntPush( p, Entry1 );
+    Vec_IntPush( p, Entry2 );
+}
 static inline void Vec_IntPushArray( Vec_Int_t * p, int * pEntries, int nEntries )
 {
     int i;
@@ -1037,6 +1069,34 @@
 
 /**Function*************************************************************
 
+  Synopsis    [Removes odd entries.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline void Vec_IntRemoveOdd( Vec_Int_t * p )
+{
+    int i;
+    assert( (p->nSize & 1) == 0 );
+    p->nSize >>= 1;
+    for ( i = 0; i < p->nSize; i++ )
+        p->pArray[i] = p->pArray[2*i];
+}
+static inline void Vec_IntRemoveEven( Vec_Int_t * p )
+{
+    int i;
+    assert( (p->nSize & 1) == 0 );
+    p->nSize >>= 1;
+    for ( i = 0; i < p->nSize; i++ )
+        p->pArray[i] = p->pArray[2*i+1];
+}
+
+/**Function*************************************************************
+
   Synopsis    []
 
   Description []
@@ -1117,6 +1177,20 @@
         Counter += (p->pArray[i] == Entry);
     return Counter;
 }
+static inline int Vec_IntCountLarger( Vec_Int_t * p, int Entry ) 
+{
+    int i, Counter = 0;
+    for ( i = 0; i < p->nSize; i++ )
+        Counter += (p->pArray[i] > Entry);
+    return Counter;
+}
+static inline int Vec_IntCountSmaller( Vec_Int_t * p, int Entry ) 
+{
+    int i, Counter = 0;
+    for ( i = 0; i < p->nSize; i++ )
+        Counter += (p->pArray[i] < Entry);
+    return Counter;
+}
 
 /**Function*************************************************************
 
@@ -1136,6 +1210,13 @@
         Counter += (p->pArray[i] > 0);
     return Counter;
 }
+static inline int Vec_IntCountZero( Vec_Int_t * p ) 
+{
+    int i, Counter = 0;
+    for ( i = 0; i < p->nSize; i++ )
+        Counter += (p->pArray[i] == 0);
+    return Counter;
+}
 
 /**Function*************************************************************
 
@@ -1757,6 +1838,12 @@
     Vec_IntForEachEntry( vVec, Entry, i )
         printf( " %d", Entry );
     printf( " }\n" );
+}
+static inline void Vec_IntPrintBinary( Vec_Int_t * vVec )
+{
+    int i, Entry;
+    Vec_IntForEachEntry( vVec, Entry, i )
+        printf( "%d", (int)(Entry != 0) );
 }
 
 /**Function*************************************************************
diff --git a/abc-build/src/misc/vec/vecMem.h b/abc-build/src/misc/vec/vecMem.h
--- a/abc-build/src/misc/vec/vecMem.h
+++ b/abc-build/src/misc/vec/vecMem.h
@@ -84,6 +84,14 @@
   SeeAlso     []
 
 ***********************************************************************/
+static inline void Vec_MemAlloc_( Vec_Mem_t * p, int nEntrySize, int LogPageSze )
+{
+    memset( p, 0, sizeof(Vec_Mem_t) );
+    p->nEntrySize = nEntrySize;
+    p->LogPageSze = LogPageSze;
+    p->PageMask   = (1 << p->LogPageSze) - 1;
+    p->iPage      = -1;
+}
 static inline Vec_Mem_t * Vec_MemAlloc( int nEntrySize, int LogPageSze )
 {
     Vec_Mem_t * p;
diff --git a/abc-build/src/misc/vec/vecPtr.h b/abc-build/src/misc/vec/vecPtr.h
--- a/abc-build/src/misc/vec/vecPtr.h
+++ b/abc-build/src/misc/vec/vecPtr.h
@@ -91,6 +91,16 @@
     p->pArray = p->nCap? ABC_ALLOC( void *, p->nCap ) : NULL;
     return p;
 }
+static inline Vec_Ptr_t * Vec_PtrAllocExact( int nCap )
+{
+    Vec_Ptr_t * p;
+    assert( nCap >= 0 );
+    p = ABC_ALLOC( Vec_Ptr_t, 1 );
+    p->nSize  = 0;
+    p->nCap   = nCap;
+    p->pArray = p->nCap? ABC_ALLOC( void *, p->nCap ) : NULL;
+    return p;
+}
 
 /**Function*************************************************************
 
@@ -883,14 +893,15 @@
             p->pArray[k++] = p->pArray[i];
     p->nSize = k;
 }
-static void Vec_PtrUniqify2( Vec_Ptr_t * p, int (*Vec_PtrSortCompare)(), void (*Vec_PtrObjFree)(), Vec_Int_t * vCounts )
+static void Vec_PtrUniqify2( Vec_Ptr_t * p, int (*Vec_PtrSortCompare)(void**, void**), void (*Vec_PtrObjFree)(void*), Vec_Int_t * vCounts ) ___unused;
+static void Vec_PtrUniqify2( Vec_Ptr_t * p, int (*Vec_PtrSortCompare)(void**, void**), void (*Vec_PtrObjFree)(void*), Vec_Int_t * vCounts )
 {
     int i, k;
     if ( vCounts )
         Vec_IntFill( vCounts, 1, 1 );
     if ( p->nSize < 2 )
         return;
-    Vec_PtrSort( p, Vec_PtrSortCompare );
+    Vec_PtrSort( p, (int (*)())Vec_PtrSortCompare );
     for ( i = k = 1; i < p->nSize; i++ )
         if ( Vec_PtrSortCompare(p->pArray+i, p->pArray+k-1) != 0 )
         {
diff --git a/abc-build/src/misc/vec/vecSet.h b/abc-build/src/misc/vec/vecSet.h
--- a/abc-build/src/misc/vec/vecSet.h
+++ b/abc-build/src/misc/vec/vecSet.h
@@ -242,6 +242,20 @@
     Vec_SetIncLimitS( p->pPages[p->iPageS], nWords );
     return Vec_SetHandCurrentS(p) - nWords;
 }
+static inline int Vec_SetFetchH( Vec_Set_t * p, int nBytes )
+{
+    return Vec_SetAppend(p, NULL, (nBytes + 3) >> 2);
+}
+static inline void * Vec_SetFetch( Vec_Set_t * p, int nBytes )
+{
+    return (void *)Vec_SetEntry( p, Vec_SetFetchH(p, nBytes) );
+}
+static inline char * Vec_SetStrsav( Vec_Set_t * p, char * pName )
+{
+    char * pStr = (char *)Vec_SetFetch( p, strlen(pName) + 1 );
+    strcpy( pStr, pName );
+    return pStr;
+}
 
 /**Function*************************************************************
 
diff --git a/abc-build/src/misc/vec/vecStr.h b/abc-build/src/misc/vec/vecStr.h
--- a/abc-build/src/misc/vec/vecStr.h
+++ b/abc-build/src/misc/vec/vecStr.h
@@ -80,6 +80,16 @@
     p->pArray = p->nCap? ABC_ALLOC( char, p->nCap ) : NULL;
     return p;
 }
+static inline Vec_Str_t * Vec_StrAllocExact( int nCap )
+{
+    Vec_Str_t * p;
+    assert( nCap >= 0 );
+    p = ABC_ALLOC( Vec_Str_t, 1 );
+    p->nSize  = 0;
+    p->nCap   = nCap;
+    p->pArray = p->nCap? ABC_ALLOC( char, p->nCap ) : NULL;
+    return p;
+}
 
 /**Function*************************************************************
 
@@ -201,6 +211,18 @@
   SeeAlso     []
 
 ***********************************************************************/
+static inline void Vec_StrZero( Vec_Str_t * p )
+{
+    p->pArray = NULL;
+    p->nSize = 0;
+    p->nCap = 0;
+}
+static inline void Vec_StrErase( Vec_Str_t * p )
+{
+    ABC_FREE( p->pArray );
+    p->nSize = 0;
+    p->nCap = 0;
+}
 static inline void Vec_StrFree( Vec_Str_t * p )
 {
     ABC_FREE( p->pArray );
@@ -531,6 +553,13 @@
     }
     p->pArray[p->nSize++] = Entry;
 }
+static inline void Vec_StrPushBuffer( Vec_Str_t * p, char * pBuffer, int nSize )
+{
+    if ( p->nSize + nSize > p->nCap )
+        Vec_StrGrow( p, 2 * (p->nSize + nSize) );
+    memcpy( p->pArray + p->nSize, pBuffer, nSize );
+    p->nSize += nSize;
+}
 
 /**Function*************************************************************
 
@@ -634,6 +663,12 @@
 {
     Vec_StrPrintStr( p, pString );
 }
+static inline void Vec_StrCopy( Vec_Str_t * p, const char * pString )
+{
+    Vec_StrClear( p );
+    Vec_StrAppend( p, pString );
+    Vec_StrPush( p, '\0' );
+}
 
 /**Function*************************************************************
 
@@ -673,6 +708,39 @@
     int i, Counter = 0;
     for ( i = 0; i < p->nSize; i++ )
         Counter += (int)p->pArray[i];
+    return Counter;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline int Vec_StrCountEntry( Vec_Str_t * p, char Entry ) 
+{
+    int i, Counter = 0;
+    for ( i = 0; i < p->nSize; i++ )
+        Counter += (p->pArray[i] == Entry);
+    return Counter;
+}
+static inline int Vec_StrCountLarger( Vec_Str_t * p, char Entry ) 
+{
+    int i, Counter = 0;
+    for ( i = 0; i < p->nSize; i++ )
+        Counter += (p->pArray[i] > Entry);
+    return Counter;
+}
+static inline int Vec_StrCountSmaller( Vec_Str_t * p, char Entry ) 
+{
+    int i, Counter = 0;
+    for ( i = 0; i < p->nSize; i++ )
+        Counter += (p->pArray[i] < Entry);
     return Counter;
 }
 
diff --git a/abc-build/src/misc/vec/vecWec.h b/abc-build/src/misc/vec/vecWec.h
--- a/abc-build/src/misc/vec/vecWec.h
+++ b/abc-build/src/misc/vec/vecWec.h
@@ -95,6 +95,16 @@
     p->pArray = p->nCap? ABC_CALLOC( Vec_Int_t, p->nCap ) : NULL;
     return p;
 }
+static inline Vec_Wec_t * Vec_WecAllocExact( int nCap )
+{
+    Vec_Wec_t * p;
+    assert( nCap >= 0 );
+    p = ABC_ALLOC( Vec_Wec_t, 1 );
+    p->nSize  = 0;
+    p->nCap   = nCap;
+    p->pArray = p->nCap? ABC_CALLOC( Vec_Int_t, p->nCap ) : NULL;
+    return p;
+}
 static inline Vec_Wec_t * Vec_WecStart( int nSize )
 {
     Vec_Wec_t * p;
diff --git a/abc-build/src/misc/vec/vecWrd.h b/abc-build/src/misc/vec/vecWrd.h
--- a/abc-build/src/misc/vec/vecWrd.h
+++ b/abc-build/src/misc/vec/vecWrd.h
@@ -88,6 +88,16 @@
     p->pArray = p->nCap? ABC_ALLOC( word, p->nCap ) : NULL;
     return p;
 }
+static inline Vec_Wrd_t * Vec_WrdAllocExact( int nCap )
+{
+    Vec_Wrd_t * p;
+    assert( nCap >= 0 );
+    p = ABC_ALLOC( Vec_Wrd_t, 1 );
+    p->nSize  = 0;
+    p->nCap   = nCap;
+    p->pArray = p->nCap? ABC_ALLOC( word, p->nCap ) : NULL;
+    return p;
+}
 
 /**Function*************************************************************
 
diff --git a/abc-build/src/opt/dau/dauGia.c b/abc-build/src/opt/dau/dauGia.c
--- a/abc-build/src/opt/dau/dauGia.c
+++ b/abc-build/src/opt/dau/dauGia.c
@@ -30,7 +30,7 @@
 
 extern int Kit_TruthToGia( Gia_Man_t * pMan, unsigned * pTruth, int nVars, Vec_Int_t * vMemory, Vec_Int_t * vLeaves, int fHash );
 
-#define DAU_DSD_MAX_VAR 8
+#define DAU_DSD_MAX_VAR 12
 
 static int m_Calls = 0;
 static int m_NonDsd = 0;
@@ -494,8 +494,15 @@
     vCover  = Vec_IntAlloc( 1 << 16 );
     Gia_ManHashStart( pNew );
     Gia_ObjComputeTruthTableStart( p, Gia_ManLutSizeMax(p) );
-    Gia_ManForEachLut( p, iLut )
+    Gia_ManForEachAnd( p, pObj, iLut )
     {
+        if ( Gia_ObjIsBuf(pObj) )
+        {
+            pObj->Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(pObj) );
+            continue;
+        }
+        if ( !Gia_ObjIsLut(p, iLut) )
+            continue;
         // collect leaves
         Vec_IntClear( vLeaves );
         Gia_LutForEachFanin( p, iLut, iVar, k )
diff --git a/abc-build/src/opt/dau/dauMerge.c b/abc-build/src/opt/dau/dauMerge.c
--- a/abc-build/src/opt/dau/dauMerge.c
+++ b/abc-build/src/opt/dau/dauMerge.c
@@ -264,7 +264,7 @@
 
 /**Function*************************************************************
 
-  Synopsis    [Computes independence status for each opening paranthesis.]
+  Synopsis    [Computes independence status for each opening parenthesis.]
 
   Description []
                
diff --git a/abc-build/src/opt/rwr/rwrEva.c b/abc-build/src/opt/rwr/rwrEva.c
--- a/abc-build/src/opt/rwr/rwrEva.c
+++ b/abc-build/src/opt/rwr/rwrEva.c
@@ -68,7 +68,7 @@
     char * pPerm;
     int Required, nNodesSaved;
     int nNodesSaveCur = -1; // Suppress "might be used uninitialized"
-    int i, GainCur, GainBest = -1;
+    int i, GainCur = -1, GainBest = -1;
     abctime clk, clk2;//, Counter;
 
     p->nNodesConsidered++;
diff --git a/abc-build/src/opt/sfm/sfm.h b/abc-build/src/opt/sfm/sfm.h
--- a/abc-build/src/opt/sfm/sfm.h
+++ b/abc-build/src/opt/sfm/sfm.h
@@ -77,7 +77,7 @@
 extern int          Sfm_NodeReadFixed( Sfm_Ntk_t * p, int i );
 extern int          Sfm_NodeReadUsed( Sfm_Ntk_t * p, int i );
 /*=== sfmWin.c ==========================================================*/
-extern Vec_Int_t *  Sfm_NtkDfs( Sfm_Ntk_t * p );
+extern Vec_Int_t *  Sfm_NtkDfs( Sfm_Ntk_t * p, Vec_Wec_t * vGroups, Vec_Int_t * vGroupMap, Vec_Int_t * vBoxesLeft );
 
 
 ABC_NAMESPACE_HEADER_END
diff --git a/abc-build/src/opt/sfm/sfmCore.c b/abc-build/src/opt/sfm/sfmCore.c
--- a/abc-build/src/opt/sfm/sfmCore.c
+++ b/abc-build/src/opt/sfm/sfmCore.c
@@ -258,8 +258,13 @@
 {
     int i, k, Counter = 0;
     p->timeTotal = Abc_Clock();
-    if ( pPars->fVerbose && Vec_StrSum(p->vFixed) > 0 )
-        printf( "Performing MFS with %d fixed objects.\n", Vec_StrSum(p->vFixed) );
+    if ( pPars->fVerbose )
+    {
+        int nFixed = p->vFixed ? Vec_StrSum(p->vFixed) : 0;
+        int nEmpty = p->vEmpty ? Vec_StrSum(p->vEmpty) : 0;
+        printf( "Performing MFS with %d PIs, %d POs, %d nodes (%d flexible, %d fixed, %d empty).\n", 
+            p->nPis, p->nPos, p->nNodes, p->nNodes-nFixed, nFixed, nEmpty );
+    }
     p->pPars = pPars;
     Sfm_NtkPrepare( p );
 //    Sfm_ComputeInterpolantCheck( p );
diff --git a/abc-build/src/opt/sfm/sfmNtk.c b/abc-build/src/opt/sfm/sfmNtk.c
--- a/abc-build/src/opt/sfm/sfmNtk.c
+++ b/abc-build/src/opt/sfm/sfmNtk.c
@@ -54,7 +54,8 @@
             assert( Vec_IntSize(vArray) == 0 && Vec_StrEntry(vFixed, i) == (char)0 );
         // nodes are in a topo order; POs cannot be fanins
         Vec_IntForEachEntry( vArray, Fanin, k )
-            assert( Fanin < i && Fanin + nPos < Vec_WecSize(vFanins) );
+//            assert( Fanin < i && Fanin + nPos < Vec_WecSize(vFanins) );
+            assert( Fanin + nPos < Vec_WecSize(vFanins) );
         // POs have one fanout
         if ( i + nPos >= Vec_WecSize(vFanins) )
             assert( Vec_IntSize(vArray) == 1 && Vec_StrEntry(vFixed, i) == (char)0 );
diff --git a/abc-build/src/opt/sfm/sfmSat.c b/abc-build/src/opt/sfm/sfmSat.c
--- a/abc-build/src/opt/sfm/sfmSat.c
+++ b/abc-build/src/opt/sfm/sfmSat.c
@@ -91,7 +91,8 @@
             if ( Vec_IntSize(vClause) == 0 )
                 break;
             RetValue = sat_solver_addclause( p->pSat, Vec_IntArray(vClause), Vec_IntArray(vClause) + Vec_IntSize(vClause) );
-            assert( RetValue );
+            if ( RetValue == 0 )
+                return 0;
         }
     }
     if ( Vec_IntSize(p->vTfo) > 0 )
@@ -126,7 +127,8 @@
                 if ( Vec_IntSize(vClause) == 0 )
                     break;
                 RetValue = sat_solver_addclause( p->pSat, Vec_IntArray(vClause), Vec_IntArray(vClause) + Vec_IntSize(vClause) );
-                assert( RetValue );
+                if ( RetValue == 0 )
+                    return 0;
             }
         }
         // create XOR clauses for the roots
diff --git a/abc-build/src/opt/sfm/sfmWin.c b/abc-build/src/opt/sfm/sfmWin.c
--- a/abc-build/src/opt/sfm/sfmWin.c
+++ b/abc-build/src/opt/sfm/sfmWin.c
@@ -125,33 +125,53 @@
 
   Synopsis    [Collects used internal nodes in a topological order.]
 
-  Description []
+  Description [Additionally considers objects in groups as a single object
+  and collects them in a topological order together as single entity.]
                
   SideEffects []
 
   SeeAlso     []
 
 ***********************************************************************/
-void Sfm_NtkDfs_rec( Sfm_Ntk_t * p, int iNode, Vec_Int_t * vNodes )
+void Sfm_NtkDfs_rec( Sfm_Ntk_t * p, int iNode, Vec_Int_t * vNodes, Vec_Wec_t * vGroups, Vec_Int_t * vGroupMap, Vec_Int_t * vBoxesLeft )
 {
     int i, iFanin;
     if ( Sfm_ObjIsPi(p, iNode) )
         return;
     if ( Sfm_ObjIsTravIdCurrent(p, iNode) )
         return;
-    Sfm_ObjSetTravIdCurrent(p, iNode);
-    Sfm_ObjForEachFanin( p, iNode, iFanin, i )
-        Sfm_NtkDfs_rec( p, iFanin, vNodes );
-    Vec_IntPush( vNodes, iNode );
+    if ( Vec_IntEntry(vGroupMap, iNode) >= 0 )
+    {
+        int k, iGroup = Abc_Lit2Var( Vec_IntEntry(vGroupMap, iNode) );
+        Vec_Int_t * vGroup = Vec_WecEntry( vGroups, iGroup );
+        Vec_IntForEachEntry( vGroup, iNode, i )
+            assert( Sfm_ObjIsNode(p, iNode) );
+        Vec_IntForEachEntry( vGroup, iNode, i )
+            Sfm_ObjSetTravIdCurrent( p, iNode );
+        Vec_IntForEachEntry( vGroup, iNode, i )
+            Sfm_ObjForEachFanin( p, iNode, iFanin, k )
+                Sfm_NtkDfs_rec( p, iFanin, vNodes, vGroups, vGroupMap, vBoxesLeft );
+        Vec_IntForEachEntry( vGroup, iNode, i )
+            Vec_IntPush( vNodes, iNode );
+        Vec_IntPush( vBoxesLeft, iGroup );
+    }
+    else
+    {
+        Sfm_ObjSetTravIdCurrent(p, iNode);
+        Sfm_ObjForEachFanin( p, iNode, iFanin, i )
+            Sfm_NtkDfs_rec( p, iFanin, vNodes, vGroups, vGroupMap, vBoxesLeft );
+        Vec_IntPush( vNodes, iNode );
+    }
 }
-Vec_Int_t * Sfm_NtkDfs( Sfm_Ntk_t * p )
+Vec_Int_t * Sfm_NtkDfs( Sfm_Ntk_t * p, Vec_Wec_t * vGroups, Vec_Int_t * vGroupMap, Vec_Int_t * vBoxesLeft )
 {
     Vec_Int_t * vNodes;
     int i;
+    Vec_IntClear( vBoxesLeft );
     vNodes = Vec_IntAlloc( p->nObjs );
     Sfm_NtkIncrementTravId( p );
     Sfm_NtkForEachPo( p, i )
-        Sfm_NtkDfs_rec( p, Sfm_ObjFanin(p, i, 0), vNodes );
+        Sfm_NtkDfs_rec( p, Sfm_ObjFanin(p, i, 0), vNodes, vGroups, vGroupMap, vBoxesLeft );
     return vNodes;
 }
 
diff --git a/abc-build/src/proof/abs/absPth.c b/abc-build/src/proof/abs/absPth.c
--- a/abc-build/src/proof/abs/absPth.c
+++ b/abc-build/src/proof/abs/absPth.c
@@ -194,7 +194,7 @@
     return 1;
 }
 
-#endif
+#endif // pthreads are used
 
 ////////////////////////////////////////////////////////////////////////
 ///                       END OF FILE                                ///
diff --git a/abc-build/src/proof/cec/cec.h b/abc-build/src/proof/cec/cec.h
--- a/abc-build/src/proof/cec/cec.h
+++ b/abc-build/src/proof/cec/cec.h
@@ -122,6 +122,7 @@
 //    int              fFirstStop;    // stop on the first sat output
     int              fUseSmartCnf;  // use smart CNF computation
     int              fRewriting;    // enables AIG rewriting
+    int              fNaive;        // performs naive SAT-based checking
     int              fVeryVerbose;  // verbose stats
     int              fVerbose;      // verbose stats
     int              iOutFail;      // the number of failed output
diff --git a/abc-build/src/proof/cec/cecCec.c b/abc-build/src/proof/cec/cecCec.c
--- a/abc-build/src/proof/cec/cecCec.c
+++ b/abc-build/src/proof/cec/cecCec.c
@@ -21,6 +21,8 @@
 #include "cecInt.h"
 #include "proof/fra/fra.h"
 #include "aig/gia/giaAig.h"
+#include "misc/extra/extra.h"
+#include "sat/cnf/cnf.h"
 
 ABC_NAMESPACE_IMPL_START
 
@@ -190,6 +192,107 @@
     }
     return -1;
 }
+
+/**Function*************************************************************
+
+  Synopsis    [Performs naive checking.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Cec_ManVerifyNaive( Gia_Man_t * p, Cec_ParCec_t * pPars )
+{
+    extern Cnf_Dat_t * Mf_ManGenerateCnf( Gia_Man_t * pGia, int nLutSize, int fCnfObjIds, int fAddOrCla, int fVerbose );
+    Cnf_Dat_t * pCnf = Mf_ManGenerateCnf( p, 8, 0, 0, 0 );
+    sat_solver * pSat = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
+    Gia_Obj_t * pObj0, * pObj1;
+    abctime clkStart = Abc_Clock();
+    int nPairs = Gia_ManPoNum(p)/2;
+    int nUnsats = 0, nSats = 0, nUndecs = 0, nTrivs = 0;
+    int i, iVar0, iVar1, pLits[2], status, RetValue;
+    ProgressBar * pProgress = Extra_ProgressBarStart( stdout, nPairs );
+    assert( Gia_ManPoNum(p) % 2 == 0 );
+    for ( i = 0; i < nPairs; i++ )
+    {
+        if ( (i & 0xFF) == 0 )
+            Extra_ProgressBarUpdate( pProgress, i, NULL );
+        pObj0 = Gia_ManPo(p, 2*i);
+        pObj1 = Gia_ManPo(p, 2*i+1);
+        if ( Gia_ObjChild0(pObj0) == Gia_ObjChild0(pObj1) )
+        {
+            nUnsats++;
+            nTrivs++;
+            continue;
+        }
+        if ( pPars->TimeLimit && (Abc_Clock() - clkStart)/CLOCKS_PER_SEC >= pPars->TimeLimit )
+        {
+            printf( "Timeout (%d sec) is reached.\n", pPars->TimeLimit );
+            nUndecs = nPairs - nUnsats - nSats;
+            break;
+        }
+        iVar0 = pCnf->pVarNums[ Gia_ObjId(p, pObj0) ];
+        iVar1 = pCnf->pVarNums[ Gia_ObjId(p, pObj1) ];
+        assert( iVar0 >= 0 && iVar1 >= 0 );
+        pLits[0] = Abc_Var2Lit( iVar0, 0 );
+        pLits[1] = Abc_Var2Lit( iVar1, 0 );
+        // check direct
+        pLits[0] = lit_neg(pLits[0]);
+        status = sat_solver_solve( pSat, pLits, pLits + 2, pPars->nBTLimit, 0, 0, 0 );
+        if ( status == l_False )
+        {
+            pLits[0] = lit_neg( pLits[0] );
+            pLits[1] = lit_neg( pLits[1] );
+            RetValue = sat_solver_addclause( pSat, pLits, pLits + 2 );
+            assert( RetValue );
+        }
+        else if ( status == l_True )
+        {
+            printf( "Output %d is SAT.\n", i );
+            nSats++;
+            continue;
+        }
+        else
+        {
+            nUndecs++;
+            continue;
+        }
+        // check inverse
+        status = sat_solver_solve( pSat, pLits, pLits + 2, pPars->nBTLimit, 0, 0, 0 );
+        if ( status == l_False )
+        {
+            pLits[0] = lit_neg( pLits[0] );
+            pLits[1] = lit_neg( pLits[1] );
+            RetValue = sat_solver_addclause( pSat, pLits, pLits + 2 );
+            assert( RetValue );
+        }
+        else if ( status == l_True )
+        {
+            printf( "Output %d is SAT.\n", i );
+            nSats++;
+            continue;
+        }
+        else
+        {
+            nUndecs++;
+            continue;
+        }
+        nUnsats++;
+    }
+    Extra_ProgressBarStop( pProgress );
+    printf( "UNSAT = %6d.  SAT = %6d.   UNDEC = %6d.  Trivial = %6d.  ", nUnsats, nSats, nUndecs, nTrivs );
+    Abc_PrintTime( 1, "Time", Abc_Clock() - clkStart );
+    Cnf_DataFree( pCnf );
+    sat_solver_delete( pSat );
+    if ( nSats )
+        return 0;
+    if ( nUndecs )
+        return -1;
+    return 1;
+}
 
 /**Function*************************************************************
 
@@ -221,7 +324,13 @@
     p = Gia_ManDup( pInit );
     Gia_ManEquivFixOutputPairs( p );
     p = Gia_ManCleanup( pNew = p );
-    Gia_ManStop( pNew );
+    Gia_ManStop( pNew );
+    if ( pPars->fNaive )
+    {
+        RetValue = Cec_ManVerifyNaive( p, pPars );
+        Gia_ManStop( p );
+        return RetValue;
+    }
     // sweep for equivalences
     Cec_ManFraSetDefaultParams( pParsFra );
     pParsFra->nItersMax    = 1000;
diff --git a/abc-build/src/proof/cec/cecCorr.c b/abc-build/src/proof/cec/cecCorr.c
--- a/abc-build/src/proof/cec/cecCorr.c
+++ b/abc-build/src/proof/cec/cecCorr.c
@@ -111,8 +111,8 @@
     int f, i, iPrev, iObj, iPrevNew, iObjNew;
     assert( nFrames > 0 );
     assert( Gia_ManRegNum(p) > 0 );
-    assert( p->pReprs != NULL );
-    p->pCopies = ABC_FALLOC( int, (nFrames+fScorr)*Gia_ManObjNum(p) );
+    assert( p->pReprs != NULL );
+    Vec_IntFill( &p->vCopies, (nFrames+fScorr)*Gia_ManObjNum(p), -1 );
     Gia_ManSetPhase( p );
     pNew = Gia_ManStart( nFrames * Gia_ManObjNum(p) );
     pNew->pName = Abc_UtilStrsav( p->pName );
@@ -200,7 +200,7 @@
         Gia_ManAppendCo( pNew, iObjNew );
     Vec_IntFree( vXorLits );
     Gia_ManHashStop( pNew );
-    ABC_FREE( p->pCopies );
+    Vec_IntErase( &p->vCopies );
 //Abc_Print( 1, "Before sweeping = %d\n", Gia_ManAndNum(pNew) );
     pNew = Gia_ManCleanup( pTemp = pNew );
 //Abc_Print( 1, "After sweeping = %d\n", Gia_ManAndNum(pNew) );
@@ -228,8 +228,8 @@
     int f, i, iPrevNew, iObjNew;
     assert( (!fScorr && nFrames > 1) || (fScorr && nFrames > 0) || nPrefix );
     assert( Gia_ManRegNum(p) > 0 );
-    assert( p->pReprs != NULL );
-    p->pCopies = ABC_FALLOC( int, (nFrames+nPrefix+fScorr)*Gia_ManObjNum(p) );
+    assert( p->pReprs != NULL );
+    Vec_IntFill( &p->vCopies, (nFrames+nPrefix+fScorr)*Gia_ManObjNum(p), -1 );
     Gia_ManSetPhase( p );
     pNew = Gia_ManStart( (nFrames+nPrefix) * Gia_ManObjNum(p) );
     pNew->pName = Abc_UtilStrsav( p->pName );
@@ -270,7 +270,7 @@
         Gia_ManAppendCo( pNew, iObjNew );
     Vec_IntFree( vXorLits );
     Gia_ManHashStop( pNew );
-    ABC_FREE( p->pCopies );
+    Vec_IntErase( &p->vCopies );
 //Abc_Print( 1, "Before sweeping = %d\n", Gia_ManAndNum(pNew) );
     pNew = Gia_ManCleanup( pTemp = pNew );
 //Abc_Print( 1, "After sweeping = %d\n", Gia_ManAndNum(pNew) );
diff --git a/abc-build/src/proof/cec/cecSplit.c b/abc-build/src/proof/cec/cecSplit.c
--- a/abc-build/src/proof/cec/cecSplit.c
+++ b/abc-build/src/proof/cec/cecSplit.c
@@ -43,7 +43,13 @@
 ////////////////////////////////////////////////////////////////////////
 ///                        DECLARATIONS                              ///
 ////////////////////////////////////////////////////////////////////////
-
+
+#ifndef ABC_USE_PTHREADS
+
+int Cec_GiaSplitTest( Gia_Man_t * p, int nProcs, int nTimeOut, int nIterMax, int LookAhead, int fVerbose, int fVeryVerbose ) { return -1; }
+
+#else // pthreads are used
+
 ////////////////////////////////////////////////////////////////////////
 ///                     FUNCTION DEFINITIONS                         ///
 ////////////////////////////////////////////////////////////////////////
@@ -824,6 +830,8 @@
         Gia_ManStop( pCof1 );
     }
 }
+
+#endif // pthreads are used
 
 ////////////////////////////////////////////////////////////////////////
 ///                       END OF FILE                                ///
diff --git a/abc-build/src/proof/int/intUtil.c b/abc-build/src/proof/int/intUtil.c
--- a/abc-build/src/proof/int/intUtil.c
+++ b/abc-build/src/proof/int/intUtil.c
@@ -49,7 +49,7 @@
     Aig_Obj_t * pObj;
     sat_solver * pSat;
     int i, status;
-    abctime clk = Abc_Clock();
+    //abctime clk = Abc_Clock();
     pCnf = Cnf_Derive( p, Saig_ManRegNum(p) ); 
     pSat = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, 1, 1 );
     if ( pSat == NULL )
@@ -58,7 +58,7 @@
         return 0;
     }
     status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
-    ABC_PRT( "Time", Abc_Clock() - clk );
+    //ABC_PRT( "Time", Abc_Clock() - clk );
     if ( status == l_True )
     {
         p->pSeqModel = Abc_CexAlloc( Aig_ManRegNum(p), Saig_ManPiNum(p), 1 );
diff --git a/abc-build/src/proof/pdr/pdrCore.c b/abc-build/src/proof/pdr/pdrCore.c
--- a/abc-build/src/proof/pdr/pdrCore.c
+++ b/abc-build/src/proof/pdr/pdrCore.c
@@ -618,7 +618,8 @@
                 }
                 pCexNew = (p->pPars->fUseBridge || p->pPars->fStoreCex) ? Abc_CexMakeTriv( Aig_ManRegNum(p->pAig), Saig_ManPiNum(p->pAig), Saig_ManPoNum(p->pAig), k*Saig_ManPoNum(p->pAig)+p->iOutCur ) : (Abc_Cex_t *)(ABC_PTRINT_T)1;
                 p->pPars->nFailOuts++;
-                if ( p->pPars->vOutMap ) Vec_IntWriteEntry( p->pPars->vOutMap, p->iOutCur, 0 );
+                if ( p->pPars->vOutMap ) Vec_IntWriteEntry( p->pPars->vOutMap, p->iOutCur, 0 );
+                if ( !p->pPars->fNotVerbose )
                 Abc_Print( 1, "Output %*d was trivially asserted in frame %2d (solved %*d out of %*d outputs).\n",
                     nOutDigits, p->iOutCur, k, nOutDigits, p->pPars->nFailOuts, nOutDigits, Saig_ManPoNum(p->pAig) );
                 assert( Vec_PtrEntry(p->vCexes, p->iOutCur) == NULL );
diff --git a/abc-build/src/python/pyabc.i b/abc-build/src/python/pyabc.i
--- a/abc-build/src/python/pyabc.i
+++ b/abc-build/src/python/pyabc.i
@@ -744,15 +744,21 @@
 class _Cex(object):
 
     def __new__(cls, pCex):
+    
         if not pCex:
-            return None        
+            return None
+            
+        if int(pCex)==1:
+        	return True 
+        	      
         return object.__new__(cls)
 
     def __init__(self, pCex):
         self.pCex = pCex
         
     def __del__(self):
-        _cex_free(self.pCex)
+    	if _cex_free:
+        	_cex_free(self.pCex)
 
     def n_regs(self):
         return _cex_n_regs(self.pCex)
diff --git a/abc-build/src/sat/bmc/bmc.h b/abc-build/src/sat/bmc/bmc.h
--- a/abc-build/src/sat/bmc/bmc.h
+++ b/abc-build/src/sat/bmc/bmc.h
@@ -129,6 +129,7 @@
     int        fComplVars;
     int        fStartPats;
     int        nTimeOut;
+    int        nIterCheck;
     int        fBasic;
     int        fDump;
     int        fDumpUntest;
diff --git a/abc-build/src/sat/bmc/bmcBmc3.c b/abc-build/src/sat/bmc/bmcBmc3.c
--- a/abc-build/src/sat/bmc/bmcBmc3.c
+++ b/abc-build/src/sat/bmc/bmcBmc3.c
@@ -1635,7 +1635,7 @@
                     pCexNew0 = pCexNew; 
                     pCexNew = (Abc_Cex_t *)(ABC_PTRINT_T)1;
                 }
-                Vec_PtrWriteEntry( p->vCexes, i, pCexNew );
+                Vec_PtrWriteEntry( p->vCexes, i, Abc_CexDup(pCexNew, Saig_ManRegNum(pAig)) ); 
                 if ( pPars->pFuncOnFail && pPars->pFuncOnFail(i, pPars->fStoreCex ? (Abc_Cex_t *)Vec_PtrEntry(p->vCexes, i) : NULL) )
                 {
                     Abc_CexFreeP( &pCexNew0 );
diff --git a/abc-build/src/sat/bmc/bmcCexTools.c b/abc-build/src/sat/bmc/bmcCexTools.c
--- a/abc-build/src/sat/bmc/bmcCexTools.c
+++ b/abc-build/src/sat/bmc/bmcCexTools.c
@@ -306,7 +306,7 @@
 ***********************************************************************/
 void Bmc_CexPrint( Abc_Cex_t * pCex, int nInputs, int fVerbose )
 {
-    int i, k, Count, iBit = 0;
+    int i, k, Count, iBit = pCex->nRegs;
     Abc_CexPrintStatsInputs( pCex, nInputs );
     if ( !fVerbose )
         return;
diff --git a/abc-build/src/sat/bmc/bmcChain.c b/abc-build/src/sat/bmc/bmcChain.c
new file mode 100644
--- /dev/null
+++ b/abc-build/src/sat/bmc/bmcChain.c
@@ -0,0 +1,397 @@
+/**CFile****************************************************************
+
+  FileName    [bmcChain.c]
+
+  SystemName  [ABC: Logic synthesis and verification system.]
+
+  PackageName [SAT-based bounded model checking.]
+
+  Synopsis    [Implementation of chain BMC.]
+
+  Author      [Alan Mishchenko]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - June 20, 2005.]
+
+  Revision    [$Id: bmcChain.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "bmc.h"
+#include "aig/gia/giaAig.h"
+#include "sat/cnf/cnf.h"
+#include "sat/bsat/satSolver.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    [Find the first failure.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Abc_Cex_t * Bmc_ChainFailOneOutput( Gia_Man_t * p, int nFrameMax, int nConfMax, int fVerbose, int fVeryVerbose )
+{
+    int RetValue;
+    Abc_Cex_t * pCex = NULL;
+    Aig_Man_t * pAig = Gia_ManToAigSimple( p );
+    Saig_ParBmc_t Pars, * pPars = &Pars;
+    Saig_ParBmcSetDefaultParams( pPars );
+    pPars->nFramesMax = nFrameMax;
+    pPars->nConfLimit = nConfMax;
+    pPars->fVerbose   = fVeryVerbose;
+    RetValue = Saig_ManBmcScalable( pAig, pPars );
+    if ( RetValue == 0 ) // SAT
+    {
+        pCex = pAig->pSeqModel, pAig->pSeqModel = NULL;
+        if ( fVeryVerbose )
+            Abc_Print( 1, "Output %d of miter \"%s\" was asserted in frame %d.\n", pCex->iPo, p->pName, pCex->iFrame );
+    }
+    else if ( fVeryVerbose )
+        Abc_Print( 1, "No output asserted in %d frames. Resource limit reached.\n", pPars->iFrame+2 );
+    Aig_ManStop( pAig );
+    return pCex;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Move GIA into the failing state.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManDupWithInit( Gia_Man_t * p )
+{
+    Gia_Man_t * pNew;
+    Gia_Obj_t * pObj;
+    int i;
+    pNew = Gia_ManStart( Gia_ManObjNum(p) );
+    pNew->pName = Abc_UtilStrsav( p->pName );
+    pNew->pSpec = Abc_UtilStrsav( p->pSpec );
+    Gia_ManConst0(p)->Value = 0;
+    Gia_ManForEachObj1( p, pObj, i )
+    {
+        if ( Gia_ObjIsAnd(pObj) )
+            pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+        else if ( Gia_ObjIsCi(pObj) )
+        {
+            pObj->Value = Gia_ManAppendCi( pNew );
+            pObj->Value = Abc_LitNotCond( pObj->Value, pObj->fMark0 );
+        }
+        else if ( Gia_ObjIsCo(pObj) )
+        {
+            pObj->Value = Gia_ObjFanin0Copy(pObj);
+            pObj->Value = Abc_LitNotCond( pObj->Value, pObj->fMark0 );
+            pObj->Value = Gia_ManAppendCo( pNew, pObj->Value );
+        }
+    }
+    Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+    return pNew;
+}
+Gia_Man_t * Gia_ManVerifyCexAndMove( Gia_Man_t * pGia, Abc_Cex_t * p )
+{
+    Gia_Man_t * pNew;
+    Gia_Obj_t * pObj, * pObjRi, * pObjRo;
+    int RetValue, i, k, iBit = 0;
+    Gia_ManCleanMark0(pGia);
+    Gia_ManForEachRo( pGia, pObj, i )
+        pObj->fMark0 = Abc_InfoHasBit(p->pData, iBit++);
+    for ( i = 0; i <= p->iFrame; i++ )
+    {
+        Gia_ManForEachPi( pGia, pObj, k )
+            pObj->fMark0 = Abc_InfoHasBit(p->pData, iBit++);
+        Gia_ManForEachAnd( pGia, pObj, k )
+            pObj->fMark0 = (Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj)) & 
+                           (Gia_ObjFanin1(pObj)->fMark0 ^ Gia_ObjFaninC1(pObj));
+        Gia_ManForEachCo( pGia, pObj, k )
+            pObj->fMark0 = Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj);
+        if ( i == p->iFrame )
+            break;
+        Gia_ManForEachRiRo( pGia, pObjRi, pObjRo, k )
+            pObjRo->fMark0 = pObjRi->fMark0;
+    }
+    assert( iBit == p->nBits );
+    RetValue = Gia_ManPo(pGia, p->iPo)->fMark0;
+    assert( RetValue );
+    // set PI/PO values to zero and transfer RO values to RI
+    Gia_ManForEachPi( pGia, pObj, k )
+        pObj->fMark0 = 0;
+    Gia_ManForEachPo( pGia, pObj, k )
+        pObj->fMark0 = 0;
+    Gia_ManForEachRiRo( pGia, pObjRi, pObjRo, k )
+        pObjRi->fMark0 = pObjRo->fMark0;
+    // duplicate assuming CI/CO marks are set correctly
+    pNew = Gia_ManDupWithInit( pGia );
+    Gia_ManCleanMark0(pGia);
+    return pNew;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Find what outputs fail in this state.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManDupPosAndPropagateInit( Gia_Man_t * p )
+{
+    Gia_Man_t * pNew, * pTemp;
+    Gia_Obj_t * pObj;  int i;
+    pNew = Gia_ManStart( Gia_ManObjNum(p) );
+    pNew->pName = Abc_UtilStrsav( p->pName );
+    pNew->pSpec = Abc_UtilStrsav( p->pSpec );
+    Gia_ManConst0(p)->Value = 0;
+    Gia_ManHashAlloc( pNew );
+    Gia_ManForEachObj1( p, pObj, i )
+    {
+        if ( Gia_ObjIsAnd(pObj) )
+            pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+        else if ( Gia_ObjIsPi(p, pObj) )
+            pObj->Value = Gia_ManAppendCi( pNew );
+        else if ( Gia_ObjIsCi(pObj) )
+            pObj->Value = 0;
+        else if ( Gia_ObjIsPo(p, pObj) )
+            Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+    }
+    Gia_ManHashStop( pNew );
+    assert( Gia_ManPiNum(p) == Gia_ManPiNum(pNew) );
+    assert( Gia_ManPoNum(p) == Gia_ManPoNum(pNew) );
+    pNew = Gia_ManCleanup( pTemp = pNew );
+    Gia_ManStop( pTemp );
+    return pNew;
+}
+sat_solver * Gia_ManDeriveSatSolver( Gia_Man_t * p, Vec_Int_t * vSatIds )
+{
+//    extern Cnf_Dat_t * Mf_ManGenerateCnf( Gia_Man_t * pGia, int nLutSize, int fCnfObjIds, int fAddOrCla, int fVerbose );
+    sat_solver * pSat;
+    Aig_Man_t * pAig = Gia_ManToAigSimple( p );
+//    Cnf_Dat_t * pCnf = Mf_ManGenerateCnf( p, 8, 0, 0, 0 );
+    Cnf_Dat_t * pCnf = Cnf_Derive( pAig, Aig_ManCoNum(pAig) );
+    // save SAT vars for the primary inputs
+    if ( vSatIds )
+    {
+        Aig_Obj_t * pObj; int i;
+        Vec_IntClear( vSatIds );
+        Aig_ManForEachCi( pAig, pObj, i )
+            Vec_IntPush( vSatIds, pCnf->pVarNums[ Aig_ObjId(pObj) ] );
+        assert( Vec_IntSize(vSatIds) == Gia_ManPiNum(p) );
+    }
+    Aig_ManStop( pAig );
+    pSat = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
+    Cnf_DataFree( pCnf );
+    assert( p->nRegs == 0 );
+    return pSat;
+}
+Vec_Int_t * Bmc_ChainFindFailedOutputs( Gia_Man_t * p, Vec_Ptr_t * vCexes )
+{
+    Vec_Int_t * vOutputs;
+    Vec_Int_t * vSatIds;
+    Gia_Man_t * pInit;
+    Gia_Obj_t * pObj;
+    sat_solver * pSat;
+    int i, j, Lit, status = 0;
+    // derive output logic cones
+    pInit = Gia_ManDupPosAndPropagateInit( p );
+    // derive SAT solver and test
+    vSatIds = Vec_IntAlloc( Gia_ManPiNum(p) );
+    pSat = Gia_ManDeriveSatSolver( pInit, vSatIds );
+    vOutputs = Vec_IntAlloc( 100 );
+    Gia_ManForEachPo( pInit, pObj, i )
+    {
+        if ( Gia_ObjFaninLit0p(pInit, pObj) == 0 )
+            continue;
+        Lit = Abc_Var2Lit( i+1, 0 );
+        status = sat_solver_solve( pSat, &Lit, &Lit + 1, 0, 0, 0, 0 );
+        if ( status == l_True )
+        {
+            // save the index of solved output
+            Vec_IntPush( vOutputs, i );
+            // create CEX for this output
+            if ( vCexes )
+            {
+                Abc_Cex_t * pCex = Abc_CexAlloc( Gia_ManRegNum(p), Gia_ManPiNum(p), 1 );
+                pCex->iFrame = 0;
+                pCex->iPo = i;
+                for ( j = 0; j < Gia_ManPiNum(p); j++ )
+                    if ( sat_solver_var_value( pSat, Vec_IntEntry(vSatIds, j) ) )
+                        Abc_InfoSetBit( pCex->pData, Gia_ManRegNum(p) + j );
+                Vec_PtrPush( vCexes, pCex );
+            }
+        }
+    }
+    Gia_ManStop( pInit );
+    sat_solver_delete( pSat );
+    Vec_IntFree( vSatIds );
+    return vOutputs;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Cleanup AIG by removing COs replacing failed out by const0.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+static inline void Gia_ObjMakePoConst0( Gia_Man_t * p, Gia_Obj_t * pObj )
+{ 
+    assert( Gia_ObjIsCo(pObj) );
+    pObj->iDiff0 = Gia_ObjId( p, pObj );
+    pObj->fCompl0 = 0;
+}
+int Gia_ManCountNonConst0( Gia_Man_t * p )
+{ 
+    Gia_Obj_t * pObj;
+    int i, Count = 0;
+    Gia_ManForEachPo( p, pObj, i )
+        Count += (Gia_ObjFaninLit0p(p, pObj) != 0);
+    return Count;
+}
+Gia_Man_t * Bmc_ChainCleanup( Gia_Man_t * p, Vec_Int_t * vOutputs )
+{
+    int i, iOut;
+    Vec_IntForEachEntry( vOutputs, iOut, i )
+    {
+        Gia_Obj_t * pObj = Gia_ManPo( p, iOut );
+        assert( Gia_ObjFaninLit0p(p, pObj) != 0 );
+        Gia_ObjMakePoConst0( p, pObj );
+        assert( Gia_ObjFaninLit0p(p, pObj) == 0 );
+    }
+    return Gia_ManCleanup( p );
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Bmc_ChainTest( Gia_Man_t * p, int nFrameMax, int nConfMax, int fVerbose, int fVeryVerbose, Vec_Ptr_t ** pvCexes )
+{
+    int Iter, IterMax = 10000;
+    Gia_Man_t * pTemp, * pNew = Gia_ManDup(p);
+    Abc_Cex_t * pCex = NULL;
+    Vec_Int_t * vOutputs;
+    abctime clk2, clk = Abc_Clock(); 
+    abctime clkBmc = 0;
+    abctime clkMov = 0;
+    abctime clkSat = 0;
+    abctime clkCln = 0;
+    abctime clkSwp = 0;
+    int DepthTotal = 0;
+    if ( pvCexes )
+        *pvCexes = Vec_PtrAlloc( 1000 );
+    for ( Iter = 0; Iter < IterMax; Iter++ )
+    {
+        if ( Gia_ManPoNum(pNew) == 0 )
+        {
+            if ( fVerbose )
+                printf( "Finished all POs.\n" );
+            break;
+        }
+        // run BMC till the first failure
+        clk2 = Abc_Clock(); 
+        pCex = Bmc_ChainFailOneOutput( pNew, nFrameMax, nConfMax, fVerbose, fVeryVerbose );
+        clkBmc += Abc_Clock() - clk2;
+        if ( pCex == NULL )
+        {
+            if ( fVerbose )
+                printf( "BMC could not detect a failed output in %d frames with %d conflicts.\n", nFrameMax, nConfMax );
+            break;
+        }
+        assert( !Iter || pCex->iFrame > 0 );
+        // move the AIG to the failure state
+        clk2 = Abc_Clock(); 
+        pNew = Gia_ManVerifyCexAndMove( pTemp = pNew, pCex );
+        Gia_ManStop( pTemp );
+        DepthTotal += pCex->iFrame;
+        clkMov += Abc_Clock() - clk2;
+        // find outputs that fail in this state
+        clk2 = Abc_Clock(); 
+        vOutputs = Bmc_ChainFindFailedOutputs( pNew, pvCexes ? *pvCexes : NULL );
+        assert( Vec_IntFind(vOutputs, pCex->iPo) >= 0 );
+        // save the counter-example
+        if ( pvCexes )
+            Vec_PtrPush( *pvCexes, pCex );
+        else
+            Abc_CexFree( pCex );
+        clkSat += Abc_Clock() - clk2;
+        // remove them from the AIG 
+        clk2 = Abc_Clock(); 
+        pNew = Bmc_ChainCleanup( pTemp = pNew, vOutputs );
+        Gia_ManStop( pTemp );
+        clkCln += Abc_Clock() - clk2;
+        // perform sequential cleanup
+        clk2 = Abc_Clock(); 
+//        pNew = Gia_ManSeqStructSweep( pTemp = pNew, 0, 1, 0 );
+//        Gia_ManStop( pTemp );
+        clkSwp += Abc_Clock() - clk2;
+        // printout
+        if ( fVerbose )
+        {
+            int nNonConst = Gia_ManCountNonConst0(pNew);
+            printf( "Iter %4d : ",    Iter+1 );
+            printf( "Depth =%5d  ",   DepthTotal );
+            printf( "FailPo =%5d  ",  Vec_IntSize(vOutputs) );
+            printf( "UndecPo =%5d ",  nNonConst );
+            printf( "(%6.2f %%)  ",   100.0 * nNonConst / Gia_ManPoNum(pNew) );
+            printf( "AIG =%8d  ",     Gia_ManAndNum(pNew) );
+            Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
+        }
+        Vec_IntFree( vOutputs );
+    }
+    printf( "Completed a CEX chain with %d segments, %d frames, and %d failed POs (out of %d). ", 
+        Iter, DepthTotal, Gia_ManPoNum(pNew) - Gia_ManCountNonConst0(pNew), Gia_ManPoNum(pNew) );
+    if ( fVerbose )
+    {
+    Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
+    Abc_PrintTimeP( 1, "BMC  ", clkBmc, Abc_Clock() - clk );
+    Abc_PrintTimeP( 1, "Init ", clkMov, Abc_Clock() - clk );
+    Abc_PrintTimeP( 1, "SAT  ", clkSat, Abc_Clock() - clk );
+    Abc_PrintTimeP( 1, "Clean", clkCln, Abc_Clock() - clk );
+//    Abc_PrintTimeP( 1, "Sweep", clkSwp, Abc_Clock() - clk );
+    }
+    Gia_ManStop( pNew );
+    if ( pvCexes )
+        printf( "Total number of CEXes collected = %d.\n", Vec_PtrSize(*pvCexes) );
+    return 0;
+}
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/abc-build/src/sat/bmc/bmcFault.c b/abc-build/src/sat/bmc/bmcFault.c
--- a/abc-build/src/sat/bmc/bmcFault.c
+++ b/abc-build/src/sat/bmc/bmcFault.c
@@ -55,6 +55,7 @@
     p->Algo          =     0; 
     p->fStartPats    =     0; 
     p->nTimeOut      =     0; 
+    p->nIterCheck    =     0;
     p->fBasic        =     0; 
     p->fDump         =     0; 
     p->fDumpUntest   =     0; 
@@ -228,11 +229,11 @@
   SeeAlso     []
 
 ***********************************************************************/
-Gia_Man_t * Gia_ManStuckAtUnfold( Gia_Man_t * p )
+Gia_Man_t * Gia_ManStuckAtUnfold( Gia_Man_t * p, Vec_Int_t * vMap )
 {
     Gia_Man_t * pNew, * pTemp;
     Gia_Obj_t * pObj;
-    int i;
+    int i, iFuncVars = 0;
     pNew = Gia_ManStart( 3 * Gia_ManObjNum(p) );
     pNew->pName = Abc_UtilStrsav( p->pName );
     Gia_ManHashAlloc( pNew );
@@ -242,9 +243,18 @@
     Gia_ManForEachAnd( p, pObj, i )
     {
         pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
-        pObj->Value = Gia_ManHashAnd( pNew, Abc_LitNot(Gia_ManAppendCi(pNew)), pObj->Value );
-        pObj->Value = Gia_ManHashOr( pNew, Gia_ManAppendCi(pNew), pObj->Value );
+
+        if ( Vec_IntEntry(vMap, iFuncVars++) )
+            pObj->Value = Gia_ManHashAnd( pNew, Abc_LitNot(Gia_ManAppendCi(pNew)), pObj->Value );
+        else
+            Gia_ManAppendCi(pNew);
+
+        if ( Vec_IntEntry(vMap, iFuncVars++) )
+            pObj->Value = Gia_ManHashOr( pNew, Gia_ManAppendCi(pNew), pObj->Value );
+        else
+            Gia_ManAppendCi(pNew);
     }
+    assert( iFuncVars == Vec_IntSize(vMap) );
     Gia_ManForEachCo( p, pObj, i )
         pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
     pNew = Gia_ManCleanup( pTemp = pNew );
@@ -264,11 +274,11 @@
   SeeAlso     []
 
 ***********************************************************************/
-Gia_Man_t * Gia_ManFlipUnfold( Gia_Man_t * p )
+Gia_Man_t * Gia_ManFlipUnfold( Gia_Man_t * p, Vec_Int_t * vMap )
 {
     Gia_Man_t * pNew, * pTemp;
     Gia_Obj_t * pObj;
-    int i;
+    int i, iFuncVars = 0;
     pNew = Gia_ManStart( 4 * Gia_ManObjNum(p) );
     pNew->pName = Abc_UtilStrsav( p->pName );
     Gia_ManHashAlloc( pNew );
@@ -278,8 +288,12 @@
     Gia_ManForEachAnd( p, pObj, i )
     {
         pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
-        pObj->Value = Gia_ManHashXor( pNew, Gia_ManAppendCi(pNew), pObj->Value );
+        if ( Vec_IntEntry(vMap, iFuncVars++) )
+            pObj->Value = Gia_ManHashXor( pNew, Gia_ManAppendCi(pNew), pObj->Value );
+        else
+            Gia_ManAppendCi(pNew);
     }
+    assert( iFuncVars == Vec_IntSize(vMap) );
     Gia_ManForEachCo( p, pObj, i )
         pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
     pNew = Gia_ManCleanup( pTemp = pNew );
@@ -299,11 +313,11 @@
   SeeAlso     []
 
 ***********************************************************************/
-Gia_Man_t * Gia_ManFOFUnfold( Gia_Man_t * p )
+Gia_Man_t * Gia_ManFOFUnfold( Gia_Man_t * p, Vec_Int_t * vMap )
 {
     Gia_Man_t * pNew, * pTemp;
     Gia_Obj_t * pObj;
-    int i, iCtrl0, iCtrl1, iCtrl2, iCtrl3, iMuxA, iMuxB;
+    int i, iCtrl0, iCtrl1, iCtrl2, iCtrl3, iMuxA, iMuxB, iFuncVars = 0;
     pNew = Gia_ManStart( 9 * Gia_ManObjNum(p) );
     pNew->pName = Abc_UtilStrsav( p->pName );
     Gia_ManHashAlloc( pNew );
@@ -312,10 +326,26 @@
         pObj->Value = Gia_ManAppendCi( pNew );
     Gia_ManForEachAnd( p, pObj, i )
     {
-        iCtrl0 = Gia_ManAppendCi(pNew);
-        iCtrl1 = Gia_ManAppendCi(pNew);
-        iCtrl2 = Gia_ManAppendCi(pNew);
-        iCtrl3 = Gia_ManAppendCi(pNew);
+        if ( Vec_IntEntry(vMap, iFuncVars++) )
+            iCtrl0 = Gia_ManAppendCi(pNew);
+        else
+            iCtrl0 = 0, Gia_ManAppendCi(pNew);
+
+        if ( Vec_IntEntry(vMap, iFuncVars++) )
+            iCtrl1 = Gia_ManAppendCi(pNew);
+        else
+            iCtrl1 = 0, Gia_ManAppendCi(pNew);
+
+        if ( Vec_IntEntry(vMap, iFuncVars++) )
+            iCtrl2 = Gia_ManAppendCi(pNew);
+        else
+            iCtrl2 = 0, Gia_ManAppendCi(pNew);
+
+        if ( Vec_IntEntry(vMap, iFuncVars++) )
+            iCtrl3 = Gia_ManAppendCi(pNew);
+        else
+            iCtrl3 = 0, Gia_ManAppendCi(pNew);
+
         if ( Gia_ObjFaninC0(pObj) && Gia_ObjFaninC1(pObj) )
             iCtrl0 = Abc_LitNot(iCtrl0);
         else if ( !Gia_ObjFaninC0(pObj) && Gia_ObjFaninC1(pObj) )
@@ -324,10 +354,12 @@
             iCtrl2 = Abc_LitNot(iCtrl2);
         else //if ( !Gia_ObjFaninC0(pObj) && !Gia_ObjFaninC1(pObj) )
             iCtrl3 = Abc_LitNot(iCtrl3);
+
         iMuxA       = Gia_ManHashMux( pNew, Gia_ObjFanin0(pObj)->Value, iCtrl1, iCtrl0 );
         iMuxB       = Gia_ManHashMux( pNew, Gia_ObjFanin0(pObj)->Value, iCtrl3, iCtrl2 );
         pObj->Value = Gia_ManHashMux( pNew, Gia_ObjFanin1(pObj)->Value, iMuxB,  iMuxA );
     }
+    assert( iFuncVars == Vec_IntSize(vMap) );
     Gia_ManForEachCo( p, pObj, i )
         pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
     pNew = Gia_ManCleanup( pTemp = pNew );
@@ -352,12 +384,12 @@
     int i, Counter = 0;
     if ( pStr[0] != '(' )
     {
-        printf( "The first symbol should be the opening paranthesis \"(\".\n" );
+        printf( "The first symbol should be the opening parenthesis \"(\".\n" );
         return 1;
     }
     if ( pStr[strlen(pStr)-1] != ')' )
     {
-        printf( "The last symbol should be the closing paranthesis \")\".\n" );
+        printf( "The last symbol should be the closing parenthesis \")\".\n" );
         return 1;
     }
     for ( i = 0; pStr[i]; i++ )
@@ -367,7 +399,7 @@
             Counter--;
     if ( Counter != 0 )
     {
-        printf( "The number of opening and closing parantheses is not equal.\n" );
+        printf( "The number of opening and closing parentheses is not equal.\n" );
         return 1;
     }
     *pnVars = 0;
@@ -640,7 +672,7 @@
   SeeAlso     []
 
 ***********************************************************************/
-void Gia_ManFaultAddOne( Gia_Man_t * pM, Cnf_Dat_t * pCnf, sat_solver * pSat, Vec_Int_t * vLits, int nFuncVars )
+int Gia_ManFaultAddOne( Gia_Man_t * pM, Cnf_Dat_t * pCnf, sat_solver * pSat, Vec_Int_t * vLits, int nFuncVars )
 {
     Gia_Man_t * pC;
     Cnf_Dat_t * pCnf2;
@@ -656,13 +688,21 @@
     // add timeframe clauses
     for ( i = 0; i < pCnf2->nClauses; i++ )
         if ( !sat_solver_addclause( pSat, pCnf2->pClauses[i], pCnf2->pClauses[i+1] ) )
-            assert( 0 );
+        {
+            Cnf_DataFree( pCnf2 );
+            Gia_ManStop( pC );
+            return 0;
+        }
     // add constraint clauses
     Gia_ManForEachPo( pC, pObj, i )
     {
         Lit = Abc_Var2Lit( pCnf2->pVarNums[Gia_ObjId(pC, pObj)], 1 );
         if ( !sat_solver_addclause( pSat, &Lit, &Lit+1 ) )
-            assert( 0 );
+        {
+            Cnf_DataFree( pCnf2 );
+            Gia_ManStop( pC );
+            return 0;
+        }
     }
     // add connection clauses
     Gia_ManForEachPi( pM, pObj, i )
@@ -670,6 +710,7 @@
             sat_solver_add_buffer( pSat, pCnf->pVarNums[Gia_ObjId(pM, pObj)], pCnf2->pVarNums[Gia_ObjId(pC, Gia_ManPi(pC, i))], 0 );
     Cnf_DataFree( pCnf2 );
     Gia_ManStop( pC );
+    return 1;
 }
 
 
@@ -802,61 +843,71 @@
   SeeAlso     []
 
 ***********************************************************************/
-void Gia_ManFaultTest( Gia_Man_t * p, Gia_Man_t * pG, Bmc_ParFf_t * pPars )
+int Gia_ManFaultAnalyze( sat_solver * pSat, Vec_Int_t * vPars, Vec_Int_t * vMap, Vec_Int_t * vLits, int Iter )
 {
-    int nIterMax = 1000000, nVars, nPars;
-    int i, Iter, Iter2, status, nFuncVars = -1;
-    abctime clkSat = 0, clkTotal = Abc_Clock();
-    Vec_Int_t * vLits, * vTests;
+    int nConfLimit = 100;
+    int status, i, v, iVar, Lit;
+    int nUnsats = 0, nRuns = 0;
+    abctime clk = Abc_Clock();
+    assert( Vec_IntSize(vPars) == Vec_IntSize(vMap) );
+    // check presence of each variable
+    Vec_IntClear( vLits );
+    Vec_IntAppend( vLits, vMap );
+    for ( v = 0; v < Vec_IntSize(vPars); v++ )
+    {
+        if ( !Vec_IntEntry(vLits, v) )
+            continue;
+        assert( Vec_IntEntry(vLits, v) == 1 );
+        nRuns++;
+        Lit = Abc_Var2Lit( Vec_IntEntry(vPars, v), 0 );
+        status = sat_solver_solve( pSat, &Lit, &Lit+1, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
+        if ( status == l_Undef )
+            continue;
+        if ( status == l_False )
+        {
+            nUnsats++;
+            assert( Vec_IntEntry(vMap, v) == 1 );
+            Vec_IntWriteEntry( vMap, v, 0 );
+            Lit = Abc_LitNot(Lit);
+            //status = sat_solver_addclause( pSat, &Lit, &Lit+1 );
+            //assert( status );
+            continue;
+        }
+        Vec_IntForEachEntry( vPars, iVar, i )
+            if ( Vec_IntEntry(vLits, i) && sat_solver_var_value(pSat, iVar) )
+                Vec_IntWriteEntry( vLits, i, 0 );
+        assert( Vec_IntEntry(vLits, v) == 0 );
+    }
+    printf( "Iteration %3d has determined %5d (out of %5d) parameters after %6d SAT calls.  ", Iter, Vec_IntSize(vMap) - Vec_IntCountPositive(vMap), Vec_IntSize(vPars), nRuns );
+    Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
+    return nUnsats;
+}
+
+/**Function*************************************************************
+
+  Synopsis    [Generate miter, CNF and solver.]
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Gia_ManFaultPrepare( Gia_Man_t * p, Gia_Man_t * pG, Bmc_ParFf_t * pPars, int nFuncVars, Vec_Int_t * vMap, Vec_Int_t * vTests, Vec_Int_t * vLits, Gia_Man_t ** ppMiter, Cnf_Dat_t ** ppCnf, sat_solver ** ppSat, int fWarmUp )
+{
     Gia_Man_t * p0 = NULL, * p1 = NULL, * pM;
     Gia_Obj_t * pObj;
     Cnf_Dat_t * pCnf;
     sat_solver * pSat;
-
-    if ( pPars->Algo == 0 && Gia_FormStrCount( pPars->pFormStr, &nVars, &nPars ) )
-        return;
-
-    // select algorithm
-    if ( pPars->Algo == 0 )
-        printf( "FFTEST is computing test patterns for fault model \"%s\"...\n", pPars->pFormStr );
-    else if ( pPars->Algo == 1 )
-        printf( "FFTEST is computing test patterns for %sdelay faults...\n", pPars->fBasic ? "single " : "" );
-    else if ( pPars->Algo == 2 )
-        printf( "FFTEST is computing test patterns for %sstuck-at faults...\n", pPars->fBasic ? "single " : "" );
-    else if ( pPars->Algo == 3 )
-        printf( "FFTEST is computing test patterns for %scomplement faults...\n", pPars->fBasic ? "single " : "" );
-    else if ( pPars->Algo == 4 )
-        printf( "FFTEST is computing test patterns for %sfunctionally observable faults...\n", pPars->fBasic ? "single " : "" );
-    else
-    {
-        printf( "Unrecognized algorithm (%d).\n", pPars->Algo );
-        return;
-    }
-
-    // select algorithm
-    if ( pPars->Algo == 0 )
-        nFuncVars = Gia_ManCiNum(p);
-    else if ( pPars->Algo == 1 )
-        nFuncVars = Gia_ManRegNum(p) + 2 * Gia_ManPiNum(p);
-    else if ( pPars->Algo == 2 )
-        nFuncVars = Gia_ManCiNum(p);
-    else if ( pPars->Algo == 3 )
-        nFuncVars = Gia_ManCiNum(p);
-    else if ( pPars->Algo == 4 )
-        nFuncVars = Gia_ManCiNum(p);
+    int i, Iter, status;
+    abctime clkSat = 0;
 
-    // collect test patterns from file
-    if ( pPars->pFileName )
-        vTests = Gia_ManGetTestPatterns( pPars->pFileName );
-    else
-        vTests = Vec_IntAlloc( 10000 );
-    if ( vTests == NULL )
-        return;
-    if ( Vec_IntSize(vTests) % nFuncVars != 0 )
+    if ( Vec_IntSize(vTests) && (Vec_IntSize(vTests) % nFuncVars != 0) )
     {
         printf( "The number of symbols in the input patterns (%d) does not divide evenly on the number of test variables (%d).\n", Vec_IntSize(vTests), nFuncVars );
         Vec_IntFree( vTests );
-        return;
+        return 0;
     }
 
     // select algorithm
@@ -869,11 +920,11 @@
         p1 = Gia_ManFaultUnfold( p, 1 );
     }
     else if ( pPars->Algo == 2 )
-        p1 = Gia_ManStuckAtUnfold( p );
+        p1 = Gia_ManStuckAtUnfold( p, vMap );
     else if ( pPars->Algo == 3 )
-        p1 = Gia_ManFlipUnfold( p );
+        p1 = Gia_ManFlipUnfold( p, vMap );
     else if ( pPars->Algo == 4 )
-        p1 = Gia_ManFOFUnfold( p );
+        p1 = Gia_ManFOFUnfold( p, vMap );
     if ( pPars->Algo != 1 )
         p0 = Gia_ManDeriveDup( pG, Gia_ManCiNum(p1) - Gia_ManCiNum(pG) );
 //    Gia_AigerWrite( p1, "newfault.aig", 0, 0 );
@@ -895,7 +946,7 @@
             assert( 0 );
 
     // add one large OR clause
-    vLits = Vec_IntAlloc( Gia_ManCoNum(p) );
+    Vec_IntClear( vLits );
     Gia_ManForEachCo( pM, pObj, i )
         Vec_IntPush( vLits, Abc_Var2Lit(pCnf->pVarNums[Gia_ObjId(pM, pObj)], 0) );
     sat_solver_addclause( pSat, Vec_IntArray(vLits), Vec_IntArray(vLits) + Vec_IntSize(vLits) );
@@ -915,31 +966,43 @@
     {
         int nTests = Vec_IntSize(vTests) / nFuncVars;
         assert( Vec_IntSize(vTests) % nFuncVars == 0 );
-        printf( "Reading %d pre-computed test patterns from file \"%s\".\n", Vec_IntSize(vTests) / nFuncVars, pPars->pFileName );
+        if ( pPars->pFileName )
+            printf( "Reading %d pre-computed test patterns from file \"%s\".\n", Vec_IntSize(vTests) / nFuncVars, pPars->pFileName );
+        else
+            printf( "Reading %d pre-computed test patterns from previous rounds.\n", Vec_IntSize(vTests) / nFuncVars );
         for ( Iter = 0; Iter < nTests; Iter++ )
         {
-            abctime clk = Abc_Clock();
-            status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
-            clkSat += Abc_Clock() - clk;
-            if ( status == l_Undef )
+            if ( fWarmUp )
             {
-                if ( pPars->fVerbose )
-                    printf( "\n" );
-                printf( "Timeout reached after %d seconds and adding %d tests.\n", pPars->nTimeOut, Iter );
-                goto finish;
+                abctime clk = Abc_Clock();
+                status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
+                clkSat += Abc_Clock() - clk;
+                if ( status == l_Undef )
+                {
+                    if ( pPars->fVerbose )
+                        printf( "\n" );
+                    printf( "Timeout reached after %d seconds and adding %d tests.\n", pPars->nTimeOut, Iter );
+                    return 0;
+                }
+                if ( status == l_False )
+                {
+                    if ( pPars->fVerbose )
+                        printf( "\n" );
+                    printf( "The problem is UNSAT after adding %d tests.\n", Iter );
+                    return 0;
+                }
             }
-            if ( status == l_False )
+            // get pattern
+            Vec_IntClear( vLits );
+            for ( i = 0; i < nFuncVars; i++ )
+                Vec_IntPush( vLits, Vec_IntEntry(vTests, Iter*nFuncVars + i) );
+            if ( !Gia_ManFaultAddOne( pM, pCnf, pSat, vLits, nFuncVars ) )
             {
                 if ( pPars->fVerbose )
                     printf( "\n" );
                 printf( "The problem is UNSAT after adding %d tests.\n", Iter );
-                goto finish;
+                return 0;
             }
-            // get pattern
-            Vec_IntClear( vLits );
-            for ( i = 0; i < nFuncVars; i++ )
-                Vec_IntPush( vLits, Vec_IntEntry(vTests, Iter*nFuncVars + i) );
-            Gia_ManFaultAddOne( pM, pCnf, pSat, vLits, nFuncVars );
             if ( pPars->fVerbose )
             {
                 printf( "Iter%6d : ",       Iter );
@@ -961,26 +1024,142 @@
                 if ( pPars->fVerbose )
                     printf( "\n" );
                 printf( "Timeout reached after %d seconds and %d iterations.\n", pPars->nTimeOut, Iter );
-                goto finish;
+                return 0;
             }
             if ( status == l_False )
             {
                 if ( pPars->fVerbose )
                     printf( "\n" );
                 printf( "The problem is UNSAT after %d iterations.\n", Iter );
-                goto finish;
+                return 0;
             }
             // initialize simple pattern
             Vec_IntFill( vLits, nFuncVars, Iter );
             Vec_IntAppend( vTests, vLits );
-            Gia_ManFaultAddOne( pM, pCnf, pSat, vLits, nFuncVars );
+            if ( !Gia_ManFaultAddOne( pM, pCnf, pSat, vLits, nFuncVars ) )
+            {
+                if ( pPars->fVerbose )
+                    printf( "\n" );
+                printf( "The problem is UNSAT after adding %d tests.\n", Iter );
+                return 0;
+            }
         }
     }
 
+    printf( "Using miter with:  AIG nodes = %6d.  CNF variables = %6d.  CNF clauses = %8d.\n", Gia_ManAndNum(pM), pCnf->nVars, pCnf->nClauses );
+
+    *ppMiter = pM;
+    *ppCnf = pCnf;
+    *ppSat = pSat;
+    return 1;
+}
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+void Gia_ManFaultTest( Gia_Man_t * p, Gia_Man_t * pG, Bmc_ParFf_t * pPars )
+{
+    int nIterMax = 1000000, nVars, nPars;
+    int i, Iter, Iter2, status, nFuncVars = -1;
+    abctime clk, clkSat = 0, clkTotal = Abc_Clock();
+    Vec_Int_t * vLits, * vMap = NULL, * vTests, * vPars = NULL;
+    Gia_Man_t * pM;
+    Gia_Obj_t * pObj;
+    Cnf_Dat_t * pCnf;
+    sat_solver * pSat;
+
+    if ( pPars->Algo == 0 && Gia_FormStrCount( pPars->pFormStr, &nVars, &nPars ) )
+        return;
+
+    // select algorithm
+    if ( pPars->Algo == 0 )
+        printf( "FFTEST is computing test patterns for fault model \"%s\"...\n", pPars->pFormStr );
+    else if ( pPars->Algo == 1 )
+        printf( "FFTEST is computing test patterns for %sdelay faults...\n", pPars->fBasic ? "single " : "" );
+    else if ( pPars->Algo == 2 )
+        printf( "FFTEST is computing test patterns for %sstuck-at faults...\n", pPars->fBasic ? "single " : "" );
+    else if ( pPars->Algo == 3 )
+        printf( "FFTEST is computing test patterns for %scomplement faults...\n", pPars->fBasic ? "single " : "" );
+    else if ( pPars->Algo == 4 )
+        printf( "FFTEST is computing test patterns for %sfunctionally observable faults...\n", pPars->fBasic ? "single " : "" );
+    else
+    {
+        printf( "Unrecognized algorithm (%d).\n", pPars->Algo );
+        return;
+    }
+
+    // select algorithm
+    if ( pPars->Algo == 0 )
+        nFuncVars = Gia_ManCiNum(p);
+    else if ( pPars->Algo == 1 )
+        nFuncVars = Gia_ManRegNum(p) + 2 * Gia_ManPiNum(p);
+    else if ( pPars->Algo == 2 )
+        nFuncVars = Gia_ManCiNum(p);
+    else if ( pPars->Algo == 3 )
+        nFuncVars = Gia_ManCiNum(p);
+    else if ( pPars->Algo == 4 )
+        nFuncVars = Gia_ManCiNum(p);
+
+    // collect test patterns from file
+    if ( pPars->pFileName )
+        vTests = Gia_ManGetTestPatterns( pPars->pFileName );
+    else
+        vTests = Vec_IntAlloc( 10000 );
+    if ( vTests == NULL )
+        return;
+
+    // select algorithm
+    vMap = Vec_IntAlloc( 0 );
+    if ( pPars->Algo == 2 )
+        Vec_IntFill( vMap, 2 * Gia_ManAndNum(p), 1 );
+    else if ( pPars->Algo == 3 )
+        Vec_IntFill( vMap,     Gia_ManAndNum(p), 1 );
+    else if ( pPars->Algo == 4 )
+        Vec_IntFill( vMap, 4 * Gia_ManAndNum(p), 1 );
+
+    // prepare SAT solver
+    vLits = Vec_IntAlloc( Gia_ManCoNum(p) );
+    if ( !Gia_ManFaultPrepare(p, pG, pPars, nFuncVars, vMap, vTests, vLits, &pM, &pCnf, &pSat, 1) )
+        return;
+
     // iterate through the test vectors
     for ( Iter = pPars->fStartPats ? 2 : Vec_IntSize(vTests) / nFuncVars; Iter < nIterMax; Iter++ )
     {
-        abctime clk = Abc_Clock();
+        // collect parameter variables
+        if ( pPars->nIterCheck && vPars == NULL )
+        {
+            vPars = Vec_IntAlloc( Gia_ManPiNum(pM) - nFuncVars );
+            Gia_ManForEachPi( pM, pObj, i )
+                if ( i >= nFuncVars )
+                    Vec_IntPush( vPars, pCnf->pVarNums[Gia_ObjId(pM, pObj)] );
+            assert( Vec_IntSize(vPars) == Gia_ManPiNum(pM) - nFuncVars );
+        }
+        // derive unit parameter variables
+        if ( Iter && pPars->nIterCheck && (Iter % pPars->nIterCheck) == 0 )
+        {
+            Gia_ManFaultAnalyze( pSat, vPars, vMap, vLits, Iter );
+            // cleanup
+            Gia_ManStop( pM );
+            Cnf_DataFree( pCnf );
+            sat_solver_delete( pSat );
+            // recompute
+            if ( !Gia_ManFaultPrepare(p, pG, pPars, nFuncVars, vMap, vTests, vLits, &pM, &pCnf, &pSat, 0) )
+            {
+                printf( "This should never happen.\n" );
+                return;
+            }
+            Vec_IntFreeP( &vPars );
+        }
+        // solve
+        clk = Abc_Clock();
         status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
         clkSat += Abc_Clock() - clk;
         if ( pPars->fVerbose )
@@ -1014,7 +1193,13 @@
                 Vec_IntPush( vLits, sat_solver_var_value(pSat, pCnf->pVarNums[Gia_ObjId(pM, pObj)]) );
         Vec_IntAppend( vTests, vLits );
         // add constraint
-        Gia_ManFaultAddOne( pM, pCnf, pSat, vLits, nFuncVars );
+        if ( !Gia_ManFaultAddOne( pM, pCnf, pSat, vLits, nFuncVars ) )
+        {
+            if ( pPars->fVerbose )
+                printf( "\n" );
+            printf( "The problem is UNSAT after adding %d tests.\n", Iter );
+            break;
+        }
     }
 finish:
     // print results
@@ -1031,7 +1216,7 @@
     }
 
     // compute untestable faults
-    if ( p != pG || pPars->fDumpUntest )
+    if ( Iter && (p != pG || pPars->fDumpUntest) )
     {
         abctime clkTotal = Abc_Clock();
         // restart the SAT solver
@@ -1101,7 +1286,11 @@
             Vec_IntClear( vLits );
             for ( i = 0; i < nFuncVars; i++ )
                 Vec_IntPush( vLits, Vec_IntEntry(vTests, Iter2*nFuncVars + i) );
-            Gia_ManFaultAddOne( pM, pCnf, pSat, vLits, nFuncVars );
+            if ( !Gia_ManFaultAddOne( pM, pCnf, pSat, vLits, nFuncVars ) )
+            {
+                printf( "The problem is UNSAT after adding %d tests.\n", Iter2 );
+                goto finish;
+            }
         }
         assert( Iter2 == Iter );
         if ( pPars->fVerbose )
@@ -1141,7 +1330,9 @@
     Cnf_DataFree( pCnf );
     Gia_ManStop( pM );
     Vec_IntFree( vTests );
+    Vec_IntFree( vMap );
     Vec_IntFree( vLits );
+    Vec_IntFreeP( &vPars );
 }
 
 
diff --git a/abc-build/src/sat/bmc/module.make b/abc-build/src/sat/bmc/module.make
--- a/abc-build/src/sat/bmc/module.make
+++ b/abc-build/src/sat/bmc/module.make
@@ -10,6 +10,7 @@
 	src/sat/bmc/bmcCexMin1.c \
 	src/sat/bmc/bmcCexMin2.c \
 	src/sat/bmc/bmcCexTools.c \
+	src/sat/bmc/bmcChain.c \
 	src/sat/bmc/bmcEco.c \
 	src/sat/bmc/bmcFault.c \
 	src/sat/bmc/bmcICheck.c \
diff --git a/abc-build/src/sat/bsat/satSolver.h b/abc-build/src/sat/bsat/satSolver.h
--- a/abc-build/src/sat/bsat/satSolver.h
+++ b/abc-build/src/sat/bsat/satSolver.h
@@ -211,8 +211,8 @@
 {
     int i;
     for (i = 0; i < s->size; i++)
-        s->activity[i] = 0.0;
-    s->var_inc = 1.0;
+        s->activity[i] = 0;
+    s->var_inc = 1;
 }
 static void sat_solver_compress(sat_solver* s) 
 {
diff --git a/abc-build/src/sat/bsat2/AbcApi.cpp b/abc-build/src/sat/bsat2/AbcApi.cpp
new file mode 100644
--- /dev/null
+++ b/abc-build/src/sat/bsat2/AbcApi.cpp
@@ -0,0 +1,59 @@
+/**CFile****************************************************************
+
+  FileName    [AbcApi.cpp]
+
+  PackageName [A C++ version of SAT solver MiniSAT 2.2 developed 
+  by Niklas Sorensson and Niklas Een. http://minisat.se.]
+
+  Synopsis    [Interface to the SAT solver.]
+
+  Author      [Niklas Sorensson and Niklas Een.]
+  
+  Affiliation [UC Berkeley]
+
+  Date        [Ver. 1.0. Started - January 1, 2004.]
+
+  Revision    [$Id: AbcApi.cpp,v 1.0 2004/01/01 1:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "Solver.h"
+#include "sat/cnf/cnf.h"
+
+ABC_NAMESPACE_IMPL_START
+
+using namespace Minisat;
+
+////////////////////////////////////////////////////////////////////////
+///                        DECLARATIONS                              ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+///                     FUNCTION DEFINITIONS                         ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+  Synopsis    []
+
+  Description []
+               
+  SideEffects []
+
+  SeeAlso     []
+
+***********************************************************************/
+int Abc_CallMiniSat22( Cnf_Dat_t * p )
+{
+    Solver S;
+    int Result = -1;
+    return Result;
+}
+
+
+////////////////////////////////////////////////////////////////////////
+///                       END OF FILE                                ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
diff --git a/abc-build/src/sat/bsat2/Alg.h b/abc-build/src/sat/bsat2/Alg.h
new file mode 100644
--- /dev/null
+++ b/abc-build/src/sat/bsat2/Alg.h
@@ -0,0 +1,84 @@
+/*******************************************************************************************[Alg.h]
+Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson
+Copyright (c) 2007-2010, Niklas Sorensson
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
+associated documentation files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or
+substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
+NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
+OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+**************************************************************************************************/
+
+#ifndef Minisat_Alg_h
+#define Minisat_Alg_h
+
+#include "Vec.h"
+
+namespace Minisat {
+
+//=================================================================================================
+// Useful functions on vector-like types:
+
+//=================================================================================================
+// Removing and searching for elements:
+//
+
+template<class V, class T>
+static inline void remove(V& ts, const T& t)
+{
+    int j = 0;
+    for (; j < ts.size() && ts[j] != t; j++);
+    assert(j < ts.size());
+    for (; j < ts.size()-1; j++) ts[j] = ts[j+1];
+    ts.pop();
+}
+
+
+template<class V, class T>
+static inline bool find(V& ts, const T& t)
+{
+    int j = 0;
+    for (; j < ts.size() && ts[j] != t; j++);
+    return j < ts.size();
+}
+
+
+//=================================================================================================
+// Copying vectors with support for nested vector types:
+//
+
+// Base case:
+template<class T>
+static inline void copy(const T& from, T& to)
+{
+    to = from;
+}
+
+// Recursive case:
+template<class T>
+static inline void copy(const vec<T>& from, vec<T>& to, bool append = false)
+{
+    if (!append)
+        to.clear();
+    for (int i = 0; i < from.size(); i++){
+        to.push();
+        copy(from[i], to.last());
+    }
+}
+
+template<class T>
+static inline void append(const vec<T>& from, vec<T>& to){ copy(from, to, true); }
+
+//=================================================================================================
+}
+
+#endif
diff --git a/abc-build/src/sat/bsat2/Alloc.h b/abc-build/src/sat/bsat2/Alloc.h
new file mode 100644
--- /dev/null
+++ b/abc-build/src/sat/bsat2/Alloc.h
@@ -0,0 +1,131 @@
+/*****************************************************************************************[Alloc.h]
+Copyright (c) 2008-2010, Niklas Sorensson
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
+associated documentation files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or
+substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
+NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
+OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+**************************************************************************************************/
+
+
+#ifndef Minisat_Alloc_h
+#define Minisat_Alloc_h
+
+#include "XAlloc.h"
+#include "Vec.h"
+
+namespace Minisat {
+
+//=================================================================================================
+// Simple Region-based memory allocator:
+
+template<class T>
+class RegionAllocator
+{
+    T*        memory;
+    uint32_t  sz;
+    uint32_t  cap;
+    uint32_t  wasted_;
+
+    void capacity(uint32_t min_cap);
+
+ public:
+    // TODO: make this a class for better type-checking?
+    typedef uint32_t Ref;
+    enum { Ref_Undef = UINT32_MAX };
+    enum { Unit_Size = sizeof(uint32_t) };
+
+    explicit RegionAllocator(uint32_t start_cap = 1024*1024) : memory(NULL), sz(0), cap(0), wasted_(0){ capacity(start_cap); }
+    ~RegionAllocator()
+    {
+        if (memory != NULL)
+            ::free(memory);
+    }
+
+
+    uint32_t size      () const      { return sz; }
+    uint32_t wasted    () const      { return wasted_; }
+
+    Ref      alloc     (int size); 
+    void     _free      (int size)    { wasted_ += size; }
+
+    // Deref, Load Effective Address (LEA), Inverse of LEA (AEL):
+    T&       operator[](Ref r)       { assert(r >= 0 && r < sz); return memory[r]; }
+    const T& operator[](Ref r) const { assert(r >= 0 && r < sz); return memory[r]; }
+
+    T*       lea       (Ref r)       { assert(r >= 0 && r < sz); return &memory[r]; }
+    const T* lea       (Ref r) const { assert(r >= 0 && r < sz); return &memory[r]; }
+    Ref      ael       (const T* t)  { assert((void*)t >= (void*)&memory[0] && (void*)t < (void*)&memory[sz-1]);
+        return  (Ref)(t - &memory[0]); }
+
+    void     moveTo(RegionAllocator& to) {
+        if (to.memory != NULL) ::free(to.memory);
+        to.memory = memory;
+        to.sz = sz;
+        to.cap = cap;
+        to.wasted_ = wasted_;
+
+        memory = NULL;
+        sz = cap = wasted_ = 0;
+    }
+
+
+};
+
+template<class T>
+void RegionAllocator<T>::capacity(uint32_t min_cap)
+{
+    if (cap >= min_cap) return;
+
+    uint32_t prev_cap = cap;
+    while (cap < min_cap){
+        // NOTE: Multiply by a factor (13/8) without causing overflow, then add 2 and make the
+        // result even by clearing the least significant bit. The resulting sequence of capacities
+        // is carefully chosen to hit a maximum capacity that is close to the '2^32-1' limit when
+        // using 'uint32_t' as indices so that as much as possible of this space can be used.
+        uint32_t delta = ((cap >> 1) + (cap >> 3) + 2) & ~1;
+        cap += delta;
+
+        if (cap <= prev_cap)
+            throw OutOfMemoryException();
+    }
+    // printf(" .. (%p) cap = %u\n", this, cap);
+
+    assert(cap > 0);
+    memory = (T*)xrealloc(memory, sizeof(T)*cap);
+}
+
+
+template<class T>
+typename RegionAllocator<T>::Ref
+RegionAllocator<T>::alloc(int size)
+{ 
+    // printf("ALLOC called (this = %p, size = %d)\n", this, size); fflush(stdout);
+    assert(size > 0);
+    capacity(sz + size);
+
+    uint32_t prev_sz = sz;
+    sz += size;
+    
+    // Handle overflow:
+    if (sz < prev_sz)
+        throw OutOfMemoryException();
+
+    return prev_sz;
+}
+
+
+//=================================================================================================
+}
+
+#endif
diff --git a/abc-build/src/sat/bsat2/Dimacs.h b/abc-build/src/sat/bsat2/Dimacs.h
new file mode 100644
--- /dev/null
+++ b/abc-build/src/sat/bsat2/Dimacs.h
@@ -0,0 +1,89 @@
+/****************************************************************************************[Dimacs.h]
+Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson
+Copyright (c) 2007-2010, Niklas Sorensson
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
+associated documentation files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or
+substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
+NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
+OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+**************************************************************************************************/
+
+#ifndef Minisat_Dimacs_h
+#define Minisat_Dimacs_h
+
+#include <stdio.h>
+
+#include "ParseUtils.h"
+#include "SolverTypes.h"
+
+namespace Minisat {
+
+//=================================================================================================
+// DIMACS Parser:
+
+template<class B, class Solver>
+static void readClause(B& in, Solver& S, vec<Lit>& lits) {
+    int     parsed_lit, var;
+    lits.clear();
+    for (;;){
+        parsed_lit = parseInt(in);
+        if (parsed_lit == 0) break;
+        var = abs(parsed_lit)-1;
+        while (var >= S.nVars()) S.newVar();
+        lits.push( (parsed_lit > 0) ? mkLit(var) : ~mkLit(var) );
+    }
+}
+
+template<class B, class Solver>
+static void parse_DIMACS_main(B& in, Solver& S) {
+    vec<Lit> lits;
+    int vars    = 0;
+    int clauses = 0;
+    int cnt     = 0;
+    for (;;){
+        skipWhitespace(in);
+        if (*in == EOF) break;
+        else if (*in == 'p'){
+            if (eagerMatch(in, "p cnf")){
+                vars    = parseInt(in);
+                clauses = parseInt(in);
+                // SATRACE'06 hack
+                // if (clauses > 4000000)
+                //     S.eliminate(true);
+            }else{
+                printf("PARSE ERROR! Unexpected char: %c\n", *in), exit(3);
+            }
+        } else if (*in == 'c' || *in == 'p')
+            skipLine(in);
+        else{
+            cnt++;
+            readClause(in, S, lits);
+            S.addClause_(lits); }
+    }
+    if (vars != S.nVars())
+        fprintf(stderr, "WARNING! DIMACS header mismatch: wrong number of variables.\n");
+    if (cnt  != clauses)
+        fprintf(stderr, "WARNING! DIMACS header mismatch: wrong number of clauses.\n");
+}
+
+// Inserts problem into solver.
+//
+template<class Solver>
+static void parse_DIMACS(gzFile input_stream, Solver& S) {
+    StreamBuffer in(input_stream);
+    parse_DIMACS_main(in, S); }
+
+//=================================================================================================
+}
+
+#endif
diff --git a/abc-build/src/sat/bsat2/Heap.h b/abc-build/src/sat/bsat2/Heap.h
new file mode 100644
--- /dev/null
+++ b/abc-build/src/sat/bsat2/Heap.h
@@ -0,0 +1,149 @@
+/******************************************************************************************[Heap.h]
+Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson
+Copyright (c) 2007-2010, Niklas Sorensson
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
+associated documentation files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or
+substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
+NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
+OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+**************************************************************************************************/
+
+#ifndef Minisat_Heap_h
+#define Minisat_Heap_h
+
+#include "Vec.h"
+
+namespace Minisat {
+
+//=================================================================================================
+// A heap implementation with support for decrease/increase key.
+
+
+template<class Comp>
+class Heap {
+    Comp     lt;       // The heap is a minimum-heap with respect to this comparator
+    vec<int> heap;     // Heap of integers
+    vec<int> indices;  // Each integers position (index) in the Heap
+
+    // Index "traversal" functions
+    static inline int left  (int i) { return i*2+1; }
+    static inline int right (int i) { return (i+1)*2; }
+    static inline int parent(int i) { return (i-1) >> 1; }
+
+
+    void percolateUp(int i)
+    {
+        int x  = heap[i];
+        int p  = parent(i);
+        
+        while (i != 0 && lt(x, heap[p])){
+            heap[i]          = heap[p];
+            indices[heap[p]] = i;
+            i                = p;
+            p                = parent(p);
+        }
+        heap   [i] = x;
+        indices[x] = i;
+    }
+
+
+    void percolateDown(int i)
+    {
+        int x = heap[i];
+        while (left(i) < heap.size()){
+            int child = right(i) < heap.size() && lt(heap[right(i)], heap[left(i)]) ? right(i) : left(i);
+            if (!lt(heap[child], x)) break;
+            heap[i]          = heap[child];
+            indices[heap[i]] = i;
+            i                = child;
+        }
+        heap   [i] = x;
+        indices[x] = i;
+    }
+
+
+  public:
+    Heap(const Comp& c) : lt(c) { }
+
+    int  size      ()          const { return heap.size(); }
+    bool empty     ()          const { return heap.size() == 0; }
+    bool inHeap    (int n)     const { return n < indices.size() && indices[n] >= 0; }
+    int  operator[](int index) const { assert(index < heap.size()); return heap[index]; }
+
+
+    void decrease  (int n) { assert(inHeap(n)); percolateUp  (indices[n]); }
+    void increase  (int n) { assert(inHeap(n)); percolateDown(indices[n]); }
+
+
+    // Safe variant of insert/decrease/increase:
+    void update(int n)
+    {
+        if (!inHeap(n))
+            insert(n);
+        else {
+            percolateUp(indices[n]);
+            percolateDown(indices[n]); }
+    }
+
+
+    void insert(int n)
+    {
+        indices.growTo(n+1, -1);
+        assert(!inHeap(n));
+
+        indices[n] = heap.size();
+        heap.push(n);
+        percolateUp(indices[n]); 
+    }
+
+
+    int  removeMin()
+    {
+        int x            = heap[0];
+        heap[0]          = heap.last();
+        indices[heap[0]] = 0;
+        indices[x]       = -1;
+        heap.pop();
+        if (heap.size() > 1) percolateDown(0);
+        return x; 
+    }
+
+
+    // Rebuild the heap from scratch, using the elements in 'ns':
+    void build(vec<int>& ns) {
+        int i;
+        for (i = 0; i < heap.size(); i++)
+            indices[heap[i]] = -1;
+        heap.clear();
+
+        for (i = 0; i < ns.size(); i++){
+            indices[ns[i]] = i;
+            heap.push(ns[i]); }
+
+        for (i = heap.size() / 2 - 1; i >= 0; i--)
+            percolateDown(i);
+    }
+
+    void clear(bool dealloc = false) 
+    { 
+        for (int i = 0; i < heap.size(); i++)
+            indices[heap[i]] = -1;
+        heap.clear(dealloc); 
+    }
+};
+
+
+//=================================================================================================
+}
+
+#endif
diff --git a/abc-build/src/sat/bsat2/IntTypes.h b/abc-build/src/sat/bsat2/IntTypes.h
new file mode 100644
--- /dev/null
+++ b/abc-build/src/sat/bsat2/IntTypes.h
@@ -0,0 +1,47 @@
+/**************************************************************************************[IntTypes.h]
+Copyright (c) 2009-2010, Niklas Sorensson
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
+associated documentation files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or
+substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
+NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
+OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+**************************************************************************************************/
+
+#ifndef Minisat_IntTypes_h
+#define Minisat_IntTypes_h
+
+#ifdef __sun
+    // Not sure if there are newer versions that support C99 headers. The
+    // needed features are implemented in the headers below though:
+
+#   include <sys/int_types.h>
+#   include <sys/int_fmtio.h>
+#   include <sys/int_limits.h>
+
+#elif _WIN32
+
+#   include "pstdint.h"
+
+#else
+
+#   define __STDC_LIMIT_MACROS
+#   include <stdint.h>
+#   include <inttypes.h>
+
+#endif
+
+#include <limits.h>
+
+//=================================================================================================
+
+#endif
diff --git a/abc-build/src/sat/bsat2/LICENSE b/abc-build/src/sat/bsat2/LICENSE
new file mode 100644
--- /dev/null
+++ b/abc-build/src/sat/bsat2/LICENSE
@@ -0,0 +1,21 @@
+MiniSat -- Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson
+           Copyright (c) 2007-2010  Niklas Sorensson
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/abc-build/src/sat/bsat2/MainSat.cpp b/abc-build/src/sat/bsat2/MainSat.cpp
new file mode 100644
--- /dev/null
+++ b/abc-build/src/sat/bsat2/MainSat.cpp
@@ -0,0 +1,197 @@
+/*****************************************************************************************[Main.cc]
+Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson
+Copyright (c) 2007-2010, Niklas Sorensson
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
+associated documentation files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or
+substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
+NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
+OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+**************************************************************************************************/
+
+#include <errno.h>
+
+#include <signal.h>
+#include "misc/zlib/zlib.h"
+
+#include "System.h"
+#include "ParseUtils.h"
+#include "Options.h"
+#include "Dimacs.h"
+#include "Solver.h"
+
+using namespace Minisat;
+
+//=================================================================================================
+
+
+void printStats(Solver& solver)
+{
+    double cpu_time = cpuTime();
+    double mem_used = memUsedPeak();
+    printf("restarts              : %-12.0f\n",                                (double)(int64_t)solver.starts);
+    printf("conflicts             : %-12.0f  (%.0f /sec)\n",                   (double)(int64_t)solver.conflicts,    (double)(int64_t)solver.conflicts / cpu_time);
+    printf("decisions             : %-12.0f  (%4.2f %% random) (%.0f /sec)\n", (double)(int64_t)solver.decisions,    (double)(int64_t)solver.rnd_decisions*100 / (double)(int64_t)solver.decisions, (double)(int64_t)solver.decisions / cpu_time);
+    printf("propagations          : %-12.0f  (%.0f /sec)\n",                   (double)(int64_t)solver.propagations, (double)(int64_t)solver.propagations / cpu_time);
+    printf("conflict literals     : %-12.0f  (%4.2f %% deleted)\n",            (double)(int64_t)solver.tot_literals, (double)(int64_t)(solver.max_literals - solver.tot_literals)*100 / (double)(int64_t)solver.max_literals);
+    if (mem_used != 0) printf("Memory used           : %.2f MB\n", mem_used);
+    printf("CPU time              : %g s\n", cpu_time);
+}
+
+
+static Solver* solver;
+// Terminate by notifying the solver and back out gracefully. This is mainly to have a test-case
+// for this feature of the Solver as it may take longer than an immediate call to '_exit()'.
+static void SIGINT_interrupt(int signum) { solver->interrupt(); }
+
+// Note that '_exit()' rather than 'exit()' has to be used. The reason is that 'exit()' calls
+// destructors and may cause deadlocks if a malloc/free function happens to be running (these
+// functions are guarded by locks for multithreaded use).
+static void SIGINT_exit(int signum) {
+    printf("\n"); printf("*** INTERRUPTED ***\n");
+    if (solver->verbosity > 0){
+        printStats(*solver);
+        printf("\n"); printf("*** INTERRUPTED ***\n"); }
+    _exit(1); }
+
+
+//=================================================================================================
+// Main:
+
+
+extern "C" int MainSat(int argc, char** argv)
+{
+    try {
+        setUsageHelp("USAGE: %s [options] <input-file> <result-output-file>\n\n  where input may be either in plain or gzipped DIMACS.\n");
+        // printf("This is MiniSat 2.0 beta\n");
+        
+#if defined(__linux__)
+        fpu_control_t oldcw, newcw;
+        _FPU_GETCW(oldcw); newcw = (oldcw & ~_FPU_EXTENDED) | _FPU_DOUBLE; _FPU_SETCW(newcw);
+        printf("WARNING: for repeatability, setting FPU to use double precision\n");
+#endif
+        // Extra options:
+        //
+        IntOption    verb   ("MAIN", "verb",   "Verbosity level (0=silent, 1=some, 2=more).", 1, IntRange(0, 2));
+        IntOption    cpu_lim("MAIN", "cpu-lim","Limit on CPU time allowed in seconds.\n", INT32_MAX, IntRange(0, INT32_MAX));
+        IntOption    mem_lim("MAIN", "mem-lim","Limit on memory usage in megabytes.\n", INT32_MAX, IntRange(0, INT32_MAX));
+        
+        if ( !parseOptions(argc, argv, true) )
+            return 1;
+
+        Solver S;
+        double initial_time = cpuTime();
+
+        S.verbosity = verb;
+        
+        solver = &S;
+/*
+        // Use signal handlers that forcibly quit until the solver will be able to respond to
+        // interrupts:
+        signal(SIGINT, SIGINT_exit);
+        signal(SIGXCPU,SIGINT_exit);
+
+        // Set limit on CPU-time:
+        if (cpu_lim != INT32_MAX){
+            rlimit rl;
+            getrlimit(RLIMIT_CPU, &rl);
+            if (rl.rlim_max == RLIM_INFINITY || (rlim_t)cpu_lim < rl.rlim_max){
+                rl.rlim_cur = cpu_lim;
+                if (setrlimit(RLIMIT_CPU, &rl) == -1)
+                    printf("WARNING! Could not set resource limit: CPU-time.\n");
+            } }
+
+        // Set limit on virtual memory:
+        if (mem_lim != INT32_MAX){
+            rlim_t new_mem_lim = (rlim_t)mem_lim * 1024*1024;
+            rlimit rl;
+            getrlimit(RLIMIT_AS, &rl);
+            if (rl.rlim_max == RLIM_INFINITY || new_mem_lim < rl.rlim_max){
+                rl.rlim_cur = new_mem_lim;
+                if (setrlimit(RLIMIT_AS, &rl) == -1)
+                    printf("WARNING! Could not set resource limit: Virtual memory.\n");
+            } }
+*/        
+        if (argc == 1)
+        {
+            printf("Reading from standard input... Use '--help' for help.\n");
+            return 1;
+        }
+        
+        gzFile in = (argc == 1) ? gzdopen(0, "rb") : gzopen(argv[1], "rb");
+        if (in == NULL)
+            printf("ERROR! Could not open file: %s\n", argc == 1 ? "<stdin>" : argv[1]), exit(1);
+        
+        if (S.verbosity > 0){
+            printf("============================[ Problem Statistics ]=============================\n");
+            printf("|                                                                             |\n"); }
+        
+        parse_DIMACS(in, S);
+        gzclose(in);
+        FILE* res = (argc >= 3) ? fopen(argv[2], "wb") : NULL;
+        
+        if (S.verbosity > 0){
+            printf("|  Number of variables:  %12d                                         |\n", S.nVars());
+            printf("|  Number of clauses:    %12d                                         |\n", S.nClauses()); }
+        
+        double parsed_time = cpuTime();
+        if (S.verbosity > 0){
+            printf("|  Parse time:           %12.2f s                                       |\n", parsed_time - initial_time);
+            printf("|                                                                             |\n"); }
+ 
+        // Change to signal-handlers that will only notify the solver and allow it to terminate
+        // voluntarily:
+//        signal(SIGINT, SIGINT_interrupt);
+//        signal(SIGXCPU,SIGINT_interrupt);
+       
+        if (!S.simplify()){
+            if (res != NULL) fprintf(res, "UNSAT\n"), fclose(res);
+            if (S.verbosity > 0){
+                printf("===============================================================================\n");
+                printf("Solved by unit propagation\n");
+                printStats(S);
+                printf("\n"); }
+            printf("UNSATISFIABLE\n");
+            exit(20);
+        }
+        
+        vec<Lit> dummy;
+        lbool ret = S.solveLimited(dummy);
+        if (S.verbosity > 0){
+            printStats(S);
+            printf("\n"); }
+        printf(ret == l_True ? "SATISFIABLE\n" : ret == l_False ? "UNSATISFIABLE\n" : "INDETERMINATE\n");
+        if (res != NULL){
+            if (ret == l_True){
+                fprintf(res, "SAT\n");
+                for (int i = 0; i < S.nVars(); i++)
+                    if (S.model[i] != l_Undef)
+                        fprintf(res, "%s%s%d", (i==0)?"":" ", (S.model[i]==l_True)?"":"-", i+1);
+                fprintf(res, " 0\n");
+            }else if (ret == l_False)
+                fprintf(res, "UNSAT\n");
+            else
+                fprintf(res, "INDET\n");
+            fclose(res);
+        }
+        
+//#ifdef NDEBUG
+//        exit(ret == l_True ? 10 : ret == l_False ? 20 : 0);     // (faster than "return", which will invoke the destructor for 'Solver')
+//#else
+        return (ret == l_True ? 10 : ret == l_False ? 20 : 0);
+//#endif
+    } catch (OutOfMemoryException&){
+        printf("===============================================================================\n");
+        printf("INDETERMINATE\n");
+        exit(0);
+    }
+}
diff --git a/abc-build/src/sat/bsat2/MainSimp.cpp b/abc-build/src/sat/bsat2/MainSimp.cpp
new file mode 100644
--- /dev/null
+++ b/abc-build/src/sat/bsat2/MainSimp.cpp
@@ -0,0 +1,206 @@
+/*****************************************************************************************[Main.cc]
+Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson
+Copyright (c) 2007,      Niklas Sorensson
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
+associated documentation files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or
+substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
+NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
+OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+**************************************************************************************************/
+
+#include <errno.h>
+
+#include <signal.h>
+#include "misc/zlib/zlib.h"
+
+#ifndef _WIN32
+#include <sys/resource.h>
+#endif
+
+#include "System.h"
+#include "ParseUtils.h"
+#include "Options.h"
+#include "Dimacs.h"
+#include "SimpSolver.h"
+
+using namespace Minisat;
+
+//=================================================================================================
+
+extern void printStats(Solver& solver);
+
+static Solver* solver;
+// Terminate by notifying the solver and back out gracefully. This is mainly to have a test-case
+// for this feature of the Solver as it may take longer than an immediate call to '_exit()'.
+static void SIGINT_interrupt(int signum) { solver->interrupt(); }
+
+// Note that '_exit()' rather than 'exit()' has to be used. The reason is that 'exit()' calls
+// destructors and may cause deadlocks if a malloc/free function happens to be running (these
+// functions are guarded by locks for multithreaded use).
+static void SIGINT_exit(int signum) {
+    printf("\n"); printf("*** INTERRUPTED ***\n");
+    if (solver->verbosity > 0){
+        printStats(*solver);
+        printf("\n"); printf("*** INTERRUPTED ***\n"); }
+    _exit(1); }
+
+
+//=================================================================================================
+// Main:
+
+extern "C" int MainSimp(int argc, char** argv)
+{
+    try {
+        setUsageHelp("USAGE: %s [options] <input-file> <result-output-file>\n\n  where input may be either in plain or gzipped DIMACS.\n");
+        // printf("This is MiniSat 2.0 beta\n");
+        
+#if defined(__linux__)
+        fpu_control_t oldcw, newcw;
+        _FPU_GETCW(oldcw); newcw = (oldcw & ~_FPU_EXTENDED) | _FPU_DOUBLE; _FPU_SETCW(newcw);
+        printf("WARNING: for repeatability, setting FPU to use double precision\n");
+#endif
+        // Extra options:
+        //
+        IntOption    verb   ("MAIN", "verb",   "Verbosity level (0=silent, 1=some, 2=more).", 1, IntRange(0, 2));
+        BoolOption   pre    ("MAIN", "pre",    "Completely turn on/off any preprocessing.", true);
+        StringOption dimacs ("MAIN", "dimacs", "If given, stop after preprocessing and write the result to this file.");
+        IntOption    cpu_lim("MAIN", "cpu-lim","Limit on CPU time allowed in seconds.\n", INT32_MAX, IntRange(0, INT32_MAX));
+        IntOption    mem_lim("MAIN", "mem-lim","Limit on memory usage in megabytes.\n", INT32_MAX, IntRange(0, INT32_MAX));
+
+        if ( !parseOptions(argc, argv, true) )
+            return 1;
+        
+        SimpSolver  S;
+        double      initial_time = cpuTime();
+
+        if (!pre) S.eliminate(true);
+
+        S.verbosity = verb;
+        
+        solver = &S;
+/*
+        // Use signal handlers that forcibly quit until the solver will be able to respond to
+        // interrupts:
+        signal(SIGINT, SIGINT_exit);
+        signal(SIGXCPU,SIGINT_exit);
+
+        // Set limit on CPU-time:
+        if (cpu_lim != INT32_MAX){
+            rlimit rl;
+            getrlimit(RLIMIT_CPU, &rl);
+            if (rl.rlim_max == RLIM_INFINITY || (rlim_t)cpu_lim < rl.rlim_max){
+                rl.rlim_cur = cpu_lim;
+                if (setrlimit(RLIMIT_CPU, &rl) == -1)
+                    printf("WARNING! Could not set resource limit: CPU-time.\n");
+            } }
+
+        // Set limit on virtual memory:
+        if (mem_lim != INT32_MAX){
+            rlim_t new_mem_lim = (rlim_t)mem_lim * 1024*1024;
+            rlimit rl;
+            getrlimit(RLIMIT_AS, &rl);
+            if (rl.rlim_max == RLIM_INFINITY || new_mem_lim < rl.rlim_max){
+                rl.rlim_cur = new_mem_lim;
+                if (setrlimit(RLIMIT_AS, &rl) == -1)
+                    printf("WARNING! Could not set resource limit: Virtual memory.\n");
+            } }
+*/        
+        if (argc == 1)
+        {
+            printf("Reading from standard input... Use '--help' for help.\n");
+            return 1;
+        }
+
+        gzFile in = (argc == 1) ? gzdopen(0, "rb") : gzopen(argv[1], "rb");
+        if (in == NULL)
+            printf("ERROR! Could not open file: %s\n", argc == 1 ? "<stdin>" : argv[1]), exit(1);
+        
+        if (S.verbosity > 0){
+            printf("============================[ Problem Statistics ]=============================\n");
+            printf("|                                                                             |\n"); }
+        
+        parse_DIMACS(in, S);
+        gzclose(in);
+        FILE* res = (argc >= 3) ? fopen(argv[2], "wb") : NULL;
+
+        if (S.verbosity > 0){
+            printf("|  Number of variables:  %12d                                         |\n", S.nVars());
+            printf("|  Number of clauses:    %12d                                         |\n", S.nClauses()); }
+        
+        double parsed_time = cpuTime();
+        if (S.verbosity > 0)
+            printf("|  Parse time:           %12.2f s                                       |\n", parsed_time - initial_time);
+
+        // Change to signal-handlers that will only notify the solver and allow it to terminate
+        // voluntarily:
+//        signal(SIGINT, SIGINT_interrupt);
+//        signal(SIGXCPU,SIGINT_interrupt);
+
+        S.eliminate(true);
+        double simplified_time = cpuTime();
+        if (S.verbosity > 0){
+            printf("|  Simplification time:  %12.2f s                                       |\n", simplified_time - parsed_time);
+            printf("|                                                                             |\n"); }
+
+        if (!S.okay()){
+            if (res != NULL) fprintf(res, "UNSAT\n"), fclose(res);
+            if (S.verbosity > 0){
+                printf("===============================================================================\n");
+                printf("Solved by simplification\n");
+                printStats(S);
+                printf("\n"); }
+            printf("UNSATISFIABLE\n");
+            exit(20);
+        }
+
+        if (dimacs){
+            if (S.verbosity > 0)
+                printf("==============================[ Writing DIMACS ]===============================\n");
+            S.toDimacs((const char*)dimacs);
+            if (S.verbosity > 0)
+                printStats(S);
+            exit(0);
+        }
+
+        vec<Lit> dummy;
+        lbool ret = S.solveLimited(dummy);
+        
+        if (S.verbosity > 0){
+            printStats(S);
+            printf("\n"); }
+        printf(ret == l_True ? "SATISFIABLE\n" : ret == l_False ? "UNSATISFIABLE\n" : "INDETERMINATE\n");
+        if (res != NULL){
+            if (ret == l_True){
+                fprintf(res, "SAT\n");
+                for (int i = 0; i < S.nVars(); i++)
+                    if (S.model[i] != l_Undef)
+                        fprintf(res, "%s%s%d", (i==0)?"":" ", (S.model[i]==l_True)?"":"-", i+1);
+                fprintf(res, " 0\n");
+            }else if (ret == l_False)
+                fprintf(res, "UNSAT\n");
+            else
+                fprintf(res, "INDET\n");
+            fclose(res);
+        }
+
+//#ifdef NDEBUG
+//        exit(ret == l_True ? 10 : ret == l_False ? 20 : 0);     // (faster than "return", which will invoke the destructor for 'Solver')
+//#else
+        return (ret == l_True ? 10 : ret == l_False ? 20 : 0);
+//#endif
+    } catch (OutOfMemoryException&){
+        printf("===============================================================================\n");
+        printf("INDETERMINATE\n");
+        exit(0);
+    }
+}
diff --git a/abc-build/src/sat/bsat2/Map.h b/abc-build/src/sat/bsat2/Map.h
new file mode 100644
--- /dev/null
+++ b/abc-build/src/sat/bsat2/Map.h
@@ -0,0 +1,193 @@
+/*******************************************************************************************[Map.h]
+Copyright (c) 2006-2010, Niklas Sorensson
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
+associated documentation files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or
+substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
+NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
+OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+**************************************************************************************************/
+
+#ifndef Minisat_Map_h
+#define Minisat_Map_h
+
+#include "IntTypes.h"
+#include "Vec.h"
+
+namespace Minisat {
+
+//=================================================================================================
+// Default hash/equals functions
+//
+
+template<class K> struct Hash  { uint32_t operator()(const K& k)               const { return hash(k);  } };
+template<class K> struct Equal { bool     operator()(const K& k1, const K& k2) const { return k1 == k2; } };
+
+template<class K> struct DeepHash  { uint32_t operator()(const K* k)               const { return hash(*k);  } };
+template<class K> struct DeepEqual { bool     operator()(const K* k1, const K* k2) const { return *k1 == *k2; } };
+
+static inline uint32_t hash(uint32_t x){ return x; }
+static inline uint32_t hash(uint64_t x){ return (uint32_t)x; }
+static inline uint32_t hash(int32_t x) { return (uint32_t)x; }
+static inline uint32_t hash(int64_t x) { return (uint32_t)x; }
+
+
+//=================================================================================================
+// Some primes
+//
+
+static const int nprimes          = 25;
+static const int primes [nprimes] = { 31, 73, 151, 313, 643, 1291, 2593, 5233, 10501, 21013, 42073, 84181, 168451, 337219, 674701, 1349473, 2699299, 5398891, 10798093, 21596719, 43193641, 86387383, 172775299, 345550609, 691101253 };
+
+//=================================================================================================
+// Hash table implementation of Maps
+//
+
+template<class K, class D, class H = Hash<K>, class E = Equal<K> >
+class Map {
+ public:
+    struct Pair { K key; D data; };
+
+ private:
+    H          hash;
+    E          equals;
+
+    vec<Pair>* table;
+    int        cap;
+    int        size;
+
+    // Don't allow copying (error prone):
+    Map<K,D,H,E>&  operator = (Map<K,D,H,E>& other) { assert(0); }
+                   Map        (Map<K,D,H,E>& other) { assert(0); }
+
+    bool    checkCap(int new_size) const { return new_size > cap; }
+
+    int32_t index  (const K& k) const { return hash(k) % cap; }
+    void   _insert (const K& k, const D& d) { 
+        vec<Pair>& ps = table[index(k)];
+        ps.push(); ps.last().key = k; ps.last().data = d; }
+
+    void    rehash () {
+        const vec<Pair>* old = table;
+
+        int old_cap = cap;
+        int newsize = primes[0];
+        for (int i = 1; newsize <= cap && i < nprimes; i++)
+           newsize = primes[i];
+
+        table = new vec<Pair>[newsize];
+        cap   = newsize;
+
+        for (int i = 0; i < old_cap; i++){
+            for (int j = 0; j < old[i].size(); j++){
+                _insert(old[i][j].key, old[i][j].data); }}
+
+        delete [] old;
+
+        // printf(" --- rehashing, old-cap=%d, new-cap=%d\n", cap, newsize);
+    }
+
+    
+ public:
+
+    Map () : table(NULL), cap(0), size(0) {}
+    Map (const H& h, const E& e) : hash(h), equals(e), table(NULL), cap(0), size(0){}
+    ~Map () { delete [] table; }
+
+    // PRECONDITION: the key must already exist in the map.
+    const D& operator [] (const K& k) const
+    {
+        assert(size != 0);
+        const D*         res = NULL;
+        const vec<Pair>& ps  = table[index(k)];
+        for (int i = 0; i < ps.size(); i++)
+            if (equals(ps[i].key, k))
+                res = &ps[i].data;
+        assert(res != NULL);
+        return *res;
+    }
+
+    // PRECONDITION: the key must already exist in the map.
+    D& operator [] (const K& k)
+    {
+        assert(size != 0);
+        D*         res = NULL;
+        vec<Pair>& ps  = table[index(k)];
+        for (int i = 0; i < ps.size(); i++)
+            if (equals(ps[i].key, k))
+                res = &ps[i].data;
+        assert(res != NULL);
+        return *res;
+    }
+
+    // PRECONDITION: the key must *NOT* exist in the map.
+    void insert (const K& k, const D& d) { if (checkCap(size+1)) rehash(); _insert(k, d); size++; }
+    bool peek   (const K& k, D& d) const {
+        if (size == 0) return false;
+        const vec<Pair>& ps = table[index(k)];
+        for (int i = 0; i < ps.size(); i++)
+            if (equals(ps[i].key, k)){
+                d = ps[i].data;
+                return true; } 
+        return false;
+    }
+
+    bool has   (const K& k) const {
+        if (size == 0) return false;
+        const vec<Pair>& ps = table[index(k)];
+        for (int i = 0; i < ps.size(); i++)
+            if (equals(ps[i].key, k))
+                return true;
+        return false;
+    }
+
+    // PRECONDITION: the key must exist in the map.
+    void remove(const K& k) {
+        assert(table != NULL);
+        vec<Pair>& ps = table[index(k)];
+        int j = 0;
+        for (; j < ps.size() && !equals(ps[j].key, k); j++);
+        assert(j < ps.size());
+        ps[j] = ps.last();
+        ps.pop();
+        size--;
+    }
+
+    void clear  () {
+        cap = size = 0;
+        delete [] table;
+        table = NULL;
+    }
+
+    int  elems() const { return size; }
+    int  bucket_count() const { return cap; }
+
+    // NOTE: the hash and equality objects are not moved by this method:
+    void moveTo(Map& other){
+        delete [] other.table;
+
+        other.table = table;
+        other.cap   = cap;
+        other.size  = size;
+
+        table = NULL;
+        size = cap = 0;
+    }
+
+    // NOTE: given a bit more time, I could make a more C++-style iterator out of this:
+    const vec<Pair>& bucket(int i) const { return table[i]; }
+};
+
+//=================================================================================================
+}
+
+#endif
diff --git a/abc-build/src/sat/bsat2/Options.cpp b/abc-build/src/sat/bsat2/Options.cpp
new file mode 100644
--- /dev/null
+++ b/abc-build/src/sat/bsat2/Options.cpp
@@ -0,0 +1,93 @@
+/**************************************************************************************[Options.cc]
+Copyright (c) 2008-2010, Niklas Sorensson
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
+associated documentation files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or
+substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
+NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
+OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+**************************************************************************************************/
+
+#include "Sort.h"
+#include "Options.h"
+#include "ParseUtils.h"
+
+using namespace Minisat;
+
+int Minisat::parseOptions(int& argc, char** argv, bool strict)
+{
+    int i, j;
+    for (i = j = 1; i < argc; i++){
+        const char* str = argv[i];
+        if (match(str, "--") && match(str, Option::getHelpPrefixString()) && match(str, "help")){
+            if (*str == '\0')
+                return printUsageAndExit(argc, argv);
+            else if (match(str, "-verb"))
+                return printUsageAndExit(argc, argv, true);
+        } else {
+            bool parsed_ok = false;
+        
+            for (int k = 0; !parsed_ok && k < Option::getOptionList().size(); k++){
+                parsed_ok = Option::getOptionList()[k]->parse(argv[i]);
+
+                // fprintf(stderr, "checking %d: %s against flag <%s> (%s)\n", i, argv[i], Option::getOptionList()[k]->name, parsed_ok ? "ok" : "skip");
+            }
+
+            if (!parsed_ok)
+                if (strict && match(argv[i], "-"))
+                    { fprintf(stderr, "ERROR! Unknown flag \"%s\". Use '--%shelp' for help.\n", argv[i], Option::getHelpPrefixString()); return 0; } //  exit(0);
+                else
+                    argv[j++] = argv[i];
+        }
+    }
+
+    argc -= (i - j);
+    return 1;
+}
+
+
+void Minisat::setUsageHelp      (const char* str){ Option::getUsageString() = str; }
+void Minisat::setHelpPrefixStr  (const char* str){ Option::getHelpPrefixString() = str; }
+int Minisat::printUsageAndExit (int argc, char** argv, bool verbose)
+{
+    const char* usage = Option::getUsageString();
+    if (usage != NULL)
+        fprintf(stderr, usage, argv[0]);
+
+    sort(Option::getOptionList(), Option::OptionLt());
+
+    const char* prev_cat  = NULL;
+    const char* prev_type = NULL;
+
+    for (int i = 0; i < Option::getOptionList().size(); i++){
+        const char* cat  = Option::getOptionList()[i]->category;
+        const char* type = Option::getOptionList()[i]->type_name;
+
+        if (cat != prev_cat)
+            fprintf(stderr, "\n%s OPTIONS:\n\n", cat);
+        else if (type != prev_type)
+            fprintf(stderr, "\n");
+
+        Option::getOptionList()[i]->help(verbose);
+
+        prev_cat  = Option::getOptionList()[i]->category;
+        prev_type = Option::getOptionList()[i]->type_name;
+    }
+
+    fprintf(stderr, "\nHELP OPTIONS:\n\n");
+    fprintf(stderr, "  --%shelp        Print help message.\n", Option::getHelpPrefixString());
+    fprintf(stderr, "  --%shelp-verb   Print verbose help message.\n", Option::getHelpPrefixString());
+    fprintf(stderr, "\n");
+//    exit(0);
+    return 0;
+}
+
diff --git a/abc-build/src/sat/bsat2/Options.h b/abc-build/src/sat/bsat2/Options.h
new file mode 100644
--- /dev/null
+++ b/abc-build/src/sat/bsat2/Options.h
@@ -0,0 +1,387 @@
+/***************************************************************************************[Options.h]
+Copyright (c) 2008-2010, Niklas Sorensson
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
+associated documentation files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or
+substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
+NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
+OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+**************************************************************************************************/
+
+#ifndef Minisat_Options_h
+#define Minisat_Options_h
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#include <string.h>
+
+#include "IntTypes.h"
+#include "Vec.h"
+#include "ParseUtils.h"
+
+namespace Minisat {
+
+//==================================================================================================
+// Top-level option parse/help functions:
+
+
+extern int parseOptions     (int& argc, char** argv, bool strict = false);
+extern int printUsageAndExit(int  argc, char** argv, bool verbose = false);
+extern void setUsageHelp     (const char* str);
+extern void setHelpPrefixStr (const char* str);
+
+
+//==================================================================================================
+// Options is an abstract class that gives the interface for all types options:
+
+
+class Option
+{
+ public:
+    const char* name;
+    const char* description;
+    const char* category;
+    const char* type_name;
+
+    static vec<Option*>& getOptionList () { static vec<Option*> options; return options; }
+    static const char*&  getUsageString() { static const char* usage_str; return usage_str; }
+    static const char*&  getHelpPrefixString() { static const char* help_prefix_str = ""; return help_prefix_str; }
+
+    struct OptionLt {
+        bool operator()(const Option* x, const Option* y) {
+            int test1 = strcmp(x->category, y->category);
+            return test1 < 0 || test1 == 0 && strcmp(x->type_name, y->type_name) < 0;
+        }
+    };
+
+    Option(const char* name_, 
+           const char* desc_,
+           const char* cate_,
+           const char* type_) : 
+      name       (name_)
+    , description(desc_)
+    , category   (cate_)
+    , type_name  (type_)
+    { 
+        getOptionList().push(this); 
+    }
+
+ public:
+    virtual ~Option() {}
+
+    virtual bool parse             (const char* str)      = 0;
+    virtual void help              (bool verbose = false) = 0;
+
+    friend  int parseOptions      (int& argc, char** argv, bool strict);
+    friend  int printUsageAndExit (int  argc, char** argv, bool verbose);
+    friend  void setUsageHelp      (const char* str);
+    friend  void setHelpPrefixStr  (const char* str);
+};
+
+
+//==================================================================================================
+// Range classes with specialization for floating types:
+
+
+struct IntRange {
+    int begin;
+    int end;
+    IntRange(int b, int e) : begin(b), end(e) {}
+};
+
+struct Int64Range {
+    int64_t begin;
+    int64_t end;
+    Int64Range(int64_t b, int64_t e) : begin(b), end(e) {}
+};
+
+struct DoubleRange {
+    double begin;
+    double end;
+    bool  begin_inclusive;
+    bool  end_inclusive;
+    DoubleRange(double b, bool binc, double e, bool einc) : begin(b), end(e), begin_inclusive(binc), end_inclusive(einc) {}
+};
+
+
+//==================================================================================================
+// Double options:
+
+
+class DoubleOption : public Option
+{
+ protected:
+    DoubleRange range;
+    double      value;
+
+ public:
+    DoubleOption(const char* c, const char* n, const char* d, double def = double(), DoubleRange r = DoubleRange(-HUGE_VAL, false, HUGE_VAL, false))
+        : Option(n, d, c, "<double>"), range(r), value(def) {
+        // FIXME: set LC_NUMERIC to "C" to make sure that strtof/strtod parses decimal point correctly.
+    }
+
+    operator      double   (void) const { return value; }
+    operator      double&  (void)       { return value; }
+    DoubleOption& operator=(double x)   { value = x; return *this; }
+
+    virtual bool parse(const char* str){
+        const char* span = str; 
+
+        if (!match(span, "-") || !match(span, name) || !match(span, "="))
+            return false;
+
+        char*  end;
+        double tmp = strtod(span, &end);
+
+        if (end == NULL) 
+            return false;
+        else if (tmp >= range.end && (!range.end_inclusive || tmp != range.end)){
+            fprintf(stderr, "ERROR! value <%s> is too large for option \"%s\".\n", span, name);
+            exit(1);
+        }else if (tmp <= range.begin && (!range.begin_inclusive || tmp != range.begin)){
+            fprintf(stderr, "ERROR! value <%s> is too small for option \"%s\".\n", span, name);
+            exit(1); }
+
+        value = tmp;
+        // fprintf(stderr, "READ VALUE: %g\n", value);
+
+        return true;
+    }
+
+    virtual void help (bool verbose = false){
+        fprintf(stderr, "  -%-12s = %-8s %c%4.2g .. %4.2g%c (default: %g)\n", 
+                name, type_name, 
+                range.begin_inclusive ? '[' : '(', 
+                range.begin,
+                range.end,
+                range.end_inclusive ? ']' : ')', 
+                value);
+        if (verbose){
+            fprintf(stderr, "\n        %s\n", description);
+            fprintf(stderr, "\n");
+        }
+    }
+};
+
+
+//==================================================================================================
+// Int options:
+
+
+class IntOption : public Option
+{
+ protected:
+    IntRange range;
+    int32_t  value;
+
+ public:
+    IntOption(const char* c, const char* n, const char* d, int32_t def = int32_t(), IntRange r = IntRange(INT32_MIN, INT32_MAX))
+        : Option(n, d, c, "<int32>"), range(r), value(def) {}
+ 
+    operator   int32_t   (void) const { return value; }
+    operator   int32_t&  (void)       { return value; }
+    IntOption& operator= (int32_t x)  { value = x; return *this; }
+
+    virtual bool parse(const char* str){
+        const char* span = str; 
+
+        if (!match(span, "-") || !match(span, name) || !match(span, "="))
+            return false;
+
+        char*   end;
+        int32_t tmp = strtol(span, &end, 10);
+
+        if (end == NULL) 
+            return false;
+        else if (tmp > range.end){
+            fprintf(stderr, "ERROR! value <%s> is too large for option \"%s\".\n", span, name);
+            exit(1);
+        }else if (tmp < range.begin){
+            fprintf(stderr, "ERROR! value <%s> is too small for option \"%s\".\n", span, name);
+            exit(1); }
+
+        value = tmp;
+
+        return true;
+    }
+
+    virtual void help (bool verbose = false){
+        fprintf(stderr, "  -%-12s = %-8s [", name, type_name);
+        if (range.begin == INT32_MIN)
+            fprintf(stderr, "imin");
+        else
+            fprintf(stderr, "%4d", range.begin);
+
+        fprintf(stderr, " .. ");
+        if (range.end == INT32_MAX)
+            fprintf(stderr, "imax");
+        else
+            fprintf(stderr, "%4d", range.end);
+
+        fprintf(stderr, "] (default: %d)\n", value);
+        if (verbose){
+            fprintf(stderr, "\n        %s\n", description);
+            fprintf(stderr, "\n");
+        }
+    }
+};
+
+/*
+// Leave this out for visual C++ until Microsoft implements C99 and gets support for strtoll.
+#ifndef _MSC_VER
+
+class Int64Option : public Option
+{
+ protected:
+    Int64Range range;
+    int64_t  value;
+
+ public:
+    Int64Option(const char* c, const char* n, const char* d, int64_t def = int64_t(), Int64Range r = Int64Range(INT64_MIN, INT64_MAX))
+        : Option(n, d, c, "<int64>"), range(r), value(def) {}
+ 
+    operator     int64_t   (void) const { return value; }
+    operator     int64_t&  (void)       { return value; }
+    Int64Option& operator= (int64_t x)  { value = x; return *this; }
+
+    virtual bool parse(const char* str){
+        const char* span = str; 
+
+        if (!match(span, "-") || !match(span, name) || !match(span, "="))
+            return false;
+
+        char*   end;
+        int64_t tmp = strtoll(span, &end, 10);
+
+        if (end == NULL) 
+            return false;
+        else if (tmp > range.end){
+            fprintf(stderr, "ERROR! value <%s> is too large for option \"%s\".\n", span, name);
+            exit(1);
+        }else if (tmp < range.begin){
+            fprintf(stderr, "ERROR! value <%s> is too small for option \"%s\".\n", span, name);
+            exit(1); }
+
+        value = tmp;
+
+        return true;
+    }
+
+    virtual void help (bool verbose = false){
+        fprintf(stderr, "  -%-12s = %-8s [", name, type_name);
+        if (range.begin == INT64_MIN)
+            fprintf(stderr, "imin");
+        else
+            fprintf(stderr, "%4"PRIi64, range.begin);
+
+        fprintf(stderr, " .. ");
+        if (range.end == INT64_MAX)
+            fprintf(stderr, "imax");
+        else
+            fprintf(stderr, "%4"PRIi64, range.end);
+
+        fprintf(stderr, "] (default: %"PRIi64")\n", value);
+        if (verbose){
+            fprintf(stderr, "\n        %s\n", description);
+            fprintf(stderr, "\n");
+        }
+    }
+};
+#endif
+*/
+
+//==================================================================================================
+// String option:
+
+
+class StringOption : public Option
+{
+    const char* value;
+ public:
+    StringOption(const char* c, const char* n, const char* d, const char* def = NULL) 
+        : Option(n, d, c, "<string>"), value(def) {}
+
+    operator      const char*  (void) const     { return value; }
+    operator      const char*& (void)           { return value; }
+    StringOption& operator=    (const char* x)  { value = x; return *this; }
+
+    virtual bool parse(const char* str){
+        const char* span = str; 
+
+        if (!match(span, "-") || !match(span, name) || !match(span, "="))
+            return false;
+
+        value = span;
+        return true;
+    }
+
+    virtual void help (bool verbose = false){
+        fprintf(stderr, "  -%-10s = %8s\n", name, type_name);
+        if (verbose){
+            fprintf(stderr, "\n        %s\n", description);
+            fprintf(stderr, "\n");
+        }
+    }    
+};
+
+
+//==================================================================================================
+// Bool option:
+
+
+class BoolOption : public Option
+{
+    bool value;
+
+ public:
+    BoolOption(const char* c, const char* n, const char* d, bool v) 
+        : Option(n, d, c, "<bool>"), value(v) {}
+
+    operator    bool     (void) const { return value; }
+    operator    bool&    (void)       { return value; }
+    BoolOption& operator=(bool b)     { value = b; return *this; }
+
+    virtual bool parse(const char* str){
+        const char* span = str; 
+        
+        if (match(span, "-")){
+            bool b = !match(span, "no-");
+
+            if (strcmp(span, name) == 0){
+                value = b;
+                return true; }
+        }
+
+        return false;
+    }
+
+    virtual void help (bool verbose = false){
+
+        fprintf(stderr, "  -%s, -no-%s", name, name);
+
+        for (uint32_t i = 0; i < 32 - strlen(name)*2; i++)
+            fprintf(stderr, " ");
+
+        fprintf(stderr, " ");
+        fprintf(stderr, "(default: %s)\n", value ? "on" : "off");
+        if (verbose){
+            fprintf(stderr, "\n        %s\n", description);
+            fprintf(stderr, "\n");
+        }
+    }
+};
+
+//=================================================================================================
+}
+
+#endif
diff --git a/abc-build/src/sat/bsat2/ParseUtils.h b/abc-build/src/sat/bsat2/ParseUtils.h
new file mode 100644
--- /dev/null
+++ b/abc-build/src/sat/bsat2/ParseUtils.h
@@ -0,0 +1,122 @@
+/************************************************************************************[ParseUtils.h]
+Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson
+Copyright (c) 2007-2010, Niklas Sorensson
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
+associated documentation files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or
+substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
+NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
+OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+**************************************************************************************************/
+
+#ifndef Minisat_ParseUtils_h
+#define Minisat_ParseUtils_h
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "misc/zlib/zlib.h"
+
+namespace Minisat {
+
+//-------------------------------------------------------------------------------------------------
+// A simple buffered character stream class:
+
+static const int buffer_size = 1048576;
+
+
+class StreamBuffer {
+    gzFile        in;
+    unsigned char buf[buffer_size];
+    int           pos;
+    int           size;
+
+    void assureLookahead() {
+        if (pos >= size) {
+            pos  = 0;
+            size = gzread(in, buf, sizeof(buf)); } }
+
+public:
+    explicit StreamBuffer(gzFile i) : in(i), pos(0), size(0) { assureLookahead(); }
+
+    int  operator *  () const { return (pos >= size) ? EOF : buf[pos]; }
+    void operator ++ ()       { pos++; assureLookahead(); }
+    int  position    () const { return pos; }
+};
+
+
+//-------------------------------------------------------------------------------------------------
+// End-of-file detection functions for StreamBuffer and char*:
+
+
+static inline bool isEof(StreamBuffer& in) { return *in == EOF;  }
+static inline bool isEof(const char*   in) { return *in == '\0'; }
+
+//-------------------------------------------------------------------------------------------------
+// Generic parse functions parametrized over the input-stream type.
+
+
+template<class B>
+static void skipWhitespace(B& in) {
+    while ((*in >= 9 && *in <= 13) || *in == 32)
+        ++in; }
+
+
+template<class B>
+static void skipLine(B& in) {
+    for (;;){
+        if (isEof(in)) return;
+        if (*in == '\n') { ++in; return; }
+        ++in; } }
+
+
+template<class B>
+static int parseInt(B& in) {
+    int     val = 0;
+    bool    neg = false;
+    skipWhitespace(in);
+    if      (*in == '-') neg = true, ++in;
+    else if (*in == '+') ++in;
+    if (*in < '0' || *in > '9') fprintf(stderr, "PARSE ERROR! Unexpected char: %c\n", *in), exit(3);
+    while (*in >= '0' && *in <= '9')
+        val = val*10 + (*in - '0'),
+        ++in;
+    return neg ? -val : val; }
+
+
+// String matching: in case of a match the input iterator will be advanced the corresponding
+// number of characters.
+template<class B>
+static bool match(B& in, const char* str) {
+    int i;
+    for (i = 0; str[i] != '\0'; i++)
+        if (in[i] != str[i])
+            return false;
+
+    in += i;
+
+    return true; 
+}
+
+// String matching: consumes characters eagerly, but does not require random access iterator.
+template<class B>
+static bool eagerMatch(B& in, const char* str) {
+    for (; *str != '\0'; ++str, ++in)
+        if (*str != *in)
+            return false;
+    return true; }
+
+
+//=================================================================================================
+}
+
+#endif
diff --git a/abc-build/src/sat/bsat2/Queue.h b/abc-build/src/sat/bsat2/Queue.h
new file mode 100644
--- /dev/null
+++ b/abc-build/src/sat/bsat2/Queue.h
@@ -0,0 +1,69 @@
+/*****************************************************************************************[Queue.h]
+Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson
+Copyright (c) 2007-2010, Niklas Sorensson
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
+associated documentation files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or
+substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
+NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
+OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+**************************************************************************************************/
+
+#ifndef Minisat_Queue_h
+#define Minisat_Queue_h
+
+#include "Vec.h"
+
+namespace Minisat {
+
+//=================================================================================================
+
+template<class T>
+class Queue {
+    vec<T>  buf;
+    int     first;
+    int     end;
+
+public:
+    typedef T Key;
+
+    Queue() : buf(1), first(0), end(0) {}
+
+    void clear (bool dealloc = false) { buf.clear(dealloc); buf.growTo(1); first = end = 0; }
+    int  size  () const { return (end >= first) ? end - first : end - first + buf.size(); }
+
+    const T& operator [] (int index) const  { assert(index >= 0); assert(index < size()); return buf[(first + index) % buf.size()]; }
+    T&       operator [] (int index)        { assert(index >= 0); assert(index < size()); return buf[(first + index) % buf.size()]; }
+
+    T    peek  () const { assert(first != end); return buf[first]; }
+    void pop   () { assert(first != end); first++; if (first == buf.size()) first = 0; }
+    void insert(T elem) {   // INVARIANT: buf[end] is always unused
+        buf[end++] = elem;
+        if (end == buf.size()) end = 0;
+        if (first == end){  // Resize:
+            vec<T>  tmp((buf.size()*3 + 1) >> 1);
+            //**/printf("queue alloc: %d elems (%.1f MB)\n", tmp.size(), tmp.size() * sizeof(T) / 1000000.0);
+            int j, i = 0;
+            for (j = first; j < buf.size(); j++) tmp[i++] = buf[j];
+            for (j = 0    ; j < end       ; j++) tmp[i++] = buf[j];
+            first = 0;
+            end   = buf.size();
+            tmp.moveTo(buf);
+        }
+    }
+};
+
+
+//=================================================================================================
+}
+
+#endif
diff --git a/abc-build/src/sat/bsat2/README b/abc-build/src/sat/bsat2/README
new file mode 100644
--- /dev/null
+++ b/abc-build/src/sat/bsat2/README
@@ -0,0 +1,24 @@
+================================================================================
+DIRECTORY OVERVIEW:
+
+mtl/            Mini Template Library
+utils/          Generic helper code (I/O, Parsing, CPU-time, etc)
+core/           A core version of the solver
+simp/           An extended solver with simplification capabilities
+README
+LICENSE
+
+================================================================================
+BUILDING: (release version: without assertions, statically linked, etc)
+
+export MROOT=<minisat-dir>              (or setenv in cshell)
+cd { core | simp }
+gmake rs
+cp minisat_static <install-dir>/minisat
+
+================================================================================
+EXAMPLES:
+
+Run minisat with same heuristics as version 2.0:
+
+> minisat <cnf-file> -no-luby -rinc=1.5 -phase-saving=0 -rnd-freq=0.02
diff --git a/abc-build/src/sat/bsat2/ReleaseNotes-2.2.0.txt b/abc-build/src/sat/bsat2/ReleaseNotes-2.2.0.txt
new file mode 100644
--- /dev/null
+++ b/abc-build/src/sat/bsat2/ReleaseNotes-2.2.0.txt
@@ -0,0 +1,79 @@
+Release Notes for MiniSat 2.2.0
+===============================
+
+Changes since version 2.0:
+
+ * Started using a more standard release numbering.
+
+ * Includes some now well-known heuristics: phase-saving and luby
+   restarts. The old heuristics are still present and can be activated
+   if needed.
+
+ * Detection/Handling of out-of-memory and vector capacity
+   overflow. This is fairly new and relatively untested.
+
+ * Simple resource controls: CPU-time, memory, number of
+   conflicts/decisions.
+
+ * CPU-time limiting is implemented by a more general, but simple,
+   asynchronous interruption feature. This means that the solving
+   procedure can be interrupted from another thread or in a signal
+   handler.
+
+ * Improved portability with respect to building on Solaris and with
+   Visual Studio. This is not regularly tested and chances are that
+   this have been broken since, but should be fairly easy to fix if
+   so.
+
+ * Changed C++ file-extention to the less problematic ".cc".
+
+ * Source code is now namespace-protected
+
+ * Introducing a new Clause Memory Allocator that brings reduced
+   memory consumption on 64-bit architechtures and improved
+   performance (to some extent). The allocator uses a region-based
+   approach were all references to clauses are represented as a 32-bit
+   index into a global memory region that contains all clauses. To
+   free up and compact memory it uses a simple copying garbage
+   collector.
+
+ * Improved unit-propagation by Blocking Literals. For each entry in
+   the watcher lists, pair the pointer to a clause with some
+   (arbitrary) literal from the clause. The idea is that if the
+   literal is currently true (i.e. the clause is satisfied) the
+   watchers of the clause does not need to be altered. This can thus
+   be detected without touching the clause's memory at all. As often
+   as can be done cheaply, the blocking literal for entries to the
+   watcher list of a literal 'p' is set to the other literal watched
+   in the corresponding clause.
+
+ * Basic command-line/option handling system. Makes it easy to specify
+   options in the class that they affect, and whenever that class is
+   used in an executable, parsing of options and help messages are
+   brought in automatically.
+
+ * General clean-up and various minor bug-fixes.
+
+ * Changed implementation of variable-elimination/model-extension:
+    
+     - The interface is changed so that arbitrary remembering is no longer
+       possible. If you need to mention some variable again in the future,
+       this variable has to be frozen.
+    
+     - When eliminating a variable, only clauses that contain the variable
+       with one sign is necessary to store. Thereby making the other sign
+       a "default" value when extending models.
+    
+     - The memory consumption for eliminated clauses is further improved
+       by storing all eliminated clauses in a single contiguous vector.
+
+  * Some common utility code (I/O, Parsing, CPU-time, etc) is ripped
+    out and placed in a separate "utils" directory.
+
+  * The DIMACS parse is refactored so that it can be reused in other
+    applications (not very elegant, but at least possible).
+
+  * Some simple improvements to scalability of preprocessing, using
+    more lazy clause removal from data-structures and a couple of
+    ad-hoc limits (the longest clause that can be produced in variable
+    elimination, and the longest clause used in backward subsumption).
diff --git a/abc-build/src/sat/bsat2/SimpSolver.cpp b/abc-build/src/sat/bsat2/SimpSolver.cpp
new file mode 100644
--- /dev/null
+++ b/abc-build/src/sat/bsat2/SimpSolver.cpp
@@ -0,0 +1,720 @@
+/***********************************************************************************[SimpSolver.cc]
+Copyright (c) 2006,      Niklas Een, Niklas Sorensson
+Copyright (c) 2007-2010, Niklas Sorensson
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
+associated documentation files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or
+substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
+NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
+OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+**************************************************************************************************/
+
+#include "Sort.h"
+#include "SimpSolver.h"
+#include "System.h"
+
+using namespace Minisat;
+
+//=================================================================================================
+// Options:
+
+
+static const char* _cat = "SIMP";
+
+static BoolOption   opt_use_asymm        (_cat, "asymm",        "Shrink clauses by asymmetric branching.", false);
+static BoolOption   opt_use_rcheck       (_cat, "rcheck",       "Check if a clause is already implied. (costly)", false);
+static BoolOption   opt_use_elim         (_cat, "elim",         "Perform variable elimination.", true);
+static IntOption    opt_grow             (_cat, "grow",         "Allow a variable elimination step to grow by a number of clauses.", 0);
+static IntOption    opt_clause_lim       (_cat, "cl-lim",       "Variables are not eliminated if it produces a resolvent with a length above this limit. -1 means no limit", 20,   IntRange(-1, INT32_MAX));
+static IntOption    opt_subsumption_lim  (_cat, "sub-lim",      "Do not check if subsumption against a clause larger than this. -1 means no limit.", 1000, IntRange(-1, INT32_MAX));
+static DoubleOption opt_simp_garbage_frac(_cat, "simp-gc-frac", "The fraction of wasted memory allowed before a garbage collection is triggered during simplification.",  0.5, DoubleRange(0, false, HUGE_VAL, false));
+
+
+//=================================================================================================
+// Constructor/Destructor:
+
+
+SimpSolver::SimpSolver() :
+    grow               (opt_grow)
+  , clause_lim         (opt_clause_lim)
+  , subsumption_lim    (opt_subsumption_lim)
+  , simp_garbage_frac  (opt_simp_garbage_frac)
+  , use_asymm          (opt_use_asymm)
+  , use_rcheck         (opt_use_rcheck)
+  , use_elim           (opt_use_elim)
+  , merges             (0)
+  , asymm_lits         (0)
+  , eliminated_vars    (0)
+  , elimorder          (1)
+  , use_simplification (true)
+  , occurs             (ClauseDeleted(ca))
+  , elim_heap          (ElimLt(n_occ))
+  , bwdsub_assigns     (0)
+  , n_touched          (0)
+{
+    vec<Lit> dummy(1,lit_Undef);
+    ca.extra_clause_field = true; // NOTE: must happen before allocating the dummy clause below.
+    bwdsub_tmpunit        = ca.alloc(dummy);
+    remove_satisfied      = false;
+}
+
+
+SimpSolver::~SimpSolver()
+{
+}
+
+
+Var SimpSolver::newVar(bool sign, bool dvar) {
+    Var v = Solver::newVar(sign, dvar);
+
+    frozen    .push((char)false);
+    eliminated.push((char)false);
+
+    if (use_simplification){
+        n_occ     .push(0);
+        n_occ     .push(0);
+        occurs    .init(v);
+        touched   .push(0);
+        elim_heap .insert(v);
+    }
+    return v; }
+
+
+
+lbool SimpSolver::solve_(bool do_simp, bool turn_off_simp)
+{
+    vec<Var> extra_frozen;
+    lbool    result = l_True;
+
+    do_simp &= use_simplification;
+
+    if (do_simp){
+        // Assumptions must be temporarily frozen to run variable elimination:
+        for (int i = 0; i < assumptions.size(); i++){
+            Var v = var(assumptions[i]);
+
+            // If an assumption has been eliminated, remember it.
+            assert(!isEliminated(v));
+
+            if (!frozen[v]){
+                // Freeze and store.
+                setFrozen(v, true);
+                extra_frozen.push(v);
+            } }
+
+        result = lbool(eliminate(turn_off_simp));
+    }
+
+    if (result == l_True)
+        result = Solver::solve_();
+    else if (verbosity >= 1)
+        printf("===============================================================================\n");
+
+    if (result == l_True)
+        extendModel();
+
+    if (do_simp)
+        // Unfreeze the assumptions that were frozen:
+        for (int i = 0; i < extra_frozen.size(); i++)
+            setFrozen(extra_frozen[i], false);
+
+    return result;
+}
+
+
+
+bool SimpSolver::addClause_(vec<Lit>& ps)
+{
+#ifndef NDEBUG
+    for (int i = 0; i < ps.size(); i++)
+        assert(!isEliminated(var(ps[i])));
+#endif
+
+    int nclauses = clauses.size();
+
+    if (use_rcheck && implied(ps))
+        return true;
+
+    if (!Solver::addClause_(ps))
+        return false;
+
+    if (use_simplification && clauses.size() == nclauses + 1){
+        CRef          cr = clauses.last();
+        const Clause& c  = ca[cr];
+
+        // NOTE: the clause is added to the queue immediately and then
+        // again during 'gatherTouchedClauses()'. If nothing happens
+        // in between, it will only be checked once. Otherwise, it may
+        // be checked twice unnecessarily. This is an unfortunate
+        // consequence of how backward subsumption is used to mimic
+        // forward subsumption.
+        subsumption_queue.insert(cr);
+        for (int i = 0; i < c.size(); i++){
+            occurs[var(c[i])].push(cr);
+            n_occ[toInt(c[i])]++;
+            touched[var(c[i])] = 1;
+            n_touched++;
+            if (elim_heap.inHeap(var(c[i])))
+                elim_heap.increase(var(c[i]));
+        }
+    }
+
+    return true;
+}
+
+
+void SimpSolver::removeClause(CRef cr)
+{
+    const Clause& c = ca[cr];
+
+    if (use_simplification)
+        for (int i = 0; i < c.size(); i++){
+            n_occ[toInt(c[i])]--;
+            updateElimHeap(var(c[i]));
+            occurs.smudge(var(c[i]));
+        }
+
+    Solver::removeClause(cr);
+}
+
+
+bool SimpSolver::strengthenClause(CRef cr, Lit l)
+{
+    Clause& c = ca[cr];
+    assert(decisionLevel() == 0);
+    assert(use_simplification);
+
+    // FIX: this is too inefficient but would be nice to have (properly implemented)
+    // if (!find(subsumption_queue, &c))
+    subsumption_queue.insert(cr);
+
+    if (c.size() == 2){
+        removeClause(cr);
+        c.strengthen(l);
+    }else{
+        detachClause(cr, true);
+        c.strengthen(l);
+        attachClause(cr);
+        remove(occurs[var(l)], cr);
+        n_occ[toInt(l)]--;
+        updateElimHeap(var(l));
+    }
+
+    return c.size() == 1 ? enqueue(c[0]) && propagate() == CRef_Undef : true;
+}
+
+
+// Returns FALSE if clause is always satisfied ('out_clause' should not be used).
+bool SimpSolver::merge(const Clause& _ps, const Clause& _qs, Var v, vec<Lit>& out_clause)
+{
+    merges++;
+    out_clause.clear();
+
+    bool  ps_smallest = _ps.size() < _qs.size();
+    const Clause& ps  =  ps_smallest ? _qs : _ps;
+    const Clause& qs  =  ps_smallest ? _ps : _qs;
+    int i, j;
+
+    for (i = 0; i < qs.size(); i++){
+        if (var(qs[i]) != v){
+            for (j = 0; j < ps.size(); j++)
+                if (var(ps[j]) == var(qs[i]))
+                    if (ps[j] == ~qs[i])
+                        return false;
+                    else
+                        goto next;
+            out_clause.push(qs[i]);
+        }
+        next:;
+    }
+
+    for (i = 0; i < ps.size(); i++)
+        if (var(ps[i]) != v)
+            out_clause.push(ps[i]);
+
+    return true;
+}
+
+
+// Returns FALSE if clause is always satisfied.
+bool SimpSolver::merge(const Clause& _ps, const Clause& _qs, Var v, int& size)
+{
+    merges++;
+
+    bool  ps_smallest = _ps.size() < _qs.size();
+    const Clause& ps  =  ps_smallest ? _qs : _ps;
+    const Clause& qs  =  ps_smallest ? _ps : _qs;
+    const Lit*  __ps  = (const Lit*)ps;
+    const Lit*  __qs  = (const Lit*)qs;
+
+    size = ps.size()-1;
+
+    for (int i = 0; i < qs.size(); i++){
+        if (var(__qs[i]) != v){
+            for (int j = 0; j < ps.size(); j++)
+                if (var(__ps[j]) == var(__qs[i]))
+                    if (__ps[j] == ~__qs[i])
+                        return false;
+                    else
+                        goto next;
+            size++;
+        }
+        next:;
+    }
+
+    return true;
+}
+
+
+void SimpSolver::gatherTouchedClauses()
+{
+    if (n_touched == 0) return;
+
+    int i,j;
+    for (i = j = 0; i < subsumption_queue.size(); i++)
+        if (ca[subsumption_queue[i]].mark() == 0)
+            ca[subsumption_queue[i]].mark(2);
+
+    for (i = 0; i < touched.size(); i++)
+        if (touched[i]){
+            const vec<CRef>& cs = occurs.lookup(i);
+            for (j = 0; j < cs.size(); j++)
+                if (ca[cs[j]].mark() == 0){
+                    subsumption_queue.insert(cs[j]);
+                    ca[cs[j]].mark(2);
+                }
+            touched[i] = 0;
+        }
+
+    for (i = 0; i < subsumption_queue.size(); i++)
+        if (ca[subsumption_queue[i]].mark() == 2)
+            ca[subsumption_queue[i]].mark(0);
+
+    n_touched = 0;
+}
+
+
+bool SimpSolver::implied(const vec<Lit>& c)
+{
+    assert(decisionLevel() == 0);
+
+    trail_lim.push(trail.size());
+    for (int i = 0; i < c.size(); i++)
+        if (value(c[i]) == l_True){
+            cancelUntil(0);
+            return false;
+        }else if (value(c[i]) != l_False){
+            assert(value(c[i]) == l_Undef);
+            uncheckedEnqueue(~c[i]);
+        }
+
+    bool result = propagate() != CRef_Undef;
+    cancelUntil(0);
+    return result;
+}
+
+
+// Backward subsumption + backward subsumption resolution
+bool SimpSolver::backwardSubsumptionCheck(bool verbose)
+{
+    int cnt = 0;
+    int subsumed = 0;
+    int deleted_literals = 0;
+    assert(decisionLevel() == 0);
+
+    while (subsumption_queue.size() > 0 || bwdsub_assigns < trail.size()){
+
+        // Empty subsumption queue and return immediately on user-interrupt:
+        if (asynch_interrupt){
+            subsumption_queue.clear();
+            bwdsub_assigns = trail.size();
+            break; }
+
+        // Check top-level assignments by creating a dummy clause and placing it in the queue:
+        if (subsumption_queue.size() == 0 && bwdsub_assigns < trail.size()){
+            Lit l = trail[bwdsub_assigns++];
+            ca[bwdsub_tmpunit][0] = l;
+            ca[bwdsub_tmpunit].calcAbstraction();
+            subsumption_queue.insert(bwdsub_tmpunit); }
+
+        CRef    cr = subsumption_queue.peek(); subsumption_queue.pop();
+        Clause& c  = ca[cr];
+
+        if (c.mark()) continue;
+
+        if (verbose && verbosity >= 2 && cnt++ % 1000 == 0)
+            printf("subsumption left: %10d (%10d subsumed, %10d deleted literals)\r", subsumption_queue.size(), subsumed, deleted_literals);
+
+        assert(c.size() > 1 || value(c[0]) == l_True);    // Unit-clauses should have been propagated before this point.
+
+        // Find best variable to scan:
+        Var best = var(c[0]);
+        for (int i = 1; i < c.size(); i++)
+            if (occurs[var(c[i])].size() < occurs[best].size())
+                best = var(c[i]);
+
+        // Search all candidates:
+        vec<CRef>& _cs = occurs.lookup(best);
+        CRef*       cs = (CRef*)_cs;
+
+        for (int j = 0; j < _cs.size(); j++)
+            if (c.mark())
+                break;
+            else if (!ca[cs[j]].mark() &&  cs[j] != cr && (subsumption_lim == -1 || ca[cs[j]].size() < subsumption_lim)){
+                Lit l = c.subsumes(ca[cs[j]]);
+
+                if (l == lit_Undef)
+                    subsumed++, removeClause(cs[j]);
+                else if (l != lit_Error){
+                    deleted_literals++;
+
+                    if (!strengthenClause(cs[j], ~l))
+                        return false;
+
+                    // Did current candidate get deleted from cs? Then check candidate at index j again:
+                    if (var(l) == best)
+                        j--;
+                }
+            }
+    }
+
+    return true;
+}
+
+
+bool SimpSolver::asymm(Var v, CRef cr)
+{
+    Clause& c = ca[cr];
+    assert(decisionLevel() == 0);
+
+    if (c.mark() || satisfied(c)) return true;
+
+    trail_lim.push(trail.size());
+    Lit l = lit_Undef;
+    for (int i = 0; i < c.size(); i++)
+        if (var(c[i]) != v && value(c[i]) != l_False)
+            uncheckedEnqueue(~c[i]);
+        else
+            l = c[i];
+
+    if (propagate() != CRef_Undef){
+        cancelUntil(0);
+        asymm_lits++;
+        if (!strengthenClause(cr, l))
+            return false;
+    }else
+        cancelUntil(0);
+
+    return true;
+}
+
+
+bool SimpSolver::asymmVar(Var v)
+{
+    assert(use_simplification);
+
+    const vec<CRef>& cls = occurs.lookup(v);
+
+    if (value(v) != l_Undef || cls.size() == 0)
+        return true;
+
+    for (int i = 0; i < cls.size(); i++)
+        if (!asymm(v, cls[i]))
+            return false;
+
+    return backwardSubsumptionCheck();
+}
+
+
+static void mkElimClause(vec<uint32_t>& elimclauses, Lit x)
+{
+    elimclauses.push(toInt(x));
+    elimclauses.push(1);
+}
+
+
+static void mkElimClause(vec<uint32_t>& elimclauses, Var v, Clause& c)
+{
+    int first = elimclauses.size();
+    int v_pos = -1;
+
+    // Copy clause to elimclauses-vector. Remember position where the
+    // variable 'v' occurs:
+    for (int i = 0; i < c.size(); i++){
+        elimclauses.push(toInt(c[i]));
+        if (var(c[i]) == v)
+            v_pos = i + first;
+    }
+    assert(v_pos != -1);
+
+    // Swap the first literal with the 'v' literal, so that the literal
+    // containing 'v' will occur first in the clause:
+    uint32_t tmp = elimclauses[v_pos];
+    elimclauses[v_pos] = elimclauses[first];
+    elimclauses[first] = tmp;
+
+    // Store the length of the clause last:
+    elimclauses.push(c.size());
+}
+
+
+
+bool SimpSolver::eliminateVar(Var v)
+{
+    assert(!frozen[v]);
+    assert(!isEliminated(v));
+    assert(value(v) == l_Undef);
+    int i;
+
+    // Split the occurrences into positive and negative:
+    //
+    const vec<CRef>& cls = occurs.lookup(v);
+    vec<CRef>        pos, neg;
+    for (i = 0; i < cls.size(); i++)
+        (find(ca[cls[i]], mkLit(v)) ? pos : neg).push(cls[i]);
+
+    // Check wether the increase in number of clauses stays within the allowed ('grow'). Moreover, no
+    // clause must exceed the limit on the maximal clause size (if it is set):
+    //
+    int cnt         = 0;
+    int clause_size = 0;
+
+    for (i = 0; i < pos.size(); i++)
+        for (int j = 0; j < neg.size(); j++)
+            if (merge(ca[pos[i]], ca[neg[j]], v, clause_size) && 
+                (++cnt > cls.size() + grow || (clause_lim != -1 && clause_size > clause_lim)))
+                return true;
+
+    // Delete and store old clauses:
+    eliminated[v] = true;
+    setDecisionVar(v, false);
+    eliminated_vars++;
+
+    if (pos.size() > neg.size()){
+        for (int i = 0; i < neg.size(); i++)
+            mkElimClause(elimclauses, v, ca[neg[i]]);
+        mkElimClause(elimclauses, mkLit(v));
+    }else{
+        for (int i = 0; i < pos.size(); i++)
+            mkElimClause(elimclauses, v, ca[pos[i]]);
+        mkElimClause(elimclauses, ~mkLit(v));
+    }
+
+    for (i = 0; i < cls.size(); i++)
+        removeClause(cls[i]); 
+
+    // Produce clauses in cross product:
+    vec<Lit>& resolvent = add_tmp;
+    for (i = 0; i < pos.size(); i++)
+        for (int j = 0; j < neg.size(); j++)
+            if (merge(ca[pos[i]], ca[neg[j]], v, resolvent) && !addClause_(resolvent))
+                return false;
+
+    // Free occurs list for this variable:
+    occurs[v].clear(true);
+    
+    // Free watchers lists for this variable, if possible:
+    if (watches[ mkLit(v)].size() == 0) watches[ mkLit(v)].clear(true);
+    if (watches[~mkLit(v)].size() == 0) watches[~mkLit(v)].clear(true);
+
+    return backwardSubsumptionCheck();
+}
+
+
+bool SimpSolver::substitute(Var v, Lit x)
+{
+    assert(!frozen[v]);
+    assert(!isEliminated(v));
+    assert(value(v) == l_Undef);
+
+    if (!ok) return false;
+
+    eliminated[v] = true;
+    setDecisionVar(v, false);
+    const vec<CRef>& cls = occurs.lookup(v);
+    
+    vec<Lit>& subst_clause = add_tmp;
+    for (int i = 0; i < cls.size(); i++){
+        Clause& c = ca[cls[i]];
+
+        subst_clause.clear();
+        for (int j = 0; j < c.size(); j++){
+            Lit p = c[j];
+            subst_clause.push(var(p) == v ? x ^ sign(p) : p);
+        }
+
+        removeClause(cls[i]);
+
+        if (!addClause_(subst_clause))
+            return ok = false;
+    }
+
+    return true;
+}
+
+
+void SimpSolver::extendModel()
+{
+    int i, j;
+    Lit x;
+
+    for (i = elimclauses.size()-1; i > 0; i -= j){
+        for (j = elimclauses[i--]; j > 1; j--, i--)
+            if (modelValue(toLit(elimclauses[i])) != l_False)
+                goto next;
+
+        x = toLit(elimclauses[i]);
+        model[var(x)] = lbool(!sign(x));
+    next:;
+    }
+}
+
+
+bool SimpSolver::eliminate(bool turn_off_elim)
+{
+    if (!simplify())
+        return false;
+    else if (!use_simplification)
+        return true;
+
+    // Main simplification loop:
+    //
+    while (n_touched > 0 || bwdsub_assigns < trail.size() || elim_heap.size() > 0){
+
+        gatherTouchedClauses();
+        // printf("  ## (time = %6.2f s) BWD-SUB: queue = %d, trail = %d\n", cpuTime(), subsumption_queue.size(), trail.size() - bwdsub_assigns);
+        if ((subsumption_queue.size() > 0 || bwdsub_assigns < trail.size()) && 
+            !backwardSubsumptionCheck(true)){
+            ok = false; goto cleanup; }
+
+        // Empty elim_heap and return immediately on user-interrupt:
+        if (asynch_interrupt){
+            assert(bwdsub_assigns == trail.size());
+            assert(subsumption_queue.size() == 0);
+            assert(n_touched == 0);
+            elim_heap.clear();
+            goto cleanup; }
+
+        // printf("  ## (time = %6.2f s) ELIM: vars = %d\n", cpuTime(), elim_heap.size());
+        for (int cnt = 0; !elim_heap.empty(); cnt++){
+            Var elim = elim_heap.removeMin();
+            
+            if (asynch_interrupt) break;
+
+            if (isEliminated(elim) || value(elim) != l_Undef) continue;
+
+            if (verbosity >= 2 && cnt % 100 == 0)
+                printf("elimination left: %10d\r", elim_heap.size());
+
+            if (use_asymm){
+                // Temporarily freeze variable. Otherwise, it would immediately end up on the queue again:
+                bool was_frozen = frozen[elim];
+                frozen[elim] = true;
+                if (!asymmVar(elim)){
+                    ok = false; goto cleanup; }
+                frozen[elim] = was_frozen; }
+
+            // At this point, the variable may have been set by assymetric branching, so check it
+            // again. Also, don't eliminate frozen variables:
+            if (use_elim && value(elim) == l_Undef && !frozen[elim] && !eliminateVar(elim)){
+                ok = false; goto cleanup; }
+
+            checkGarbage(simp_garbage_frac);
+        }
+
+        assert(subsumption_queue.size() == 0);
+    }
+ cleanup:
+
+    // If no more simplification is needed, free all simplification-related data structures:
+    if (turn_off_elim){
+        touched  .clear(true);
+        occurs   .clear(true);
+        n_occ    .clear(true);
+        elim_heap.clear(true);
+        subsumption_queue.clear(true);
+
+        use_simplification    = false;
+        remove_satisfied      = true;
+        ca.extra_clause_field = false;
+
+        // Force full cleanup (this is safe and desirable since it only happens once):
+        rebuildOrderHeap();
+        garbageCollect();
+    }else{
+        // Cheaper cleanup:
+        cleanUpClauses(); // TODO: can we make 'cleanUpClauses()' not be linear in the problem size somehow?
+        checkGarbage();
+    }
+
+    if (verbosity >= 1 && elimclauses.size() > 0)
+        printf("|  Eliminated clauses:     %10.2f Mb                                      |\n", 
+               double(elimclauses.size() * sizeof(uint32_t)) / (1024*1024));
+
+    return ok;
+}
+
+
+void SimpSolver::cleanUpClauses()
+{
+    occurs.cleanAll();
+    int i,j;
+    for (i = j = 0; i < clauses.size(); i++)
+        if (ca[clauses[i]].mark() == 0)
+            clauses[j++] = clauses[i];
+    clauses.shrink(i - j);
+}
+
+
+//=================================================================================================
+// Garbage Collection methods:
+
+
+void SimpSolver::relocAll(ClauseAllocator& to)
+{
+    if (!use_simplification) return;
+
+    // All occurs lists:
+    //
+    int i;
+    for (i = 0; i < nVars(); i++){
+        vec<CRef>& cs = occurs[i];
+        for (int j = 0; j < cs.size(); j++)
+            ca.reloc(cs[j], to);
+    }
+
+    // Subsumption queue:
+    //
+    for (i = 0; i < subsumption_queue.size(); i++)
+        ca.reloc(subsumption_queue[i], to);
+
+    // Temporary clause:
+    //
+    ca.reloc(bwdsub_tmpunit, to);
+}
+
+
+void SimpSolver::garbageCollect()
+{
+    // Initialize the next region to a size corresponding to the estimated utilization degree. This
+    // is not precise but should avoid some unnecessary reallocations for the new region:
+    ClauseAllocator to(ca.size() - ca.wasted()); 
+
+    cleanUpClauses();
+    to.extra_clause_field = ca.extra_clause_field; // NOTE: this is important to keep (or lose) the extra fields.
+    relocAll(to);
+    Solver::relocAll(to);
+    if (verbosity >= 2)
+        printf("|  Garbage collection:   %12d bytes => %12d bytes             |\n", 
+               ca.size()*ClauseAllocator::Unit_Size, to.size()*ClauseAllocator::Unit_Size);
+    to.moveTo(ca);
+}
diff --git a/abc-build/src/sat/bsat2/SimpSolver.h b/abc-build/src/sat/bsat2/SimpSolver.h
new file mode 100644
--- /dev/null
+++ b/abc-build/src/sat/bsat2/SimpSolver.h
@@ -0,0 +1,197 @@
+/************************************************************************************[SimpSolver.h]
+Copyright (c) 2006,      Niklas Een, Niklas Sorensson
+Copyright (c) 2007-2010, Niklas Sorensson
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
+associated documentation files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or
+substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
+NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
+OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+**************************************************************************************************/
+
+#ifndef Minisat_SimpSolver_h
+#define Minisat_SimpSolver_h
+
+#include "Queue.h"
+#include "Solver.h"
+
+
+namespace Minisat {
+
+//=================================================================================================
+
+
+class SimpSolver : public Solver {
+ public:
+    // Constructor/Destructor:
+    //
+    SimpSolver();
+    ~SimpSolver();
+
+    // Problem specification:
+    //
+    Var     newVar    (bool polarity = true, bool dvar = true);
+    bool    addClause (const vec<Lit>& ps);
+    bool    addEmptyClause();                // Add the empty clause to the solver.
+    bool    addClause (Lit p);               // Add a unit clause to the solver.
+    bool    addClause (Lit p, Lit q);        // Add a binary clause to the solver.
+    bool    addClause (Lit p, Lit q, Lit r); // Add a ternary clause to the solver.
+    bool    addClause_(      vec<Lit>& ps);
+    bool    substitute(Var v, Lit x);  // Replace all occurences of v with x (may cause a contradiction).
+
+    // Variable mode:
+    // 
+    void    setFrozen (Var v, bool b); // If a variable is frozen it will not be eliminated.
+    bool    isEliminated(Var v) const;
+
+    // Solving:
+    //
+    bool    solve       (const vec<Lit>& assumps, bool do_simp = true, bool turn_off_simp = false);
+    lbool   solveLimited(const vec<Lit>& assumps, bool do_simp = true, bool turn_off_simp = false);
+    bool    solve       (                     bool do_simp = true, bool turn_off_simp = false);
+    bool    solve       (Lit p       ,        bool do_simp = true, bool turn_off_simp = false);       
+    bool    solve       (Lit p, Lit q,        bool do_simp = true, bool turn_off_simp = false);
+    bool    solve       (Lit p, Lit q, Lit r, bool do_simp = true, bool turn_off_simp = false);
+    bool    eliminate   (bool turn_off_elim = false);  // Perform variable elimination based simplification. 
+
+    // Memory managment:
+    //
+    virtual void garbageCollect();
+
+
+    // Generate a (possibly simplified) DIMACS file:
+    //
+#if 0
+    void    toDimacs  (const char* file, const vec<Lit>& assumps);
+    void    toDimacs  (const char* file);
+    void    toDimacs  (const char* file, Lit p);
+    void    toDimacs  (const char* file, Lit p, Lit q);
+    void    toDimacs  (const char* file, Lit p, Lit q, Lit r);
+#endif
+
+    // Mode of operation:
+    //
+    int     grow;              // Allow a variable elimination step to grow by a number of clauses (default to zero).
+    int     clause_lim;        // Variables are not eliminated if it produces a resolvent with a length above this limit.
+                               // -1 means no limit.
+    int     subsumption_lim;   // Do not check if subsumption against a clause larger than this. -1 means no limit.
+    double  simp_garbage_frac; // A different limit for when to issue a GC during simplification (Also see 'garbage_frac').
+
+    bool    use_asymm;         // Shrink clauses by asymmetric branching.
+    bool    use_rcheck;        // Check if a clause is already implied. Prett costly, and subsumes subsumptions :)
+    bool    use_elim;          // Perform variable elimination.
+
+    // Statistics:
+    //
+    int     merges;
+    int     asymm_lits;
+    int     eliminated_vars;
+
+ protected:
+
+    // Helper structures:
+    //
+    struct ElimLt {
+        const vec<int>& n_occ;
+        explicit ElimLt(const vec<int>& no) : n_occ(no) {}
+
+        // TODO: are 64-bit operations here noticably bad on 32-bit platforms? Could use a saturating
+        // 32-bit implementation instead then, but this will have to do for now.
+        uint64_t cost  (Var x)        const { return (uint64_t)n_occ[toInt(mkLit(x))] * (uint64_t)n_occ[toInt(~mkLit(x))]; }
+        bool operator()(Var x, Var y) const { return cost(x) < cost(y); }
+        
+        // TODO: investigate this order alternative more.
+        // bool operator()(Var x, Var y) const { 
+        //     int c_x = cost(x);
+        //     int c_y = cost(y);
+        //     return c_x < c_y || c_x == c_y && x < y; }
+    };
+
+    struct ClauseDeleted {
+        const ClauseAllocator& ca;
+        explicit ClauseDeleted(const ClauseAllocator& _ca) : ca(_ca) {}
+        bool operator()(const CRef& cr) const { return ca[cr].mark() == 1; } };
+
+    // Solver state:
+    //
+    int                 elimorder;
+    bool                use_simplification;
+    vec<uint32_t>       elimclauses;
+    vec<char>           touched;
+    OccLists<Var, vec<CRef>, ClauseDeleted>
+                        occurs;
+    vec<int>            n_occ;
+    Heap<ElimLt>        elim_heap;
+    Queue<CRef>         subsumption_queue;
+    vec<char>           frozen;
+    vec<char>           eliminated;
+    int                 bwdsub_assigns;
+    int                 n_touched;
+
+    // Temporaries:
+    //
+    CRef                bwdsub_tmpunit;
+
+    // Main internal methods:
+    //
+    lbool         solve_                   (bool do_simp = true, bool turn_off_simp = false);
+    bool          asymm                    (Var v, CRef cr);
+    bool          asymmVar                 (Var v);
+    void          updateElimHeap           (Var v);
+    void          gatherTouchedClauses     ();
+    bool          merge                    (const Clause& _ps, const Clause& _qs, Var v, vec<Lit>& out_clause);
+    bool          merge                    (const Clause& _ps, const Clause& _qs, Var v, int& size);
+    bool          backwardSubsumptionCheck (bool verbose = false);
+    bool          eliminateVar             (Var v);
+    void          extendModel              ();
+
+    void          removeClause             (CRef cr);
+    bool          strengthenClause         (CRef cr, Lit l);
+    void          cleanUpClauses           ();
+    bool          implied                  (const vec<Lit>& c);
+    void          relocAll                 (ClauseAllocator& to);
+};
+
+
+//=================================================================================================
+// Implementation of inline methods:
+
+
+inline bool SimpSolver::isEliminated (Var v) const { return eliminated[v]; }
+inline void SimpSolver::updateElimHeap(Var v) {
+    assert(use_simplification);
+    // if (!frozen[v] && !isEliminated(v) && value(v) == l_Undef)
+    if (elim_heap.inHeap(v) || (!frozen[v] && !isEliminated(v) && value(v) == l_Undef))
+        elim_heap.update(v); }
+
+
+inline bool SimpSolver::addClause    (const vec<Lit>& ps)    { ps.copyTo(add_tmp); return addClause_(add_tmp); }
+inline bool SimpSolver::addEmptyClause()                     { add_tmp.clear(); return addClause_(add_tmp); }
+inline bool SimpSolver::addClause    (Lit p)                 { add_tmp.clear(); add_tmp.push(p); return addClause_(add_tmp); }
+inline bool SimpSolver::addClause    (Lit p, Lit q)          { add_tmp.clear(); add_tmp.push(p); add_tmp.push(q); return addClause_(add_tmp); }
+inline bool SimpSolver::addClause    (Lit p, Lit q, Lit r)   { add_tmp.clear(); add_tmp.push(p); add_tmp.push(q); add_tmp.push(r); return addClause_(add_tmp); }
+inline void SimpSolver::setFrozen    (Var v, bool b) { frozen[v] = (char)b; if (use_simplification && !b) { updateElimHeap(v); } }
+
+inline bool SimpSolver::solve        (                     bool do_simp, bool turn_off_simp)  { budgetOff(); assumptions.clear(); return solve_(do_simp, turn_off_simp) == l_True; }
+inline bool SimpSolver::solve        (Lit p       ,        bool do_simp, bool turn_off_simp)  { budgetOff(); assumptions.clear(); assumptions.push(p); return solve_(do_simp, turn_off_simp) == l_True; }
+inline bool SimpSolver::solve        (Lit p, Lit q,        bool do_simp, bool turn_off_simp)  { budgetOff(); assumptions.clear(); assumptions.push(p); assumptions.push(q); return solve_(do_simp, turn_off_simp) == l_True; }
+inline bool SimpSolver::solve        (Lit p, Lit q, Lit r, bool do_simp, bool turn_off_simp)  { budgetOff(); assumptions.clear(); assumptions.push(p); assumptions.push(q); assumptions.push(r); return solve_(do_simp, turn_off_simp) == l_True; }
+inline bool SimpSolver::solve        (const vec<Lit>& assumps, bool do_simp, bool turn_off_simp){ 
+    budgetOff(); assumps.copyTo(assumptions); return solve_(do_simp, turn_off_simp) == l_True; }
+
+inline lbool SimpSolver::solveLimited (const vec<Lit>& assumps, bool do_simp, bool turn_off_simp){ 
+    assumps.copyTo(assumptions); return solve_(do_simp, turn_off_simp); }
+
+//=================================================================================================
+}
+
+#endif
diff --git a/abc-build/src/sat/bsat2/Solver.cpp b/abc-build/src/sat/bsat2/Solver.cpp
new file mode 100644
--- /dev/null
+++ b/abc-build/src/sat/bsat2/Solver.cpp
@@ -0,0 +1,924 @@
+/***************************************************************************************[Solver.cc]
+Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson
+Copyright (c) 2007-2010, Niklas Sorensson
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
+associated documentation files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or
+substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
+NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
+OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+**************************************************************************************************/
+
+#include <math.h>
+
+#include "Sort.h"
+#include "Solver.h"
+
+using namespace Minisat;
+
+//=================================================================================================
+// Options:
+
+
+static const char* _cat = "CORE";
+
+static DoubleOption  opt_var_decay         (_cat, "var-decay",   "The variable activity decay factor",            0.95,     DoubleRange(0, false, 1, false));
+static DoubleOption  opt_clause_decay      (_cat, "cla-decay",   "The clause activity decay factor",              0.999,    DoubleRange(0, false, 1, false));
+static DoubleOption  opt_random_var_freq   (_cat, "rnd-freq",    "The frequency with which the decision heuristic tries to choose a random variable", 0, DoubleRange(0, true, 1, true));
+static DoubleOption  opt_random_seed       (_cat, "rnd-seed",    "Used by the random variable selection",         91648253, DoubleRange(0, false, HUGE_VAL, false));
+static IntOption     opt_ccmin_mode        (_cat, "ccmin-mode",  "Controls conflict clause minimization (0=none, 1=basic, 2=deep)", 2, IntRange(0, 2));
+static IntOption     opt_phase_saving      (_cat, "phase-saving", "Controls the level of phase saving (0=none, 1=limited, 2=full)", 2, IntRange(0, 2));
+static BoolOption    opt_rnd_init_act      (_cat, "rnd-init",    "Randomize the initial activity", false);
+static BoolOption    opt_luby_restart      (_cat, "luby",        "Use the Luby restart sequence", true);
+static IntOption     opt_restart_first     (_cat, "rfirst",      "The base restart interval", 100, IntRange(1, INT32_MAX));
+static DoubleOption  opt_restart_inc       (_cat, "rinc",        "Restart interval increase factor", 2, DoubleRange(1, false, HUGE_VAL, false));
+static DoubleOption  opt_garbage_frac      (_cat, "gc-frac",     "The fraction of wasted memory allowed before a garbage collection is triggered",  0.20, DoubleRange(0, false, HUGE_VAL, false));
+
+
+//=================================================================================================
+// Constructor/Destructor:
+
+
+Solver::Solver() :
+
+    // Parameters (user settable):
+    //
+    verbosity        (0)
+  , var_decay        (opt_var_decay)
+  , clause_decay     (opt_clause_decay)
+  , random_var_freq  (opt_random_var_freq)
+  , random_seed      (opt_random_seed)
+  , luby_restart     (opt_luby_restart)
+  , ccmin_mode       (opt_ccmin_mode)
+  , phase_saving     (opt_phase_saving)
+  , rnd_pol          (false)
+  , rnd_init_act     (opt_rnd_init_act)
+  , garbage_frac     (opt_garbage_frac)
+  , restart_first    (opt_restart_first)
+  , restart_inc      (opt_restart_inc)
+
+    // Parameters (the rest):
+    //
+  , learntsize_factor((double)1/(double)3), learntsize_inc(1.1)
+
+    // Parameters (experimental):
+    //
+  , learntsize_adjust_start_confl (100)
+  , learntsize_adjust_inc         (1.5)
+
+    // Statistics: (formerly in 'SolverStats')
+    //
+  , solves(0), starts(0), decisions(0), rnd_decisions(0), propagations(0), conflicts(0)
+  , dec_vars(0), clauses_literals(0), learnts_literals(0), max_literals(0), tot_literals(0)
+
+  , ok                 (true)
+  , cla_inc            (1)
+  , var_inc            (1)
+  , watches            (WatcherDeleted(ca))
+  , qhead              (0)
+  , simpDB_assigns     (-1)
+  , simpDB_props       (0)
+  , order_heap         (VarOrderLt(activity))
+  , progress_estimate  (0)
+  , remove_satisfied   (true)
+
+    // Resource constraints:
+    //
+  , conflict_budget    (-1)
+  , propagation_budget (-1)
+  , asynch_interrupt   (false)
+{}
+
+
+Solver::~Solver()
+{
+}
+
+
+//=================================================================================================
+// Minor methods:
+
+
+// Creates a new SAT variable in the solver. If 'decision' is cleared, variable will not be
+// used as a decision variable (NOTE! This has effects on the meaning of a SATISFIABLE result).
+//
+Var Solver::newVar(bool sign, bool dvar)
+{
+    int v = nVars();
+    watches  .init(mkLit(v, false));
+    watches  .init(mkLit(v, true ));
+    assigns  .push(l_Undef);
+    vardata  .push(mkVarData(CRef_Undef, 0));
+    //activity .push(0);
+    activity .push(rnd_init_act ? drand(random_seed) * 0.00001 : 0);
+    seen     .push(0);
+    polarity .push(sign);
+    decision .push();
+    trail    .capacity(v+1);
+    setDecisionVar(v, dvar);
+    return v;
+}
+
+
+bool Solver::addClause_(vec<Lit>& ps)
+{
+    assert(decisionLevel() == 0);
+    if (!ok) return false;
+
+    // Check if clause is satisfied and remove false/duplicate literals:
+    sort(ps);
+    Lit p; int i, j;
+    for (i = j = 0, p = lit_Undef; i < ps.size(); i++)
+        if (value(ps[i]) == l_True || ps[i] == ~p)
+            return true;
+        else if (value(ps[i]) != l_False && ps[i] != p)
+            ps[j++] = p = ps[i];
+    ps.shrink(i - j);
+
+    if (ps.size() == 0)
+        return ok = false;
+    else if (ps.size() == 1){
+        uncheckedEnqueue(ps[0]);
+        return ok = (propagate() == CRef_Undef);
+    }else{
+        CRef cr = ca.alloc(ps, false);
+        clauses.push(cr);
+        attachClause(cr);
+    }
+
+    return true;
+}
+
+
+void Solver::attachClause(CRef cr) {
+    const Clause& c = ca[cr];
+    assert(c.size() > 1);
+    watches[~c[0]].push(Watcher(cr, c[1]));
+    watches[~c[1]].push(Watcher(cr, c[0]));
+    if (c.learnt()) learnts_literals += c.size();
+    else            clauses_literals += c.size(); }
+
+
+void Solver::detachClause(CRef cr, bool strict) {
+    const Clause& c = ca[cr];
+    assert(c.size() > 1);
+    
+    if (strict){
+        remove(watches[~c[0]], Watcher(cr, c[1]));
+        remove(watches[~c[1]], Watcher(cr, c[0]));
+    }else{
+        // Lazy detaching: (NOTE! Must clean all watcher lists before garbage collecting this clause)
+        watches.smudge(~c[0]);
+        watches.smudge(~c[1]);
+    }
+
+    if (c.learnt()) learnts_literals -= c.size();
+    else            clauses_literals -= c.size(); }
+
+
+void Solver::removeClause(CRef cr) {
+    Clause& c = ca[cr];
+    detachClause(cr);
+    // Don't leave pointers to free'd memory!
+    if (locked(c)) vardata[var(c[0])].reason = CRef_Undef;
+    c.mark(1); 
+    ca._free(cr);
+}
+
+
+bool Solver::satisfied(const Clause& c) const {
+    for (int i = 0; i < c.size(); i++)
+        if (value(c[i]) == l_True)
+            return true;
+    return false; }
+
+
+// Revert to the state at given level (keeping all assignment at 'level' but not beyond).
+//
+void Solver::cancelUntil(int level) {
+    if (decisionLevel() > level){
+        for (int c = trail.size()-1; c >= trail_lim[level]; c--){
+            Var      x  = var(trail[c]);
+            assigns [x] = l_Undef;
+            if (phase_saving > 1 || (phase_saving == 1) && c > trail_lim.last())
+                polarity[x] = sign(trail[c]);
+            insertVarOrder(x); }
+        qhead = trail_lim[level];
+        trail.shrink(trail.size() - trail_lim[level]);
+        trail_lim.shrink(trail_lim.size() - level);
+    } }
+
+
+//=================================================================================================
+// Major methods:
+
+
+Lit Solver::pickBranchLit()
+{
+    Var next = var_Undef;
+
+    // Random decision:
+    if (drand(random_seed) < random_var_freq && !order_heap.empty()){
+        next = order_heap[irand(random_seed,order_heap.size())];
+        if (value(next) == l_Undef && decision[next])
+            rnd_decisions++; }
+
+    // Activity based decision:
+    while (next == var_Undef || value(next) != l_Undef || !decision[next])
+        if (order_heap.empty()){
+            next = var_Undef;
+            break;
+        }else
+            next = order_heap.removeMin();
+
+    return next == var_Undef ? lit_Undef : mkLit(next, rnd_pol ? drand(random_seed) < 0.5 : polarity[next]);
+}
+
+
+/*_________________________________________________________________________________________________
+|
+|  analyze : (confl : Clause*) (out_learnt : vec<Lit>&) (out_btlevel : int&)  ->  [void]
+|  
+|  Description:
+|    Analyze conflict and produce a reason clause.
+|  
+|    Pre-conditions:
+|      * 'out_learnt' is assumed to be cleared.
+|      * Current decision level must be greater than root level.
+|  
+|    Post-conditions:
+|      * 'out_learnt[0]' is the asserting literal at level 'out_btlevel'.
+|      * If out_learnt.size() > 1 then 'out_learnt[1]' has the greatest decision level of the 
+|        rest of literals. There may be others from the same level though.
+|  
+|________________________________________________________________________________________________@*/
+void Solver::analyze(CRef confl, vec<Lit>& out_learnt, int& out_btlevel)
+{
+    int pathC = 0;
+    Lit p     = lit_Undef;
+
+    // Generate conflict clause:
+    //
+    out_learnt.push();      // (leave room for the asserting literal)
+    int index   = trail.size() - 1;
+
+    do{
+        assert(confl != CRef_Undef); // (otherwise should be UIP)
+        Clause& c = ca[confl];
+
+        if (c.learnt())
+            claBumpActivity(c);
+
+        for (int j = (p == lit_Undef) ? 0 : 1; j < c.size(); j++){
+            Lit q = c[j];
+
+            if (!seen[var(q)] && level(var(q)) > 0){
+                varBumpActivity(var(q));
+                seen[var(q)] = 1;
+                if (level(var(q)) >= decisionLevel())
+                    pathC++;
+                else
+                    out_learnt.push(q);
+            }
+        }
+        
+        // Select next clause to look at:
+        while (!seen[var(trail[index--])]);
+        p     = trail[index+1];
+        confl = reason(var(p));
+        seen[var(p)] = 0;
+        pathC--;
+
+    }while (pathC > 0);
+    out_learnt[0] = ~p;
+
+    // Simplify conflict clause:
+    //
+    int i, j;
+    out_learnt.copyTo(analyze_toclear);
+    if (ccmin_mode == 2){
+        uint32_t abstract_level = 0;
+        for (i = 1; i < out_learnt.size(); i++)
+            abstract_level |= abstractLevel(var(out_learnt[i])); // (maintain an abstraction of levels involved in conflict)
+
+        for (i = j = 1; i < out_learnt.size(); i++)
+            if (reason(var(out_learnt[i])) == CRef_Undef || !litRedundant(out_learnt[i], abstract_level))
+                out_learnt[j++] = out_learnt[i];
+        
+    }else if (ccmin_mode == 1){
+        for (i = j = 1; i < out_learnt.size(); i++){
+            Var x = var(out_learnt[i]);
+
+            if (reason(x) == CRef_Undef)
+                out_learnt[j++] = out_learnt[i];
+            else{
+                Clause& c = ca[reason(var(out_learnt[i]))];
+                for (int k = 1; k < c.size(); k++)
+                    if (!seen[var(c[k])] && level(var(c[k])) > 0){
+                        out_learnt[j++] = out_learnt[i];
+                        break; }
+            }
+        }
+    }else
+        i = j = out_learnt.size();
+
+    max_literals += out_learnt.size();
+    out_learnt.shrink(i - j);
+    tot_literals += out_learnt.size();
+
+    // Find correct backtrack level:
+    //
+    if (out_learnt.size() == 1)
+        out_btlevel = 0;
+    else{
+        int max_i = 1;
+        // Find the first literal assigned at the next-highest level:
+        for (int i = 2; i < out_learnt.size(); i++)
+            if (level(var(out_learnt[i])) > level(var(out_learnt[max_i])))
+                max_i = i;
+        // Swap-in this literal at index 1:
+        Lit p             = out_learnt[max_i];
+        out_learnt[max_i] = out_learnt[1];
+        out_learnt[1]     = p;
+        out_btlevel       = level(var(p));
+    }
+
+    for (j = 0; j < analyze_toclear.size(); j++) seen[var(analyze_toclear[j])] = 0;    // ('seen[]' is now cleared)
+}
+
+
+// Check if 'p' can be removed. 'abstract_levels' is used to abort early if the algorithm is
+// visiting literals at levels that cannot be removed later.
+bool Solver::litRedundant(Lit p, uint32_t abstract_levels)
+{
+    analyze_stack.clear(); analyze_stack.push(p);
+    int top = analyze_toclear.size();
+    while (analyze_stack.size() > 0){
+        assert(reason(var(analyze_stack.last())) != CRef_Undef);
+        Clause& c = ca[reason(var(analyze_stack.last()))]; analyze_stack.pop();
+
+        for (int i = 1; i < c.size(); i++){
+            Lit p  = c[i];
+            if (!seen[var(p)] && level(var(p)) > 0){
+                if (reason(var(p)) != CRef_Undef && (abstractLevel(var(p)) & abstract_levels) != 0){
+                    seen[var(p)] = 1;
+                    analyze_stack.push(p);
+                    analyze_toclear.push(p);
+                }else{
+                    for (int j = top; j < analyze_toclear.size(); j++)
+                        seen[var(analyze_toclear[j])] = 0;
+                    analyze_toclear.shrink(analyze_toclear.size() - top);
+                    return false;
+                }
+            }
+        }
+    }
+
+    return true;
+}
+
+
+/*_________________________________________________________________________________________________
+|
+|  analyzeFinal : (p : Lit)  ->  [void]
+|  
+|  Description:
+|    Specialized analysis procedure to express the final conflict in terms of assumptions.
+|    Calculates the (possibly empty) set of assumptions that led to the assignment of 'p', and
+|    stores the result in 'out_conflict'.
+|________________________________________________________________________________________________@*/
+void Solver::analyzeFinal(Lit p, vec<Lit>& out_conflict)
+{
+    out_conflict.clear();
+    out_conflict.push(p);
+
+    if (decisionLevel() == 0)
+        return;
+
+    seen[var(p)] = 1;
+
+    for (int i = trail.size()-1; i >= trail_lim[0]; i--){
+        Var x = var(trail[i]);
+        if (seen[x]){
+            if (reason(x) == CRef_Undef){
+                assert(level(x) > 0);
+                out_conflict.push(~trail[i]);
+            }else{
+                Clause& c = ca[reason(x)];
+                for (int j = 1; j < c.size(); j++)
+                    if (level(var(c[j])) > 0)
+                        seen[var(c[j])] = 1;
+            }
+            seen[x] = 0;
+        }
+    }
+
+    seen[var(p)] = 0;
+}
+
+
+void Solver::uncheckedEnqueue(Lit p, CRef from)
+{
+    assert(value(p) == l_Undef);
+    assigns[var(p)] = lbool(!sign(p));
+    vardata[var(p)] = mkVarData(from, decisionLevel());
+    trail.push_(p);
+}
+
+
+/*_________________________________________________________________________________________________
+|
+|  propagate : [void]  ->  [Clause*]
+|  
+|  Description:
+|    Propagates all enqueued facts. If a conflict arises, the conflicting clause is returned,
+|    otherwise CRef_Undef.
+|  
+|    Post-conditions:
+|      * the propagation queue is empty, even if there was a conflict.
+|________________________________________________________________________________________________@*/
+CRef Solver::propagate()
+{
+    CRef    confl     = CRef_Undef;
+    int     num_props = 0;
+    watches.cleanAll();
+
+    while (qhead < trail.size()){
+        Lit            p   = trail[qhead++];     // 'p' is enqueued fact to propagate.
+        vec<Watcher>&  ws  = watches[p];
+        Watcher        *i, *j, *end;
+        num_props++;
+
+        for (i = j = (Watcher*)ws, end = i + ws.size();  i != end;){
+            // Try to avoid inspecting the clause:
+            Lit blocker = i->blocker;
+            if (value(blocker) == l_True){
+                *j++ = *i++; continue; }
+
+            // Make sure the false literal is data[1]:
+            CRef     cr        = i->cref;
+            Clause&  c         = ca[cr];
+            Lit      false_lit = ~p;
+            if (c[0] == false_lit)
+                c[0] = c[1], c[1] = false_lit;
+            assert(c[1] == false_lit);
+            i++;
+
+            // If 0th watch is true, then clause is already satisfied.
+            Lit     first = c[0];
+            Watcher w     = Watcher(cr, first);
+            if (first != blocker && value(first) == l_True){
+                *j++ = w; continue; }
+
+            // Look for new watch:
+            for (int k = 2; k < c.size(); k++)
+                if (value(c[k]) != l_False){
+                    c[1] = c[k]; c[k] = false_lit;
+                    watches[~c[1]].push(w);
+                    goto NextClause; }
+
+            // Did not find watch -- clause is unit under assignment:
+            *j++ = w;
+            if (value(first) == l_False){
+                confl = cr;
+                qhead = trail.size();
+                // Copy the remaining watches:
+                while (i < end)
+                    *j++ = *i++;
+            }else
+                uncheckedEnqueue(first, cr);
+
+        NextClause:;
+        }
+        ws.shrink(i - j);
+    }
+    propagations += num_props;
+    simpDB_props -= num_props;
+
+    return confl;
+}
+
+
+/*_________________________________________________________________________________________________
+|
+|  reduceDB : ()  ->  [void]
+|  
+|  Description:
+|    Remove half of the learnt clauses, minus the clauses locked by the current assignment. Locked
+|    clauses are clauses that are reason to some assignment. Binary clauses are never removed.
+|________________________________________________________________________________________________@*/
+struct reduceDB_lt { 
+    ClauseAllocator& ca;
+    reduceDB_lt(ClauseAllocator& ca_) : ca(ca_) {}
+    bool operator () (CRef x, CRef y) { 
+        return ca[x].size() > 2 && (ca[y].size() == 2 || ca[x].activity() < ca[y].activity()); } 
+};
+void Solver::reduceDB()
+{
+    int     i, j;
+    double  extra_lim = cla_inc / learnts.size();    // Remove any clause below this activity
+
+    sort(learnts, reduceDB_lt(ca));
+    // Don't delete binary or locked clauses. From the rest, delete clauses from the first half
+    // and clauses with activity smaller than 'extra_lim':
+    for (i = j = 0; i < learnts.size(); i++){
+        Clause& c = ca[learnts[i]];
+        if (c.size() > 2 && !locked(c) && (i < learnts.size() / 2 || c.activity() < extra_lim))
+            removeClause(learnts[i]);
+        else
+            learnts[j++] = learnts[i];
+    }
+    learnts.shrink(i - j);
+    checkGarbage();
+}
+
+
+void Solver::removeSatisfied(vec<CRef>& cs)
+{
+    int i, j;
+    for (i = j = 0; i < cs.size(); i++){
+        Clause& c = ca[cs[i]];
+        if (satisfied(c))
+            removeClause(cs[i]);
+        else
+            cs[j++] = cs[i];
+    }
+    cs.shrink(i - j);
+}
+
+
+void Solver::rebuildOrderHeap()
+{
+    vec<Var> vs;
+    for (Var v = 0; v < nVars(); v++)
+        if (decision[v] && value(v) == l_Undef)
+            vs.push(v);
+    order_heap.build(vs);
+}
+
+
+/*_________________________________________________________________________________________________
+|
+|  simplify : [void]  ->  [bool]
+|  
+|  Description:
+|    Simplify the clause database according to the current top-level assigment. Currently, the only
+|    thing done here is the removal of satisfied clauses, but more things can be put here.
+|________________________________________________________________________________________________@*/
+bool Solver::simplify()
+{
+    assert(decisionLevel() == 0);
+
+    if (!ok || propagate() != CRef_Undef)
+        return ok = false;
+
+    if (nAssigns() == simpDB_assigns || (simpDB_props > 0))
+        return true;
+
+    // Remove satisfied clauses:
+    removeSatisfied(learnts);
+    if (remove_satisfied)        // Can be turned off.
+        removeSatisfied(clauses);
+    checkGarbage();
+    rebuildOrderHeap();
+
+    simpDB_assigns = nAssigns();
+    simpDB_props   = clauses_literals + learnts_literals;   // (shouldn't depend on stats really, but it will do for now)
+
+    return true;
+}
+
+
+/*_________________________________________________________________________________________________
+|
+|  search : (nof_conflicts : int) (params : const SearchParams&)  ->  [lbool]
+|  
+|  Description:
+|    Search for a model the specified number of conflicts. 
+|    NOTE! Use negative value for 'nof_conflicts' indicate infinity.
+|  
+|  Output:
+|    'l_True' if a partial assigment that is consistent with respect to the clauseset is found. If
+|    all variables are decision variables, this means that the clause set is satisfiable. 'l_False'
+|    if the clause set is unsatisfiable. 'l_Undef' if the bound on number of conflicts is reached.
+|________________________________________________________________________________________________@*/
+lbool Solver::search(int nof_conflicts)
+{
+    assert(ok);
+    int         backtrack_level;
+    int         conflictC = 0;
+    vec<Lit>    learnt_clause;
+    starts++;
+
+    for (;;){
+        CRef confl = propagate();
+        if (confl != CRef_Undef){
+            // CONFLICT
+            conflicts++; conflictC++;
+            if (decisionLevel() == 0) return l_False;
+
+            learnt_clause.clear();
+            analyze(confl, learnt_clause, backtrack_level);
+            cancelUntil(backtrack_level);
+
+            if (learnt_clause.size() == 1){
+                uncheckedEnqueue(learnt_clause[0]);
+            }else{
+                CRef cr = ca.alloc(learnt_clause, true);
+                learnts.push(cr);
+                attachClause(cr);
+                claBumpActivity(ca[cr]);
+                uncheckedEnqueue(learnt_clause[0], cr);
+            }
+
+            varDecayActivity();
+            claDecayActivity();
+
+            if (--learntsize_adjust_cnt == 0){
+                learntsize_adjust_confl *= learntsize_adjust_inc;
+                learntsize_adjust_cnt    = (int)learntsize_adjust_confl;
+                max_learnts             *= learntsize_inc;
+
+                if (verbosity >= 1)
+                    printf("| %9d | %7d %8d %8d | %8d %8d %6.0f | %6.3f %% |\n", 
+                           (int)conflicts, 
+                           (int)dec_vars - (trail_lim.size() == 0 ? trail.size() : trail_lim[0]), nClauses(), (int)clauses_literals, 
+                           (int)max_learnts, nLearnts(), ((double)((int64_t)learnts_literals))/nLearnts(), progressEstimate()*100);
+            }
+
+        }else{
+            // NO CONFLICT
+            if (nof_conflicts >= 0 && conflictC >= nof_conflicts || !withinBudget()){
+                // Reached bound on number of conflicts:
+                progress_estimate = progressEstimate();
+                cancelUntil(0);
+                return l_Undef; }
+
+            // Simplify the set of problem clauses:
+            if (decisionLevel() == 0 && !simplify())
+                return l_False;
+
+            if (learnts.size()-nAssigns() >= max_learnts)
+                // Reduce the set of learnt clauses:
+                reduceDB();
+
+            Lit next = lit_Undef;
+            while (decisionLevel() < assumptions.size()){
+                // Perform user provided assumption:
+                Lit p = assumptions[decisionLevel()];
+                if (value(p) == l_True){
+                    // Dummy decision level:
+                    newDecisionLevel();
+                }else if (value(p) == l_False){
+                    analyzeFinal(~p, conflict);
+                    return l_False;
+                }else{
+                    next = p;
+                    break;
+                }
+            }
+
+            if (next == lit_Undef){
+                // New variable decision:
+                decisions++;
+                next = pickBranchLit();
+
+                if (next == lit_Undef)
+                    // Model found:
+                    return l_True;
+            }
+
+            // Increase decision level and enqueue 'next'
+            newDecisionLevel();
+            uncheckedEnqueue(next);
+        }
+    }
+}
+
+
+double Solver::progressEstimate() const
+{
+    double  progress = 0;
+    double  F = 1.0 / nVars();
+
+    for (int i = 0; i <= decisionLevel(); i++){
+        int beg = i == 0 ? 0 : trail_lim[i - 1];
+        int end = i == decisionLevel() ? trail.size() : trail_lim[i];
+        progress += pow(F, i) * (end - beg);
+    }
+
+    return progress / nVars();
+}
+
+/*
+  Finite subsequences of the Luby-sequence:
+
+  0: 1
+  1: 1 1 2
+  2: 1 1 2 1 1 2 4
+  3: 1 1 2 1 1 2 4 1 1 2 1 1 2 4 8
+  ...
+
+
+ */
+
+static double luby(double y, int x){
+
+    // Find the finite subsequence that contains index 'x', and the
+    // size of that subsequence:
+    int size, seq;
+    for (size = 1, seq = 0; size < x+1; seq++, size = 2*size+1);
+
+    while (size-1 != x){
+        size = (size-1)>>1;
+        seq--;
+        x = x % size;
+    }
+
+    return pow(y, seq);
+}
+
+// NOTE: assumptions passed in member-variable 'assumptions'.
+lbool Solver::solve_()
+{
+    model.clear();
+    conflict.clear();
+    if (!ok) return l_False;
+
+    solves++;
+
+    max_learnts               = nClauses() * learntsize_factor;
+    learntsize_adjust_confl   = learntsize_adjust_start_confl;
+    learntsize_adjust_cnt     = (int)learntsize_adjust_confl;
+    lbool   status            = l_Undef;
+
+    if (verbosity >= 1){
+        printf("============================[ Search Statistics ]==============================\n");
+        printf("| Conflicts |          ORIGINAL         |          LEARNT          | Progress |\n");
+        printf("|           |    Vars  Clauses Literals |    Limit  Clauses Lit/Cl |          |\n");
+        printf("===============================================================================\n");
+    }
+
+    // Search:
+    int curr_restarts = 0;
+    while (status == l_Undef){
+        double rest_base = luby_restart ? luby(restart_inc, curr_restarts) : pow(restart_inc, curr_restarts);
+        status = search(rest_base * restart_first);
+        if (!withinBudget()) break;
+        curr_restarts++;
+    }
+
+    if (verbosity >= 1)
+        printf("===============================================================================\n");
+
+
+    if (status == l_True){
+        // Extend & copy model:
+        model.growTo(nVars());
+        for (int i = 0; i < nVars(); i++) model[i] = value(i);
+    }else if (status == l_False && conflict.size() == 0)
+        ok = false;
+
+    cancelUntil(0);
+    return status;
+}
+
+//=================================================================================================
+// Writing CNF to DIMACS:
+// 
+// FIXME: this needs to be rewritten completely.
+
+static Var mapVar(Var x, vec<Var>& map, Var& max)
+{
+    if (map.size() <= x || map[x] == -1){
+        map.growTo(x+1, -1);
+        map[x] = max++;
+    }
+    return map[x];
+}
+
+
+void Solver::toDimacs(FILE* f, Clause& c, vec<Var>& map, Var& max)
+{
+    if (satisfied(c)) return;
+
+    for (int i = 0; i < c.size(); i++)
+        if (value(c[i]) != l_False)
+            fprintf(f, "%s%d ", sign(c[i]) ? "-" : "", mapVar(var(c[i]), map, max)+1);
+    fprintf(f, "0\n");
+}
+
+
+void Solver::toDimacs(const char *file, const vec<Lit>& assumps)
+{
+    FILE* f = fopen(file, "wr");
+    if (f == NULL)
+        fprintf(stderr, "could not open file %s\n", file), exit(1);
+    toDimacs(f, assumps);
+    fclose(f);
+}
+
+
+void Solver::toDimacs(FILE* f, const vec<Lit>& assumps)
+{
+    // Handle case when solver is in contradictory state:
+    if (!ok){
+        fprintf(f, "p cnf 1 2\n1 0\n-1 0\n");
+        return; }
+
+    vec<Var> map; Var max = 0;
+
+    // Cannot use removeClauses here because it is not safe
+    // to deallocate them at this point. Could be improved.
+    int i, cnt = 0;
+    for (i = 0; i < clauses.size(); i++)
+        if (!satisfied(ca[clauses[i]]))
+            cnt++;
+        
+    for (i = 0; i < clauses.size(); i++)
+        if (!satisfied(ca[clauses[i]])){
+            Clause& c = ca[clauses[i]];
+            for (int j = 0; j < c.size(); j++)
+                if (value(c[j]) != l_False)
+                    mapVar(var(c[j]), map, max);
+        }
+
+    // Assumptions are added as unit clauses:
+    cnt += assumptions.size();
+
+    fprintf(f, "p cnf %d %d\n", max, cnt);
+
+    for (i = 0; i < assumptions.size(); i++){
+        assert(value(assumptions[i]) != l_False);
+        fprintf(f, "%s%d 0\n", sign(assumptions[i]) ? "-" : "", mapVar(var(assumptions[i]), map, max)+1);
+    }
+
+    for (i = 0; i < clauses.size(); i++)
+        toDimacs(f, ca[clauses[i]], map, max);
+
+    if (verbosity > 0)
+        printf("Wrote %d clauses with %d variables.\n", cnt, max);
+}
+
+
+//=================================================================================================
+// Garbage Collection methods:
+
+void Solver::relocAll(ClauseAllocator& to)
+{
+    // All watchers:
+    //
+    // for (int i = 0; i < watches.size(); i++)
+    watches.cleanAll();
+    for (int v = 0; v < nVars(); v++)
+        for (int s = 0; s < 2; s++){
+            Lit p = mkLit(v, s);
+            // printf(" >>> RELOCING: %s%d\n", sign(p)?"-":"", var(p)+1);
+            vec<Watcher>& ws = watches[p];
+            for (int j = 0; j < ws.size(); j++)
+                ca.reloc(ws[j].cref, to);
+        }
+
+    // All reasons:
+    //
+    int i;
+    for (i = 0; i < trail.size(); i++){
+        Var v = var(trail[i]);
+
+        if (reason(v) != CRef_Undef && (ca[reason(v)].reloced() || locked(ca[reason(v)])))
+            ca.reloc(vardata[v].reason, to);
+    }
+
+    // All learnt:
+    //
+    for (i = 0; i < learnts.size(); i++)
+        ca.reloc(learnts[i], to);
+
+    // All original:
+    //
+    for (i = 0; i < clauses.size(); i++)
+        ca.reloc(clauses[i], to);
+}
+
+
+void Solver::garbageCollect()
+{
+    // Initialize the next region to a size corresponding to the estimated utilization degree. This
+    // is not precise but should avoid some unnecessary reallocations for the new region:
+    ClauseAllocator to(ca.size() - ca.wasted()); 
+
+    relocAll(to);
+    if (verbosity >= 2)
+        printf("|  Garbage collection:   %12d bytes => %12d bytes             |\n", 
+               ca.size()*ClauseAllocator::Unit_Size, to.size()*ClauseAllocator::Unit_Size);
+    to.moveTo(ca);
+}
diff --git a/abc-build/src/sat/bsat2/Solver.h b/abc-build/src/sat/bsat2/Solver.h
new file mode 100644
--- /dev/null
+++ b/abc-build/src/sat/bsat2/Solver.h
@@ -0,0 +1,373 @@
+/****************************************************************************************[Solver.h]
+Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson
+Copyright (c) 2007-2010, Niklas Sorensson
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
+associated documentation files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or
+substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
+NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
+OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+**************************************************************************************************/
+
+#ifndef Minisat_Solver_h
+#define Minisat_Solver_h
+
+#include "Vec.h"
+#include "Heap.h"
+#include "Alg.h"
+#include "Options.h"
+#include "SolverTypes.h"
+
+
+namespace Minisat {
+
+//=================================================================================================
+// Solver -- the main class:
+
+class Solver {
+public:
+
+    // Constructor/Destructor:
+    //
+    Solver();
+    virtual ~Solver();
+
+    // Problem specification:
+    //
+    Var     newVar    (bool polarity = true, bool dvar = true); // Add a new variable with parameters specifying variable mode.
+
+    bool    addClause (const vec<Lit>& ps);                     // Add a clause to the solver. 
+    bool    addEmptyClause();                                   // Add the empty clause, making the solver contradictory.
+    bool    addClause (Lit p);                                  // Add a unit clause to the solver. 
+    bool    addClause (Lit p, Lit q);                           // Add a binary clause to the solver. 
+    bool    addClause (Lit p, Lit q, Lit r);                    // Add a ternary clause to the solver. 
+    bool    addClause_(      vec<Lit>& ps);                     // Add a clause to the solver without making superflous internal copy. Will
+                                                                // change the passed vector 'ps'.
+
+    // Solving:
+    //
+    bool    simplify     ();                        // Removes already satisfied clauses.
+    bool    solve        (const vec<Lit>& assumps); // Search for a model that respects a given set of assumptions.
+    lbool   solveLimited (const vec<Lit>& assumps); // Search for a model that respects a given set of assumptions (With resource constraints).
+    bool    solve        ();                        // Search without assumptions.
+    bool    solve        (Lit p);                   // Search for a model that respects a single assumption.
+    bool    solve        (Lit p, Lit q);            // Search for a model that respects two assumptions.
+    bool    solve        (Lit p, Lit q, Lit r);     // Search for a model that respects three assumptions.
+    bool    okay         () const;                  // FALSE means solver is in a conflicting state
+
+    void    toDimacs     (FILE* f, const vec<Lit>& assumps);            // Write CNF to file in DIMACS-format.
+    void    toDimacs     (const char *file, const vec<Lit>& assumps);
+    void    toDimacs     (FILE* f, Clause& c, vec<Var>& map, Var& max);
+
+    // Convenience versions of 'toDimacs()':
+    void    toDimacs     (const char* file);
+    void    toDimacs     (const char* file, Lit p);
+    void    toDimacs     (const char* file, Lit p, Lit q);
+    void    toDimacs     (const char* file, Lit p, Lit q, Lit r);
+    
+    // Variable mode:
+    // 
+    void    setPolarity    (Var v, bool b); // Declare which polarity the decision heuristic should use for a variable. Requires mode 'polarity_user'.
+    void    setDecisionVar (Var v, bool b); // Declare if a variable should be eligible for selection in the decision heuristic.
+
+    // Read state:
+    //
+    lbool   value      (Var x) const;       // The current value of a variable.
+    lbool   value      (Lit p) const;       // The current value of a literal.
+    lbool   modelValue (Var x) const;       // The value of a variable in the last model. The last call to solve must have been satisfiable.
+    lbool   modelValue (Lit p) const;       // The value of a literal in the last model. The last call to solve must have been satisfiable.
+    int     nAssigns   ()      const;       // The current number of assigned literals.
+    int     nClauses   ()      const;       // The current number of original clauses.
+    int     nLearnts   ()      const;       // The current number of learnt clauses.
+    int     nVars      ()      const;       // The current number of variables.
+    int     nFreeVars  ()      const;
+
+    // Resource contraints:
+    //
+    void    setConfBudget(int64_t x);
+    void    setPropBudget(int64_t x);
+    void    budgetOff();
+    void    interrupt();          // Trigger a (potentially asynchronous) interruption of the solver.
+    void    clearInterrupt();     // Clear interrupt indicator flag.
+
+    // Memory managment:
+    //
+    virtual void garbageCollect();
+    void    checkGarbage(double gf);
+    void    checkGarbage();
+
+    // Extra results: (read-only member variable)
+    //
+    vec<lbool> model;             // If problem is satisfiable, this vector contains the model (if any).
+    vec<Lit>   conflict;          // If problem is unsatisfiable (possibly under assumptions),
+                                  // this vector represent the final conflict clause expressed in the assumptions.
+
+    // Mode of operation:
+    //
+    int       verbosity;
+    double    var_decay;
+    double    clause_decay;
+    double    random_var_freq;
+    double    random_seed;
+    bool      luby_restart;
+    int       ccmin_mode;         // Controls conflict clause minimization (0=none, 1=basic, 2=deep).
+    int       phase_saving;       // Controls the level of phase saving (0=none, 1=limited, 2=full).
+    bool      rnd_pol;            // Use random polarities for branching heuristics.
+    bool      rnd_init_act;       // Initialize variable activities with a small random value.
+    double    garbage_frac;       // The fraction of wasted memory allowed before a garbage collection is triggered.
+
+    int       restart_first;      // The initial restart limit.                                                                (default 100)
+    double    restart_inc;        // The factor with which the restart limit is multiplied in each restart.                    (default 1.5)
+    double    learntsize_factor;  // The intitial limit for learnt clauses is a factor of the original clauses.                (default 1 / 3)
+    double    learntsize_inc;     // The limit for learnt clauses is multiplied with this factor each restart.                 (default 1.1)
+
+    int       learntsize_adjust_start_confl;
+    double    learntsize_adjust_inc;
+
+    // Statistics: (read-only member variable)
+    //
+    uint64_t solves, starts, decisions, rnd_decisions, propagations, conflicts;
+    uint64_t dec_vars, clauses_literals, learnts_literals, max_literals, tot_literals;
+
+protected:
+
+    // Helper structures:
+    //
+    struct VarData { CRef reason; int level; };
+    static inline VarData mkVarData(CRef cr, int l){ VarData d = {cr, l}; return d; }
+
+    struct Watcher {
+        CRef cref;
+        Lit  blocker;
+        Watcher(CRef cr, Lit p) : cref(cr), blocker(p) {}
+        bool operator==(const Watcher& w) const { return cref == w.cref; }
+        bool operator!=(const Watcher& w) const { return cref != w.cref; }
+    };
+
+    struct WatcherDeleted
+    {
+        const ClauseAllocator& ca;
+        WatcherDeleted(const ClauseAllocator& _ca) : ca(_ca) {}
+        bool operator()(const Watcher& w) const { return ca[w.cref].mark() == 1; }
+    };
+
+    struct VarOrderLt {
+        const vec<double>&  activity;
+        bool operator () (Var x, Var y) const { return activity[x] > activity[y]; }
+        VarOrderLt(const vec<double>&  act) : activity(act) { }
+    };
+
+    // Solver state:
+    //
+    bool                ok;               // If FALSE, the constraints are already unsatisfiable. No part of the solver state may be used!
+    vec<CRef>           clauses;          // List of problem clauses.
+    vec<CRef>           learnts;          // List of learnt clauses.
+    double              cla_inc;          // Amount to bump next clause with.
+    vec<double>         activity;         // A heuristic measurement of the activity of a variable.
+    double              var_inc;          // Amount to bump next variable with.
+    OccLists<Lit, vec<Watcher>, WatcherDeleted>
+                        watches;          // 'watches[lit]' is a list of constraints watching 'lit' (will go there if literal becomes true).
+    vec<lbool>          assigns;          // The current assignments.
+    vec<char>           polarity;         // The preferred polarity of each variable.
+    vec<char>           decision;         // Declares if a variable is eligible for selection in the decision heuristic.
+    vec<Lit>            trail;            // Assignment stack; stores all assigments made in the order they were made.
+    vec<int>            trail_lim;        // Separator indices for different decision levels in 'trail'.
+    vec<VarData>        vardata;          // Stores reason and level for each variable.
+    int                 qhead;            // Head of queue (as index into the trail -- no more explicit propagation queue in MiniSat).
+    int                 simpDB_assigns;   // Number of top-level assignments since last execution of 'simplify()'.
+    int64_t             simpDB_props;     // Remaining number of propagations that must be made before next execution of 'simplify()'.
+    vec<Lit>            assumptions;      // Current set of assumptions provided to solve by the user.
+    Heap<VarOrderLt>    order_heap;       // A priority queue of variables ordered with respect to the variable activity.
+    double              progress_estimate;// Set by 'search()'.
+    bool                remove_satisfied; // Indicates whether possibly inefficient linear scan for satisfied clauses should be performed in 'simplify'.
+
+    ClauseAllocator     ca;
+
+    // Temporaries (to reduce allocation overhead). Each variable is prefixed by the method in which it is
+    // used, exept 'seen' wich is used in several places.
+    //
+    vec<char>           seen;
+    vec<Lit>            analyze_stack;
+    vec<Lit>            analyze_toclear;
+    vec<Lit>            add_tmp;
+
+    double              max_learnts;
+    double              learntsize_adjust_confl;
+    int                 learntsize_adjust_cnt;
+
+    // Resource contraints:
+    //
+    int64_t             conflict_budget;    // -1 means no budget.
+    int64_t             propagation_budget; // -1 means no budget.
+    bool                asynch_interrupt;
+
+    // Main internal methods:
+    //
+    void     insertVarOrder   (Var x);                                                 // Insert a variable in the decision order priority queue.
+    Lit      pickBranchLit    ();                                                      // Return the next decision variable.
+    void     newDecisionLevel ();                                                      // Begins a new decision level.
+    void     uncheckedEnqueue (Lit p, CRef from = CRef_Undef);                         // Enqueue a literal. Assumes value of literal is undefined.
+    bool     enqueue          (Lit p, CRef from = CRef_Undef);                         // Test if fact 'p' contradicts current state, enqueue otherwise.
+    CRef     propagate        ();                                                      // Perform unit propagation. Returns possibly conflicting clause.
+    void     cancelUntil      (int level);                                             // Backtrack until a certain level.
+    void     analyze          (CRef confl, vec<Lit>& out_learnt, int& out_btlevel);    // (bt = backtrack)
+    void     analyzeFinal     (Lit p, vec<Lit>& out_conflict);                         // COULD THIS BE IMPLEMENTED BY THE ORDINARIY "analyze" BY SOME REASONABLE GENERALIZATION?
+    bool     litRedundant     (Lit p, uint32_t abstract_levels);                       // (helper method for 'analyze()')
+    lbool    search           (int nof_conflicts);                                     // Search for a given number of conflicts.
+    lbool    solve_           ();                                                      // Main solve method (assumptions given in 'assumptions').
+    void     reduceDB         ();                                                      // Reduce the set of learnt clauses.
+    void     removeSatisfied  (vec<CRef>& cs);                                         // Shrink 'cs' to contain only non-satisfied clauses.
+    void     rebuildOrderHeap ();
+
+    // Maintaining Variable/Clause activity:
+    //
+    void     varDecayActivity ();                      // Decay all variables with the specified factor. Implemented by increasing the 'bump' value instead.
+    void     varBumpActivity  (Var v, double inc);     // Increase a variable with the current 'bump' value.
+    void     varBumpActivity  (Var v);                 // Increase a variable with the current 'bump' value.
+    void     claDecayActivity ();                      // Decay all clauses with the specified factor. Implemented by increasing the 'bump' value instead.
+    void     claBumpActivity  (Clause& c);             // Increase a clause with the current 'bump' value.
+
+    // Operations on clauses:
+    //
+    void     attachClause     (CRef cr);               // Attach a clause to watcher lists.
+    void     detachClause     (CRef cr, bool strict = false); // Detach a clause to watcher lists.
+    void     removeClause     (CRef cr);               // Detach and free a clause.
+    bool     locked           (const Clause& c) const; // Returns TRUE if a clause is a reason for some implication in the current state.
+    bool     satisfied        (const Clause& c) const; // Returns TRUE if a clause is satisfied in the current state.
+
+    void     relocAll         (ClauseAllocator& to);
+
+    // Misc:
+    //
+    int      decisionLevel    ()      const; // Gives the current decisionlevel.
+    uint32_t abstractLevel    (Var x) const; // Used to represent an abstraction of sets of decision levels.
+    CRef     reason           (Var x) const;
+    int      level            (Var x) const;
+    double   progressEstimate ()      const; // DELETE THIS ?? IT'S NOT VERY USEFUL ...
+    bool     withinBudget     ()      const;
+
+    // Static helpers:
+    //
+
+    // Returns a random float 0 <= x < 1. Seed must never be 0.
+    static inline double drand(double& seed) {
+        seed *= 1389796;
+        int q = (int)(seed / 2147483647);
+        seed -= (double)q * 2147483647;
+        return seed / 2147483647; }
+
+    // Returns a random integer 0 <= x < size. Seed must never be 0.
+    static inline int irand(double& seed, int size) {
+        return (int)(drand(seed) * size); }
+};
+
+
+//=================================================================================================
+// Implementation of inline methods:
+
+inline CRef Solver::reason(Var x) const { return vardata[x].reason; }
+inline int  Solver::level (Var x) const { return vardata[x].level; }
+
+inline void Solver::insertVarOrder(Var x) {
+    if (!order_heap.inHeap(x) && decision[x]) order_heap.insert(x); }
+
+inline void Solver::varDecayActivity() { var_inc *= (1 / var_decay); }
+inline void Solver::varBumpActivity(Var v) { varBumpActivity(v, var_inc); }
+inline void Solver::varBumpActivity(Var v, double inc) {
+    if ( (activity[v] += inc) > 1e100 ) {
+        // Rescale:
+        for (int i = 0; i < nVars(); i++)
+            activity[i] *= 1e-100;
+        var_inc *= 1e-100; }
+
+    // Update order_heap with respect to new activity:
+    if (order_heap.inHeap(v))
+        order_heap.decrease(v); }
+
+inline void Solver::claDecayActivity() { cla_inc *= (1 / clause_decay); }
+inline void Solver::claBumpActivity (Clause& c) {
+        if ( (c.activity() += cla_inc) > 1e20 ) {
+            // Rescale:
+            for (int i = 0; i < learnts.size(); i++)
+                ca[learnts[i]].activity() *= (float)1e-20;
+            cla_inc *= 1e-20; } }
+
+inline void Solver::checkGarbage(void){ checkGarbage(garbage_frac); }
+inline void Solver::checkGarbage(double gf){
+    if (ca.wasted() > ca.size() * gf)
+        garbageCollect(); }
+
+// NOTE: enqueue does not set the ok flag! (only public methods do)
+inline bool     Solver::enqueue         (Lit p, CRef from)      { return value(p) != l_Undef ? value(p) != l_False : (uncheckedEnqueue(p, from), true); }
+inline bool     Solver::addClause       (const vec<Lit>& ps)    { ps.copyTo(add_tmp); return addClause_(add_tmp); }
+inline bool     Solver::addEmptyClause  ()                      { add_tmp.clear(); return addClause_(add_tmp); }
+inline bool     Solver::addClause       (Lit p)                 { add_tmp.clear(); add_tmp.push(p); return addClause_(add_tmp); }
+inline bool     Solver::addClause       (Lit p, Lit q)          { add_tmp.clear(); add_tmp.push(p); add_tmp.push(q); return addClause_(add_tmp); }
+inline bool     Solver::addClause       (Lit p, Lit q, Lit r)   { add_tmp.clear(); add_tmp.push(p); add_tmp.push(q); add_tmp.push(r); return addClause_(add_tmp); }
+inline bool     Solver::locked          (const Clause& c) const { return value(c[0]) == l_True && reason(var(c[0])) != CRef_Undef && ca.lea(reason(var(c[0]))) == &c; }
+inline void     Solver::newDecisionLevel()                      { trail_lim.push(trail.size()); }
+
+inline int      Solver::decisionLevel ()      const   { return trail_lim.size(); }
+inline uint32_t Solver::abstractLevel (Var x) const   { return 1 << (level(x) & 31); }
+inline lbool    Solver::value         (Var x) const   { return assigns[x]; }
+inline lbool    Solver::value         (Lit p) const   { return assigns[var(p)] ^ sign(p); }
+inline lbool    Solver::modelValue    (Var x) const   { return model[x]; }
+inline lbool    Solver::modelValue    (Lit p) const   { return model[var(p)] ^ sign(p); }
+inline int      Solver::nAssigns      ()      const   { return trail.size(); }
+inline int      Solver::nClauses      ()      const   { return clauses.size(); }
+inline int      Solver::nLearnts      ()      const   { return learnts.size(); }
+inline int      Solver::nVars         ()      const   { return vardata.size(); }
+inline int      Solver::nFreeVars     ()      const   { return (int)dec_vars - (trail_lim.size() == 0 ? trail.size() : trail_lim[0]); }
+inline void     Solver::setPolarity   (Var v, bool b) { polarity[v] = b; }
+inline void     Solver::setDecisionVar(Var v, bool b) 
+{ 
+    if      ( b && !decision[v]) dec_vars++;
+    else if (!b &&  decision[v]) dec_vars--;
+
+    decision[v] = b;
+    insertVarOrder(v);
+}
+inline void     Solver::setConfBudget(int64_t x){ conflict_budget    = conflicts    + x; }
+inline void     Solver::setPropBudget(int64_t x){ propagation_budget = propagations + x; }
+inline void     Solver::interrupt(){ asynch_interrupt = true; }
+inline void     Solver::clearInterrupt(){ asynch_interrupt = false; }
+inline void     Solver::budgetOff(){ conflict_budget = propagation_budget = -1; }
+inline bool     Solver::withinBudget() const {
+    return !asynch_interrupt &&
+           (conflict_budget    < 0 || conflicts < (uint64_t)conflict_budget) &&
+           (propagation_budget < 0 || propagations < (uint64_t)propagation_budget); }
+
+// FIXME: after the introduction of asynchronous interrruptions the solve-versions that return a
+// pure bool do not give a safe interface. Either interrupts must be possible to turn off here, or
+// all calls to solve must return an 'lbool'. I'm not yet sure which I prefer.
+inline bool     Solver::solve         ()                    { budgetOff(); assumptions.clear(); return solve_() == l_True; }
+inline bool     Solver::solve         (Lit p)               { budgetOff(); assumptions.clear(); assumptions.push(p); return solve_() == l_True; }
+inline bool     Solver::solve         (Lit p, Lit q)        { budgetOff(); assumptions.clear(); assumptions.push(p); assumptions.push(q); return solve_() == l_True; }
+inline bool     Solver::solve         (Lit p, Lit q, Lit r) { budgetOff(); assumptions.clear(); assumptions.push(p); assumptions.push(q); assumptions.push(r); return solve_() == l_True; }
+inline bool     Solver::solve         (const vec<Lit>& assumps){ budgetOff(); assumps.copyTo(assumptions); return solve_() == l_True; }
+inline lbool    Solver::solveLimited  (const vec<Lit>& assumps){ assumps.copyTo(assumptions); return solve_(); }
+inline bool     Solver::okay          ()      const   { return ok; }
+
+inline void     Solver::toDimacs     (const char* file){ vec<Lit> as; toDimacs(file, as); }
+inline void     Solver::toDimacs     (const char* file, Lit p){ vec<Lit> as; as.push(p); toDimacs(file, as); }
+inline void     Solver::toDimacs     (const char* file, Lit p, Lit q){ vec<Lit> as; as.push(p); as.push(q); toDimacs(file, as); }
+inline void     Solver::toDimacs     (const char* file, Lit p, Lit q, Lit r){ vec<Lit> as; as.push(p); as.push(q); as.push(r); toDimacs(file, as); }
+
+
+//=================================================================================================
+// Debug etc:
+
+
+//=================================================================================================
+}
+
+#endif
diff --git a/abc-build/src/sat/bsat2/SolverTypes.h b/abc-build/src/sat/bsat2/SolverTypes.h
new file mode 100644
--- /dev/null
+++ b/abc-build/src/sat/bsat2/SolverTypes.h
@@ -0,0 +1,407 @@
+/***********************************************************************************[SolverTypes.h]
+Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson
+Copyright (c) 2007-2010, Niklas Sorensson
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
+associated documentation files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or
+substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
+NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
+OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+**************************************************************************************************/
+
+
+#ifndef Minisat_SolverTypes_h
+#define Minisat_SolverTypes_h
+
+#include <assert.h>
+
+#include "IntTypes.h"
+#include "Alg.h"
+#include "Vec.h"
+#include "Map.h"
+#include "Alloc.h"
+
+namespace Minisat {
+
+//=================================================================================================
+// Variables, literals, lifted booleans, clauses:
+
+
+// NOTE! Variables are just integers. No abstraction here. They should be chosen from 0..N,
+// so that they can be used as array indices.
+
+typedef int Var;
+#define var_Undef (-1)
+
+
+struct Lit {
+    int     x;
+
+    // Use this as a constructor:
+    friend Lit mkLit(Var var, bool sign = false);
+
+    bool operator == (Lit p) const { return x == p.x; }
+    bool operator != (Lit p) const { return x != p.x; }
+    bool operator <  (Lit p) const { return x < p.x;  } // '<' makes p, ~p adjacent in the ordering.
+};
+
+
+inline  Lit  mkLit     (Var var, bool sign) { Lit p; p.x = var + var + (int)sign; return p; }
+inline  Lit  operator ~(Lit p)              { Lit q; q.x = p.x ^ 1; return q; }
+inline  Lit  operator ^(Lit p, bool b)      { Lit q; q.x = p.x ^ (unsigned int)b; return q; }
+inline  bool sign      (Lit p)              { return p.x & 1; }
+inline  int  var       (Lit p)              { return p.x >> 1; }
+
+// Mapping Literals to and from compact integers suitable for array indexing:
+inline  int  toInt     (Var v)              { return v; } 
+inline  int  toInt     (Lit p)              { return p.x; } 
+inline  Lit  toLit     (int i)              { Lit p; p.x = i; return p; } 
+
+//const Lit lit_Undef = mkLit(var_Undef, false);  // }- Useful special constants.
+//const Lit lit_Error = mkLit(var_Undef, true );  // }
+
+const Lit lit_Undef = { -2 };  // }- Useful special constants.
+const Lit lit_Error = { -1 };  // }
+
+
+//=================================================================================================
+// Lifted booleans:
+//
+// NOTE: this implementation is optimized for the case when comparisons between values are mostly
+//       between one variable and one constant. Some care had to be taken to make sure that gcc 
+//       does enough constant propagation to produce sensible code, and this appears to be somewhat
+//       fragile unfortunately.
+
+#define l_True  (lbool((uint8_t)0)) // gcc does not do constant propagation if these are real constants.
+#define l_False (lbool((uint8_t)1))
+#define l_Undef (lbool((uint8_t)2))
+
+class lbool {
+    uint8_t value;
+
+public:
+    explicit lbool(uint8_t v) : value(v) { }
+
+    lbool()       : value(0) { }
+    explicit lbool(bool x) : value(!x) { }
+
+    bool  operator == (lbool b) const { return ((b.value&2) & (value&2)) | (!(b.value&2)&(value == b.value)); }
+    bool  operator != (lbool b) const { return !(*this == b); }
+    lbool operator ^  (bool  b) const { return lbool((uint8_t)(value^(uint8_t)b)); }
+
+    lbool operator && (lbool b) const { 
+        uint8_t sel = (this->value << 1) | (b.value << 3);
+        uint8_t v   = (0xF7F755F4 >> sel) & 3;
+        return lbool(v); }
+
+    lbool operator || (lbool b) const {
+        uint8_t sel = (this->value << 1) | (b.value << 3);
+        uint8_t v   = (0xFCFCF400 >> sel) & 3;
+        return lbool(v); }
+
+    friend int   toInt  (lbool l);
+    friend lbool toLbool(int   v);
+};
+inline int   toInt  (lbool l) { return l.value; }
+inline lbool toLbool(int   v) { return lbool((uint8_t)v);  }
+
+//=================================================================================================
+// Clause -- a simple class for representing a clause:
+
+class Clause;
+typedef RegionAllocator<uint32_t>::Ref CRef;
+
+class Clause {
+    struct {
+        unsigned mark      : 2;
+        unsigned learnt    : 1;
+        unsigned has_extra : 1;
+        unsigned reloced   : 1;
+        unsigned size      : 27; }                            header;
+    union { Lit lit; float act; uint32_t abs; CRef rel; } data[0];
+
+    friend class ClauseAllocator;
+
+    // NOTE: This constructor cannot be used directly (doesn't allocate enough memory).
+    template<class V>
+    Clause(const V& ps, bool use_extra, bool learnt) {
+        header.mark      = 0;
+        header.learnt    = learnt;
+        header.has_extra = use_extra;
+        header.reloced   = 0;
+        header.size      = ps.size();
+
+        for (int i = 0; i < ps.size(); i++) 
+            data[i].lit = ps[i];
+
+        if (header.has_extra){
+            if (header.learnt)
+                data[header.size].act = 0; 
+            else 
+                calcAbstraction(); }
+    }
+
+public:
+    void calcAbstraction() {
+        assert(header.has_extra);
+        uint32_t abstraction = 0;
+        for (int i = 0; i < size(); i++)
+            abstraction |= 1 << (var(data[i].lit) & 31);
+        data[header.size].abs = abstraction;  }
+
+
+    int          size        ()      const   { return header.size; }
+    void         shrink      (int i)         { assert(i <= size()); if (header.has_extra) data[header.size-i] = data[header.size]; header.size -= i; }
+    void         pop         ()              { shrink(1); }
+    bool         learnt      ()      const   { return header.learnt; }
+    bool         has_extra   ()      const   { return header.has_extra; }
+    uint32_t     mark        ()      const   { return header.mark; }
+    void         mark        (uint32_t m)    { header.mark = m; }
+    const Lit&   last        ()      const   { return data[header.size-1].lit; }
+
+    bool         reloced     ()      const   { return header.reloced; }
+    CRef         relocation  ()      const   { return data[0].rel; }
+    void         relocate    (CRef c)        { header.reloced = 1; data[0].rel = c; }
+
+    // NOTE: somewhat unsafe to change the clause in-place! Must manually call 'calcAbstraction' afterwards for
+    //       subsumption operations to behave correctly.
+    Lit&         operator [] (int i)         { return data[i].lit; }
+    Lit          operator [] (int i) const   { return data[i].lit; }
+    operator const Lit* (void) const         { return (Lit*)data; }
+
+    float&       activity    ()              { assert(header.has_extra); return data[header.size].act; }
+    uint32_t     abstraction () const        { assert(header.has_extra); return data[header.size].abs; }
+
+    Lit          subsumes    (const Clause& other) const;
+    void         strengthen  (Lit p);
+};
+
+
+//=================================================================================================
+// ClauseAllocator -- a simple class for allocating memory for clauses:
+
+
+const CRef CRef_Undef = RegionAllocator<uint32_t>::Ref_Undef;
+class ClauseAllocator : public RegionAllocator<uint32_t>
+{
+    static int clauseWord32Size(int size, bool has_extra){
+        return (sizeof(Clause) + (sizeof(Lit) * (size + (int)has_extra))) / sizeof(uint32_t); }
+ public:
+    bool extra_clause_field;
+
+    ClauseAllocator(uint32_t start_cap) : RegionAllocator<uint32_t>(start_cap), extra_clause_field(false){}
+    ClauseAllocator() : extra_clause_field(false){}
+
+    void moveTo(ClauseAllocator& to){
+        to.extra_clause_field = extra_clause_field;
+        RegionAllocator<uint32_t>::moveTo(to); }
+
+    template<class Lits>
+    CRef alloc(const Lits& ps, bool learnt = false)
+    {
+        assert(sizeof(Lit)      == sizeof(uint32_t));
+        assert(sizeof(float)    == sizeof(uint32_t));
+        bool use_extra = learnt | extra_clause_field;
+
+        CRef cid = RegionAllocator<uint32_t>::alloc(clauseWord32Size(ps.size(), use_extra));
+        new (lea(cid)) Clause(ps, use_extra, learnt);
+
+        return cid;
+    }
+
+    // Deref, Load Effective Address (LEA), Inverse of LEA (AEL):
+    Clause&       operator[](Ref r)       { return (Clause&)RegionAllocator<uint32_t>::operator[](r); }
+    const Clause& operator[](Ref r) const { return (Clause&)RegionAllocator<uint32_t>::operator[](r); }
+    Clause*       lea       (Ref r)       { return (Clause*)RegionAllocator<uint32_t>::lea(r); }
+    const Clause* lea       (Ref r) const { return (Clause*)RegionAllocator<uint32_t>::lea(r); }
+    Ref           ael       (const Clause* t){ return RegionAllocator<uint32_t>::ael((uint32_t*)t); }
+
+    void _free(CRef cid)
+    {
+        Clause& c = operator[](cid);
+        RegionAllocator<uint32_t>::_free(clauseWord32Size(c.size(), c.has_extra()));
+    }
+
+    void reloc(CRef& cr, ClauseAllocator& to)
+    {
+        Clause& c = operator[](cr);
+        
+        if (c.reloced()) { cr = c.relocation(); return; }
+        
+        cr = to.alloc(c, c.learnt());
+        c.relocate(cr);
+        
+        // Copy extra data-fields: 
+        // (This could be cleaned-up. Generalize Clause-constructor to be applicable here instead?)
+        to[cr].mark(c.mark());
+        if (to[cr].learnt())         to[cr].activity() = c.activity();
+        else if (to[cr].has_extra()) to[cr].calcAbstraction();
+    }
+};
+
+
+//=================================================================================================
+// OccLists -- a class for maintaining occurence lists with lazy deletion:
+
+template<class Idx, class Vec, class Deleted>
+class OccLists
+{
+    vec<Vec>  occs;
+    vec<char> dirty;
+    vec<Idx>  dirties;
+    Deleted   deleted;
+
+ public:
+    OccLists(const Deleted& d) : deleted(d) {}
+    
+    void  init      (const Idx& idx){ occs.growTo(toInt(idx)+1); dirty.growTo(toInt(idx)+1, 0); }
+    // Vec&  operator[](const Idx& idx){ return occs[toInt(idx)]; }
+    Vec&  operator[](const Idx& idx){ return occs[toInt(idx)]; }
+    Vec&  lookup    (const Idx& idx){ if (dirty[toInt(idx)]) clean(idx); return occs[toInt(idx)]; }
+
+    void  cleanAll  ();
+    void  clean     (const Idx& idx);
+    void  smudge    (const Idx& idx){
+        if (dirty[toInt(idx)] == 0){
+            dirty[toInt(idx)] = 1;
+            dirties.push(idx);
+        }
+    }
+
+    void  clear(bool free = true){
+        occs   .clear(free);
+        dirty  .clear(free);
+        dirties.clear(free);
+    }
+};
+
+
+template<class Idx, class Vec, class Deleted>
+void OccLists<Idx,Vec,Deleted>::cleanAll()
+{
+    for (int i = 0; i < dirties.size(); i++)
+        // Dirties may contain duplicates so check here if a variable is already cleaned:
+        if (dirty[toInt(dirties[i])])
+            clean(dirties[i]);
+    dirties.clear();
+}
+
+
+template<class Idx, class Vec, class Deleted>
+void OccLists<Idx,Vec,Deleted>::clean(const Idx& idx)
+{
+    Vec& vec = occs[toInt(idx)];
+    int  i, j;
+    for (i = j = 0; i < vec.size(); i++)
+        if (!deleted(vec[i]))
+            vec[j++] = vec[i];
+    vec.shrink(i - j);
+    dirty[toInt(idx)] = 0;
+}
+
+
+//=================================================================================================
+// CMap -- a class for mapping clauses to values:
+
+
+template<class T>
+class CMap
+{
+    struct CRefHash {
+        uint32_t operator()(CRef cr) const { return (uint32_t)cr; } };
+
+    typedef Map<CRef, T, CRefHash> HashTable;
+    HashTable map;
+        
+ public:
+    // Size-operations:
+    void     clear       ()                           { map.clear(); }
+    int      size        ()                const      { return map.elems(); }
+
+    
+    // Insert/Remove/Test mapping:
+    void     insert      (CRef cr, const T& t){ map.insert(cr, t); }
+    void     growTo      (CRef cr, const T& t){ map.insert(cr, t); } // NOTE: for compatibility
+    void     remove      (CRef cr)            { map.remove(cr); }
+    bool     has         (CRef cr, T& t)      { return map.peek(cr, t); }
+
+    // Vector interface (the clause 'c' must already exist):
+    const T& operator [] (CRef cr) const      { return map[cr]; }
+    T&       operator [] (CRef cr)            { return map[cr]; }
+
+    // Iteration (not transparent at all at the moment):
+    int  bucket_count() const { return map.bucket_count(); }
+    const vec<typename HashTable::Pair>& bucket(int i) const { return map.bucket(i); }
+
+    // Move contents to other map:
+    void moveTo(CMap& other){ map.moveTo(other.map); }
+
+    // TMP debug:
+    void debug(){
+        printf(" --- size = %d, bucket_count = %d\n", size(), map.bucket_count()); }
+};
+
+
+/*_________________________________________________________________________________________________
+|
+|  subsumes : (other : const Clause&)  ->  Lit
+|  
+|  Description:
+|       Checks if clause subsumes 'other', and at the same time, if it can be used to simplify 'other'
+|       by subsumption resolution.
+|  
+|    Result:
+|       lit_Error  - No subsumption or simplification
+|       lit_Undef  - Clause subsumes 'other'
+|       p          - The literal p can be deleted from 'other'
+|________________________________________________________________________________________________@*/
+inline Lit Clause::subsumes(const Clause& other) const
+{
+    //if (other.size() < size() || (extra.abst & ~other.extra.abst) != 0)
+    //if (other.size() < size() || (!learnt() && !other.learnt() && (extra.abst & ~other.extra.abst) != 0))
+    assert(!header.learnt);   assert(!other.header.learnt);
+    assert(header.has_extra); assert(other.header.has_extra);
+    if (other.header.size < header.size || (data[header.size].abs & ~other.data[other.header.size].abs) != 0)
+        return lit_Error;
+
+    Lit        ret = lit_Undef;
+    const Lit* c   = (const Lit*)(*this);
+    const Lit* d   = (const Lit*)other;
+
+    for (unsigned i = 0; i < header.size; i++) {
+        // search for c[i] or ~c[i]
+        for (unsigned j = 0; j < other.header.size; j++)
+            if (c[i] == d[j])
+                goto ok;
+            else if (ret == lit_Undef && c[i] == ~d[j]){
+                ret = c[i];
+                goto ok;
+            }
+
+        // did not find it
+        return lit_Error;
+    ok:;
+    }
+
+    return ret;
+}
+
+inline void Clause::strengthen(Lit p)
+{
+    remove(*this, p);
+    calcAbstraction();
+}
+
+//=================================================================================================
+}
+
+#endif
diff --git a/abc-build/src/sat/bsat2/Sort.h b/abc-build/src/sat/bsat2/Sort.h
new file mode 100644
--- /dev/null
+++ b/abc-build/src/sat/bsat2/Sort.h
@@ -0,0 +1,98 @@
+/******************************************************************************************[Sort.h]
+Copyright (c) 2003-2007, Niklas Een, Niklas Sorensson
+Copyright (c) 2007-2010, Niklas Sorensson
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
+associated documentation files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or
+substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
+NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
+OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+**************************************************************************************************/
+
+#ifndef Minisat_Sort_h
+#define Minisat_Sort_h
+
+#include "Vec.h"
+
+//=================================================================================================
+// Some sorting algorithms for vec's
+
+
+namespace Minisat {
+
+template<class T>
+struct LessThan_default {
+    bool operator () (T x, T y) { return x < y; }
+};
+
+
+template <class T, class LessThan>
+void selectionSort(T* array, int size, LessThan lt)
+{
+    int     i, j, best_i;
+    T       tmp;
+
+    for (i = 0; i < size-1; i++){
+        best_i = i;
+        for (j = i+1; j < size; j++){
+            if (lt(array[j], array[best_i]))
+                best_i = j;
+        }
+        tmp = array[i]; array[i] = array[best_i]; array[best_i] = tmp;
+    }
+}
+template <class T> static inline void selectionSort(T* array, int size) {
+    selectionSort(array, size, LessThan_default<T>()); }
+
+template <class T, class LessThan>
+void sort(T* array, int size, LessThan lt)
+{
+    if (size <= 15)
+        selectionSort(array, size, lt);
+
+    else{
+        T           pivot = array[size / 2];
+        T           tmp;
+        int         i = -1;
+        int         j = size;
+
+        for(;;){
+            do i++; while(lt(array[i], pivot));
+            do j--; while(lt(pivot, array[j]));
+
+            if (i >= j) break;
+
+            tmp = array[i]; array[i] = array[j]; array[j] = tmp;
+        }
+
+        sort(array    , i     , lt);
+        sort(&array[i], size-i, lt);
+    }
+}
+template <class T> static inline void sort(T* array, int size) {
+    sort(array, size, LessThan_default<T>()); }
+
+
+//=================================================================================================
+// For 'vec's:
+
+
+template <class T, class LessThan> void sort(vec<T>& v, LessThan lt) {
+    sort((T*)v, v.size(), lt); }
+template <class T> void sort(vec<T>& v) {
+    sort(v, LessThan_default<T>()); }
+
+
+//=================================================================================================
+}
+
+#endif
diff --git a/abc-build/src/sat/bsat2/System.cpp b/abc-build/src/sat/bsat2/System.cpp
new file mode 100644
--- /dev/null
+++ b/abc-build/src/sat/bsat2/System.cpp
@@ -0,0 +1,95 @@
+/***************************************************************************************[System.cc]
+Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson
+Copyright (c) 2007-2010, Niklas Sorensson
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
+associated documentation files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or
+substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
+NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
+OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+**************************************************************************************************/
+
+#include "System.h"
+
+#if defined(__linux__)
+
+#include <stdio.h>
+#include <stdlib.h>
+
+using namespace Minisat;
+
+// TODO: split the memory reading functions into two: one for reading high-watermark of RSS, and
+// one for reading the current virtual memory size.
+
+static inline int memReadStat(int field)
+{
+    char  name[256];
+    pid_t pid = getpid();
+    int   value;
+
+    sprintf(name, "/proc/%d/statm", pid);
+    FILE* in = fopen(name, "rb");
+    if (in == NULL) return 0;
+
+    for (; field >= 0; field--)
+        if (fscanf(in, "%d", &value) != 1)
+            printf("ERROR! Failed to parse memory statistics from \"/proc\".\n"), exit(1);
+    fclose(in);
+    return value;
+}
+
+
+static inline int memReadPeak(void)
+{
+    char  name[256];
+    pid_t pid = getpid();
+
+    sprintf(name, "/proc/%d/status", pid);
+    FILE* in = fopen(name, "rb");
+    if (in == NULL) return 0;
+
+    // Find the correct line, beginning with "VmPeak:":
+    int peak_kb = 0;
+    while (!feof(in) && fscanf(in, "VmPeak: %d kB", &peak_kb) != 1)
+        while (!feof(in) && fgetc(in) != '\n')
+            ;
+    fclose(in);
+
+    return peak_kb;
+}
+
+double Minisat::memUsed() { return (double)memReadStat(0) * (double)getpagesize() / (1024*1024); }
+double Minisat::memUsedPeak() { 
+    double peak = memReadPeak() / 1024;
+    return peak == 0 ? memUsed() : peak; }
+
+#elif defined(__FreeBSD__)
+
+double Minisat::memUsed(void) {
+    struct rusage ru;
+    getrusage(RUSAGE_SELF, &ru);
+    return (double)ru.ru_maxrss / 1024; }
+double MiniSat::memUsedPeak(void) { return memUsed(); }
+
+
+#elif defined(__APPLE__)
+#include <malloc/malloc.h>
+
+double Minisat::memUsed(void) {
+    malloc_statistics_t t;
+    malloc_zone_statistics(NULL, &t);
+    return (double)t.max_size_in_use / (1024*1024); }
+
+#else
+double Minisat::memUsed()     { return 0; }
+double Minisat::memUsedPeak() { return 0; }
+#endif
diff --git a/abc-build/src/sat/bsat2/System.h b/abc-build/src/sat/bsat2/System.h
new file mode 100644
--- /dev/null
+++ b/abc-build/src/sat/bsat2/System.h
@@ -0,0 +1,60 @@
+/****************************************************************************************[System.h]
+Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson
+Copyright (c) 2007-2010, Niklas Sorensson
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
+associated documentation files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or
+substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
+NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
+OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+**************************************************************************************************/
+
+#ifndef Minisat_System_h
+#define Minisat_System_h
+
+#if defined(__linux__)
+#include <fpu_control.h>
+#endif
+
+#include "IntTypes.h"
+
+//-------------------------------------------------------------------------------------------------
+
+namespace Minisat {
+
+static inline double cpuTime(void); // CPU-time in seconds.
+extern double memUsed();            // Memory in mega bytes (returns 0 for unsupported architectures).
+extern double memUsedPeak();        // Peak-memory in mega bytes (returns 0 for unsupported architectures).
+
+}
+
+//-------------------------------------------------------------------------------------------------
+// Implementation of inline functions:
+
+#if defined(_MSC_VER) || defined(__MINGW32__)
+#include <time.h>
+
+static inline double Minisat::cpuTime(void) { return (double)clock() / CLOCKS_PER_SEC; }
+
+#else
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <unistd.h>
+
+static inline double Minisat::cpuTime(void) {
+    struct rusage ru;
+    getrusage(RUSAGE_SELF, &ru);
+    return (double)ru.ru_utime.tv_sec + (double)ru.ru_utime.tv_usec / 1000000; }
+
+#endif
+
+#endif
diff --git a/abc-build/src/sat/bsat2/Vec.h b/abc-build/src/sat/bsat2/Vec.h
new file mode 100644
--- /dev/null
+++ b/abc-build/src/sat/bsat2/Vec.h
@@ -0,0 +1,130 @@
+/*******************************************************************************************[Vec.h]
+Copyright (c) 2003-2007, Niklas Een, Niklas Sorensson
+Copyright (c) 2007-2010, Niklas Sorensson
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
+associated documentation files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or
+substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
+NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
+OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+**************************************************************************************************/
+
+#ifndef Minisat_Vec_h
+#define Minisat_Vec_h
+
+#include <assert.h>
+#include <new>
+
+#include "IntTypes.h"
+#include "XAlloc.h"
+
+namespace Minisat {
+
+//=================================================================================================
+// Automatically resizable arrays
+//
+// NOTE! Don't use this vector on datatypes that cannot be re-located in memory (with realloc)
+
+template<class T>
+class vec {
+    T*  data;
+    int sz;
+    int cap;
+
+    // Don't allow copying (error prone):
+    vec<T>&  operator = (vec<T>& other) { assert(0); return *this; }
+             vec        (vec<T>& other) { assert(0); }
+             
+    // Helpers for calculating next capacity:
+    static inline int  imax   (int x, int y) { int mask = (y-x) >> (sizeof(int)*8-1); return (x&mask) + (y&(~mask)); }
+    //static inline void nextCap(int& cap){ cap += ((cap >> 1) + 2) & ~1; }
+    static inline void nextCap(int& cap){ cap += ((cap >> 1) + 2) & ~1; }
+
+public:
+    // Constructors:
+    vec()                       : data(NULL) , sz(0)   , cap(0)    { }
+    explicit vec(int size)      : data(NULL) , sz(0)   , cap(0)    { growTo(size); }
+    vec(int size, const T& pad) : data(NULL) , sz(0)   , cap(0)    { growTo(size, pad); }
+   ~vec()                                                          { clear(true); }
+
+    // Pointer to first element:
+    operator T*       (void)           { return data; }
+
+    // Size operations:
+    int      size     (void) const     { return sz; }
+    void     shrink   (int nelems)     { assert(nelems <= sz); for (int i = 0; i < nelems; i++) sz--, data[sz].~T(); }
+    void     shrink_  (int nelems)     { assert(nelems <= sz); sz -= nelems; }
+    int      capacity (void) const     { return cap; }
+    void     capacity (int min_cap);
+    void     growTo   (int size);
+    void     growTo   (int size, const T& pad);
+    void     clear    (bool dealloc = false);
+
+    // Stack interface:
+    void     push  (void)              { if (sz == cap) capacity(sz+1); new (&data[sz]) T(); sz++; }
+    void     push  (const T& elem)     { if (sz == cap) capacity(sz+1); data[sz++] = elem; }
+    void     push_ (const T& elem)     { assert(sz < cap); data[sz++] = elem; }
+    void     pop   (void)              { assert(sz > 0); sz--, data[sz].~T(); }
+    // NOTE: it seems possible that overflow can happen in the 'sz+1' expression of 'push()', but
+    // in fact it can not since it requires that 'cap' is equal to INT_MAX. This in turn can not
+    // happen given the way capacities are calculated (below). Essentially, all capacities are
+    // even, but INT_MAX is odd.
+
+    const T& last  (void) const        { return data[sz-1]; }
+    T&       last  (void)              { return data[sz-1]; }
+
+    // Vector interface:
+    const T& operator [] (int index) const { return data[index]; }
+    T&       operator [] (int index)       { return data[index]; }
+
+    // Duplicatation (preferred instead):
+    void copyTo(vec<T>& copy) const { copy.clear(); copy.growTo(sz); for (int i = 0; i < sz; i++) copy[i] = data[i]; }
+    void moveTo(vec<T>& dest) { dest.clear(true); dest.data = data; dest.sz = sz; dest.cap = cap; data = NULL; sz = 0; cap = 0; }
+};
+
+
+template<class T>
+void vec<T>::capacity(int min_cap) {
+    if (cap >= min_cap) return;
+    int add = imax((min_cap - cap + 1) & ~1, ((cap >> 1) + 2) & ~1);   // NOTE: grow by approximately 3/2
+    if (add > INT_MAX - cap || (((data = (T*)::realloc(data, (cap += add) * sizeof(T))) == NULL) && errno == ENOMEM))
+        throw OutOfMemoryException();
+ }
+
+
+template<class T>
+void vec<T>::growTo(int size, const T& pad) {
+    if (sz >= size) return;
+    capacity(size);
+    for (int i = sz; i < size; i++) data[i] = pad;
+    sz = size; }
+
+
+template<class T>
+void vec<T>::growTo(int size) {
+    if (sz >= size) return;
+    capacity(size);
+    for (int i = sz; i < size; i++) new (&data[i]) T();
+    sz = size; }
+
+
+template<class T>
+void vec<T>::clear(bool dealloc) {
+    if (data != NULL){
+        for (int i = 0; i < sz; i++) data[i].~T();
+        sz = 0;
+        if (dealloc) free(data), data = NULL, cap = 0; } }
+
+//=================================================================================================
+}
+
+#endif
diff --git a/abc-build/src/sat/bsat2/XAlloc.h b/abc-build/src/sat/bsat2/XAlloc.h
new file mode 100644
--- /dev/null
+++ b/abc-build/src/sat/bsat2/XAlloc.h
@@ -0,0 +1,45 @@
+/****************************************************************************************[XAlloc.h]
+Copyright (c) 2009-2010, Niklas Sorensson
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
+associated documentation files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or
+substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
+NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
+OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+**************************************************************************************************/
+
+
+#ifndef Minisat_XAlloc_h
+#define Minisat_XAlloc_h
+
+#include <errno.h>
+#include <stdlib.h>
+
+namespace Minisat {
+
+//=================================================================================================
+// Simple layer on top of malloc/realloc to catch out-of-memory situtaions and provide some typing:
+
+class OutOfMemoryException{};
+static inline void* xrealloc(void *ptr, size_t size)
+{
+    void* mem = realloc(ptr, size);
+    if (mem == NULL && errno == ENOMEM){
+        throw OutOfMemoryException();
+    }else
+        return mem;
+}
+
+//=================================================================================================
+}
+
+#endif
diff --git a/abc-build/src/sat/bsat2/module.make b/abc-build/src/sat/bsat2/module.make
new file mode 100644
--- /dev/null
+++ b/abc-build/src/sat/bsat2/module.make
@@ -0,0 +1,7 @@
+SRC +=  src/sat/bsat2/AbcApi.cpp \
+	src/sat/bsat2/MainSat.cpp \
+	src/sat/bsat2/MainSimp.cpp \
+	src/sat/bsat2/Options.cpp \
+	src/sat/bsat2/SimpSolver.cpp \
+	src/sat/bsat2/Solver.cpp \
+	src/sat/bsat2/System.cpp
diff --git a/abc-build/src/sat/bsat2/pstdint.h b/abc-build/src/sat/bsat2/pstdint.h
new file mode 100644
--- /dev/null
+++ b/abc-build/src/sat/bsat2/pstdint.h
@@ -0,0 +1,813 @@
+/*  A portable stdint.h
+ ****************************************************************************
+ *  BSD License:
+ ****************************************************************************
+ *
+ *  Copyright (c) 2005-2014 Paul Hsieh
+ *  All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *  1. Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *  2. Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *  3. The name of the author may not be used to endorse or promote products
+ *     derived from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ *  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ *  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ *  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************
+ *
+ *  Version 0.1.14
+ *
+ *  The ANSI C standard committee, for the C99 standard, specified the
+ *  inclusion of a new standard include file called stdint.h.  This is
+ *  a very useful and long desired include file which contains several
+ *  very precise definitions for integer scalar types that is
+ *  critically important for making portable several classes of
+ *  applications including cryptography, hashing, variable length
+ *  integer libraries and so on.  But for most developers its likely
+ *  useful just for programming sanity.
+ *
+ *  The problem is that most compiler vendors have decided not to
+ *  implement the C99 standard, and the next C++ language standard
+ *  (which has a lot more mindshare these days) will be a long time in
+ *  coming and its unknown whether or not it will include stdint.h or
+ *  how much adoption it will have.  Either way, it will be a long time
+ *  before all compilers come with a stdint.h and it also does nothing
+ *  for the extremely large number of compilers available today which
+ *  do not include this file, or anything comparable to it.
+ *
+ *  So that's what this file is all about.  Its an attempt to build a
+ *  single universal include file that works on as many platforms as
+ *  possible to deliver what stdint.h is supposed to.  A few things
+ *  that should be noted about this file:
+ *
+ *    1) It is not guaranteed to be portable and/or present an identical
+ *       interface on all platforms.  The extreme variability of the
+ *       ANSI C standard makes this an impossibility right from the
+ *       very get go. Its really only meant to be useful for the vast
+ *       majority of platforms that possess the capability of
+ *       implementing usefully and precisely defined, standard sized
+ *       integer scalars.  Systems which are not intrinsically 2s
+ *       complement may produce invalid constants.
+ *
+ *    2) There is an unavoidable use of non-reserved symbols.
+ *
+ *    3) Other standard include files are invoked.
+ *
+ *    4) This file may come in conflict with future platforms that do
+ *       include stdint.h.  The hope is that one or the other can be
+ *       used with no real difference.
+ *
+ *    5) In the current verison, if your platform can't represent
+ *       int32_t, int16_t and int8_t, it just dumps out with a compiler
+ *       error.
+ *
+ *    6) 64 bit integers may or may not be defined.  Test for their
+ *       presence with the test: #ifdef INT64_MAX or #ifdef UINT64_MAX.
+ *       Note that this is different from the C99 specification which
+ *       requires the existence of 64 bit support in the compiler.  If
+ *       this is not defined for your platform, yet it is capable of
+ *       dealing with 64 bits then it is because this file has not yet
+ *       been extended to cover all of your system's capabilities.
+ *
+ *    7) (u)intptr_t may or may not be defined.  Test for its presence
+ *       with the test: #ifdef PTRDIFF_MAX.  If this is not defined
+ *       for your platform, then it is because this file has not yet
+ *       been extended to cover all of your system's capabilities, not
+ *       because its optional.
+ *
+ *    8) The following might not been defined even if your platform is
+ *       capable of defining it:
+ *
+ *       WCHAR_MIN
+ *       WCHAR_MAX
+ *       (u)int64_t
+ *       PTRDIFF_MIN
+ *       PTRDIFF_MAX
+ *       (u)intptr_t
+ *
+ *    9) The following have not been defined:
+ *
+ *       WINT_MIN
+ *       WINT_MAX
+ *
+ *   10) The criteria for defining (u)int_least(*)_t isn't clear,
+ *       except for systems which don't have a type that precisely
+ *       defined 8, 16, or 32 bit types (which this include file does
+ *       not support anyways). Default definitions have been given.
+ *
+ *   11) The criteria for defining (u)int_fast(*)_t isn't something I
+ *       would trust to any particular compiler vendor or the ANSI C
+ *       committee.  It is well known that "compatible systems" are
+ *       commonly created that have very different performance
+ *       characteristics from the systems they are compatible with,
+ *       especially those whose vendors make both the compiler and the
+ *       system.  Default definitions have been given, but its strongly
+ *       recommended that users never use these definitions for any
+ *       reason (they do *NOT* deliver any serious guarantee of
+ *       improved performance -- not in this file, nor any vendor's
+ *       stdint.h).
+ *
+ *   12) The following macros:
+ *
+ *       PRINTF_INTMAX_MODIFIER
+ *       PRINTF_INT64_MODIFIER
+ *       PRINTF_INT32_MODIFIER
+ *       PRINTF_INT16_MODIFIER
+ *       PRINTF_LEAST64_MODIFIER
+ *       PRINTF_LEAST32_MODIFIER
+ *       PRINTF_LEAST16_MODIFIER
+ *       PRINTF_INTPTR_MODIFIER
+ *
+ *       are strings which have been defined as the modifiers required
+ *       for the "d", "u" and "x" printf formats to correctly output
+ *       (u)intmax_t, (u)int64_t, (u)int32_t, (u)int16_t, (u)least64_t,
+ *       (u)least32_t, (u)least16_t and (u)intptr_t types respectively.
+ *       PRINTF_INTPTR_MODIFIER is not defined for some systems which
+ *       provide their own stdint.h.  PRINTF_INT64_MODIFIER is not
+ *       defined if INT64_MAX is not defined.  These are an extension
+ *       beyond what C99 specifies must be in stdint.h.
+ *
+ *       In addition, the following macros are defined:
+ *
+ *       PRINTF_INTMAX_HEX_WIDTH
+ *       PRINTF_INT64_HEX_WIDTH
+ *       PRINTF_INT32_HEX_WIDTH
+ *       PRINTF_INT16_HEX_WIDTH
+ *       PRINTF_INT8_HEX_WIDTH
+ *       PRINTF_INTMAX_DEC_WIDTH
+ *       PRINTF_INT64_DEC_WIDTH
+ *       PRINTF_INT32_DEC_WIDTH
+ *       PRINTF_INT16_DEC_WIDTH
+ *       PRINTF_INT8_DEC_WIDTH
+ *
+ *       Which specifies the maximum number of characters required to
+ *       print the number of that type in either hexadecimal or decimal.
+ *       These are an extension beyond what C99 specifies must be in
+ *       stdint.h.
+ *
+ *  Compilers tested (all with 0 warnings at their highest respective
+ *  settings): Borland Turbo C 2.0, WATCOM C/C++ 11.0 (16 bits and 32
+ *  bits), Microsoft Visual C++ 6.0 (32 bit), Microsoft Visual Studio
+ *  .net (VC7), Intel C++ 4.0, GNU gcc v3.3.3
+ *
+ *  This file should be considered a work in progress.  Suggestions for
+ *  improvements, especially those which increase coverage are strongly
+ *  encouraged.
+ *
+ *  Acknowledgements
+ *
+ *  The following people have made significant contributions to the
+ *  development and testing of this file:
+ *
+ *  Chris Howie
+ *  John Steele Scott
+ *  Dave Thorup
+ *  John Dill
+ *  Florian Wobbe
+ *  Christopher Sean Morrison
+ *
+ */
+
+#include <stddef.h>
+#include <limits.h>
+#include <signal.h>
+
+/*
+ *  For gcc with _STDINT_H, fill in the PRINTF_INT*_MODIFIER macros, and
+ *  do nothing else.  On the Mac OS X version of gcc this is _STDINT_H_.
+ */
+
+#if ((defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined (__WATCOMC__) && (defined (_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (__GNUC__ > 3 || defined(_STDINT_H) || defined(_STDINT_H_) || defined (__UINT_FAST64_TYPE__)) )) && !defined (_PSTDINT_H_INCLUDED)
+#include <stdint.h>
+#define _PSTDINT_H_INCLUDED
+# if defined(__GNUC__) && (defined(__x86_64__) || defined(__ppc64__))
+#  ifndef PRINTF_INT64_MODIFIER
+#   define PRINTF_INT64_MODIFIER "l"
+#  endif
+#  ifndef PRINTF_INT32_MODIFIER
+#   define PRINTF_INT32_MODIFIER ""
+#  endif
+# else
+#  ifndef PRINTF_INT64_MODIFIER
+#   define PRINTF_INT64_MODIFIER "ll"
+#  endif
+#  ifndef PRINTF_INT32_MODIFIER
+#   define PRINTF_INT32_MODIFIER "l"
+#  endif
+# endif
+# ifndef PRINTF_INT16_MODIFIER
+#  define PRINTF_INT16_MODIFIER "h"
+# endif
+# ifndef PRINTF_INTMAX_MODIFIER
+#  define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
+# endif
+# ifndef PRINTF_INT64_HEX_WIDTH
+#  define PRINTF_INT64_HEX_WIDTH "16"
+# endif
+# ifndef PRINTF_INT32_HEX_WIDTH
+#  define PRINTF_INT32_HEX_WIDTH "8"
+# endif
+# ifndef PRINTF_INT16_HEX_WIDTH
+#  define PRINTF_INT16_HEX_WIDTH "4"
+# endif
+# ifndef PRINTF_INT8_HEX_WIDTH
+#  define PRINTF_INT8_HEX_WIDTH "2"
+# endif
+# ifndef PRINTF_INT64_DEC_WIDTH
+#  define PRINTF_INT64_DEC_WIDTH "20"
+# endif
+# ifndef PRINTF_INT32_DEC_WIDTH
+#  define PRINTF_INT32_DEC_WIDTH "10"
+# endif
+# ifndef PRINTF_INT16_DEC_WIDTH
+#  define PRINTF_INT16_DEC_WIDTH "5"
+# endif
+# ifndef PRINTF_INT8_DEC_WIDTH
+#  define PRINTF_INT8_DEC_WIDTH "3"
+# endif
+# ifndef PRINTF_INTMAX_HEX_WIDTH
+#  define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
+# endif
+# ifndef PRINTF_INTMAX_DEC_WIDTH
+#  define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
+# endif
+
+/*
+ *  Something really weird is going on with Open Watcom.  Just pull some of
+ *  these duplicated definitions from Open Watcom's stdint.h file for now.
+ */
+
+# if defined (__WATCOMC__) && __WATCOMC__ >= 1250
+#  if !defined (INT64_C)
+#   define INT64_C(x)   (x + (INT64_MAX - INT64_MAX))
+#  endif
+#  if !defined (UINT64_C)
+#   define UINT64_C(x)  (x + (UINT64_MAX - UINT64_MAX))
+#  endif
+#  if !defined (INT32_C)
+#   define INT32_C(x)   (x + (INT32_MAX - INT32_MAX))
+#  endif
+#  if !defined (UINT32_C)
+#   define UINT32_C(x)  (x + (UINT32_MAX - UINT32_MAX))
+#  endif
+#  if !defined (INT16_C)
+#   define INT16_C(x)   (x)
+#  endif
+#  if !defined (UINT16_C)
+#   define UINT16_C(x)  (x)
+#  endif
+#  if !defined (INT8_C)
+#   define INT8_C(x)   (x)
+#  endif
+#  if !defined (UINT8_C)
+#   define UINT8_C(x)  (x)
+#  endif
+#  if !defined (UINT64_MAX)
+#   define UINT64_MAX  18446744073709551615ULL
+#  endif
+#  if !defined (INT64_MAX)
+#   define INT64_MAX  9223372036854775807LL
+#  endif
+#  if !defined (UINT32_MAX)
+#   define UINT32_MAX  4294967295UL
+#  endif
+#  if !defined (INT32_MAX)
+#   define INT32_MAX  2147483647L
+#  endif
+#  if !defined (INTMAX_MAX)
+#   define INTMAX_MAX INT64_MAX
+#  endif
+#  if !defined (INTMAX_MIN)
+#   define INTMAX_MIN INT64_MIN
+#  endif
+# endif
+#endif
+
+#ifndef _PSTDINT_H_INCLUDED
+#define _PSTDINT_H_INCLUDED
+
+#ifndef SIZE_MAX
+# define SIZE_MAX (~(size_t)0)
+#endif
+
+/*
+ *  Deduce the type assignments from limits.h under the assumption that
+ *  integer sizes in bits are powers of 2, and follow the ANSI
+ *  definitions.
+ */
+
+#ifndef UINT8_MAX
+# define UINT8_MAX 0xff
+#endif
+#if !defined(uint8_t) && !defined(_UINT8_T)
+# if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S)
+    typedef unsigned char uint8_t;
+#   define UINT8_C(v) ((uint8_t) v)
+# else
+#   error "Platform not supported"
+# endif
+#endif
+
+#ifndef INT8_MAX
+# define INT8_MAX 0x7f
+#endif
+#ifndef INT8_MIN
+# define INT8_MIN INT8_C(0x80)
+#endif
+#if !defined(int8_t) && !defined(_INT8_T)
+# if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S)
+    typedef signed char int8_t;
+#   define INT8_C(v) ((int8_t) v)
+# else
+#   error "Platform not supported"
+# endif
+#endif
+
+#ifndef UINT16_MAX
+# define UINT16_MAX 0xffff
+#endif
+#if !defined(uint16_t) && !defined(_UINT16_T)
+#if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S)
+  typedef unsigned int uint16_t;
+# ifndef PRINTF_INT16_MODIFIER
+#  define PRINTF_INT16_MODIFIER ""
+# endif
+# define UINT16_C(v) ((uint16_t) (v))
+#elif (USHRT_MAX == UINT16_MAX)
+  typedef unsigned short uint16_t;
+# define UINT16_C(v) ((uint16_t) (v))
+# ifndef PRINTF_INT16_MODIFIER
+#  define PRINTF_INT16_MODIFIER "h"
+# endif
+#else
+#error "Platform not supported"
+#endif
+#endif
+
+#ifndef INT16_MAX
+# define INT16_MAX 0x7fff
+#endif
+#ifndef INT16_MIN
+# define INT16_MIN INT16_C(0x8000)
+#endif
+#if !defined(int16_t) && !defined(_INT16_T)
+#if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S)
+  typedef signed int int16_t;
+# define INT16_C(v) ((int16_t) (v))
+# ifndef PRINTF_INT16_MODIFIER
+#  define PRINTF_INT16_MODIFIER ""
+# endif
+#elif (SHRT_MAX == INT16_MAX)
+  typedef signed short int16_t;
+# define INT16_C(v) ((int16_t) (v))
+# ifndef PRINTF_INT16_MODIFIER
+#  define PRINTF_INT16_MODIFIER "h"
+# endif
+#else
+#error "Platform not supported"
+#endif
+#endif
+
+#ifndef UINT32_MAX
+# define UINT32_MAX (0xffffffffUL)
+#endif
+#if !defined(uint32_t) && !defined(_UINT32_T)
+#if (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S)
+  typedef unsigned long uint32_t;
+# define UINT32_C(v) v ## UL
+# ifndef PRINTF_INT32_MODIFIER
+#  define PRINTF_INT32_MODIFIER "l"
+# endif
+#elif (UINT_MAX == UINT32_MAX)
+  typedef unsigned int uint32_t;
+# ifndef PRINTF_INT32_MODIFIER
+#  define PRINTF_INT32_MODIFIER ""
+# endif
+# define UINT32_C(v) v ## U
+#elif (USHRT_MAX == UINT32_MAX)
+  typedef unsigned short uint32_t;
+# define UINT32_C(v) ((unsigned short) (v))
+# ifndef PRINTF_INT32_MODIFIER
+#  define PRINTF_INT32_MODIFIER ""
+# endif
+#else
+#error "Platform not supported"
+#endif
+#endif
+
+#ifndef INT32_MAX
+# define INT32_MAX (0x7fffffffL)
+#endif
+#ifndef INT32_MIN
+# define INT32_MIN INT32_C(0x80000000)
+#endif
+#if !defined(int32_t) && !defined(_INT32_T)
+#if (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S)
+  typedef signed long int32_t;
+# define INT32_C(v) v ## L
+# ifndef PRINTF_INT32_MODIFIER
+#  define PRINTF_INT32_MODIFIER "l"
+# endif
+#elif (INT_MAX == INT32_MAX)
+  typedef signed int int32_t;
+# define INT32_C(v) v
+# ifndef PRINTF_INT32_MODIFIER
+#  define PRINTF_INT32_MODIFIER ""
+# endif
+#elif (SHRT_MAX == INT32_MAX)
+  typedef signed short int32_t;
+# define INT32_C(v) ((short) (v))
+# ifndef PRINTF_INT32_MODIFIER
+#  define PRINTF_INT32_MODIFIER ""
+# endif
+#else
+#error "Platform not supported"
+#endif
+#endif
+
+/*
+ *  The macro stdint_int64_defined is temporarily used to record
+ *  whether or not 64 integer support is available.  It must be
+ *  defined for any 64 integer extensions for new platforms that are
+ *  added.
+ */
+
+#undef stdint_int64_defined
+#if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined (S_SPLINT_S)
+# if (__STDC__ && __STDC_VERSION__ >= 199901L) || defined (S_SPLINT_S)
+#  define stdint_int64_defined
+   typedef long long int64_t;
+   typedef unsigned long long uint64_t;
+#  define UINT64_C(v) v ## ULL
+#  define  INT64_C(v) v ## LL
+#  ifndef PRINTF_INT64_MODIFIER
+#   define PRINTF_INT64_MODIFIER "ll"
+#  endif
+# endif
+#endif
+
+#if !defined (stdint_int64_defined)
+# if defined(__GNUC__)
+#  define stdint_int64_defined
+   __extension__ typedef long long int64_t;
+   __extension__ typedef unsigned long long uint64_t;
+#  define UINT64_C(v) v ## ULL
+#  define  INT64_C(v) v ## LL
+#  ifndef PRINTF_INT64_MODIFIER
+#   define PRINTF_INT64_MODIFIER "ll"
+#  endif
+# elif defined(__MWERKS__) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || defined (__APPLE_CC__) || defined (_LONG_LONG) || defined (_CRAYC) || defined (S_SPLINT_S)
+#  define stdint_int64_defined
+   typedef long long int64_t;
+   typedef unsigned long long uint64_t;
+#  define UINT64_C(v) v ## ULL
+#  define  INT64_C(v) v ## LL
+#  ifndef PRINTF_INT64_MODIFIER
+#   define PRINTF_INT64_MODIFIER "ll"
+#  endif
+# elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined (__BORLANDC__) && __BORLANDC__ > 0x460) || defined (__alpha) || defined (__DECC)
+#  define stdint_int64_defined
+   typedef __int64 int64_t;
+   typedef unsigned __int64 uint64_t;
+#  define UINT64_C(v) v ## UI64
+#  define  INT64_C(v) v ## I64
+#  ifndef PRINTF_INT64_MODIFIER
+#   define PRINTF_INT64_MODIFIER "I64"
+#  endif
+# endif
+#endif
+
+#if !defined (LONG_LONG_MAX) && defined (INT64_C)
+# define LONG_LONG_MAX INT64_C (9223372036854775807)
+#endif
+#ifndef ULONG_LONG_MAX
+# define ULONG_LONG_MAX UINT64_C (18446744073709551615)
+#endif
+
+#if !defined (INT64_MAX) && defined (INT64_C)
+# define INT64_MAX INT64_C (9223372036854775807)
+#endif
+#if !defined (INT64_MIN) && defined (INT64_C)
+# define INT64_MIN INT64_C (-9223372036854775808)
+#endif
+#if !defined (UINT64_MAX) && defined (INT64_C)
+# define UINT64_MAX UINT64_C (18446744073709551615)
+#endif
+
+/*
+ *  Width of hexadecimal for number field.
+ */
+
+#ifndef PRINTF_INT64_HEX_WIDTH
+# define PRINTF_INT64_HEX_WIDTH "16"
+#endif
+#ifndef PRINTF_INT32_HEX_WIDTH
+# define PRINTF_INT32_HEX_WIDTH "8"
+#endif
+#ifndef PRINTF_INT16_HEX_WIDTH
+# define PRINTF_INT16_HEX_WIDTH "4"
+#endif
+#ifndef PRINTF_INT8_HEX_WIDTH
+# define PRINTF_INT8_HEX_WIDTH "2"
+#endif
+
+#ifndef PRINTF_INT64_DEC_WIDTH
+# define PRINTF_INT64_DEC_WIDTH "20"
+#endif
+#ifndef PRINTF_INT32_DEC_WIDTH
+# define PRINTF_INT32_DEC_WIDTH "10"
+#endif
+#ifndef PRINTF_INT16_DEC_WIDTH
+# define PRINTF_INT16_DEC_WIDTH "5"
+#endif
+#ifndef PRINTF_INT8_DEC_WIDTH
+# define PRINTF_INT8_DEC_WIDTH "3"
+#endif
+
+/*
+ *  Ok, lets not worry about 128 bit integers for now.  Moore's law says
+ *  we don't need to worry about that until about 2040 at which point
+ *  we'll have bigger things to worry about.
+ */
+
+#ifdef stdint_int64_defined
+  typedef int64_t intmax_t;
+  typedef uint64_t uintmax_t;
+# define  INTMAX_MAX   INT64_MAX
+# define  INTMAX_MIN   INT64_MIN
+# define UINTMAX_MAX  UINT64_MAX
+# define UINTMAX_C(v) UINT64_C(v)
+# define  INTMAX_C(v)  INT64_C(v)
+# ifndef PRINTF_INTMAX_MODIFIER
+#   define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
+# endif
+# ifndef PRINTF_INTMAX_HEX_WIDTH
+#  define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
+# endif
+# ifndef PRINTF_INTMAX_DEC_WIDTH
+#  define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
+# endif
+#else
+  typedef int32_t intmax_t;
+  typedef uint32_t uintmax_t;
+# define  INTMAX_MAX   INT32_MAX
+# define UINTMAX_MAX  UINT32_MAX
+# define UINTMAX_C(v) UINT32_C(v)
+# define  INTMAX_C(v)  INT32_C(v)
+# ifndef PRINTF_INTMAX_MODIFIER
+#   define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER
+# endif
+# ifndef PRINTF_INTMAX_HEX_WIDTH
+#  define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH
+# endif
+# ifndef PRINTF_INTMAX_DEC_WIDTH
+#  define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH
+# endif
+#endif
+
+/*
+ *  Because this file currently only supports platforms which have
+ *  precise powers of 2 as bit sizes for the default integers, the
+ *  least definitions are all trivial.  Its possible that a future
+ *  version of this file could have different definitions.
+ */
+
+#ifndef stdint_least_defined
+  typedef   int8_t   int_least8_t;
+  typedef  uint8_t  uint_least8_t;
+  typedef  int16_t  int_least16_t;
+  typedef uint16_t uint_least16_t;
+  typedef  int32_t  int_least32_t;
+  typedef uint32_t uint_least32_t;
+# define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER
+# define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER
+# define  UINT_LEAST8_MAX  UINT8_MAX
+# define   INT_LEAST8_MAX   INT8_MAX
+# define UINT_LEAST16_MAX UINT16_MAX
+# define  INT_LEAST16_MAX  INT16_MAX
+# define UINT_LEAST32_MAX UINT32_MAX
+# define  INT_LEAST32_MAX  INT32_MAX
+# define   INT_LEAST8_MIN   INT8_MIN
+# define  INT_LEAST16_MIN  INT16_MIN
+# define  INT_LEAST32_MIN  INT32_MIN
+# ifdef stdint_int64_defined
+    typedef  int64_t  int_least64_t;
+    typedef uint64_t uint_least64_t;
+#   define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER
+#   define UINT_LEAST64_MAX UINT64_MAX
+#   define  INT_LEAST64_MAX  INT64_MAX
+#   define  INT_LEAST64_MIN  INT64_MIN
+# endif
+#endif
+#undef stdint_least_defined
+
+/*
+ *  The ANSI C committee pretending to know or specify anything about
+ *  performance is the epitome of misguided arrogance.  The mandate of
+ *  this file is to *ONLY* ever support that absolute minimum
+ *  definition of the fast integer types, for compatibility purposes.
+ *  No extensions, and no attempt to suggest what may or may not be a
+ *  faster integer type will ever be made in this file.  Developers are
+ *  warned to stay away from these types when using this or any other
+ *  stdint.h.
+ */
+
+typedef   int_least8_t   int_fast8_t;
+typedef  uint_least8_t  uint_fast8_t;
+typedef  int_least16_t  int_fast16_t;
+typedef uint_least16_t uint_fast16_t;
+typedef  int_least32_t  int_fast32_t;
+typedef uint_least32_t uint_fast32_t;
+#define  UINT_FAST8_MAX  UINT_LEAST8_MAX
+#define   INT_FAST8_MAX   INT_LEAST8_MAX
+#define UINT_FAST16_MAX UINT_LEAST16_MAX
+#define  INT_FAST16_MAX  INT_LEAST16_MAX
+#define UINT_FAST32_MAX UINT_LEAST32_MAX
+#define  INT_FAST32_MAX  INT_LEAST32_MAX
+#define   INT_FAST8_MIN   INT_LEAST8_MIN
+#define  INT_FAST16_MIN  INT_LEAST16_MIN
+#define  INT_FAST32_MIN  INT_LEAST32_MIN
+#ifdef stdint_int64_defined
+  typedef  int_least64_t  int_fast64_t;
+  typedef uint_least64_t uint_fast64_t;
+# define UINT_FAST64_MAX UINT_LEAST64_MAX
+# define  INT_FAST64_MAX  INT_LEAST64_MAX
+# define  INT_FAST64_MIN  INT_LEAST64_MIN
+#endif
+
+#undef stdint_int64_defined
+
+/*
+ *  Whatever piecemeal, per compiler thing we can do about the wchar_t
+ *  type limits.
+ */
+
+#if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__)
+# include <wchar.h>
+# ifndef WCHAR_MIN
+#  define WCHAR_MIN 0
+# endif
+# ifndef WCHAR_MAX
+#  define WCHAR_MAX ((wchar_t)-1)
+# endif
+#endif
+
+/*
+ *  Whatever piecemeal, per compiler/platform thing we can do about the
+ *  (u)intptr_t types and limits.
+ */
+
+#if (defined (_MSC_VER) && defined (_UINTPTR_T_DEFINED)) || defined (_UINTPTR_T)
+# define STDINT_H_UINTPTR_T_DEFINED
+#endif
+
+#ifndef STDINT_H_UINTPTR_T_DEFINED
+# if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (_WIN64) || defined (__ppc64__)
+#  define stdint_intptr_bits 64
+# elif defined (__WATCOMC__) || defined (__TURBOC__)
+#  if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
+#    define stdint_intptr_bits 16
+#  else
+#    define stdint_intptr_bits 32
+#  endif
+# elif defined (__i386__) || defined (_WIN32) || defined (WIN32) || defined (__ppc64__)
+#  define stdint_intptr_bits 32
+# elif defined (__INTEL_COMPILER)
+/* TODO -- what did Intel do about x86-64? */
+# else
+/* #error "This platform might not be supported yet" */
+# endif
+
+# ifdef stdint_intptr_bits
+#  define stdint_intptr_glue3_i(a,b,c)  a##b##c
+#  define stdint_intptr_glue3(a,b,c)    stdint_intptr_glue3_i(a,b,c)
+#  ifndef PRINTF_INTPTR_MODIFIER
+#    define PRINTF_INTPTR_MODIFIER      stdint_intptr_glue3(PRINTF_INT,stdint_intptr_bits,_MODIFIER)
+#  endif
+#  ifndef PTRDIFF_MAX
+#    define PTRDIFF_MAX                 stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
+#  endif
+#  ifndef PTRDIFF_MIN
+#    define PTRDIFF_MIN                 stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
+#  endif
+#  ifndef UINTPTR_MAX
+#    define UINTPTR_MAX                 stdint_intptr_glue3(UINT,stdint_intptr_bits,_MAX)
+#  endif
+#  ifndef INTPTR_MAX
+#    define INTPTR_MAX                  stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
+#  endif
+#  ifndef INTPTR_MIN
+#    define INTPTR_MIN                  stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
+#  endif
+#  ifndef INTPTR_C
+#    define INTPTR_C(x)                 stdint_intptr_glue3(INT,stdint_intptr_bits,_C)(x)
+#  endif
+#  ifndef UINTPTR_C
+#    define UINTPTR_C(x)                stdint_intptr_glue3(UINT,stdint_intptr_bits,_C)(x)
+#  endif
+  typedef stdint_intptr_glue3(uint,stdint_intptr_bits,_t) uintptr_t;
+  typedef stdint_intptr_glue3( int,stdint_intptr_bits,_t)  intptr_t;
+# else
+/* TODO -- This following is likely wrong for some platforms, and does
+   nothing for the definition of uintptr_t. */
+  typedef ptrdiff_t intptr_t;
+# endif
+# define STDINT_H_UINTPTR_T_DEFINED
+#endif
+
+/*
+ *  Assumes sig_atomic_t is signed and we have a 2s complement machine.
+ */
+
+#ifndef SIG_ATOMIC_MAX
+# define SIG_ATOMIC_MAX ((((sig_atomic_t) 1) << (sizeof (sig_atomic_t)*CHAR_BIT-1)) - 1)
+#endif
+
+#endif
+
+#if defined (__TEST_PSTDINT_FOR_CORRECTNESS)
+
+/*
+ *  Please compile with the maximum warning settings to make sure macros are not
+ *  defined more than once.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#define glue3_aux(x,y,z) x ## y ## z
+#define glue3(x,y,z) glue3_aux(x,y,z)
+
+#define DECLU(bits) glue3(uint,bits,_t) glue3(u,bits,) = glue3(UINT,bits,_C) (0);
+#define DECLI(bits) glue3(int,bits,_t) glue3(i,bits,) = glue3(INT,bits,_C) (0);
+
+#define DECL(us,bits) glue3(DECL,us,) (bits)
+
+#define TESTUMAX(bits) glue3(u,bits,) = ~glue3(u,bits,); if (glue3(UINT,bits,_MAX) != glue3(u,bits,)) printf ("Something wrong with UINT%d_MAX\n", bits)
+
+int main () {
+	DECL(I,8)
+	DECL(U,8)
+	DECL(I,16)
+	DECL(U,16)
+	DECL(I,32)
+	DECL(U,32)
+#ifdef INT64_MAX
+	DECL(I,64)
+	DECL(U,64)
+#endif
+	intmax_t imax = INTMAX_C(0);
+	uintmax_t umax = UINTMAX_C(0);
+	char str0[256], str1[256];
+
+	sprintf (str0, "%d %x\n", 0, ~0);
+
+	sprintf (str1, "%d %x\n",  i8, ~0);
+	if (0 != strcmp (str0, str1)) printf ("Something wrong with i8 : %s\n", str1);
+	sprintf (str1, "%u %x\n",  u8, ~0);
+	if (0 != strcmp (str0, str1)) printf ("Something wrong with u8 : %s\n", str1);
+	sprintf (str1, "%d %x\n",  i16, ~0);
+	if (0 != strcmp (str0, str1)) printf ("Something wrong with i16 : %s\n", str1);
+	sprintf (str1, "%u %x\n",  u16, ~0);
+	if (0 != strcmp (str0, str1)) printf ("Something wrong with u16 : %s\n", str1);
+	sprintf (str1, "%" PRINTF_INT32_MODIFIER "d %x\n",  i32, ~0);
+	if (0 != strcmp (str0, str1)) printf ("Something wrong with i32 : %s\n", str1);
+	sprintf (str1, "%" PRINTF_INT32_MODIFIER "u %x\n",  u32, ~0);
+	if (0 != strcmp (str0, str1)) printf ("Something wrong with u32 : %s\n", str1);
+#ifdef INT64_MAX
+	sprintf (str1, "%" PRINTF_INT64_MODIFIER "d %x\n",  i64, ~0);
+	if (0 != strcmp (str0, str1)) printf ("Something wrong with i64 : %s\n", str1);
+#endif
+	sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "d %x\n",  imax, ~0);
+	if (0 != strcmp (str0, str1)) printf ("Something wrong with imax : %s\n", str1);
+	sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "u %x\n",  umax, ~0);
+	if (0 != strcmp (str0, str1)) printf ("Something wrong with umax : %s\n", str1);
+
+	TESTUMAX(8);
+	TESTUMAX(16);
+	TESTUMAX(32);
+#ifdef INT64_MAX
+	TESTUMAX(64);
+#endif
+
+	return EXIT_SUCCESS;
+}
+
+#endif
diff --git a/abc-build/src/sat/msat/msatClause.c b/abc-build/src/sat/msat/msatClause.c
--- a/abc-build/src/sat/msat/msatClause.c
+++ b/abc-build/src/sat/msat/msatClause.c
@@ -294,7 +294,10 @@
 ***********************************************************************/
 float Msat_ClauseReadActivity( Msat_Clause_t * pC )
 {
-    return *((float *)(pC->pData + pC->nSize));
+    float f;
+
+    memcpy( &f, pC->pData + pC->nSize, sizeof (f));
+    return f;
 }
 
 /**Function*************************************************************
@@ -310,7 +313,7 @@
 ***********************************************************************/
 void Msat_ClauseWriteActivity( Msat_Clause_t * pC, float Num )
 {
-    *((float *)(pC->pData + pC->nSize)) = Num;
+    memcpy( pC->pData + pC->nSize, &Num, sizeof (Num) );
 }
 
 /**Function*************************************************************
diff --git a/abcBridge.cabal b/abcBridge.cabal
--- a/abcBridge.cabal
+++ b/abcBridge.cabal
@@ -1,5 +1,5 @@
 Name:               abcBridge
-Version:            0.12
+Version:            0.14
 Synopsis:           Bindings for ABC, A System for Sequential
                     Synthesis and Verification
 Description:        Bindings for ABC focused on creating And-Inverter
@@ -8,7 +8,7 @@
 License:            BSD3
 License-file:       LICENSE
 Author:             Galois Inc.
-Maintainer:         jhendrix@galois.com
+Maintainer:         jhendrix@galois.com, rdockins@galois.com
 Copyright:          (c) 2010-2015 Galois Inc.
 Category:           Data
 build-type:         Custom
@@ -86,8 +86,8 @@
 
 
   Build-depends:
-    base >= 4,
-    aig >= 0.2.1,
+    base == 4.*,
+    aig >= 0.2.3,
     containers,
     directory,
     vector
diff --git a/scripts/clean-abc.sh b/scripts/clean-abc.sh
--- a/scripts/clean-abc.sh
+++ b/scripts/clean-abc.sh
@@ -1,3 +1,3 @@
 #!/bin/sh
 rm -r abc-build
-rm galois-abcBridge.tar.bz2
+rm galois-abcBridge*.tar.bz2
diff --git a/scripts/lite-clean-abc.sh b/scripts/lite-clean-abc.sh
new file mode 100644
--- /dev/null
+++ b/scripts/lite-clean-abc.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+if [ -d abc-build ]; then
+  (cd abc-build; make clean)
+fi
diff --git a/scripts/setup-abc.sh b/scripts/setup-abc.sh
--- a/scripts/setup-abc.sh
+++ b/scripts/setup-abc.sh
@@ -3,46 +3,71 @@
 # bail out immediately if any command fails
 set -e
 
-ARCH="$1"
-OS="$2"
+echo "Setting up ABC tree for abcBridge version ${PACKAGE_VERSION:-undefined}..."
 
-SRC_TARBALL="https://bitbucket.org/rdockins/abc/get/galois-abcBridge.tar.bz2"
-LOCAL_TARBALL="galois-abcBridge.tar.bz2"
 
-echo "Setting up ABC tree for abcBridge version ${PACKAGE_VERSION}..."
+if [ -z "${PACKAGE_VERSION}" ]; then
+  if [ -d abc-build ]; then
+    echo ""
+    echo "Package version not defined; assuming compatible ABC sources are already present in directory abc-build"
+  else
+    echo ""
+    echo "Package version not defined.  Expected to find ABC sources in directory abc-build, but they are missing."
+    echo "Please manually check out or download ABC sources into directory 'abc-build'.  Alternately, execute 'cabal configure'"
+    echo "instead to automatically fetch the correct sources."
+    exit 1
+  fi
+else
+  LOCAL_TARBALL="galois-abcBridge-${PACKAGE_VERSION}.tar.bz2"
+  SRC_TARBALL="https://bitbucket.org/rdockins/abc/get/${LOCAL_TARBALL}"
+  SUCCESS=""
 
-# If the ABC source is not already fetched, download the galois-abcBridge
-# branch of the ABC project and unpack it in the "abc-build" subdirectory
-if [ ! -d abc-build ]; then
-  # Fetch the latest galois-abcBridge branch from BitBucket; use either curl or wget
-  # depending on which is installed
-  [ -e $LOCAL_TARBALL ] || curl -O $SRC_TARBALL || wget --no-check-certificate $SRC_TARBALL
+  # try at most twice to fetch sources...
+  for i in "one" "two"
+  do
+      # If the ABC source is not already fetched, download the galois-abcBridge
+      # branch of the ABC project and unpack it in the "abc-build" subdirectory
+      if [ ! -d abc-build ]; then
+	  # Fetch the latest galois-abcBridge branch from BitBucket; use either curl or wget
+	  # depending on which is installed
+	  [ -e $LOCAL_TARBALL ] || curl -O $SRC_TARBALL || wget --no-check-certificate $SRC_TARBALL
 
-  # Unpack into the abc-build subdirectory
-  # Note: some games are played to strip off the top-level directory name that
-  # is automatically assigned by BitBucket
-  mkdir -p abc-build && (cd abc-build; tar xfj "../$LOCAL_TARBALL" --strip-components=1)
-fi
+	  # Unpack into the abc-build subdirectory
+	  # Note: some games are played to strip off the top-level directory name that
+	  # is automatically assigned by BitBucket
+	  mkdir -p abc-build && (cd abc-build; tar xfj "../$LOCAL_TARBALL" --strip-components=1)
+      fi
 
-# Interrogate the expected version number of the ABC sources
-if [ -e abc-build/galois-abcBridge.version ]; then
-  ABC_VERSION=`cat abc-build/galois-abcBridge.version`
-else
-  ABC_VERSION="NONE"
-fi
+      # Interrogate the expected version number of the ABC sources
+      if [ -e abc-build/galois-abcBridge.version ]; then
+	  ABC_VERSION=`cat abc-build/galois-abcBridge.version`
+      else
+	  ABC_VERSION="NONE"
+      fi
 
-if [ $ABC_VERSION != $PACKAGE_VERSION ]; then
-  echo ""
-  echo "The ABC source version ${ABC_VERSION} does not match the abcBridge package version version ${PACKAGE_VERSION}."
-  echo ""
-  echo "This may cause problems with the build; it is recommended you cancel this build and check out matching ABC sources"
-  echo "into the abc-build directory and try again.  You can run scripts/clean_abc.sh to remove the current ABC sources;"
-  echo "this will cause latest development branch to be automatically downloaded on the next build."
-  echo ""
-  echo "Press [enter] to continue anyway, or press [^C] to abort (build will automatically abort in 15 seconds)."
-  read -t 15
+      if [ "$ABC_VERSION" != "$PACKAGE_VERSION" ]; then
+	  echo ""
+	  echo "The ABC source version $ABC_VERSION does not match the abcBridge package version $PACKAGE_VERSION."
+	  echo ""
+	  echo "Attempting to clean up and fetch fresh sources..."
+
+	  rm -r abc-build     || true
+	  rm "$LOCAL_TARBALL" || true
+      else
+	  echo "ABC sources found"
+	  SUCCESS="success"
+	  break
+      fi
+  done
+
+  if [ -z "${SUCCESS}" ]; then
+      echo ""
+      echo "Unable to fetch ABC sources. Giving up..."
+      exit 1
+  fi
 fi
 
+
 # Build a list of the files in the ABC subdirectory that we can feed into
 # the Cabal system so that "setup sdist" works correctly.  Use sed to filter out
 # compiled object files and libraries. Likewise, set up a list of directories
@@ -60,7 +85,6 @@
   touch abc-build/abc-sources.txt
   /usr/bin/find abc-build -type f | sed -e '/\/\.hg\//d' -e '/\.hgignore$/d' -e '/\.o$/d' -e '/\.a$/d' -e '/\.dll$/d' -e '/\.lib$/d' > abc-build/abc-sources.txt
 fi
-
 
 # Make sure the build scripts are executable
 chmod +x abc-build/depends.sh
diff --git a/src/Data/ABC/AIG.hs b/src/Data/ABC/AIG.hs
--- a/src/Data/ABC/AIG.hs
+++ b/src/Data/ABC/AIG.hs
@@ -1,12 +1,3 @@
-{-# LANGUAGE DoAndIfThenElse #-}
-{-# LANGUAGE EmptyDataDecls #-}
-{-# LANGUAGE FlexibleInstances #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-{-# LANGUAGE Rank2Types #-}
-{-# LANGUAGE ScopedTypeVariables #-}
-{-# LANGUAGE TypeFamilies #-}
-{-# LANGUAGE ViewPatterns #-}
-
 {- |
 Module      : Data.ABC.AIG
 Copyright   : Galois, Inc. 2010-2014
@@ -23,7 +14,15 @@
 > import qualified Data.ABC.AIG as AIG
 
 -}
-
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE DoAndIfThenElse #-}
+{-# LANGUAGE EmptyDataDecls #-}
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE Rank2Types #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE ViewPatterns #-}
 module Data.ABC.AIG
   ( AIG
   , newAIG
@@ -32,7 +31,6 @@
   , Lit
   , true
   , false
-  , writeToCNF
   , writeAIGManToCNFWithMapping
   , checkSat'
     -- * Re-exports
@@ -49,7 +47,9 @@
 
 import Foreign
 
+#if !MIN_VERSION_base(4,8,0)
 import Control.Applicative
+#endif
 import Control.Exception
 import Control.Monad
 import qualified Data.Vector.Storable as V
@@ -171,7 +171,13 @@
     Just True -> return (AIG.Sat (replicate ic False))
     Just False  -> return AIG.Unsat
     Nothing -> do
-      let params = proveParamsDefault { nItersMax'Prove_Params = 5 }
+      let params = proveParamsDefault
+                   { nItersMax'Prove_Params = 5
+                   -- Using rewriting seems to trigger a bug in some cases,
+                   -- so here we diable it.  It also seems to be faster on
+                   -- some examples to disable?
+                   , fUseRewriting'Prove_Params = False
+                   }
       with params $ \pParams -> do
         r <- abcNtkIvyProve pp (castPtr pParams)
         case r of
@@ -203,15 +209,15 @@
            m <- readIORef r
            case Map.lookup o m of
               Just t -> return t
-              _ -> memo o =<< go =<< litView o
+              _ -> memo o =<< go =<< litViewInner o
 
     -- NB: Pin down the AIG foreign pointer, even though we don't explicitly use it
     return $ (\l -> withAIGPtr g $ \_p -> objTerm l)
 
 -- Return a representation of how lit was constructed.
 -- NB: hold the AIG pointer to the graph to call this function...
-litView :: Lit s -> IO (LitView (Lit s))
-litView (Lit l) = do
+litViewInner :: Lit s -> IO (LitView (Lit s))
+litViewInner (Lit l) = do
   let c = abcObjIsComplement l
   let o = abcObjRegular l
   i <- abcObjId o
@@ -271,6 +277,15 @@
     withNetworkPtr a $ \p -> do
       ioWriteAiger p path True False False
 
+  writeCNF aig l path =
+    withNetworkPtr (AIG.Network aig [l]) $ \pNtk -> do
+      withAbcNtkToDar pNtk False False $ \pMan -> do
+        vars <- writeAIGManToCNFWithMapping pMan path
+        ciCount <- aigManCiNum pMan
+        forM [0..(ciCount - 1)] $ \i -> do
+          ci <- aigManCi pMan (fromIntegral i)
+          ((vars V.!) . fromIntegral) `fmap` (aigObjId ci)
+
   checkSat g l = do
     withNetworkPtr (AIG.Network g [l]) $ \p ->
       alloca $ \pp ->
@@ -279,6 +294,8 @@
           (abcNtkDelete =<< peek pp)
           (checkSat' pp)
 
+  litView g l = withAIGPtr g $ \_ -> litViewInner l
+
   abstractEvaluateAIG = memoFoldAIG
 
   cec x y = do
@@ -400,18 +417,6 @@
   bracket (abcNtkToDar ntk exors registers)
           aigManStop
           h
-
--- | Write a CNF file to the given path.
--- Returns vector mapping combinational inputs to CNF Variable numbers.
-writeToCNF :: AIG s -> Lit s -> FilePath -> IO [Int]
-writeToCNF aig l path =
-  withNetworkPtr (AIG.Network aig [l]) $ \pNtk -> do
-    withAbcNtkToDar pNtk False False $ \pMan -> do
-      vars <- writeAIGManToCNFWithMapping pMan path
-      ciCount <- aigManCiNum pMan
-      forM [0..(ciCount - 1)] $ \i -> do
-        ci <- aigManCi pMan (fromIntegral i)
-        ((vars V.!) . fromIntegral) `fmap` (aigObjId ci)
 
 -- | Convert the network referred to by an AIG manager into CNF format
 -- and write to a file, returning a mapping from ABC object IDs to CNF
diff --git a/src/Data/ABC/GIA.hs b/src/Data/ABC/GIA.hs
--- a/src/Data/ABC/GIA.hs
+++ b/src/Data/ABC/GIA.hs
@@ -1,10 +1,3 @@
-{-# LANGUAGE DoAndIfThenElse #-}
-{-# LANGUAGE FlexibleInstances #-}
-{-# LANGUAGE Rank2Types #-}
-{-# LANGUAGE TypeFamilies #-}
-{-# LANGUAGE ViewPatterns #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-
 {- |
 Module      : Data.ABC.GIA
 Copyright   : Galois, Inc. 2010-2014
@@ -24,9 +17,14 @@
 Verification and Synthesis Research Center's website.
 <http://bvsrc.org/research.html#AIG%20Package>  It is a more memory
 efficient method of storing AIG graphs.
-
-
 -}
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE DoAndIfThenElse #-}
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE Rank2Types #-}
+{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE ViewPatterns #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
 module Data.ABC.GIA
     ( GIA
     , newGIA
@@ -37,11 +35,9 @@
     , proxy
       -- * Inspection
     , AIG.LitView(..)
-    , litView
       -- * File IO
     , readAiger
     , writeAigerWithLatches
-    , writeCNF
       -- * QBF
     , check_exists_forall
       -- * Re-exports
@@ -56,16 +52,17 @@
 
 import Prelude hiding (and, not, or)
 import qualified Prelude
-
-
 import Control.Exception hiding (evaluate)
 import Control.Monad
-import Control.Applicative
 import qualified Data.Map as Map
 import           Data.IORef
 import qualified Data.AIG as AIG
 import           Data.AIG.Interface (LitView(..))
 import qualified Data.AIG.Trace as Tr
+#if !MIN_VERSION_base(4,8,0)
+import Data.Functor
+import Data.Traversable (traverse)
+#endif
 
 import qualified Data.Vector.Storable as SV
 import qualified Data.Vector.Unboxed as V
@@ -199,10 +196,22 @@
 
   abstractEvaluateAIG (GIA fp) = litEvaluator fp
 
+  litView g (L l) =
+    withGIAPtr g $ \p ->
+      traverse (\x -> L <$> giaObjToLit p x) =<< litViewInner =<< giaObjFromLit p l
+
   writeAiger path g = do
     withNetworkPtr g $ \p -> do
       giaAigerWrite p path False False
 
+  writeCNF ntk l f = do
+    giaNetworkAsAIGMan (AIG.Network ntk [l]) $ \pMan -> do
+      vars <- AIG.writeAIGManToCNFWithMapping pMan f
+      ciCount <- aigManCiNum pMan
+      forM [0..(ciCount - 1)] $ \i -> do
+        ci <- aigManCi pMan (fromIntegral i)
+        ((vars SV.!) . fromIntegral) `fmap` (aigObjId ci)
+
   checkSat ntk l = do
     giaNetworkAsAIGMan (AIG.Network ntk [l]) $ \pMan -> do
     -- Allocate a pointer to an ABC network.
@@ -212,34 +221,7 @@
         (abcNtkDelete =<< peek pp)
         (AIG.checkSat' pp)
 
-  cec gx gy = do
-    withNetworkPtr gx $ \x -> do
-    withNetworkPtr gy $ \y -> do
-
-    input_count_x <- giaManCiNum x
-    input_count_y <- giaManCiNum y
-
-    output_count_x <- vecIntSize =<< giaManCos x
-    output_count_y <- vecIntSize =<< giaManCos y
-
-    assert (input_count_x == input_count_y) $ do
-    assert (output_count_x == output_count_y) $ do
-
-    bracket (giaManMiter x y 0 True False False False) giaManStop $ \m -> do
-    r <- cecManVerify m cecManCecDefaultParams
-    case r of
-      1 -> return AIG.Valid
-      0 -> do
-        pCex <- giaManCexComb m
-        when (pCex == nullPtr) $ error "cec: Generated counter-example was invalid"
-        cex <- peekAbcCex pCex
-        let r2 = pData'inputs'Abc_Cex cex
-        case r2 of
-          [] -> error "cec: Generated counter-example had no inputs"
-          [bs] -> return (AIG.Invalid bs)
-          _ -> error "cec: Generated counter example has too many frames"
-      -1 -> fail "cec: failed"
-      _  -> error "cec: Unrecognized return code"
+  cec gx gy = withTwoNetworkPtrs gx gy $ giaRunCEC
 
   evaluator g inputs = do
     withGIAPtr g $ \p -> do
@@ -280,6 +262,26 @@
         c = giaLitIsCompl l
         inRange = 0 <= i && i < V.length v
 
+
+-- | Run an inner computation with two networks, while ensuring that
+--   the storage for the two networks is distinct.  We do this by
+--   copying on of the two networks if they are from the same
+--   underlying physical ABC network.
+withTwoNetworkPtrs :: AIG.Network Lit GIA
+                   -> AIG.Network Lit GIA
+                   -> (Gia_Man_t -> Gia_Man_t -> IO a)
+                   -> IO a
+withTwoNetworkPtrs g1@(AIG.Network ntk1 _) g2@(AIG.Network ntk2 _) m =
+  withGIAPtr ntk1 $ \p1 ->
+    withGIAPtr ntk2 $ \p2 ->
+      if p1 == p2
+         then withNetworkPtr_Copy g1 $ \x ->
+              withNetworkPtr_Munge g2 $ \y ->
+              m x y
+         else withNetworkPtr_Munge g1 $ \x ->
+              withNetworkPtr_Munge g2 $ \y ->
+              m x y
+
 -- | Run computation with a Gia_Man_t containing the given network.
 withNetworkPtr :: AIG.Network Lit GIA -> (Gia_Man_t -> IO a) -> IO a
 withNetworkPtr = withNetworkPtr_Munge
@@ -291,8 +293,8 @@
 -- This is a safer method for implementing withNetworkPtr; it copies the
 -- entire graph before adding the required COs and disposes of the copied
 -- graph afterwards.  Obviously, this has substantial memory usage implications.
-_withNetworkPtr_Copy :: AIG.Network Lit GIA -> (Gia_Man_t -> IO a) -> IO a
-_withNetworkPtr_Copy (AIG.Network ntk out) m = do
+withNetworkPtr_Copy :: AIG.Network Lit GIA -> (Gia_Man_t -> IO a) -> IO a
+withNetworkPtr_Copy (AIG.Network ntk out) m = do
   withGIAPtr ntk $ \p -> do
      ncos <- vecIntSize =<< giaManCos p
      assert( ncos == 0 ) $ do
@@ -348,6 +350,38 @@
       -- Run computation.
       (m p)
 
+
+giaRunCEC :: Gia_Man_t
+          -> Gia_Man_t
+          -> IO AIG.VerifyResult
+giaRunCEC x y = do
+    input_count_x <- giaManCiNum x
+    input_count_y <- giaManCiNum y
+
+    output_count_x <- vecIntSize =<< giaManCos x
+    output_count_y <- vecIntSize =<< giaManCos y
+
+    assert (input_count_x == input_count_y) $ do
+    assert (output_count_x == output_count_y) $ do
+
+    bracket (giaManMiter x y 0 True False False False) giaManStop $ \m -> do
+    r <- cecManVerify m cecManCecDefaultParams
+    case r of
+      1 -> return AIG.Valid
+      0 -> do
+        pCex <- giaManCexComb m
+        when (pCex == nullPtr) $ error "cec: Generated counter-example was invalid"
+        cex <- peekAbcCex pCex
+        let r2 = pData'inputs'Abc_Cex cex
+        case r2 of
+          [] -> error "cec: Generated counter-example had no inputs"
+          [bs] -> return (AIG.Invalid bs)
+          _ -> error "cec: Generated counter example has too many frames"
+      -1 -> fail "cec: failed"
+      _  -> error "cec: Unrecognized return code"
+
+
+
 -- | Run a computation with an AIG man created from a GIA netowrk.
 giaNetworkAsAIGMan :: AIG.Network Lit GIA
                    -> (Aig_Man_t -> IO a)
@@ -367,8 +401,8 @@
   c0 <- giaObjFaninC0 o
   return $ giaLitNotCond (giaVarLit v0) c0
 
-fanin1Lit :: Gia_Obj_t -> GiaVar -> IO GiaLit
-fanin1Lit o v = do
+_fanin1Lit :: Gia_Obj_t -> GiaVar -> IO GiaLit
+_fanin1Lit o v = do
   v0 <- giaObjFaninId1 o v
   c0 <- giaObjFaninC1 o
   return $ giaLitNotCond (giaVarLit v0) c0
@@ -386,52 +420,34 @@
         case Map.lookup o m0 of
           Just t -> return t
           _ -> do
-            let c = giaIsComplement o
-            let o' = if c then giaRegular o else o
-            isTerm <- giaObjIsTerm o'
-            d0 <- giaObjDiff0 o'
-            case () of
-              _ | Prelude.not isTerm && d0 /= gia_none -> do -- And gate
-                    x <- objTerm =<< giaObjChild0 o'
-                    y <- objTerm =<< giaObjChild1 o'
-                    let and_ = if c then NotAnd else And
-                    memo r o =<< viewFn (and_ x y)
-                | isTerm && d0 /= gia_none -> do -- Primary output
-                    -- This is a primary output, so we just get the lit
-                    -- for the gate that it is attached to.
+            memo r o =<< viewFn =<< traverse objTerm =<< litViewInner o
 
-                    -- FIXME? is this the right thing to do WRT complement?
-                    objTerm =<< giaObjChild0 o'
-                | Prelude.not isTerm -> do -- Constant value
-                    memo r o =<< viewFn (if c then TrueLit else FalseLit)
-                | otherwise -> do -- Primary input
-                    memo r o =<< viewFn . (if c then NotInput else Input) . fromIntegral
-                              =<< giaObjDiff1 o'
   return $ (\(L l) -> withForeignPtr fp $ \p -> objTerm =<< giaObjFromLit p l)
 
 
--- | Return a representation of how lit was constructed.
-litView :: GIA s -> Lit s -> IO (LitView (Lit s))
-litView g (L l)
-  | l == giaManConst0Lit = return FalseLit
-  | l == giaManConst1Lit = return TrueLit
-  | otherwise = do
-    let c = giaLitIsCompl l
-    let v = giaLitVar l
-    withGIAPtr g $ \p -> do
-    o <- giaManObj p v
-    t <- giaObjIsTerm o
-    d0 <- giaObjDiff0 o
-    if t && (d0 == gia_none) then do
-      idx <- fromIntegral <$> giaObjDiff1 o
-      return $ if c then NotInput idx else Input idx
-    else if t then do
-      l0 <- L <$> fanin0Lit o v
-      l1 <- L <$> fanin1Lit o v
-      return $ if c then NotAnd l0 l1 else And l0 l1
-    else
-      error $ "Invalid literal"
+{-# INLINE litViewInner #-}
+litViewInner :: Gia_Obj_t -> IO (LitView Gia_Obj_t)
+litViewInner o = do
+   let c = giaIsComplement o
+   let o' = if c then giaRegular o else o
+   isTerm <- giaObjIsTerm o'
+   d0 <- giaObjDiff0 o'
+   case () of
+      _ | Prelude.not isTerm && d0 /= gia_none -> do -- And gate
+            x <- giaObjChild0 o'
+            y <- giaObjChild1 o'
+            let and_ = if c then NotAnd else And
+            return $ and_ x y
+        | isTerm && d0 /= gia_none -> do -- Primary output
+            -- This is a primary output, so we just get the lit
+            -- for the gate that it is attached to.
 
+            -- FIXME? is this the right thing to do WRT complement?
+            litViewInner =<< giaObjChild0 o'
+        | Prelude.not isTerm -> do -- Constant value
+            return $ if c then TrueLit else FalseLit
+        | otherwise -> do -- Primary input
+            (if c then NotInput else Input) . fromIntegral <$> giaObjDiff1 o'
 
 -- | Allocate a vec int array from Boolean list.
 withBoolAsVecInt :: [Bool]
@@ -456,18 +472,6 @@
       1 -> return True
       _ -> fail $ "getVecAsBool given bad value " ++ show e
 
--- | Write a CNF file to the given path.
---   Returns vector mapping combinational inputs to CNF Variable numbers.
-writeCNF :: GIA s -> Lit s -> FilePath -> IO [Int]
-writeCNF ntk l f = do
-  giaNetworkAsAIGMan (AIG.Network ntk [l]) $ \pMan -> do
-    vars <- AIG.writeAIGManToCNFWithMapping pMan f
-    ciCount <- aigManCiNum pMan
-    forM [0..(ciCount - 1)] $ \i -> do
-      ci <- aigManCi pMan (fromIntegral i)
-      ((vars SV.!) . fromIntegral) `fmap` (aigObjId ci)
-
-data PartialSatResult
 -- | Check a formula of the form Ex.Ay p(x,y)@.
 -- This function takes a network where input variables are used to
 -- represent both the existentially and the universally quantified variables.
diff --git a/src/Data/ABC/Internal/ABCGlobal.chs b/src/Data/ABC/Internal/ABCGlobal.chs
--- a/src/Data/ABC/Internal/ABCGlobal.chs
+++ b/src/Data/ABC/Internal/ABCGlobal.chs
@@ -1,8 +1,3 @@
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE EmptyDataDecls #-}
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# OPTIONS_GHC -fno-warn-unused-matches #-}
-
 {- |
 Module      : Data.ABC.Internal.ABCGlobal
 Copyright   : (c) Galois, Inc. 2010
@@ -14,9 +9,12 @@
 /Incomplete./  Binding of @misc\/util\/abc_global.h@ which contains
 miscellaneous functions for ABC, including a counterexample datastructure
 and error handling mechanisms.
-
 -}
-
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE EmptyDataDecls #-}
+{-# LANGUAGE DeriveDataTypeable #-}
+{-# OPTIONS_GHC -fno-warn-unused-imports #-}
+{-# OPTIONS_GHC -fno-warn-unused-matches #-}
 module Data.ABC.Internal.ABCGlobal (
     -- * Counterexamples
       Abc_Cex_t_(..)
@@ -28,9 +26,9 @@
 #include "abc_global.h"
 #include "abcbridge.h"
 
-import Data.Word
-import Control.Applicative
 import Control.Exception (assert)
+import Data.Functor ((<$>))
+import Data.Word
 import Foreign
 import Foreign.C
 
diff --git a/src/Data/ABC/Internal/AIG.chs b/src/Data/ABC/Internal/AIG.chs
--- a/src/Data/ABC/Internal/AIG.chs
+++ b/src/Data/ABC/Internal/AIG.chs
@@ -1,6 +1,3 @@
-{-# LANGUAGE ForeignFunctionInterface, EmptyDataDecls #-}
-{-# OPTIONS_GHC -fno-warn-unused-matches #-}
-
 {- |
 Module      : Data.ABC.Internal.AIG
 Copyright   : Galois, Inc. 2010
@@ -14,9 +11,10 @@
 "Data.ABC.Internal.ABC") which is used in internal versions
 (@base\/abci\/abc.c@) 8D, 8 and occasionally for 9 (during which the GIA
 is temporarily converted into an AIG for some processing.)
-
 -}
-
+{-# LANGUAGE EmptyDataDecls #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# OPTIONS_GHC -fno-warn-unused-matches #-}
 module Data.ABC.Internal.AIG (
     -- * Types
     -- ** Enums
@@ -54,7 +52,6 @@
 #include "aig.h"
 #include "abcbridge.h"
 
-import Control.Applicative
 import Foreign
 import Foreign.C
 
@@ -102,7 +99,7 @@
   vecPtrSize =<< {#get Aig_Man_t->vObjs #} man
 
 aigManConst0 :: Aig_Man_t -> IO Aig_Obj_t
-aigManConst0 m = aigNot <$> aigManConst1 m
+aigManConst0 m = aigNot `fmap` aigManConst1 m
 
 aigManConst1 :: Aig_Man_t -> IO Aig_Obj_t
 aigManConst1 = {#get Aig_Man_t->pConst1 #}
diff --git a/src/Data/ABC/Internal/CEC.chs b/src/Data/ABC/Internal/CEC.chs
--- a/src/Data/ABC/Internal/CEC.chs
+++ b/src/Data/ABC/Internal/CEC.chs
@@ -1,7 +1,3 @@
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE EmptyDataDecls #-}
-{-# OPTIONS_GHC -fno-warn-unused-matches #-}
-
 {- |
 Module      : Data.ABC.Internal.CEC
 Copyright   : Galois, Inc. 2010-2014
@@ -14,7 +10,10 @@
 equivalence checking of scalable and-inverter graphs (GIA).
 
 -}
-
+{-# LANGUAGE EmptyDataDecls #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# OPTIONS_GHC -fno-warn-unused-imports #-}
+{-# OPTIONS_GHC -fno-warn-unused-matches #-}
 module Data.ABC.Internal.CEC (
     -- * Types
     -- ** Storable types
@@ -99,6 +98,7 @@
     , nTimeLimit'Cec_ParCec :: Int    -- ^ the runtime limit in seconds (added prefix @n@)
     , fUseSmartCnf'Cec_ParCec :: Bool -- ^ use smart CNF computation
     , fRewriting'Cec_ParCec :: Bool   -- ^ enables AIG rewriting
+    , fNaive'Cec_ParCec :: Bool       -- ^ perform naive SAT-based checking
     , fVeryVerbose'Cec_ParCec :: Bool -- ^ very verbose stats
     , fVerbose'Cec_ParCec :: Bool     -- ^ verbose stats
     , iOutFail'Cec_ParCec :: Int      -- ^ the number of failed output
@@ -112,6 +112,7 @@
         <*> fmap fromIntegral ({#get Cec_ParCec_t->TimeLimit #} p)
         <*> fmap toBool ({#get Cec_ParCec_t->fUseSmartCnf #} p)
         <*> fmap toBool ({#get Cec_ParCec_t->fRewriting #} p)
+        <*> fmap toBool ({#get Cec_ParCec_t->fNaive #} p)
         <*> fmap toBool ({#get Cec_ParCec_t->fVeryVerbose #} p)
         <*> fmap toBool ({#get Cec_ParCec_t->fVerbose #} p)
         <*> fmap fromIntegral ({#get Cec_ParCec_t->iOutFail #} p)
@@ -120,6 +121,7 @@
         {#set Cec_ParCec_t.TimeLimit #}     p (fromIntegral $ nTimeLimit'Cec_ParCec x)
         {#set Cec_ParCec_t.fUseSmartCnf #}  p (fromBool $ fUseSmartCnf'Cec_ParCec x)
         {#set Cec_ParCec_t.fRewriting #}    p (fromBool $ fRewriting'Cec_ParCec x)
+        {#set Cec_ParCec_t.fNaive #}        p (fromBool $ fNaive'Cec_ParCec x)
         {#set Cec_ParCec_t.fVeryVerbose #}  p (fromBool $ fVeryVerbose'Cec_ParCec x)
         {#set Cec_ParCec_t.fVerbose #}      p (fromBool $ fVerbose'Cec_ParCec x)
         {#set Cec_ParCec_t.iOutFail #}      p (fromIntegral $ iOutFail'Cec_ParCec x)
diff --git a/src/Data/ABC/Internal/FRAIG.chs b/src/Data/ABC/Internal/FRAIG.chs
--- a/src/Data/ABC/Internal/FRAIG.chs
+++ b/src/Data/ABC/Internal/FRAIG.chs
@@ -1,7 +1,3 @@
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE EmptyDataDecls #-}
-{-# OPTIONS_GHC -fno-warn-unused-matches #-}
-
 {- |
 Module      : Data.ABC.Internal.FRAIG
 Copyright   : Galois, Inc. 2010-2014
@@ -14,13 +10,16 @@
 process of generating functionally reduced AIGs.  Fraiging is the
 special sauce that makes ABC outperform many vanilla SAT solvers.
 -}
-
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE EmptyDataDecls #-}
+{-# OPTIONS_GHC -fno-warn-unused-imports #-}
+{-# OPTIONS_GHC -fno-warn-unused-matches #-}
 module Data.ABC.Internal.FRAIG
     ( Prove_Params_t_(..)
     , proveParamsDefault
     ) where
 
-import Control.Applicative
+import Control.Applicative ((<$>), (<*>))
 import Control.Monad
 import Foreign
 import Foreign.C
diff --git a/src/Data/ABC/Internal/GIA.chs b/src/Data/ABC/Internal/GIA.chs
--- a/src/Data/ABC/Internal/GIA.chs
+++ b/src/Data/ABC/Internal/GIA.chs
@@ -1,10 +1,3 @@
-{-# LANGUAGE EmptyDataDecls #-}
-{-# LANGUAGE FlexibleInstances #-}
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-{-# LANGUAGE TypeSynonymInstances #-}
-{-# OPTIONS_GHC -fno-warn-unused-matches #-}
-
 {- |
 Module      : Data.ABC.Internal.GIA
 Copyright   : Galois, Inc. 2010-2014
@@ -20,9 +13,14 @@
 not been officially released yet, and can be identified by the
 prefix of an ampersand, as in @&cec@, in the interactive ABC
 interface.
-
 -}
-
+{-# LANGUAGE EmptyDataDecls #-}
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE TypeSynonymInstances #-}
+{-# OPTIONS_GHC -fno-warn-unused-imports #-}
+{-# OPTIONS_GHC -fno-warn-unused-matches #-}
 module Data.ABC.Internal.GIA (
       Gia_Man_t
     , Gia_Man_t_
@@ -114,7 +112,7 @@
     , clearGiaObj
     ) where
 
-import Control.Applicative
+import Control.Applicative ((<$>), (<*>))
 import Control.Exception
 import Control.Monad
 import Foreign hiding (void)
diff --git a/tests/Tests/Basic.hs b/tests/Tests/Basic.hs
--- a/tests/Tests/Basic.hs
+++ b/tests/Tests/Basic.hs
@@ -1,22 +1,24 @@
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE PatternGuards #-}
 module Tests.Basic
   ( basic_tests
   ) where
 
+#if !MIN_VERSION_base(4,8,0)
 import Control.Applicative
+#endif
 import Control.Exception
 import Control.Monad
 import System.Directory
 import System.IO
 
 import Test.Tasty
-import Test.Tasty.HUnit
+import Test.Tasty.HUnit as HU
 import Test.Tasty.QuickCheck
-import Test.QuickCheck
 
 import qualified Data.ABC as ABC
 import qualified Data.AIG.Trace as Tr
 
-
 tryIO :: IO a -> IO (Either IOException a)
 tryIO = try
 
@@ -177,6 +179,28 @@
       z <- ABC.evaluate (ABC.Network g (ABC.bvToList y)) inputs
 
       assertEqual "aiger_eval" outputs z
+
+  , testCase "lit_view" $ do
+       ABC.SomeGraph g <- ABC.newGraph proxy
+       i  <- ABC.newInput g
+       lv <- ABC.litView g i
+       x  <- ABC.newInput g
+       xv <- ABC.litView g x
+       o  <- ABC.and g i x
+       lo <- ABC.litView g o
+
+       case lv of
+         ABC.Input 0 -> return ()
+         _ -> fail "expected input 0"
+
+       case xv of
+         ABC.Input 1 -> return ()
+         _ -> fail "expected input 1"
+
+       case lo of
+         ABC.And a1 a2
+           | a1 ABC.=== i, a2 ABC.=== x -> return ()
+         _ -> fail "expected and literal"
   ]
 
 cecNetwork :: ABC.IsAIG l g => ABC.Proxy l g -> IO (ABC.Network l g)
diff --git a/tests/Tests/Operations.hs b/tests/Tests/Operations.hs
--- a/tests/Tests/Operations.hs
+++ b/tests/Tests/Operations.hs
@@ -1,13 +1,20 @@
+{-# LANGUAGE CPP #-}
 {-# LANGUAGE Rank2Types #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+
 module Tests.Operations
   ( op_tests
   ) where
 
 import qualified Data.AIG as AIG
 import Test.Tasty
-import Test.Tasty.QuickCheck
 import Test.QuickCheck
+import Test.Tasty.QuickCheck
 
+#if MIN_VERSION_base(4,8,0)
+import qualified Data.Bits as Bits
+#endif
+
 bv :: AIG.IsAIG l g => g s -> Int -> Integer -> AIG.BV (l s)
 bv = AIG.bvFromInteger
 
@@ -24,9 +31,86 @@
     let w = 10
     AIG.SomeGraph g <- AIG.newGraph proxy
     z <- bv_op g (bv g w u) (bv g w v)
-    let expected = (c_op u v) `mod` (2^w)
+    let expected = (c_op (u `mod` (2^w)) (v `mod` (2^w))) `mod` (2^w)
     return $ Just expected == AIG.asUnsigned g z
 
+unary_test :: String
+           -> AIG.Proxy l g
+            -- ^ Proxy
+         -> (forall s . g s -> AIG.BV (l s) -> IO (AIG.BV (l s)))
+            -- ^ Bitvector operation
+         -> (Integer -> Integer)
+            -- ^ Concrete op
+         -> TestTree
+unary_test nm proxy@(AIG.Proxy f) bv_op c_op = f $
+  testProperty nm $ \u -> ioProperty $ do
+    let w = 10
+    AIG.SomeGraph g <- AIG.newGraph proxy
+    z <- bv_op g (bv g w u)
+    let expected = (c_op (u `mod` (2^w))) `mod` (2^w)
+    return $ Just expected == AIG.asUnsigned g z
+
+-- reference implementations of lg2 and lg2_up
+lg2 :: Integer -> Integer
+lg2 = go 0
+ where go i x
+         | x <= 0    = -1
+         | x == 1    = i
+         | otherwise = go (i+1) (x `div` 2)
+
+lg2_up :: Int -> Integer -> Integer
+lg2_up w 0 = toInteger w
+lg2_up _ x = lg2 (x-1) + 1
+
+
+test_lg2_down :: AIG.Proxy l g
+            -- ^ Proxy
+         -> TestTree
+test_lg2_down proxy@(AIG.Proxy f) = f $
+  testProperty "test_lg2_down" $ \(w0::Int) u0 -> ioProperty $ do
+    let w = ((abs w0) + 1)
+    let u' = (abs u0)
+    AIG.SomeGraph g <- AIG.newGraph proxy
+    z <- AIG.logBase2_down g (bv g w u')
+    let expected = (lg2 (u' `mod` (2^w))) `mod` (2^w)
+    return $ Just expected == AIG.asUnsigned g z
+
+test_lg2_up :: AIG.Proxy l g
+            -- ^ Proxy
+         -> TestTree
+test_lg2_up proxy@(AIG.Proxy f) = f $
+  testProperty "test_lg2_up" $ \(w0::Int) u0 -> ioProperty $ do
+    let w = ((abs w0) + 1)
+    let u' = (abs u0)
+    AIG.SomeGraph g <- AIG.newGraph proxy
+    z <- AIG.logBase2_up g (bv g w u')
+    let expected = (lg2_up w (u' `mod` (2^w))) `mod` (2^w)
+    return $ Just expected == AIG.asUnsigned g z
+
+#if MIN_VERSION_base(4,8,0)
+test_clz :: AIG.Proxy l g
+            -- ^ Proxy
+         -> TestTree
+test_clz proxy@(AIG.Proxy f) = f $
+  testProperty "test_clz" $ \(u::Int) -> ioProperty $ do
+    let w = Bits.finiteBitSize u
+    AIG.SomeGraph g <- AIG.newGraph proxy
+    z <- AIG.countLeadingZeros g (bv g w (toInteger u))
+    let expected = toInteger $ Bits.countLeadingZeros u
+    return $ Just expected == AIG.asUnsigned g z
+
+test_ctz :: AIG.Proxy l g
+            -- ^ Proxy
+         -> TestTree
+test_ctz proxy@(AIG.Proxy f) = f $
+  testProperty "test_ctz" $ \(u::Int) -> ioProperty $ do
+    let w = Bits.finiteBitSize u
+    AIG.SomeGraph g <- AIG.newGraph proxy
+    z <- AIG.countTrailingZeros g (bv g w (toInteger u))
+    let expected = toInteger $ Bits.countTrailingZeros u
+    return $ Just expected == AIG.asUnsigned g z
+#endif
+
 op_tests :: AIG.Proxy l g -> [TestTree]
 op_tests proxy@(AIG.Proxy f) = f $
   [ testProperty "test_bv" $ \u -> ioProperty $ do
@@ -38,10 +122,11 @@
   , bin_test "test_add" proxy AIG.add (+)
   , bin_test "test_sub" proxy AIG.sub (-)
   , bin_test "test_mul" proxy AIG.mul (*)
-  , testProperty "test_neg" $ \u -> ioProperty $ do
-      let w = 10
-      AIG.SomeGraph g <- AIG.newGraph proxy
-      z <- AIG.neg g (bv g w u)
-      let expected = (negate u) `mod` (2^w)
-      return $ Just expected == AIG.asUnsigned g z
+  , unary_test "test_neg" proxy AIG.neg negate
+  , test_lg2_down proxy
+  , test_lg2_up proxy
+#if MIN_VERSION_base(4,8,0)
+  , test_clz proxy
+  , test_ctz proxy
+#endif
   ]
diff --git a/tests/Tests/QBF.hs b/tests/Tests/QBF.hs
--- a/tests/Tests/QBF.hs
+++ b/tests/Tests/QBF.hs
@@ -19,6 +19,7 @@
       case r of
         ABC.Sat{} -> fail "abc returned sat"
         ABC.Unsat{} -> return ()
+        ABC.SatUnknown -> fail "abc returned unknown"
   , testCase "test_qbf_or" $ do
       ABC.SomeGraph g <- GIA.newGIA
       i0 <- ABC.newInput g
