Quiz time
Now that you have completed reading this chapter, try answering the following questions to test your knowledge:
- Draw the CFG for the following C program:
int foo(int b) { for (int i = 0; i < b; ++i) { if (i % b == 0) { res + = bar(i); } else { res -= baz(i); } } return res; }
The answer is the following:
Please refer to the Control flow graph section for the definition of a CFG.
- Is the following CFG reducible?

Yes!
Please use the algorithm described in the Irreducible graph section.
You can reduce it with the following sequence:
- 3 has only one predecessor: Merge 2 and 3
- 2 has now a self-edge: Remove it
- 2 has now only one predecessor: Merge 1 and 2
- 1 has now a self-edge: Remove it
If only the basic block 1 remains, the graph is irreducible.
- Given the following irreducible CFG, how could you make it reducible?