# Class: com.pnfsoftware.jeb.core.units.code.asm.cfg.CFGUtil

Static utility routines for control flow graphs.

## Constructor: CFGUtil


## Static Method: compare
- parameter: `cfg1`, type: `com.pnfsoftware.jeb.core.units.code.asm.cfg.CFG<T>`
- parameter: `cfg2`, type: `com.pnfsoftware.jeb.core.units.code.asm.cfg.CFG<T>`
- return type: `boolean`

Description: Basic CFG comparison. Expect same flags, same addresses, same blocks, same instruction in blocks. What is not checked: DFA data \(N/A\), flow/edges information \(theoretically equal if comparison succeeds since flow information is derived from CFG flags \+ instructions\).
parameter: T: 
parameter: cfg1: first CFG
parameter: cfg2: second CFG
return: true if both CFGs are equals, per the above definition

## Static Method: compare
- parameter: `failmode`, type: `int`
- parameter: `comparator`, type: `java.util.Comparator<T>`
- parameter: `cfg1`, type: `com.pnfsoftware.jeb.core.units.code.asm.cfg.CFG<T>`
- parameter: `cfg2`, type: `com.pnfsoftware.jeb.core.units.code.asm.cfg.CFG<T>`
- return type: `boolean`

Description: Basic CFG comparison. Expect same flags, same addresses, same blocks, same instruction in blocks. What is not checked: DFA data \(N/A\), flow/edges information \(theoretically equal if comparison succeeds since flow information is derived from CFG flags \+ instructions\).
parameter: T: 
parameter: failmode: 0=normal failure \(no log, return false\)
            1=normal failure with log, return false
            2=throw a [RuntimeException](RuntimeException) with message
parameter: comparator: custom instruction comparator \(optional\)
parameter: cfg1: first CFG
parameter: cfg2: second CFG
return: true if both CFGs are equals, per the above definition

## Static Method: duplicateShallow
- parameter: `cfg`, type: `com.pnfsoftware.jeb.core.units.code.asm.cfg.CFG<T>`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.cfg.CFG<T>`

Description: Shallow duplication of a CFG. The duplicated CFG references the instructions of the original CFG.
parameter: cfg: original CFG
return: a duplicated CFG \- instructions are NOT duplicated

## Static Method: getReachableBlocks
- parameter: `cfg`, type: `com.pnfsoftware.jeb.core.units.code.asm.cfg.CFG<T>`
- return type: `java.util.Collection<com.pnfsoftware.jeb.core.units.code.asm.cfg.BasicBlock<T>>`

Description: Collect the list of all blocks reachable from the entry point.
parameter: T: 
parameter: cfg: 
return: collection of blocks

## Static Method: removeUnreachableBlocks
- parameter: `cfg`, type: `com.pnfsoftware.jeb.core.units.code.asm.cfg.CFG<T>`
- return type: `int`

Description: Remove all blocks not reachable from the entry\-point. 

 If the CFG is composed of [IResizableInstruction](IResizableInstruction), instruction sizes may be adjusted to avoid the introduction of gaps between blocks.
parameter: T: 
parameter: cfg: CFG
return: count of removed blocks

## Static Method: removeUnreachableBlocks
- parameter: `cfg`, type: `com.pnfsoftware.jeb.core.units.code.asm.cfg.CFG<T>`
- parameter: `tbr`, type: `java.util.Deque<com.pnfsoftware.jeb.core.units.code.asm.cfg.BasicBlock<T>>`
- return type: `int`

Description: Remove a list of blocks from the CFG. 

 If the CFG is composed of [IResizableInstruction](IResizableInstruction), instruction sizes may be adjusted to avoid the introduction of gaps between blocks.
parameter: T: 
parameter: cfg: CFG
parameter: tbr: bootstrap list of blocks to be removed: those blocks will be removed as well as            all blocks no longer reachable from the entry point from the result of those            deletions
return: count of removed blocks

