summaryrefslogtreecommitdiff
path: root/chapter05
diff options
context:
space:
mode:
Diffstat (limited to 'chapter05')
-rw-r--r--chapter05/README.md220
-rw-r--r--chapter05/docs/05-graph2.gv9
-rw-r--r--chapter05/docs/05-graph2.svg196
-rw-r--r--chapter05/docs/05-graph3.gv15
-rw-r--r--chapter05/docs/05-graph3.svg176
-rw-r--r--chapter05/docs/05-graph4.gv63
-rw-r--r--chapter05/docs/05-graph4.svg216
-rw-r--r--chapter05/docs/05-graph5.gv60
-rw-r--r--chapter05/docs/05-graph5.svg196
-rw-r--r--chapter05/docs/05-graph6.gv58
-rw-r--r--chapter05/docs/05-graph6.svg176
-rw-r--r--chapter05/docs/05-graph7.gv72
-rw-r--r--chapter05/docs/05-graph7.svg269
-rw-r--r--chapter05/docs/05-graph8.gv129
-rw-r--r--chapter05/docs/05-graph8.svg430
-rw-r--r--chapter05/src/main/java/com/seaofnodes/simple/GraphVisualizer.java16
-rw-r--r--chapter05/src/main/java/com/seaofnodes/simple/Parser.java3
-rw-r--r--chapter05/src/main/java/com/seaofnodes/simple/node/MinusNode.java2
-rw-r--r--chapter05/src/main/java/com/seaofnodes/simple/node/ScopeNode.java12
-rw-r--r--chapter05/src/test/java/com/seaofnodes/simple/Chapter05Test.java83
20 files changed, 2184 insertions, 217 deletions
diff --git a/chapter05/README.md b/chapter05/README.md
index 23d936c5..78a8b1fe 100644
--- a/chapter05/README.md
+++ b/chapter05/README.md
@@ -15,7 +15,7 @@ Here is a recap of the nodes introduced in previous chapters:
| Node Name | Type | Chapter | Description | Inputs | Value |
|-----------|----------------|---------|------------------------------------------------|-------------------------------------------------------------------------------|----------------------------------------------------------------------------|
| Multi | Abstract class | 4 | A node that has a tuple result | | A tuple |
-| Start | Control | 1 | Start of function, now a MultiNode | A type for the input argument named `arg`. | A tuple with a ctrl token and an `arg` data node |
+| Start | Control | 1 | Start of function, now a MultiNode | | A tuple with a ctrl token and an `arg` data node |
| Proj | ? | 4 | Projection nodes extract values from MultiNode | A MultiNode and index | Result is the extracted value from the input MultiNode at offset index |
| Bool | Data | 4 | Represents results of a comparison operator | Two data nodes | Result is a comparison, represented as integer value where 1=true, 0=false |
| Return | Control | 1 | End of function | Predecessor control node and a data node for the return value of the function | Return value of the function |
@@ -112,6 +112,115 @@ This involves following:
updated to point to the `Phi` node.
10. Finally, we set the `Region` node as the control token, and discard the duplicated `ScopeNode`.
+Here is the implementing code.
+
+```java
+/**
+ * Parses a statement
+ *
+ * <pre>
+ * if ( expression ) statement [else statement]
+ * </pre>
+ * @return a {@link Node}, never {@code null}
+ */
+private Node parseIf() {
+ require("(");
+ // Parse predicate
+ var pred = require(parseExpression(), ")");
+ // IfNode takes current control and predicate
+ IfNode ifNode = (IfNode)new IfNode(ctrl(), pred).peephole();
+ // Setup projection nodes
+ Node ifT = new ProjNode(ifNode, 0, "True" ).peephole();
+ Node ifF = new ProjNode(ifNode, 1, "False").peephole();
+ // In if true branch, the ifT proj node becomes the ctrl
+ // But first clone the scope and set it as current
+ int ndefs = _scope.nIns();
+ ScopeNode fScope = _scope.dup(); // Duplicate current scope
+ _allScopes.push(fScope); // For graph visualization we need all scopes
+
+ // Parse the true side
+ ctrl(ifT); // set ctrl token to ifTrue projection
+ parseStatement(); // Parse true-side
+ ScopeNode tScope = _scope;
+
+ // Parse the false side
+ _scope = fScope; // Restore scope, then parse else block if any
+ ctrl(ifF); // Ctrl token is now set to ifFalse projection
+ if (matchx("else")) parseStatement();
+
+ if( tScope.nIns() != ndefs || fScope.nIns() != ndefs )
+ throw error("Cannot define a new name on one arm of an if");
+
+ // Merge results
+ _scope = tScope;
+ _allScopes.pop(); // Discard pushed from graph display
+ return ctrl(tScope.mergeScopes(fScope));
+}
+```
+
+## Operations on ScopeNodes
+
+As explained above, we duplicate ScopeNodes and merge them at a later point. There are some
+subtleties in how this is implemented that is worth going over.
+
+### Duplicating a ScopeNode
+
+Below is the code for duplicating a ScopeNode.
+
+Our goals are:
+1) Duplicate the name bindings across all stack levels
+2) Make the new ScopeNode a user of all the bound nodes
+3) Ensure that the order of defs in the duplicate is the same to allow easy merging
+
+```java
+/**
+ * Duplicate a ScopeNode; including all levels, up to Nodes. So this is
+ * neither shallow (would dup the Scope but not the internal HashMap
+ * tables), nor deep (would dup the Scope, the HashMap tables, but then
+ * also the program Nodes).
+ * <p>
+ * The new Scope is a full-fledged Node with proper use<->def edges.
+ */
+public ScopeNode dup() {
+ ScopeNode dup = new ScopeNode();
+ for( HashMap<String, Integer> tab : _scopes )
+ dup._scopes.push(new HashMap<>(tab));
+ for( int i=0; i<nIns(); i++ )
+ dup.add_def(in(i));
+ return dup;
+}
+```
+
+### Merging two ScopeNodes
+
+At the merge point we merge two ScopeNodes. The goals are:
+
+1) Merge names whose bindings have changed between the two nodes. For each such name, a Phi node is created, referencing the two original data nodes.
+2) A new Region node is created representing the merged control flow. The phis have this region node as the first input.
+3) After the merge is completed, the duplicate is discarded, and its use of each of the nodes is also deleted.
+
+The merging logic takes advantage of that fact that the two ScopeNodes have the bound nodes in the same order in the list of inputs. This was ensured during duplicating the ScopeNode.
+Although only the innermost occurrence of a name can have its binding changed, we scan all the nodes in our input list, and simply ignore ones where the binding has not changed.
+
+```java
+/**
+ * Merges the names whose node bindings differ, by creating Phi node for such names
+ * The names could occur at all stack levels, but a given name can only differ in the
+ * innermost stack level where the name is bound.
+ *
+ * @param that The ScopeNode to be merged into this
+ * @return A new Region node representing the merge point
+ */
+public RegionNode mergeScopes(ScopeNode that) {
+ RegionNode r = (RegionNode)ctrl(new RegionNode(null,ctrl(), that.ctrl()).peephole());
+ for( int i=1; i<nIns(); i++ )
+ if( in(i) != that.in(i) ) // No need for redundant Phis
+ set_def(i,new PhiNode(r, in(i), that.in(i)).peephole());
+ that.kill(); // Kill merged scope, removing it as user of all the nodes
+ return r;
+}
+```
+
## Example
We show the graph for the following code snippet:
@@ -152,6 +261,115 @@ Here is the graph after the `return` statement was parsed and processed.
![Graph3](./docs/05-graph3.svg)
+## More Peepholes
+
+Phi's implement a peephole shown below:
+
+```java
+@Override
+public Node idealize() {
+ // Remove a "junk" Phi: Phi(x,x) is just x
+ if( same_inputs() )
+ return in(1);
+
+ // Pull "down" a common data op. One less op in the world. One more
+ // Phi, but Phis do not make code.
+ // Phi(op(A,B),op(Q,R),op(X,Y)) becomes
+ // op(Phi(A,Q,X), Phi(B,R,Y)).
+ Node op = in(1);
+ if( op.nIns()==3 && op.in(0)==null && !op.isCFG() && same_op() ) {
+ Node[] lhss = new Node[nIns()];
+ Node[] rhss = new Node[nIns()];
+ lhss[0] = rhss[0] = in(0); // Set Region
+ for( int i=1; i<nIns(); i++ ) {
+ lhss[i] = in(i).in(1);
+ rhss[i] = in(i).in(2);
+ }
+ Node phi_lhs = new PhiNode(_label,lhss).peephole();
+ Node phi_rhs = new PhiNode(_label,rhss).peephole();
+ return op.copy(phi_lhs,phi_rhs);
+ }
+
+ return null;
+}
+
+private boolean same_op() {
+ for( int i=2; i<nIns(); i++ )
+ if( in(1).getClass() != in(i).getClass() )
+ return false;
+ return true;
+}
+
+private boolean same_inputs() {
+ for( int i=2; i<nIns(); i++ )
+ if( in(1) != in(i) )
+ return false;
+ return true;
+}
+```
+
+This is illustrated in the example:
+
+```java
+int a=arg==2;
+if( arg==1 )
+{
+ a=arg==3;
+}
+return a;
+```
+
+Pre-peephole we have:
+
+![Graph4](./docs/05-graph4.svg)
+
+Post-peephole:
+
+![Graph5](./docs/05-graph5.svg)
+
+## More examples
+
+```java
+int c = 3;
+int b = 2;
+if (arg == 1) {
+ b = 3;
+ c = 4;
+}
+```
+
+![Graph6](./docs/05-graph6.svg)
+
+```java
+int a=arg+1;
+int b=arg+2;
+if( arg==1 )
+ b=b+a;
+else
+ a=b+1;
+return a+b;
+```
+
+![Graph7](./docs/05-graph7.svg)
+
+```java
+int a=1;
+if( arg==1 )
+ if( arg==2 )
+ a=2;
+ else
+ a=3;
+else if( arg==3 )
+ a=4;
+else
+ a=5;
+return a;
+```
+
+![Graph8](./docs/05-graph8.svg)
+
+
+
[^1]: Click, C. (1995).
Combining Analyses, Combining Optimizations, 132.
diff --git a/chapter05/docs/05-graph2.gv b/chapter05/docs/05-graph2.gv
index 0be7c1d6..2adb3da5 100644
--- a/chapter05/docs/05-graph2.gv
+++ b/chapter05/docs/05-graph2.gv
@@ -9,7 +9,6 @@ else {
}
#showGraph;
return a;
-
*/
rankdir=BT;
ordering="in";
@@ -61,15 +60,15 @@ return a;
edge [ fontname=Helvetica, fontsize=8 ];
EQNode8 -> Start2:p1[taillabel=1];
EQNode8 -> Con_7[taillabel=2];
- If9 -> Start2:p0[taillabel=0; color=red];
+ If9 -> Start2:p0[taillabel=0 color=red];
If9 -> EQNode8[taillabel=1];
Add14 -> Start2:p1[taillabel=1];
Add14 -> Con_13[taillabel=2];
Sub16 -> Start2:p1[taillabel=1];
Sub16 -> Con_15[taillabel=2];
- Region17 -> If9:p0[taillabel=1; color=red];
- Region17 -> If9:p1[taillabel=2; color=red];
- Region17 -> Phi_a18 [style=invis]
+ Region17 -> If9:p0[taillabel=1 color=red];
+ Region17 -> If9:p1[taillabel=2 color=red];
+ Phi_a18 -> Region17 [style=dotted taillabel=0];
Phi_a18 -> Add14[taillabel=1];
Phi_a18 -> Sub16[taillabel=2];
edge [style=dashed color=cornflowerblue];
diff --git a/chapter05/docs/05-graph2.svg b/chapter05/docs/05-graph2.svg
index ebc4ffac..d5e48a9e 100644
--- a/chapter05/docs/05-graph2.svg
+++ b/chapter05/docs/05-graph2.svg
@@ -4,220 +4,226 @@
<!-- Generated by graphviz version 2.43.0 (0)
-->
<!-- Title: chapter05 Pages: 1 -->
-<svg width="302pt" height="428pt"
- viewBox="0.00 0.00 302.28 428.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<svg width="343pt" height="428pt"
+ viewBox="0.00 0.00 343.03 428.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 424)">
<title>chapter05</title>
-<polygon fill="white" stroke="transparent" points="-4,4 -4,-424 298.28,-424 298.28,4 -4,4"/>
+<polygon fill="white" stroke="transparent" points="-4,4 -4,-424 339.03,-424 339.03,4 -4,4"/>
<g id="clust1" class="cluster">
<title>cluster_Nodes</title>
<polygon fill="none" stroke="black" points="8,-88 8,-412 282,-412 282,-88 8,-88"/>
</g>
<g id="clust3" class="cluster">
<title>cluster_Scope1_0</title>
-<polygon fill="none" stroke="black" points="38,-8 38,-76 238,-76 238,-8 38,-8"/>
+<polygon fill="none" stroke="black" points="67,-8 67,-76 267,-76 267,-8 67,-8"/>
</g>
<g id="clust4" class="cluster">
<title>cluster_Scope1_1</title>
-<polygon fill="none" stroke="black" points="160,-16 160,-68 230,-68 230,-16 160,-16"/>
+<polygon fill="none" stroke="black" points="75,-16 75,-68 145,-68 145,-16 75,-16"/>
</g>
<!-- Start2 -->
<g id="node1" class="node">
<title>Start2</title>
-<polygon fill="yellow" stroke="transparent" points="118,-375 118,-400 199,-400 199,-375 118,-375"/>
-<polygon fill="none" stroke="black" points="118,-375 118,-400 199,-400 199,-375 118,-375"/>
-<text text-anchor="start" x="140" y="-383.8" font-family="Times,serif" font-size="14.00">Start</text>
-<polygon fill="none" stroke="black" points="118,-344 118,-375 199,-375 199,-344 118,-344"/>
-<polygon fill="yellow" stroke="transparent" points="123,-349 123,-370 163,-370 163,-349 123,-349"/>
-<polygon fill="none" stroke="black" points="123,-349 123,-370 163,-370 163,-349 123,-349"/>
-<text text-anchor="start" x="126" y="-355.8" font-family="Times,serif" font-size="14.00">$ctrl</text>
-<polygon fill="none" stroke="black" points="163,-349 163,-370 194,-370 194,-349 163,-349"/>
-<text text-anchor="start" x="166" y="-355.8" font-family="Times,serif" font-size="14.00">arg</text>
+<polygon fill="yellow" stroke="transparent" points="113,-375 113,-400 194,-400 194,-375 113,-375"/>
+<polygon fill="none" stroke="black" points="113,-375 113,-400 194,-400 194,-375 113,-375"/>
+<text text-anchor="start" x="135" y="-383.8" font-family="Times,serif" font-size="14.00">Start</text>
+<polygon fill="none" stroke="black" points="113,-344 113,-375 194,-375 194,-344 113,-344"/>
+<polygon fill="yellow" stroke="transparent" points="118,-349 118,-370 158,-370 158,-349 118,-349"/>
+<polygon fill="none" stroke="black" points="118,-349 118,-370 158,-370 158,-349 118,-349"/>
+<text text-anchor="start" x="121" y="-355.8" font-family="Times,serif" font-size="14.00">$ctrl</text>
+<polygon fill="none" stroke="black" points="158,-349 158,-370 189,-370 189,-349 158,-349"/>
+<text text-anchor="start" x="161" y="-355.8" font-family="Times,serif" font-size="14.00">arg</text>
</g>
<!-- Con_7 -->
<g id="node2" class="node">
<title>Con_7</title>
-<ellipse fill="none" stroke="black" cx="63" cy="-372" rx="27" ry="18"/>
-<text text-anchor="middle" x="63" y="-368.3" font-family="Times,serif" font-size="14.00">#1</text>
+<ellipse fill="none" stroke="black" cx="247" cy="-372" rx="27" ry="18"/>
+<text text-anchor="middle" x="247" y="-368.3" font-family="Times,serif" font-size="14.00">#1</text>
</g>
<!-- EQNode8 -->
<g id="node3" class="node">
<title>EQNode8</title>
-<ellipse fill="none" stroke="black" cx="63" cy="-286" rx="27" ry="18"/>
-<text text-anchor="middle" x="63" y="-282.3" font-family="Times,serif" font-size="14.00">==</text>
+<ellipse fill="none" stroke="black" cx="247" cy="-286" rx="27" ry="18"/>
+<text text-anchor="middle" x="247" y="-282.3" font-family="Times,serif" font-size="14.00">==</text>
</g>
<!-- EQNode8&#45;&gt;Start2 -->
<g id="edge1" class="edge">
<title>EQNode8&#45;&gt;Start2:p1</title>
-<path fill="none" stroke="black" d="M84.55,-297.13C110.75,-309.58 153.66,-330.41 171.18,-341.44"/>
-<polygon fill="black" stroke="black" points="169.09,-344.25 179,-348 173.59,-338.89 169.09,-344.25"/>
-<text text-anchor="middle" x="87.55" y="-299.73" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+<path fill="none" stroke="black" d="M236.57,-302.62C225.76,-318.5 208.98,-342.28 198.26,-353.17"/>
+<polygon fill="black" stroke="black" points="196.15,-350.37 190,-359 200.19,-356.09 196.15,-350.37"/>
+<text text-anchor="middle" x="233.57" y="-305.22" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
</g>
<!-- EQNode8&#45;&gt;Con_7 -->
<g id="edge2" class="edge">
<title>EQNode8&#45;&gt;Con_7</title>
-<path fill="none" stroke="black" d="M63,-304.4C63,-315.74 63,-330.77 63,-343.68"/>
-<polygon fill="black" stroke="black" points="59.5,-343.9 63,-353.9 66.5,-343.9 59.5,-343.9"/>
-<text text-anchor="middle" x="60" y="-307" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+<path fill="none" stroke="black" d="M247,-304.4C247,-315.74 247,-330.77 247,-343.68"/>
+<polygon fill="black" stroke="black" points="243.5,-343.9 247,-353.9 250.5,-343.9 243.5,-343.9"/>
+<text text-anchor="middle" x="244" y="-307" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
</g>
<!-- If9 -->
<g id="node4" class="node">
<title>If9</title>
-<polygon fill="yellow" stroke="transparent" points="24,-203 24,-228 118,-228 118,-203 24,-203"/>
-<polygon fill="none" stroke="black" points="24,-203 24,-228 118,-228 118,-203 24,-203"/>
-<text text-anchor="start" x="65.5" y="-211.8" font-family="Times,serif" font-size="14.00">If</text>
-<polygon fill="none" stroke="black" points="24,-172 24,-203 118,-203 118,-172 24,-172"/>
-<polygon fill="yellow" stroke="transparent" points="29,-177 29,-198 69,-198 69,-177 29,-177"/>
-<polygon fill="none" stroke="black" points="29,-177 29,-198 69,-198 69,-177 29,-177"/>
-<text text-anchor="start" x="32" y="-183.8" font-family="Times,serif" font-size="14.00">True</text>
-<polygon fill="yellow" stroke="transparent" points="69,-177 69,-198 113,-198 113,-177 69,-177"/>
-<polygon fill="none" stroke="black" points="69,-177 69,-198 113,-198 113,-177 69,-177"/>
-<text text-anchor="start" x="72" y="-183.8" font-family="Times,serif" font-size="14.00">False</text>
+<polygon fill="yellow" stroke="transparent" points="172,-203 172,-228 266,-228 266,-203 172,-203"/>
+<polygon fill="none" stroke="black" points="172,-203 172,-228 266,-228 266,-203 172,-203"/>
+<text text-anchor="start" x="213.5" y="-211.8" font-family="Times,serif" font-size="14.00">If</text>
+<polygon fill="none" stroke="black" points="172,-172 172,-203 266,-203 266,-172 172,-172"/>
+<polygon fill="yellow" stroke="transparent" points="177,-177 177,-198 217,-198 217,-177 177,-177"/>
+<polygon fill="none" stroke="black" points="177,-177 177,-198 217,-198 217,-177 177,-177"/>
+<text text-anchor="start" x="180" y="-183.8" font-family="Times,serif" font-size="14.00">True</text>
+<polygon fill="yellow" stroke="transparent" points="217,-177 217,-198 261,-198 261,-177 217,-177"/>
+<polygon fill="none" stroke="black" points="217,-177 217,-198 261,-198 261,-177 217,-177"/>
+<text text-anchor="start" x="220" y="-183.8" font-family="Times,serif" font-size="14.00">False</text>
</g>
<!-- If9&#45;&gt;Start2 -->
<g id="edge3" class="edge">
<title>If9&#45;&gt;Start2:p0</title>
-<path fill="none" stroke="red" d="M42.24,-232.39C26.58,-253.43 12.99,-281.34 27,-304 45.81,-334.43 69.02,-320.48 99,-340 106.29,-344.75 108.21,-351.45 112.41,-355.49"/>
-<polygon fill="red" stroke="red" points="111.41,-358.85 122,-359 113.81,-352.28 111.41,-358.85"/>
-<text text-anchor="middle" x="39.24" y="-234.99" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+<path fill="none" stroke="red" d="M210.31,-232.18C203.59,-253.4 193.07,-281.57 179,-304 166.9,-323.28 145.68,-322.25 139.64,-338.02"/>
+<polygon fill="red" stroke="red" points="136.17,-337.56 138,-348 143.08,-338.7 136.17,-337.56"/>
+<text text-anchor="middle" x="207.31" y="-234.78" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
</g>
<!-- If9&#45;&gt;EQNode8 -->
<g id="edge4" class="edge">
<title>If9&#45;&gt;EQNode8</title>
-<path fill="none" stroke="black" d="M68.02,-232.28C67.23,-240.58 66.38,-249.48 65.61,-257.56"/>
-<polygon fill="black" stroke="black" points="62.12,-257.31 64.66,-267.6 69.09,-257.97 62.12,-257.31"/>
-<text text-anchor="middle" x="65.02" y="-234.88" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+<path fill="none" stroke="black" d="M229.43,-232.28C232.3,-240.9 235.39,-250.17 238.16,-258.49"/>
+<polygon fill="black" stroke="black" points="234.87,-259.69 241.36,-268.07 241.51,-257.48 234.87,-259.69"/>
+<text text-anchor="middle" x="226.43" y="-234.88" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
</g>
<!-- Con_13 -->
<g id="node5" class="node">
<title>Con_13</title>
-<ellipse fill="none" stroke="black" cx="227" cy="-286" rx="27" ry="18"/>
-<text text-anchor="middle" x="227" y="-282.3" font-family="Times,serif" font-size="14.00">#2</text>
+<ellipse fill="none" stroke="black" cx="135" cy="-286" rx="27" ry="18"/>
+<text text-anchor="middle" x="135" y="-282.3" font-family="Times,serif" font-size="14.00">#2</text>
</g>
<!-- Add14 -->
<g id="node6" class="node">
<title>Add14</title>
-<ellipse fill="none" stroke="black" cx="243" cy="-200" rx="27" ry="18"/>
-<text text-anchor="middle" x="243" y="-196.3" font-family="Times,serif" font-size="14.00">+</text>
+<ellipse fill="none" stroke="black" cx="119" cy="-200" rx="27" ry="18"/>
+<text text-anchor="middle" x="119" y="-196.3" font-family="Times,serif" font-size="14.00">+</text>
</g>
<!-- Add14&#45;&gt;Start2 -->
<g id="edge5" class="edge">
<title>Add14&#45;&gt;Start2:p1</title>
-<path fill="none" stroke="black" d="M255.66,-216.26C268.24,-233.4 284.18,-261.85 273,-285"/>
-<path fill="none" stroke="black" d="M273,-287C256.15,-321.89 246.19,-348.04 217.03,-356.27"/>
-<polygon fill="black" stroke="black" points="215.98,-352.91 206.86,-358.3 217.35,-359.77 215.98,-352.91"/>
-<text text-anchor="middle" x="252.66" y="-218.86" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+<path fill="none" stroke="black" d="M134.23,-215.02C146.68,-227.55 163.4,-247.1 171,-268 181.92,-298.04 175.64,-309.96 174.25,-337.87"/>
+<polygon fill="black" stroke="black" points="170.75,-337.92 174,-348 177.75,-338.09 170.75,-337.92"/>
+<text text-anchor="middle" x="131.23" y="-217.62" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
</g>
<!-- Add14&#45;&gt;Con_13 -->
<g id="edge6" class="edge">
<title>Add14&#45;&gt;Con_13</title>
-<path fill="none" stroke="black" d="M239.76,-218C237.57,-229.5 234.63,-244.93 232.13,-258.08"/>
-<polygon fill="black" stroke="black" points="228.67,-257.55 230.23,-268.03 235.54,-258.86 228.67,-257.55"/>
-<text text-anchor="middle" x="236.76" y="-220.6" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+<path fill="none" stroke="black" d="M122.24,-218C124.43,-229.5 127.37,-244.93 129.87,-258.08"/>
+<polygon fill="black" stroke="black" points="126.46,-258.86 131.77,-268.03 133.33,-257.55 126.46,-258.86"/>
+<text text-anchor="middle" x="119.24" y="-220.6" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
</g>
<!-- Con_15 -->
<g id="node7" class="node">
<title>Con_15</title>
-<ellipse fill="none" stroke="black" cx="135" cy="-286" rx="27" ry="18"/>
-<text text-anchor="middle" x="135" y="-282.3" font-family="Times,serif" font-size="14.00">#3</text>
+<ellipse fill="none" stroke="black" cx="43" cy="-286" rx="27" ry="18"/>
+<text text-anchor="middle" x="43" y="-282.3" font-family="Times,serif" font-size="14.00">#3</text>
</g>
<!-- Sub16 -->
<g id="node8" class="node">
<title>Sub16</title>
-<ellipse fill="none" stroke="black" cx="171" cy="-200" rx="27" ry="18"/>
-<text text-anchor="middle" x="171" y="-196.3" font-family="Times,serif" font-size="14.00">&#45;</text>
+<ellipse fill="none" stroke="black" cx="47" cy="-200" rx="27" ry="18"/>
+<text text-anchor="middle" x="47" y="-196.3" font-family="Times,serif" font-size="14.00">&#45;</text>
</g>
<!-- Sub16&#45;&gt;Start2 -->
<g id="edge7" class="edge">
<title>Sub16&#45;&gt;Start2:p1</title>
-<path fill="none" stroke="black" d="M172.54,-218.18C174.7,-243.68 178.43,-293.32 178.94,-337.97"/>
-<polygon fill="black" stroke="black" points="175.44,-338.02 179,-348 182.44,-337.98 175.44,-338.02"/>
-<text text-anchor="middle" x="169.54" y="-220.78" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+<path fill="none" stroke="black" d="M54.69,-217.49C67.53,-244.81 92.56,-297.14 99,-304 122.77,-329.31 164.37,-313.46 172.57,-338.01"/>
+<polygon fill="black" stroke="black" points="169.12,-338.6 174,-348 176.05,-337.61 169.12,-338.6"/>
+<text text-anchor="middle" x="51.69" y="-220.09" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
</g>
<!-- Sub16&#45;&gt;Con_15 -->
<g id="edge8" class="edge">
<title>Sub16&#45;&gt;Con_15</title>
-<path fill="none" stroke="black" d="M163.89,-217.6C158.81,-229.45 151.88,-245.62 146.08,-259.15"/>
-<polygon fill="black" stroke="black" points="142.82,-257.87 142.1,-268.44 149.25,-260.63 142.82,-257.87"/>
-<text text-anchor="middle" x="160.89" y="-220.2" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+<path fill="none" stroke="black" d="M46.19,-218C45.65,-229.31 44.93,-244.42 44.31,-257.43"/>
+<polygon fill="black" stroke="black" points="40.8,-257.58 43.82,-267.74 47.79,-257.92 40.8,-257.58"/>
+<text text-anchor="middle" x="43.19" y="-220.6" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
</g>
<!-- Region17 -->
<g id="node9" class="node">
<title>Region17</title>
-<polygon fill="yellow" stroke="black" points="124,-132 58,-132 58,-96 124,-96 124,-132"/>
-<text text-anchor="middle" x="91" y="-110.3" font-family="Times,serif" font-size="14.00">Region</text>
+<polygon fill="yellow" stroke="black" points="232,-132 166,-132 166,-96 232,-96 232,-132"/>
+<text text-anchor="middle" x="199" y="-110.3" font-family="Times,serif" font-size="14.00">Region</text>
</g>
<!-- Region17&#45;&gt;If9 -->
<g id="edge9" class="edge">
<title>Region17&#45;&gt;If9:p0</title>
-<path fill="none" stroke="red" d="M70.98,-132.12C62.36,-141.06 53.52,-152.84 50.29,-165.84"/>
-<polygon fill="red" stroke="red" points="46.78,-165.64 49,-176 53.73,-166.52 46.78,-165.64"/>
-<text text-anchor="middle" x="67.98" y="-134.72" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+<path fill="none" stroke="red" d="M198.14,-132.09C197.72,-141.54 197.27,-153.77 197.08,-165.68"/>
+<polygon fill="red" stroke="red" points="193.58,-165.97 197,-176 200.58,-166.03 193.58,-165.97"/>
+<text text-anchor="middle" x="195.14" y="-134.69" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
</g>
<!-- Region17&#45;&gt;If9 -->
<g id="edge10" class="edge">
<title>Region17&#45;&gt;If9:p1</title>
-<path fill="none" stroke="red" d="M91,-132.09C91,-141.55 91,-153.77 91,-165.69"/>
-<polygon fill="red" stroke="red" points="87.5,-166 91,-176 94.5,-166 87.5,-166"/>
-<text text-anchor="middle" x="88" y="-134.69" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+<path fill="none" stroke="red" d="M217.83,-132.05C226.1,-141.05 234.63,-152.92 237.76,-165.89"/>
+<polygon fill="red" stroke="red" points="234.31,-166.5 239,-176 241.25,-165.65 234.31,-166.5"/>
+<text text-anchor="middle" x="214.83" y="-134.65" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
</g>
<!-- Phi_a18 -->
<g id="node10" class="node">
<title>Phi_a18</title>
-<ellipse fill="lightyellow" stroke="black" cx="187" cy="-114" rx="27" ry="18"/>
-<text text-anchor="middle" x="187" y="-110.3" font-family="Times,serif" font-size="14.00">φ_a</text>
+<ellipse fill="lightyellow" stroke="black" cx="119" cy="-114" rx="27" ry="18"/>
+<text text-anchor="middle" x="119" y="-110.3" font-family="Times,serif" font-size="14.00">φ_a</text>
</g>
-<!-- Region17&#45;&gt;Phi_a18 -->
<!-- Phi_a18&#45;&gt;Add14 -->
<g id="edge12" class="edge">
<title>Phi_a18&#45;&gt;Add14</title>
-<path fill="none" stroke="black" d="M197.53,-130.8C205.75,-143.12 217.3,-160.45 226.7,-174.55"/>
-<polygon fill="black" stroke="black" points="224.05,-176.89 232.51,-183.27 229.88,-173.01 224.05,-176.89"/>
-<text text-anchor="middle" x="194.53" y="-133.4" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+<path fill="none" stroke="black" d="M119,-132.4C119,-143.74 119,-158.77 119,-171.68"/>
+<polygon fill="black" stroke="black" points="115.5,-171.9 119,-181.9 122.5,-171.9 115.5,-171.9"/>
+<text text-anchor="middle" x="116" y="-135" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
</g>
<!-- Phi_a18&#45;&gt;Sub16 -->
<g id="edge13" class="edge">
<title>Phi_a18&#45;&gt;Sub16</title>
-<path fill="none" stroke="black" d="M183.76,-132C181.57,-143.5 178.63,-158.93 176.13,-172.08"/>
-<polygon fill="black" stroke="black" points="172.67,-171.55 174.23,-182.03 179.54,-172.86 172.67,-171.55"/>
-<text text-anchor="middle" x="180.76" y="-134.6" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+<path fill="none" stroke="black" d="M106.13,-130.02C95.07,-142.92 78.96,-161.71 66.35,-176.42"/>
+<polygon fill="black" stroke="black" points="63.61,-174.24 59.76,-184.11 68.93,-178.8 63.61,-174.24"/>
+<text text-anchor="middle" x="103.13" y="-132.62" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Phi_a18&#45;&gt;Region17 -->
+<g id="edge11" class="edge">
+<title>Phi_a18&#45;&gt;Region17</title>
+<path fill="none" stroke="black" stroke-dasharray="1,5" d="M146.19,-114C149.39,-114 152.58,-114 155.78,-114"/>
+<polygon fill="black" stroke="black" points="155.99,-117.5 165.99,-114 155.99,-110.5 155.99,-117.5"/>
+<text text-anchor="middle" x="149.19" y="-107.6" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
</g>
<!-- Scope1_0 -->
<g id="node11" class="node">
<title>Scope1_0</title>
-<polygon fill="cyan" stroke="transparent" points="55,-31 55,-52 71,-52 71,-31 55,-31"/>
-<polygon fill="none" stroke="black" points="55,-31 55,-52 71,-52 71,-31 55,-31"/>
-<text text-anchor="start" x="58" y="-37.8" font-family="Times,serif" font-size="14.00">0</text>
-<polygon fill="none" stroke="black" points="71,-31 71,-52 111,-52 111,-31 71,-31"/>
-<text text-anchor="start" x="74" y="-37.8" font-family="Times,serif" font-size="14.00">$ctrl</text>
-<polygon fill="none" stroke="black" points="111,-31 111,-52 142,-52 142,-31 111,-31"/>
-<text text-anchor="start" x="114" y="-37.8" font-family="Times,serif" font-size="14.00">arg</text>
+<polygon fill="cyan" stroke="transparent" points="164,-31 164,-52 180,-52 180,-31 164,-31"/>
+<polygon fill="none" stroke="black" points="164,-31 164,-52 180,-52 180,-31 164,-31"/>
+<text text-anchor="start" x="167" y="-37.8" font-family="Times,serif" font-size="14.00">0</text>
+<polygon fill="none" stroke="black" points="180,-31 180,-52 220,-52 220,-31 180,-31"/>
+<text text-anchor="start" x="183" y="-37.8" font-family="Times,serif" font-size="14.00">$ctrl</text>
+<polygon fill="none" stroke="black" points="220,-31 220,-52 251,-52 251,-31 220,-31"/>
+<text text-anchor="start" x="223" y="-37.8" font-family="Times,serif" font-size="14.00">arg</text>
</g>
<!-- Scope1_0&#45;&gt;Start2 -->
<g id="edge15" class="edge">
<title>Scope1_0:Scope1_0_arg&#45;&gt;Start2:p1</title>
-<path fill="none" stroke="cornflowerblue" stroke-dasharray="5,2" d="M143,-41C159.59,-41 143.27,-65.36 156,-76 179.21,-95.4 197.18,-72.23 223,-88 261.16,-111.31 269.69,-125.64 284,-168 300.71,-217.48 295.71,-237.97 273,-285"/>
+<path fill="none" stroke="cornflowerblue" stroke-dasharray="5,2" d="M252,-41C369.7,-41 344.88,-203.88 283,-304 264.19,-334.43 240.54,-319.81 211,-340 204.51,-344.44 202.84,-350.75 199.44,-354.86"/>
+<polygon fill="cornflowerblue" stroke="cornflowerblue" points="197.75,-351.78 190,-359 200.56,-358.19 197.75,-351.78"/>
</g>
<!-- Scope1_0&#45;&gt;Region17 -->
<g id="edge14" class="edge">
<title>Scope1_0:Scope1_0_$ctrl&#45;&gt;Region17</title>
-<path fill="none" stroke="cornflowerblue" stroke-dasharray="5,2" d="M91,-53C91,-63.75 91,-75.58 91,-85.87"/>
-<polygon fill="cornflowerblue" stroke="cornflowerblue" points="87.5,-85.93 91,-95.93 94.5,-85.93 87.5,-85.93"/>
+<path fill="none" stroke="cornflowerblue" stroke-dasharray="5,2" d="M200,-53C200,-63.75 199.84,-75.58 199.64,-85.87"/>
+<polygon fill="cornflowerblue" stroke="cornflowerblue" points="196.14,-85.86 199.44,-95.93 203.14,-86.01 196.14,-85.86"/>
</g>
<!-- Scope1_1 -->
<g id="node12" class="node">
<title>Scope1_1</title>
-<polygon fill="cyan" stroke="transparent" points="180,-31 180,-52 196,-52 196,-31 180,-31"/>
-<polygon fill="none" stroke="black" points="180,-31 180,-52 196,-52 196,-31 180,-31"/>
-<text text-anchor="start" x="183" y="-37.8" font-family="Times,serif" font-size="14.00">1</text>
-<polygon fill="none" stroke="black" points="196,-31 196,-52 211,-52 211,-31 196,-31"/>
-<text text-anchor="start" x="199" y="-37.8" font-family="Times,serif" font-size="14.00">a</text>
+<polygon fill="cyan" stroke="transparent" points="95,-31 95,-52 111,-52 111,-31 95,-31"/>
+<polygon fill="none" stroke="black" points="95,-31 95,-52 111,-52 111,-31 95,-31"/>
+<text text-anchor="start" x="98" y="-37.8" font-family="Times,serif" font-size="14.00">1</text>
+<polygon fill="none" stroke="black" points="111,-31 111,-52 126,-52 126,-31 111,-31"/>
+<text text-anchor="start" x="114" y="-37.8" font-family="Times,serif" font-size="14.00">a</text>
</g>
<!-- Scope1_1&#45;&gt;Phi_a18 -->
<g id="edge16" class="edge">
<title>Scope1_1:Scope1_1_a&#45;&gt;Phi_a18</title>
-<path fill="none" stroke="cornflowerblue" stroke-dasharray="5,2" d="M204,-53C204,-64.37 201.14,-76.5 197.77,-86.87"/>
-<polygon fill="cornflowerblue" stroke="cornflowerblue" points="194.38,-85.95 194.31,-96.54 200.97,-88.3 194.38,-85.95"/>
+<path fill="none" stroke="cornflowerblue" stroke-dasharray="5,2" d="M119,-53C119,-63.75 119,-75.58 119,-85.87"/>
+<polygon fill="cornflowerblue" stroke="cornflowerblue" points="115.5,-85.93 119,-95.93 122.5,-85.93 115.5,-85.93"/>
</g>
</g>
</svg>
diff --git a/chapter05/docs/05-graph3.gv b/chapter05/docs/05-graph3.gv
index 59a8a3e2..7e049c9c 100644
--- a/chapter05/docs/05-graph3.gv
+++ b/chapter05/docs/05-graph3.gv
@@ -9,7 +9,6 @@ else {
}
#showGraph;
return a;
-
*/
rankdir=BT;
ordering="in";
@@ -48,20 +47,20 @@ return a;
{ rank=same; Region17;Phi_a18;}
}
edge [ fontname=Helvetica, fontsize=8 ];
- Stop3 -> Return19[taillabel=0; color=red];
+ Stop3 -> Return19[taillabel=0 color=red];
EQNode8 -> Start2:p1[taillabel=1];
EQNode8 -> Con_7[taillabel=2];
- If9 -> Start2:p0[taillabel=0; color=red];
+ If9 -> Start2:p0[taillabel=0 color=red];
If9 -> EQNode8[taillabel=1];
Add14 -> Start2:p1[taillabel=1];
Add14 -> Con_13[taillabel=2];
Sub16 -> Start2:p1[taillabel=1];
Sub16 -> Con_15[taillabel=2];
- Region17 -> If9:p0[taillabel=1; color=red];
- Region17 -> If9:p1[taillabel=2; color=red];
- Region17 -> Phi_a18 [style=invis]
+ Region17 -> If9:p0[taillabel=1 color=red];
+ Region17 -> If9:p1[taillabel=2 color=red];
+ Phi_a18 -> Region17 [style=dotted taillabel=0];
Phi_a18 -> Add14[taillabel=1];
Phi_a18 -> Sub16[taillabel=2];
- Return19 -> Region17[taillabel=0; color=red];
+ Return19 -> Region17[taillabel=0 color=red];
Return19 -> Phi_a18[taillabel=1];
-}
+} \ No newline at end of file
diff --git a/chapter05/docs/05-graph3.svg b/chapter05/docs/05-graph3.svg
index 5b6f0c86..855fdc2c 100644
--- a/chapter05/docs/05-graph3.svg
+++ b/chapter05/docs/05-graph3.svg
@@ -16,195 +16,201 @@
<!-- Start2 -->
<g id="node1" class="node">
<title>Start2</title>
-<polygon fill="yellow" stroke="transparent" points="97,-439 97,-464 178,-464 178,-439 97,-439"/>
-<polygon fill="none" stroke="black" points="97,-439 97,-464 178,-464 178,-439 97,-439"/>
-<text text-anchor="start" x="119" y="-447.8" font-family="Times,serif" font-size="14.00">Start</text>
-<polygon fill="none" stroke="black" points="97,-408 97,-439 178,-439 178,-408 97,-408"/>
-<polygon fill="yellow" stroke="transparent" points="102,-413 102,-434 142,-434 142,-413 102,-413"/>
-<polygon fill="none" stroke="black" points="102,-413 102,-434 142,-434 142,-413 102,-413"/>
-<text text-anchor="start" x="105" y="-419.8" font-family="Times,serif" font-size="14.00">$ctrl</text>
-<polygon fill="none" stroke="black" points="142,-413 142,-434 173,-434 173,-413 142,-413"/>
-<text text-anchor="start" x="145" y="-419.8" font-family="Times,serif" font-size="14.00">arg</text>
+<polygon fill="yellow" stroke="transparent" points="113,-439 113,-464 194,-464 194,-439 113,-439"/>
+<polygon fill="none" stroke="black" points="113,-439 113,-464 194,-464 194,-439 113,-439"/>
+<text text-anchor="start" x="135" y="-447.8" font-family="Times,serif" font-size="14.00">Start</text>
+<polygon fill="none" stroke="black" points="113,-408 113,-439 194,-439 194,-408 113,-408"/>
+<polygon fill="yellow" stroke="transparent" points="118,-413 118,-434 158,-434 158,-413 118,-413"/>
+<polygon fill="none" stroke="black" points="118,-413 118,-434 158,-434 158,-413 118,-413"/>
+<text text-anchor="start" x="121" y="-419.8" font-family="Times,serif" font-size="14.00">$ctrl</text>
+<polygon fill="none" stroke="black" points="158,-413 158,-434 189,-434 189,-413 158,-413"/>
+<text text-anchor="start" x="161" y="-419.8" font-family="Times,serif" font-size="14.00">arg</text>
</g>
<!-- Stop3 -->
<g id="node2" class="node">
<title>Stop3</title>
-<polygon fill="yellow" stroke="black" points="157,-52 103,-52 103,-16 157,-16 157,-52"/>
-<text text-anchor="middle" x="130" y="-30.3" font-family="Times,serif" font-size="14.00">Stop</text>
+<polygon fill="yellow" stroke="black" points="185,-52 131,-52 131,-16 185,-16 185,-52"/>
+<text text-anchor="middle" x="158" y="-30.3" font-family="Times,serif" font-size="14.00">Stop</text>
</g>
<!-- Return19 -->
<g id="node12" class="node">
<title>Return19</title>
-<polygon fill="yellow" stroke="black" points="163,-124 97,-124 97,-88 163,-88 163,-124"/>
-<text text-anchor="middle" x="130" y="-102.3" font-family="Times,serif" font-size="14.00">Return</text>
+<polygon fill="yellow" stroke="black" points="191,-124 125,-124 125,-88 191,-88 191,-124"/>
+<text text-anchor="middle" x="158" y="-102.3" font-family="Times,serif" font-size="14.00">Return</text>
</g>
<!-- Stop3&#45;&gt;Return19 -->
<g id="edge1" class="edge">
<title>Stop3&#45;&gt;Return19</title>
-<path fill="none" stroke="red" d="M130,-52.3C130,-60.02 130,-69.29 130,-77.89"/>
-<polygon fill="red" stroke="red" points="126.5,-77.9 130,-87.9 133.5,-77.9 126.5,-77.9"/>
-<text text-anchor="middle" x="127" y="-54.9" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+<path fill="none" stroke="red" d="M158,-52.3C158,-60.02 158,-69.29 158,-77.89"/>
+<polygon fill="red" stroke="red" points="154.5,-77.9 158,-87.9 161.5,-77.9 154.5,-77.9"/>
+<text text-anchor="middle" x="155" y="-54.9" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
</g>
<!-- Con_7 -->
<g id="node3" class="node">
<title>Con_7</title>
-<ellipse fill="none" stroke="black" cx="43" cy="-436" rx="27" ry="18"/>
-<text text-anchor="middle" x="43" y="-432.3" font-family="Times,serif" font-size="14.00">#1</text>
+<ellipse fill="none" stroke="black" cx="247" cy="-436" rx="27" ry="18"/>
+<text text-anchor="middle" x="247" y="-432.3" font-family="Times,serif" font-size="14.00">#1</text>
</g>
<!-- EQNode8 -->
<g id="node4" class="node">
<title>EQNode8</title>
-<ellipse fill="none" stroke="black" cx="63" cy="-350" rx="27" ry="18"/>
-<text text-anchor="middle" x="63" y="-346.3" font-family="Times,serif" font-size="14.00">==</text>
+<ellipse fill="none" stroke="black" cx="247" cy="-350" rx="27" ry="18"/>
+<text text-anchor="middle" x="247" y="-346.3" font-family="Times,serif" font-size="14.00">==</text>
</g>
<!-- EQNode8&#45;&gt;Start2 -->
<g id="edge2" class="edge">
<title>EQNode8&#45;&gt;Start2:p1</title>
-<path fill="none" stroke="black" d="M85.51,-360.31C108.56,-370.43 142.57,-387.19 154.05,-402.35"/>
-<polygon fill="black" stroke="black" points="150.97,-404.07 158,-412 157.45,-401.42 150.97,-404.07"/>
-<text text-anchor="middle" x="88.51" y="-362.91" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+<path fill="none" stroke="black" d="M236.57,-366.62C225.76,-382.5 208.98,-406.28 198.26,-417.17"/>
+<polygon fill="black" stroke="black" points="196.15,-414.37 190,-423 200.19,-420.09 196.15,-414.37"/>
+<text text-anchor="middle" x="233.57" y="-369.22" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
</g>
<!-- EQNode8&#45;&gt;Con_7 -->
<g id="edge3" class="edge">
<title>EQNode8&#45;&gt;Con_7</title>
-<path fill="none" stroke="black" d="M58.95,-368C56.21,-379.5 52.54,-394.93 49.41,-408.08"/>
-<polygon fill="black" stroke="black" points="45.95,-407.49 47.04,-418.03 52.76,-409.11 45.95,-407.49"/>
-<text text-anchor="middle" x="55.95" y="-370.6" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+<path fill="none" stroke="black" d="M247,-368.4C247,-379.74 247,-394.77 247,-407.68"/>
+<polygon fill="black" stroke="black" points="243.5,-407.9 247,-417.9 250.5,-407.9 243.5,-407.9"/>
+<text text-anchor="middle" x="244" y="-371" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
</g>
<!-- If9 -->
<g id="node5" class="node">
<title>If9</title>
-<polygon fill="yellow" stroke="transparent" points="24,-267 24,-292 118,-292 118,-267 24,-267"/>
-<polygon fill="none" stroke="black" points="24,-267 24,-292 118,-292 118,-267 24,-267"/>
-<text text-anchor="start" x="65.5" y="-275.8" font-family="Times,serif" font-size="14.00">If</text>
-<polygon fill="none" stroke="black" points="24,-236 24,-267 118,-267 118,-236 24,-236"/>
-<polygon fill="yellow" stroke="transparent" points="29,-241 29,-262 69,-262 69,-241 29,-241"/>
-<polygon fill="none" stroke="black" points="29,-241 29,-262 69,-262 69,-241 29,-241"/>
-<text text-anchor="start" x="32" y="-247.8" font-family="Times,serif" font-size="14.00">True</text>
-<polygon fill="yellow" stroke="transparent" points="69,-241 69,-262 113,-262 113,-241 69,-241"/>
-<polygon fill="none" stroke="black" points="69,-241 69,-262 113,-262 113,-241 69,-241"/>
-<text text-anchor="start" x="72" y="-247.8" font-family="Times,serif" font-size="14.00">False</text>
+<polygon fill="yellow" stroke="transparent" points="172,-267 172,-292 266,-292 266,-267 172,-267"/>
+<polygon fill="none" stroke="black" points="172,-267 172,-292 266,-292 266,-267 172,-267"/>
+<text text-anchor="start" x="213.5" y="-275.8" font-family="Times,serif" font-size="14.00">If</text>
+<polygon fill="none" stroke="black" points="172,-236 172,-267 266,-267 266,-236 172,-236"/>
+<polygon fill="yellow" stroke="transparent" points="177,-241 177,-262 217,-262 217,-241 177,-241"/>
+<polygon fill="none" stroke="black" points="177,-241 177,-262 217,-262 217,-241 177,-241"/>
+<text text-anchor="start" x="180" y="-247.8" font-family="Times,serif" font-size="14.00">True</text>
+<polygon fill="yellow" stroke="transparent" points="217,-241 217,-262 261,-262 261,-241 217,-241"/>
+<polygon fill="none" stroke="black" points="217,-241 217,-262 261,-262 261,-241 217,-241"/>
+<text text-anchor="start" x="220" y="-247.8" font-family="Times,serif" font-size="14.00">False</text>
</g>
<!-- If9&#45;&gt;Start2 -->
<g id="edge4" class="edge">
<title>If9&#45;&gt;Start2:p0</title>
-<path fill="none" stroke="red" d="M42.97,-296.24C27.91,-316.97 14.73,-344.58 27,-368 40.05,-392.9 56.78,-386.79 79,-404 85.54,-409.07 87.43,-415.44 91.34,-419.37"/>
-<polygon fill="red" stroke="red" points="90.41,-422.76 101,-423 92.87,-416.2 90.41,-422.76"/>
-<text text-anchor="middle" x="39.97" y="-298.84" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+<path fill="none" stroke="red" d="M210.31,-296.18C203.59,-317.4 193.07,-345.57 179,-368 166.9,-387.28 145.68,-386.25 139.64,-402.02"/>
+<polygon fill="red" stroke="red" points="136.17,-401.56 138,-412 143.08,-402.7 136.17,-401.56"/>
+<text text-anchor="middle" x="207.31" y="-298.78" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
</g>
<!-- If9&#45;&gt;EQNode8 -->
<g id="edge5" class="edge">
<title>If9&#45;&gt;EQNode8</title>
-<path fill="none" stroke="black" d="M68.02,-296.28C67.23,-304.58 66.38,-313.48 65.61,-321.56"/>
-<polygon fill="black" stroke="black" points="62.12,-321.31 64.66,-331.6 69.09,-321.97 62.12,-321.31"/>
-<text text-anchor="middle" x="65.02" y="-298.88" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+<path fill="none" stroke="black" d="M229.43,-296.28C232.3,-304.9 235.39,-314.17 238.16,-322.49"/>
+<polygon fill="black" stroke="black" points="234.87,-323.69 241.36,-332.07 241.51,-321.48 234.87,-323.69"/>
+<text text-anchor="middle" x="226.43" y="-298.88" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
</g>
<!-- Con_13 -->
<g id="node6" class="node">
<title>Con_13</title>
-<ellipse fill="none" stroke="black" cx="247" cy="-350" rx="27" ry="18"/>
-<text text-anchor="middle" x="247" y="-346.3" font-family="Times,serif" font-size="14.00">#2</text>
+<ellipse fill="none" stroke="black" cx="43" cy="-350" rx="27" ry="18"/>
+<text text-anchor="middle" x="43" y="-346.3" font-family="Times,serif" font-size="14.00">#2</text>
</g>
<!-- Add14 -->
<g id="node7" class="node">
<title>Add14</title>
-<ellipse fill="none" stroke="black" cx="243" cy="-264" rx="27" ry="18"/>
-<text text-anchor="middle" x="243" y="-260.3" font-family="Times,serif" font-size="14.00">+</text>
+<ellipse fill="none" stroke="black" cx="47" cy="-264" rx="27" ry="18"/>
+<text text-anchor="middle" x="47" y="-260.3" font-family="Times,serif" font-size="14.00">+</text>
</g>
<!-- Add14&#45;&gt;Start2 -->
<g id="edge6" class="edge">
<title>Add14&#45;&gt;Start2:p1</title>
-<path fill="none" stroke="black" d="M235.08,-281.55C223.08,-306.49 200.67,-352.43 191,-368 180.22,-385.36 164.4,-387.36 159.5,-401.83"/>
-<polygon fill="black" stroke="black" points="156,-401.6 158,-412 162.92,-402.62 156,-401.6"/>
-<text text-anchor="middle" x="232.08" y="-284.15" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+<path fill="none" stroke="black" d="M54.69,-281.49C67.53,-308.81 92.56,-361.14 99,-368 122.77,-393.31 164.37,-377.46 172.57,-402.01"/>
+<polygon fill="black" stroke="black" points="169.12,-402.6 174,-412 176.05,-401.61 169.12,-402.6"/>
+<text text-anchor="middle" x="51.69" y="-284.09" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
</g>
<!-- Add14&#45;&gt;Con_13 -->
<g id="edge7" class="edge">
<title>Add14&#45;&gt;Con_13</title>
-<path fill="none" stroke="black" d="M243.81,-282C244.35,-293.31 245.07,-308.42 245.69,-321.43"/>
-<polygon fill="black" stroke="black" points="242.21,-321.92 246.18,-331.74 249.2,-321.58 242.21,-321.92"/>
-<text text-anchor="middle" x="240.81" y="-284.6" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+<path fill="none" stroke="black" d="M46.19,-282C45.65,-293.31 44.93,-308.42 44.31,-321.43"/>
+<polygon fill="black" stroke="black" points="40.8,-321.58 43.82,-331.74 47.79,-321.92 40.8,-321.58"/>
+<text text-anchor="middle" x="43.19" y="-284.6" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
</g>
<!-- Con_15 -->
<g id="node8" class="node">
<title>Con_15</title>
-<ellipse fill="none" stroke="black" cx="155" cy="-350" rx="27" ry="18"/>
-<text text-anchor="middle" x="155" y="-346.3" font-family="Times,serif" font-size="14.00">#3</text>
+<ellipse fill="none" stroke="black" cx="135" cy="-350" rx="27" ry="18"/>
+<text text-anchor="middle" x="135" y="-346.3" font-family="Times,serif" font-size="14.00">#3</text>
</g>
<!-- Sub16 -->
<g id="node9" class="node">
<title>Sub16</title>
-<ellipse fill="none" stroke="black" cx="171" cy="-264" rx="27" ry="18"/>
-<text text-anchor="middle" x="171" y="-260.3" font-family="Times,serif" font-size="14.00">&#45;</text>
+<ellipse fill="none" stroke="black" cx="119" cy="-264" rx="27" ry="18"/>
+<text text-anchor="middle" x="119" y="-260.3" font-family="Times,serif" font-size="14.00">&#45;</text>
</g>
<!-- Sub16&#45;&gt;Start2 -->
<g id="edge8" class="edge">
<title>Sub16&#45;&gt;Start2:p1</title>
-<path fill="none" stroke="black" d="M155.57,-278.95C143,-291.44 126.2,-310.97 119,-332 113.82,-347.14 113.32,-353.04 119,-368 126.82,-388.61 149.21,-387.16 156.01,-401.9"/>
-<polygon fill="black" stroke="black" points="152.64,-402.86 158,-412 159.5,-401.51 152.64,-402.86"/>
-<text text-anchor="middle" x="152.57" y="-281.55" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+<path fill="none" stroke="black" d="M134.23,-279.02C146.68,-291.55 163.4,-311.1 171,-332 181.92,-362.04 175.64,-373.96 174.25,-401.87"/>
+<polygon fill="black" stroke="black" points="170.75,-401.92 174,-412 177.75,-402.09 170.75,-401.92"/>
+<text text-anchor="middle" x="131.23" y="-281.62" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
</g>
<!-- Sub16&#45;&gt;Con_15 -->
<g id="edge9" class="edge">
<title>Sub16&#45;&gt;Con_15</title>
-<path fill="none" stroke="black" d="M167.76,-282C165.57,-293.5 162.63,-308.93 160.13,-322.08"/>
-<polygon fill="black" stroke="black" points="156.67,-321.55 158.23,-332.03 163.54,-322.86 156.67,-321.55"/>
-<text text-anchor="middle" x="164.76" y="-284.6" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+<path fill="none" stroke="black" d="M122.24,-282C124.43,-293.5 127.37,-308.93 129.87,-322.08"/>
+<polygon fill="black" stroke="black" points="126.46,-322.86 131.77,-332.03 133.33,-321.55 126.46,-322.86"/>
+<text text-anchor="middle" x="119.24" y="-284.6" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
</g>
<!-- Region17 -->
<g id="node10" class="node">
<title>Region17</title>
-<polygon fill="yellow" stroke="black" points="124,-196 58,-196 58,-160 124,-160 124,-196"/>
-<text text-anchor="middle" x="91" y="-174.3" font-family="Times,serif" font-size="14.00">Region</text>
+<polygon fill="yellow" stroke="black" points="230,-196 164,-196 164,-160 230,-160 230,-196"/>
+<text text-anchor="middle" x="197" y="-174.3" font-family="Times,serif" font-size="14.00">Region</text>
</g>
<!-- Region17&#45;&gt;If9 -->
<g id="edge10" class="edge">
<title>Region17&#45;&gt;If9:p0</title>
-<path fill="none" stroke="red" d="M70.98,-196.12C62.36,-205.06 53.52,-216.84 50.29,-229.84"/>
-<polygon fill="red" stroke="red" points="46.78,-229.64 49,-240 53.73,-230.52 46.78,-229.64"/>
-<text text-anchor="middle" x="67.98" y="-198.72" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+<path fill="none" stroke="red" d="M197,-196.09C197,-205.55 197,-217.77 197,-229.69"/>
+<polygon fill="red" stroke="red" points="193.5,-230 197,-240 200.5,-230 193.5,-230"/>
+<text text-anchor="middle" x="194" y="-198.69" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
</g>
<!-- Region17&#45;&gt;If9 -->
<g id="edge11" class="edge">
<title>Region17&#45;&gt;If9:p1</title>
-<path fill="none" stroke="red" d="M91,-196.09C91,-205.55 91,-217.77 91,-229.69"/>
-<polygon fill="red" stroke="red" points="87.5,-230 91,-240 94.5,-230 87.5,-230"/>
-<text text-anchor="middle" x="88" y="-198.69" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+<path fill="none" stroke="red" d="M217.02,-196.12C225.64,-205.06 234.48,-216.84 237.71,-229.84"/>
+<polygon fill="red" stroke="red" points="234.27,-230.52 239,-240 241.22,-229.64 234.27,-230.52"/>
+<text text-anchor="middle" x="214.02" y="-198.72" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
</g>
<!-- Phi_a18 -->
<g id="node11" class="node">
<title>Phi_a18</title>
-<ellipse fill="lightyellow" stroke="black" cx="170" cy="-178" rx="27" ry="18"/>
-<text text-anchor="middle" x="170" y="-174.3" font-family="Times,serif" font-size="14.00">φ_a</text>
+<ellipse fill="lightyellow" stroke="black" cx="119" cy="-178" rx="27" ry="18"/>
+<text text-anchor="middle" x="119" y="-174.3" font-family="Times,serif" font-size="14.00">φ_a</text>
</g>
-<!-- Region17&#45;&gt;Phi_a18 -->
<!-- Phi_a18&#45;&gt;Add14 -->
<g id="edge13" class="edge">
<title>Phi_a18&#45;&gt;Add14</title>
-<path fill="none" stroke="black" d="M183.05,-194.02C194.26,-206.92 210.59,-225.71 223.38,-240.42"/>
-<polygon fill="black" stroke="black" points="220.86,-242.86 230.06,-248.11 226.14,-238.27 220.86,-242.86"/>
-<text text-anchor="middle" x="180.05" y="-196.62" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+<path fill="none" stroke="black" d="M106.13,-194.02C95.07,-206.92 78.96,-225.71 66.35,-240.42"/>
+<polygon fill="black" stroke="black" points="63.61,-238.24 59.76,-248.11 68.93,-242.8 63.61,-238.24"/>
+<text text-anchor="middle" x="103.13" y="-196.62" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
</g>
<!-- Phi_a18&#45;&gt;Sub16 -->
<g id="edge14" class="edge">
<title>Phi_a18&#45;&gt;Sub16</title>
-<path fill="none" stroke="black" d="M170.21,-196.4C170.34,-207.74 170.52,-222.77 170.67,-235.68"/>
-<polygon fill="black" stroke="black" points="167.18,-235.95 170.8,-245.9 174.18,-235.86 167.18,-235.95"/>
-<text text-anchor="middle" x="167.21" y="-199" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+<path fill="none" stroke="black" d="M119,-196.4C119,-207.74 119,-222.77 119,-235.68"/>
+<polygon fill="black" stroke="black" points="115.5,-235.9 119,-245.9 122.5,-235.9 115.5,-235.9"/>
+<text text-anchor="middle" x="116" y="-199" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Phi_a18&#45;&gt;Region17 -->
+<g id="edge12" class="edge">
+<title>Phi_a18&#45;&gt;Region17</title>
+<path fill="none" stroke="black" stroke-dasharray="1,5" d="M146.12,-178C148.58,-178 151.04,-178 153.5,-178"/>
+<polygon fill="black" stroke="black" points="153.61,-181.5 163.61,-178 153.61,-174.5 153.61,-181.5"/>
+<text text-anchor="middle" x="149.12" y="-171.6" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
</g>
<!-- Return19&#45;&gt;Region17 -->
<g id="edge15" class="edge">
<title>Return19&#45;&gt;Region17</title>
-<path fill="none" stroke="red" d="M120.36,-124.3C115.87,-132.36 110.44,-142.11 105.48,-151.02"/>
-<polygon fill="red" stroke="red" points="102.34,-149.46 100.53,-159.9 108.45,-152.86 102.34,-149.46"/>
-<text text-anchor="middle" x="117.36" y="-126.9" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+<path fill="none" stroke="red" d="M167.64,-124.3C172.13,-132.36 177.56,-142.11 182.52,-151.02"/>
+<polygon fill="red" stroke="red" points="179.55,-152.86 187.47,-159.9 185.66,-149.46 179.55,-152.86"/>
+<text text-anchor="middle" x="164.64" y="-126.9" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
</g>
<!-- Return19&#45;&gt;Phi_a18 -->
<g id="edge16" class="edge">
<title>Return19&#45;&gt;Phi_a18</title>
-<path fill="none" stroke="black" d="M139.89,-124.3C144.68,-132.68 150.52,-142.9 155.77,-152.1"/>
-<polygon fill="black" stroke="black" points="152.77,-153.91 160.77,-160.86 158.85,-150.44 152.77,-153.91"/>
-<text text-anchor="middle" x="136.89" y="-126.9" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+<path fill="none" stroke="black" d="M148.36,-124.3C143.69,-132.68 138,-142.9 132.87,-152.1"/>
+<polygon fill="black" stroke="black" points="129.8,-150.42 127.99,-160.86 135.92,-153.82 129.8,-150.42"/>
+<text text-anchor="middle" x="145.36" y="-126.9" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
</g>
</g>
</svg>
diff --git a/chapter05/docs/05-graph4.gv b/chapter05/docs/05-graph4.gv
new file mode 100644
index 00000000..ac3dcdd7
--- /dev/null
+++ b/chapter05/docs/05-graph4.gv
@@ -0,0 +1,63 @@
+digraph chapter05 {
+/*
+int a=arg==2;
+if( arg==1 )
+{
+ a=arg==3;
+}
+return a;
+*/
+ rankdir=BT;
+ ordering="in";
+ concentrate="true";
+ subgraph cluster_Nodes {
+ Start2 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">Start</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">$ctrl</TD><TD PORT="p1">arg</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Stop3 [ shape=box style=filled fillcolor=yellow label="Stop" ];
+ Con_6 [ label="#2" ];
+ EQNode7 [ label="==" ];
+ Con_8 [ label="#1" ];
+ EQNode9 [ label="==" ];
+ If10 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">If</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">True</TD><TD PORT="p1" BGCOLOR="yellow">False</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Con_14 [ label="#3" ];
+ EQNode15 [ label="==" ];
+ Region16 [ shape=box style=filled fillcolor=yellow label="Region" ];
+ Phi_a17 [ style=filled fillcolor=lightyellow label="&phi;_a" ];
+ Return18 [ shape=box style=filled fillcolor=yellow label="Return" ];
+ { rank=same; Region16;Phi_a17;}
+ }
+ edge [ fontname=Helvetica, fontsize=8 ];
+ Stop3 -> Return18[taillabel=0 color=red];
+ EQNode7 -> Start2:p1[taillabel=1];
+ EQNode7 -> Con_6[taillabel=2];
+ EQNode9 -> Start2:p1[taillabel=1];
+ EQNode9 -> Con_8[taillabel=2];
+ If10 -> Start2:p0[taillabel=0 color=red];
+ If10 -> EQNode9[taillabel=1];
+ EQNode15 -> Start2:p1[taillabel=1];
+ EQNode15 -> Con_14[taillabel=2];
+ Region16 -> If10:p0[taillabel=1 color=red];
+ Region16 -> If10:p1[taillabel=2 color=red];
+ Phi_a17 -> Region16 [style=dotted taillabel=0];
+ Phi_a17 -> EQNode15[taillabel=1];
+ Phi_a17 -> EQNode7[taillabel=2];
+ Return18 -> Region16[taillabel=0 color=red];
+ Return18 -> Phi_a17[taillabel=1];
+} \ No newline at end of file
diff --git a/chapter05/docs/05-graph4.svg b/chapter05/docs/05-graph4.svg
new file mode 100644
index 00000000..3fcee500
--- /dev/null
+++ b/chapter05/docs/05-graph4.svg
@@ -0,0 +1,216 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<!-- Generated by graphviz version 2.43.0 (0)
+ -->
+<!-- Title: chapter05 Pages: 1 -->
+<svg width="298pt" height="492pt"
+ viewBox="0.00 0.00 298.00 492.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 488)">
+<title>chapter05</title>
+<polygon fill="white" stroke="transparent" points="-4,4 -4,-488 294,-488 294,4 -4,4"/>
+<g id="clust1" class="cluster">
+<title>cluster_Nodes</title>
+<polygon fill="none" stroke="black" points="8,-8 8,-476 282,-476 282,-8 8,-8"/>
+</g>
+<!-- Start2 -->
+<g id="node1" class="node">
+<title>Start2</title>
+<polygon fill="yellow" stroke="transparent" points="113,-439 113,-464 194,-464 194,-439 113,-439"/>
+<polygon fill="none" stroke="black" points="113,-439 113,-464 194,-464 194,-439 113,-439"/>
+<text text-anchor="start" x="135" y="-447.8" font-family="Times,serif" font-size="14.00">Start</text>
+<polygon fill="none" stroke="black" points="113,-408 113,-439 194,-439 194,-408 113,-408"/>
+<polygon fill="yellow" stroke="transparent" points="118,-413 118,-434 158,-434 158,-413 118,-413"/>
+<polygon fill="none" stroke="black" points="118,-413 118,-434 158,-434 158,-413 118,-413"/>
+<text text-anchor="start" x="121" y="-419.8" font-family="Times,serif" font-size="14.00">$ctrl</text>
+<polygon fill="none" stroke="black" points="158,-413 158,-434 189,-434 189,-413 158,-413"/>
+<text text-anchor="start" x="161" y="-419.8" font-family="Times,serif" font-size="14.00">arg</text>
+</g>
+<!-- Stop3 -->
+<g id="node2" class="node">
+<title>Stop3</title>
+<polygon fill="yellow" stroke="black" points="185,-52 131,-52 131,-16 185,-16 185,-52"/>
+<text text-anchor="middle" x="158" y="-30.3" font-family="Times,serif" font-size="14.00">Stop</text>
+</g>
+<!-- Return18 -->
+<g id="node12" class="node">
+<title>Return18</title>
+<polygon fill="yellow" stroke="black" points="191,-124 125,-124 125,-88 191,-88 191,-124"/>
+<text text-anchor="middle" x="158" y="-102.3" font-family="Times,serif" font-size="14.00">Return</text>
+</g>
+<!-- Stop3&#45;&gt;Return18 -->
+<g id="edge1" class="edge">
+<title>Stop3&#45;&gt;Return18</title>
+<path fill="none" stroke="red" d="M158,-52.3C158,-60.02 158,-69.29 158,-77.89"/>
+<polygon fill="red" stroke="red" points="154.5,-77.9 158,-87.9 161.5,-77.9 154.5,-77.9"/>
+<text text-anchor="middle" x="155" y="-54.9" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Con_6 -->
+<g id="node3" class="node">
+<title>Con_6</title>
+<ellipse fill="none" stroke="black" cx="43" cy="-350" rx="27" ry="18"/>
+<text text-anchor="middle" x="43" y="-346.3" font-family="Times,serif" font-size="14.00">#2</text>
+</g>
+<!-- EQNode7 -->
+<g id="node4" class="node">
+<title>EQNode7</title>
+<ellipse fill="none" stroke="black" cx="47" cy="-264" rx="27" ry="18"/>
+<text text-anchor="middle" x="47" y="-260.3" font-family="Times,serif" font-size="14.00">==</text>
+</g>
+<!-- EQNode7&#45;&gt;Start2 -->
+<g id="edge2" class="edge">
+<title>EQNode7&#45;&gt;Start2:p1</title>
+<path fill="none" stroke="black" d="M54.69,-281.49C67.53,-308.81 92.56,-361.14 99,-368 122.77,-393.31 164.37,-377.46 172.57,-402.01"/>
+<polygon fill="black" stroke="black" points="169.12,-402.6 174,-412 176.05,-401.61 169.12,-402.6"/>
+<text text-anchor="middle" x="51.69" y="-284.09" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- EQNode7&#45;&gt;Con_6 -->
+<g id="edge3" class="edge">
+<title>EQNode7&#45;&gt;Con_6</title>
+<path fill="none" stroke="black" d="M46.19,-282C45.65,-293.31 44.93,-308.42 44.31,-321.43"/>
+<polygon fill="black" stroke="black" points="40.8,-321.58 43.82,-331.74 47.79,-321.92 40.8,-321.58"/>
+<text text-anchor="middle" x="43.19" y="-284.6" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Con_8 -->
+<g id="node5" class="node">
+<title>Con_8</title>
+<ellipse fill="none" stroke="black" cx="247" cy="-436" rx="27" ry="18"/>
+<text text-anchor="middle" x="247" y="-432.3" font-family="Times,serif" font-size="14.00">#1</text>
+</g>
+<!-- EQNode9 -->
+<g id="node6" class="node">
+<title>EQNode9</title>
+<ellipse fill="none" stroke="black" cx="247" cy="-350" rx="27" ry="18"/>
+<text text-anchor="middle" x="247" y="-346.3" font-family="Times,serif" font-size="14.00">==</text>
+</g>
+<!-- EQNode9&#45;&gt;Start2 -->
+<g id="edge4" class="edge">
+<title>EQNode9&#45;&gt;Start2:p1</title>
+<path fill="none" stroke="black" d="M236.57,-366.62C225.76,-382.5 208.98,-406.28 198.26,-417.17"/>
+<polygon fill="black" stroke="black" points="196.15,-414.37 190,-423 200.19,-420.09 196.15,-414.37"/>
+<text text-anchor="middle" x="233.57" y="-369.22" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- EQNode9&#45;&gt;Con_8 -->
+<g id="edge5" class="edge">
+<title>EQNode9&#45;&gt;Con_8</title>
+<path fill="none" stroke="black" d="M247,-368.4C247,-379.74 247,-394.77 247,-407.68"/>
+<polygon fill="black" stroke="black" points="243.5,-407.9 247,-417.9 250.5,-407.9 243.5,-407.9"/>
+<text text-anchor="middle" x="244" y="-371" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- If10 -->
+<g id="node7" class="node">
+<title>If10</title>
+<polygon fill="yellow" stroke="transparent" points="172,-267 172,-292 266,-292 266,-267 172,-267"/>
+<polygon fill="none" stroke="black" points="172,-267 172,-292 266,-292 266,-267 172,-267"/>
+<text text-anchor="start" x="213.5" y="-275.8" font-family="Times,serif" font-size="14.00">If</text>
+<polygon fill="none" stroke="black" points="172,-236 172,-267 266,-267 266,-236 172,-236"/>
+<polygon fill="yellow" stroke="transparent" points="177,-241 177,-262 217,-262 217,-241 177,-241"/>
+<polygon fill="none" stroke="black" points="177,-241 177,-262 217,-262 217,-241 177,-241"/>
+<text text-anchor="start" x="180" y="-247.8" font-family="Times,serif" font-size="14.00">True</text>
+<polygon fill="yellow" stroke="transparent" points="217,-241 217,-262 261,-262 261,-241 217,-241"/>
+<polygon fill="none" stroke="black" points="217,-241 217,-262 261,-262 261,-241 217,-241"/>
+<text text-anchor="start" x="220" y="-247.8" font-family="Times,serif" font-size="14.00">False</text>
+</g>
+<!-- If10&#45;&gt;Start2 -->
+<g id="edge6" class="edge">
+<title>If10&#45;&gt;Start2:p0</title>
+<path fill="none" stroke="red" d="M210.31,-296.18C203.59,-317.4 193.07,-345.57 179,-368 166.9,-387.28 145.68,-386.25 139.64,-402.02"/>
+<polygon fill="red" stroke="red" points="136.17,-401.56 138,-412 143.08,-402.7 136.17,-401.56"/>
+<text text-anchor="middle" x="207.31" y="-298.78" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- If10&#45;&gt;EQNode9 -->
+<g id="edge7" class="edge">
+<title>If10&#45;&gt;EQNode9</title>
+<path fill="none" stroke="black" d="M229.43,-296.28C232.3,-304.9 235.39,-314.17 238.16,-322.49"/>
+<polygon fill="black" stroke="black" points="234.87,-323.69 241.36,-332.07 241.51,-321.48 234.87,-323.69"/>
+<text text-anchor="middle" x="226.43" y="-298.88" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Con_14 -->
+<g id="node8" class="node">
+<title>Con_14</title>
+<ellipse fill="none" stroke="black" cx="135" cy="-350" rx="27" ry="18"/>
+<text text-anchor="middle" x="135" y="-346.3" font-family="Times,serif" font-size="14.00">#3</text>
+</g>
+<!-- EQNode15 -->
+<g id="node9" class="node">
+<title>EQNode15</title>
+<ellipse fill="none" stroke="black" cx="119" cy="-264" rx="27" ry="18"/>
+<text text-anchor="middle" x="119" y="-260.3" font-family="Times,serif" font-size="14.00">==</text>
+</g>
+<!-- EQNode15&#45;&gt;Start2 -->
+<g id="edge8" class="edge">
+<title>EQNode15&#45;&gt;Start2:p1</title>
+<path fill="none" stroke="black" d="M134.23,-279.02C146.68,-291.55 163.4,-311.1 171,-332 181.92,-362.04 175.64,-373.96 174.25,-401.87"/>
+<polygon fill="black" stroke="black" points="170.75,-401.92 174,-412 177.75,-402.09 170.75,-401.92"/>
+<text text-anchor="middle" x="131.23" y="-281.62" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- EQNode15&#45;&gt;Con_14 -->
+<g id="edge9" class="edge">
+<title>EQNode15&#45;&gt;Con_14</title>
+<path fill="none" stroke="black" d="M122.24,-282C124.43,-293.5 127.37,-308.93 129.87,-322.08"/>
+<polygon fill="black" stroke="black" points="126.46,-322.86 131.77,-332.03 133.33,-321.55 126.46,-322.86"/>
+<text text-anchor="middle" x="119.24" y="-284.6" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Region16 -->
+<g id="node10" class="node">
+<title>Region16</title>
+<polygon fill="yellow" stroke="black" points="230,-196 164,-196 164,-160 230,-160 230,-196"/>
+<text text-anchor="middle" x="197" y="-174.3" font-family="Times,serif" font-size="14.00">Region</text>
+</g>
+<!-- Region16&#45;&gt;If10 -->
+<g id="edge10" class="edge">
+<title>Region16&#45;&gt;If10:p0</title>
+<path fill="none" stroke="red" d="M197,-196.09C197,-205.55 197,-217.77 197,-229.69"/>
+<polygon fill="red" stroke="red" points="193.5,-230 197,-240 200.5,-230 193.5,-230"/>
+<text text-anchor="middle" x="194" y="-198.69" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Region16&#45;&gt;If10 -->
+<g id="edge11" class="edge">
+<title>Region16&#45;&gt;If10:p1</title>
+<path fill="none" stroke="red" d="M217.02,-196.12C225.64,-205.06 234.48,-216.84 237.71,-229.84"/>
+<polygon fill="red" stroke="red" points="234.27,-230.52 239,-240 241.22,-229.64 234.27,-230.52"/>
+<text text-anchor="middle" x="214.02" y="-198.72" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Phi_a17 -->
+<g id="node11" class="node">
+<title>Phi_a17</title>
+<ellipse fill="lightyellow" stroke="black" cx="119" cy="-178" rx="27" ry="18"/>
+<text text-anchor="middle" x="119" y="-174.3" font-family="Times,serif" font-size="14.00">φ_a</text>
+</g>
+<!-- Phi_a17&#45;&gt;EQNode7 -->
+<g id="edge14" class="edge">
+<title>Phi_a17&#45;&gt;EQNode7</title>
+<path fill="none" stroke="black" d="M106.13,-194.02C95.07,-206.92 78.96,-225.71 66.35,-240.42"/>
+<polygon fill="black" stroke="black" points="63.61,-238.24 59.76,-248.11 68.93,-242.8 63.61,-238.24"/>
+<text text-anchor="middle" x="103.13" y="-196.62" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Phi_a17&#45;&gt;EQNode15 -->
+<g id="edge13" class="edge">
+<title>Phi_a17&#45;&gt;EQNode15</title>
+<path fill="none" stroke="black" d="M119,-196.4C119,-207.74 119,-222.77 119,-235.68"/>
+<polygon fill="black" stroke="black" points="115.5,-235.9 119,-245.9 122.5,-235.9 115.5,-235.9"/>
+<text text-anchor="middle" x="116" y="-199" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Phi_a17&#45;&gt;Region16 -->
+<g id="edge12" class="edge">
+<title>Phi_a17&#45;&gt;Region16</title>
+<path fill="none" stroke="black" stroke-dasharray="1,5" d="M146.12,-178C148.58,-178 151.04,-178 153.5,-178"/>
+<polygon fill="black" stroke="black" points="153.61,-181.5 163.61,-178 153.61,-174.5 153.61,-181.5"/>
+<text text-anchor="middle" x="149.12" y="-171.6" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Return18&#45;&gt;Region16 -->
+<g id="edge15" class="edge">
+<title>Return18&#45;&gt;Region16</title>
+<path fill="none" stroke="red" d="M167.64,-124.3C172.13,-132.36 177.56,-142.11 182.52,-151.02"/>
+<polygon fill="red" stroke="red" points="179.55,-152.86 187.47,-159.9 185.66,-149.46 179.55,-152.86"/>
+<text text-anchor="middle" x="164.64" y="-126.9" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Return18&#45;&gt;Phi_a17 -->
+<g id="edge16" class="edge">
+<title>Return18&#45;&gt;Phi_a17</title>
+<path fill="none" stroke="black" d="M148.36,-124.3C143.69,-132.68 138,-142.9 132.87,-152.1"/>
+<polygon fill="black" stroke="black" points="129.8,-150.42 127.99,-160.86 135.92,-153.82 129.8,-150.42"/>
+<text text-anchor="middle" x="145.36" y="-126.9" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+</g>
+</svg>
diff --git a/chapter05/docs/05-graph5.gv b/chapter05/docs/05-graph5.gv
new file mode 100644
index 00000000..b6bfd5f2
--- /dev/null
+++ b/chapter05/docs/05-graph5.gv
@@ -0,0 +1,60 @@
+digraph chapter05 {
+/*
+int a=arg==2;
+if( arg==1 )
+{
+ a=arg==3;
+}
+return a;
+*/
+ rankdir=BT;
+ ordering="in";
+ concentrate="true";
+ subgraph cluster_Nodes {
+ Start2 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">Start</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">$ctrl</TD><TD PORT="p1">arg</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Stop3 [ shape=box style=filled fillcolor=yellow label="Stop" ];
+ Con_6 [ label="#2" ];
+ Con_8 [ label="#1" ];
+ EQNode9 [ label="==" ];
+ If10 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">If</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">True</TD><TD PORT="p1" BGCOLOR="yellow">False</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Con_14 [ label="#3" ];
+ Region16 [ shape=box style=filled fillcolor=yellow label="Region" ];
+ Phi_a19 [ style=filled fillcolor=lightyellow label="&phi;_a" ];
+ EQNode20 [ label="==" ];
+ Return21 [ shape=box style=filled fillcolor=yellow label="Return" ];
+ { rank=same; Region16;Phi_a19;}
+ }
+ edge [ fontname=Helvetica, fontsize=8 ];
+ Stop3 -> Return21[taillabel=0 color=red];
+ EQNode9 -> Start2:p1[taillabel=1];
+ EQNode9 -> Con_8[taillabel=2];
+ If10 -> Start2:p0[taillabel=0 color=red];
+ If10 -> EQNode9[taillabel=1];
+ Region16 -> If10:p0[taillabel=1 color=red];
+ Region16 -> If10:p1[taillabel=2 color=red];
+ Phi_a19 -> Region16 [style=dotted taillabel=0];
+ Phi_a19 -> Con_14[taillabel=1];
+ Phi_a19 -> Con_6[taillabel=2];
+ EQNode20 -> Start2:p1[taillabel=1];
+ EQNode20 -> Phi_a19[taillabel=2];
+ Return21 -> Region16[taillabel=0 color=red];
+ Return21 -> EQNode20[taillabel=1];
+} \ No newline at end of file
diff --git a/chapter05/docs/05-graph5.svg b/chapter05/docs/05-graph5.svg
new file mode 100644
index 00000000..4f6fa4bd
--- /dev/null
+++ b/chapter05/docs/05-graph5.svg
@@ -0,0 +1,196 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<!-- Generated by graphviz version 2.43.0 (0)
+ -->
+<!-- Title: chapter05 Pages: 1 -->
+<svg width="314pt" height="564pt"
+ viewBox="0.00 0.00 314.00 564.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 560)">
+<title>chapter05</title>
+<polygon fill="white" stroke="transparent" points="-4,4 -4,-560 310,-560 310,4 -4,4"/>
+<g id="clust1" class="cluster">
+<title>cluster_Nodes</title>
+<polygon fill="none" stroke="black" points="8,-8 8,-548 298,-548 298,-8 8,-8"/>
+</g>
+<!-- Start2 -->
+<g id="node1" class="node">
+<title>Start2</title>
+<polygon fill="yellow" stroke="transparent" points="97,-511 97,-536 178,-536 178,-511 97,-511"/>
+<polygon fill="none" stroke="black" points="97,-511 97,-536 178,-536 178,-511 97,-511"/>
+<text text-anchor="start" x="119" y="-519.8" font-family="Times,serif" font-size="14.00">Start</text>
+<polygon fill="none" stroke="black" points="97,-480 97,-511 178,-511 178,-480 97,-480"/>
+<polygon fill="yellow" stroke="transparent" points="102,-485 102,-506 142,-506 142,-485 102,-485"/>
+<polygon fill="none" stroke="black" points="102,-485 102,-506 142,-506 142,-485 102,-485"/>
+<text text-anchor="start" x="105" y="-491.8" font-family="Times,serif" font-size="14.00">$ctrl</text>
+<polygon fill="none" stroke="black" points="142,-485 142,-506 173,-506 173,-485 142,-485"/>
+<text text-anchor="start" x="145" y="-491.8" font-family="Times,serif" font-size="14.00">arg</text>
+</g>
+<!-- Stop3 -->
+<g id="node2" class="node">
+<title>Stop3</title>
+<polygon fill="yellow" stroke="black" points="148,-52 94,-52 94,-16 148,-16 148,-52"/>
+<text text-anchor="middle" x="121" y="-30.3" font-family="Times,serif" font-size="14.00">Stop</text>
+</g>
+<!-- Return21 -->
+<g id="node11" class="node">
+<title>Return21</title>
+<polygon fill="yellow" stroke="black" points="154,-124 88,-124 88,-88 154,-88 154,-124"/>
+<text text-anchor="middle" x="121" y="-102.3" font-family="Times,serif" font-size="14.00">Return</text>
+</g>
+<!-- Stop3&#45;&gt;Return21 -->
+<g id="edge1" class="edge">
+<title>Stop3&#45;&gt;Return21</title>
+<path fill="none" stroke="red" d="M121,-52.3C121,-60.02 121,-69.29 121,-77.89"/>
+<polygon fill="red" stroke="red" points="117.5,-77.9 121,-87.9 124.5,-77.9 117.5,-77.9"/>
+<text text-anchor="middle" x="118" y="-54.9" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Con_6 -->
+<g id="node3" class="node">
+<title>Con_6</title>
+<ellipse fill="none" stroke="black" cx="263" cy="-336" rx="27" ry="18"/>
+<text text-anchor="middle" x="263" y="-332.3" font-family="Times,serif" font-size="14.00">#2</text>
+</g>
+<!-- Con_8 -->
+<g id="node4" class="node">
+<title>Con_8</title>
+<ellipse fill="none" stroke="black" cx="43" cy="-508" rx="27" ry="18"/>
+<text text-anchor="middle" x="43" y="-504.3" font-family="Times,serif" font-size="14.00">#1</text>
+</g>
+<!-- EQNode9 -->
+<g id="node5" class="node">
+<title>EQNode9</title>
+<ellipse fill="none" stroke="black" cx="71" cy="-422" rx="27" ry="18"/>
+<text text-anchor="middle" x="71" y="-418.3" font-family="Times,serif" font-size="14.00">==</text>
+</g>
+<!-- EQNode9&#45;&gt;Start2 -->
+<g id="edge2" class="edge">
+<title>EQNode9&#45;&gt;Start2:p1</title>
+<path fill="none" stroke="black" d="M92.51,-433.05C113.44,-443.41 143.59,-460.03 154.16,-474.46"/>
+<polygon fill="black" stroke="black" points="151.02,-476.03 158,-484 157.51,-473.42 151.02,-476.03"/>
+<text text-anchor="middle" x="89.51" y="-435.65" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- EQNode9&#45;&gt;Con_8 -->
+<g id="edge3" class="edge">
+<title>EQNode9&#45;&gt;Con_8</title>
+<path fill="none" stroke="black" d="M65.33,-440C61.44,-451.69 56.19,-467.44 51.76,-480.73"/>
+<polygon fill="black" stroke="black" points="48.4,-479.72 48.56,-490.31 55.04,-481.93 48.4,-479.72"/>
+<text text-anchor="middle" x="62.33" y="-442.6" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- If10 -->
+<g id="node6" class="node">
+<title>If10</title>
+<polygon fill="yellow" stroke="transparent" points="24,-339 24,-364 118,-364 118,-339 24,-339"/>
+<polygon fill="none" stroke="black" points="24,-339 24,-364 118,-364 118,-339 24,-339"/>
+<text text-anchor="start" x="65.5" y="-347.8" font-family="Times,serif" font-size="14.00">If</text>
+<polygon fill="none" stroke="black" points="24,-308 24,-339 118,-339 118,-308 24,-308"/>
+<polygon fill="yellow" stroke="transparent" points="29,-313 29,-334 69,-334 69,-313 29,-313"/>
+<polygon fill="none" stroke="black" points="29,-313 29,-334 69,-334 69,-313 29,-313"/>
+<text text-anchor="start" x="32" y="-319.8" font-family="Times,serif" font-size="14.00">True</text>
+<polygon fill="yellow" stroke="transparent" points="69,-313 69,-334 113,-334 113,-313 69,-313"/>
+<polygon fill="none" stroke="black" points="69,-313 69,-334 113,-334 113,-313 69,-313"/>
+<text text-anchor="start" x="72" y="-319.8" font-family="Times,serif" font-size="14.00">False</text>
+</g>
+<!-- If10&#45;&gt;Start2 -->
+<g id="edge4" class="edge">
+<title>If10&#45;&gt;Start2:p0</title>
+<path fill="none" stroke="red" d="M90.29,-368.12C96.41,-379.12 102.69,-391.8 107,-404 117.81,-434.65 121.3,-445.6 121.9,-473.74"/>
+<polygon fill="red" stroke="red" points="118.4,-474.03 122,-484 125.4,-473.97 118.4,-474.03"/>
+<text text-anchor="middle" x="87.29" y="-370.72" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- If10&#45;&gt;EQNode9 -->
+<g id="edge5" class="edge">
+<title>If10&#45;&gt;EQNode9</title>
+<path fill="none" stroke="black" d="M71,-368.28C71,-376.58 71,-385.48 71,-393.56"/>
+<polygon fill="black" stroke="black" points="67.5,-393.6 71,-403.6 74.5,-393.6 67.5,-393.6"/>
+<text text-anchor="middle" x="68" y="-370.88" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Con_14 -->
+<g id="node7" class="node">
+<title>Con_14</title>
+<ellipse fill="none" stroke="black" cx="191" cy="-336" rx="27" ry="18"/>
+<text text-anchor="middle" x="191" y="-332.3" font-family="Times,serif" font-size="14.00">#3</text>
+</g>
+<!-- Region16 -->
+<g id="node8" class="node">
+<title>Region16</title>
+<polygon fill="yellow" stroke="black" points="125,-268 59,-268 59,-232 125,-232 125,-268"/>
+<text text-anchor="middle" x="92" y="-246.3" font-family="Times,serif" font-size="14.00">Region</text>
+</g>
+<!-- Region16&#45;&gt;If10 -->
+<g id="edge6" class="edge">
+<title>Region16&#45;&gt;If10:p0</title>
+<path fill="none" stroke="red" d="M71.51,-268.03C62.68,-276.94 53.63,-288.71 50.32,-301.78"/>
+<polygon fill="red" stroke="red" points="46.81,-301.63 49,-312 53.75,-302.53 46.81,-301.63"/>
+<text text-anchor="middle" x="68.51" y="-270.63" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Region16&#45;&gt;If10 -->
+<g id="edge7" class="edge">
+<title>Region16&#45;&gt;If10:p1</title>
+<path fill="none" stroke="red" d="M91.57,-268.09C91.36,-277.55 91.13,-289.77 91.04,-301.69"/>
+<polygon fill="red" stroke="red" points="87.54,-301.99 91,-312 94.54,-302.01 87.54,-301.99"/>
+<text text-anchor="middle" x="88.57" y="-270.69" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Phi_a19 -->
+<g id="node9" class="node">
+<title>Phi_a19</title>
+<ellipse fill="lightyellow" stroke="black" cx="191" cy="-250" rx="27" ry="18"/>
+<text text-anchor="middle" x="191" y="-246.3" font-family="Times,serif" font-size="14.00">φ_a</text>
+</g>
+<!-- Phi_a19&#45;&gt;Con_6 -->
+<g id="edge10" class="edge">
+<title>Phi_a19&#45;&gt;Con_6</title>
+<path fill="none" stroke="black" d="M203.87,-266.02C214.93,-278.92 231.04,-297.71 243.65,-312.42"/>
+<polygon fill="black" stroke="black" points="241.07,-314.8 250.24,-320.11 246.39,-310.24 241.07,-314.8"/>
+<text text-anchor="middle" x="200.87" y="-268.62" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Phi_a19&#45;&gt;Con_14 -->
+<g id="edge9" class="edge">
+<title>Phi_a19&#45;&gt;Con_14</title>
+<path fill="none" stroke="black" d="M191,-268.4C191,-279.74 191,-294.77 191,-307.68"/>
+<polygon fill="black" stroke="black" points="187.5,-307.9 191,-317.9 194.5,-307.9 187.5,-307.9"/>
+<text text-anchor="middle" x="188" y="-271" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Phi_a19&#45;&gt;Region16 -->
+<g id="edge8" class="edge">
+<title>Phi_a19&#45;&gt;Region16</title>
+<path fill="none" stroke="black" stroke-dasharray="1,5" d="M163.78,-250C154.35,-250 144.92,-250 135.49,-250"/>
+<polygon fill="black" stroke="black" points="135.26,-246.5 125.26,-250 135.26,-253.5 135.26,-246.5"/>
+<text text-anchor="middle" x="160.78" y="-243.6" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- EQNode20 -->
+<g id="node10" class="node">
+<title>EQNode20</title>
+<ellipse fill="none" stroke="black" cx="145" cy="-178" rx="27" ry="18"/>
+<text text-anchor="middle" x="145" y="-174.3" font-family="Times,serif" font-size="14.00">==</text>
+</g>
+<!-- EQNode20&#45;&gt;Start2 -->
+<g id="edge11" class="edge">
+<title>EQNode20&#45;&gt;Start2:p1</title>
+<path fill="none" stroke="black" d="M145.93,-196.36C148.75,-249.2 157.02,-408.5 157.92,-473.67"/>
+<polygon fill="black" stroke="black" points="154.42,-474.03 158,-484 161.42,-473.97 154.42,-474.03"/>
+<text text-anchor="middle" x="142.93" y="-198.96" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- EQNode20&#45;&gt;Phi_a19 -->
+<g id="edge12" class="edge">
+<title>EQNode20&#45;&gt;Phi_a19</title>
+<path fill="none" stroke="black" d="M155.44,-194.88C161.2,-203.66 168.48,-214.74 174.96,-224.58"/>
+<polygon fill="black" stroke="black" points="172.19,-226.74 180.6,-233.18 178.04,-222.9 172.19,-226.74"/>
+<text text-anchor="middle" x="152.44" y="-197.48" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Return21&#45;&gt;Region16 -->
+<g id="edge13" class="edge">
+<title>Return21&#45;&gt;Region16</title>
+<path fill="none" stroke="red" d="M116.96,-124.15C114.56,-134.51 111.51,-147.99 109,-160 104.69,-180.66 100.23,-204.11 96.96,-221.75"/>
+<polygon fill="red" stroke="red" points="93.46,-221.44 95.09,-231.9 100.34,-222.7 93.46,-221.44"/>
+<text text-anchor="middle" x="113.96" y="-126.75" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Return21&#45;&gt;EQNode20 -->
+<g id="edge14" class="edge">
+<title>Return21&#45;&gt;EQNode20</title>
+<path fill="none" stroke="black" d="M126.93,-124.3C129.68,-132.3 132.99,-141.98 136.03,-150.85"/>
+<polygon fill="black" stroke="black" points="132.75,-152.05 139.3,-160.38 139.37,-149.78 132.75,-152.05"/>
+<text text-anchor="middle" x="123.93" y="-126.9" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+</g>
+</svg>
diff --git a/chapter05/docs/05-graph6.gv b/chapter05/docs/05-graph6.gv
new file mode 100644
index 00000000..f888e8e9
--- /dev/null
+++ b/chapter05/docs/05-graph6.gv
@@ -0,0 +1,58 @@
+digraph chapter05 {
+/*
+int c = 3;
+int b = 2;
+if (arg == 1) {
+ b = 3;
+ c = 4;
+}
+return c;
+*/
+ rankdir=BT;
+ ordering="in";
+ concentrate="true";
+ subgraph cluster_Nodes {
+ Start2 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">Start</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">$ctrl</TD><TD PORT="p1">arg</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Stop3 [ shape=box style=filled fillcolor=yellow label="Stop" ];
+ Con_6 [ label="#3" ];
+ Con_8 [ label="#1" ];
+ EQNode9 [ label="==" ];
+ If10 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">If</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">True</TD><TD PORT="p1" BGCOLOR="yellow">False</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Con_15 [ label="#4" ];
+ Region16 [ shape=box style=filled fillcolor=yellow label="Region" ];
+ Phi_c17 [ style=filled fillcolor=lightyellow label="&phi;_c" ];
+ Return19 [ shape=box style=filled fillcolor=yellow label="Return" ];
+ { rank=same; Region16;Phi_c17;}
+ }
+ edge [ fontname=Helvetica, fontsize=8 ];
+ Stop3 -> Return19[taillabel=0 color=red];
+ EQNode9 -> Start2:p1[taillabel=1];
+ EQNode9 -> Con_8[taillabel=2];
+ If10 -> Start2:p0[taillabel=0 color=red];
+ If10 -> EQNode9[taillabel=1];
+ Region16 -> If10:p0[taillabel=1 color=red];
+ Region16 -> If10:p1[taillabel=2 color=red];
+ Phi_c17 -> Region16 [style=dotted taillabel=0];
+ Phi_c17 -> Con_15[taillabel=1];
+ Phi_c17 -> Con_6[taillabel=2];
+ Return19 -> Region16[taillabel=0 color=red];
+ Return19 -> Phi_c17[taillabel=1];
+} \ No newline at end of file
diff --git a/chapter05/docs/05-graph6.svg b/chapter05/docs/05-graph6.svg
new file mode 100644
index 00000000..71527d7f
--- /dev/null
+++ b/chapter05/docs/05-graph6.svg
@@ -0,0 +1,176 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<!-- Generated by graphviz version 2.43.0 (0)
+ -->
+<!-- Title: chapter05 Pages: 1 -->
+<svg width="294pt" height="492pt"
+ viewBox="0.00 0.00 294.00 492.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 488)">
+<title>chapter05</title>
+<polygon fill="white" stroke="transparent" points="-4,4 -4,-488 290,-488 290,4 -4,4"/>
+<g id="clust1" class="cluster">
+<title>cluster_Nodes</title>
+<polygon fill="none" stroke="black" points="8,-8 8,-476 278,-476 278,-8 8,-8"/>
+</g>
+<!-- Start2 -->
+<g id="node1" class="node">
+<title>Start2</title>
+<polygon fill="yellow" stroke="transparent" points="109,-439 109,-464 190,-464 190,-439 109,-439"/>
+<polygon fill="none" stroke="black" points="109,-439 109,-464 190,-464 190,-439 109,-439"/>
+<text text-anchor="start" x="131" y="-447.8" font-family="Times,serif" font-size="14.00">Start</text>
+<polygon fill="none" stroke="black" points="109,-408 109,-439 190,-439 190,-408 109,-408"/>
+<polygon fill="yellow" stroke="transparent" points="114,-413 114,-434 154,-434 154,-413 114,-413"/>
+<polygon fill="none" stroke="black" points="114,-413 114,-434 154,-434 154,-413 114,-413"/>
+<text text-anchor="start" x="117" y="-419.8" font-family="Times,serif" font-size="14.00">$ctrl</text>
+<polygon fill="none" stroke="black" points="154,-413 154,-434 185,-434 185,-413 154,-413"/>
+<text text-anchor="start" x="157" y="-419.8" font-family="Times,serif" font-size="14.00">arg</text>
+</g>
+<!-- Stop3 -->
+<g id="node2" class="node">
+<title>Stop3</title>
+<polygon fill="yellow" stroke="black" points="181,-52 127,-52 127,-16 181,-16 181,-52"/>
+<text text-anchor="middle" x="154" y="-30.3" font-family="Times,serif" font-size="14.00">Stop</text>
+</g>
+<!-- Return19 -->
+<g id="node10" class="node">
+<title>Return19</title>
+<polygon fill="yellow" stroke="black" points="187,-124 121,-124 121,-88 187,-88 187,-124"/>
+<text text-anchor="middle" x="154" y="-102.3" font-family="Times,serif" font-size="14.00">Return</text>
+</g>
+<!-- Stop3&#45;&gt;Return19 -->
+<g id="edge1" class="edge">
+<title>Stop3&#45;&gt;Return19</title>
+<path fill="none" stroke="red" d="M154,-52.3C154,-60.02 154,-69.29 154,-77.89"/>
+<polygon fill="red" stroke="red" points="150.5,-77.9 154,-87.9 157.5,-77.9 150.5,-77.9"/>
+<text text-anchor="middle" x="151" y="-54.9" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Con_6 -->
+<g id="node3" class="node">
+<title>Con_6</title>
+<ellipse fill="none" stroke="black" cx="43" cy="-264" rx="27" ry="18"/>
+<text text-anchor="middle" x="43" y="-260.3" font-family="Times,serif" font-size="14.00">#3</text>
+</g>
+<!-- Con_8 -->
+<g id="node4" class="node">
+<title>Con_8</title>
+<ellipse fill="none" stroke="black" cx="243" cy="-436" rx="27" ry="18"/>
+<text text-anchor="middle" x="243" y="-432.3" font-family="Times,serif" font-size="14.00">#1</text>
+</g>
+<!-- EQNode9 -->
+<g id="node5" class="node">
+<title>EQNode9</title>
+<ellipse fill="none" stroke="black" cx="215" cy="-350" rx="27" ry="18"/>
+<text text-anchor="middle" x="215" y="-346.3" font-family="Times,serif" font-size="14.00">==</text>
+</g>
+<!-- EQNode9&#45;&gt;Start2 -->
+<g id="edge2" class="edge">
+<title>EQNode9&#45;&gt;Start2:p1</title>
+<path fill="none" stroke="black" d="M197.73,-364.01C187.32,-373.17 175.33,-386.49 171.36,-401.73"/>
+<polygon fill="black" stroke="black" points="167.84,-401.63 170,-412 174.78,-402.54 167.84,-401.63"/>
+<text text-anchor="middle" x="194.73" y="-366.61" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- EQNode9&#45;&gt;Con_8 -->
+<g id="edge3" class="edge">
+<title>EQNode9&#45;&gt;Con_8</title>
+<path fill="none" stroke="black" d="M220.67,-368C224.56,-379.69 229.81,-395.44 234.24,-408.73"/>
+<polygon fill="black" stroke="black" points="230.96,-409.93 237.44,-418.31 237.6,-407.72 230.96,-409.93"/>
+<text text-anchor="middle" x="217.67" y="-370.6" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- If10 -->
+<g id="node6" class="node">
+<title>If10</title>
+<polygon fill="yellow" stroke="transparent" points="168,-267 168,-292 262,-292 262,-267 168,-267"/>
+<polygon fill="none" stroke="black" points="168,-267 168,-292 262,-292 262,-267 168,-267"/>
+<text text-anchor="start" x="209.5" y="-275.8" font-family="Times,serif" font-size="14.00">If</text>
+<polygon fill="none" stroke="black" points="168,-236 168,-267 262,-267 262,-236 168,-236"/>
+<polygon fill="yellow" stroke="transparent" points="173,-241 173,-262 213,-262 213,-241 173,-241"/>
+<polygon fill="none" stroke="black" points="173,-241 173,-262 213,-262 213,-241 173,-241"/>
+<text text-anchor="start" x="176" y="-247.8" font-family="Times,serif" font-size="14.00">True</text>
+<polygon fill="yellow" stroke="transparent" points="213,-241 213,-262 257,-262 257,-241 213,-241"/>
+<polygon fill="none" stroke="black" points="213,-241 213,-262 257,-262 257,-241 213,-241"/>
+<text text-anchor="start" x="216" y="-247.8" font-family="Times,serif" font-size="14.00">False</text>
+</g>
+<!-- If10&#45;&gt;Start2 -->
+<g id="edge4" class="edge">
+<title>If10&#45;&gt;Start2:p0</title>
+<path fill="none" stroke="red" d="M185.76,-296.14C164.32,-322.05 138.32,-361.17 134.48,-401.9"/>
+<polygon fill="red" stroke="red" points="130.98,-401.84 134,-412 137.97,-402.18 130.98,-401.84"/>
+<text text-anchor="middle" x="182.76" y="-298.74" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- If10&#45;&gt;EQNode9 -->
+<g id="edge5" class="edge">
+<title>If10&#45;&gt;EQNode9</title>
+<path fill="none" stroke="black" d="M215,-296.28C215,-304.58 215,-313.48 215,-321.56"/>
+<polygon fill="black" stroke="black" points="211.5,-321.6 215,-331.6 218.5,-321.6 211.5,-321.6"/>
+<text text-anchor="middle" x="212" y="-298.88" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Con_15 -->
+<g id="node7" class="node">
+<title>Con_15</title>
+<ellipse fill="none" stroke="black" cx="115" cy="-264" rx="27" ry="18"/>
+<text text-anchor="middle" x="115" y="-260.3" font-family="Times,serif" font-size="14.00">#4</text>
+</g>
+<!-- Region16 -->
+<g id="node8" class="node">
+<title>Region16</title>
+<polygon fill="yellow" stroke="black" points="226,-196 160,-196 160,-160 226,-160 226,-196"/>
+<text text-anchor="middle" x="193" y="-174.3" font-family="Times,serif" font-size="14.00">Region</text>
+</g>
+<!-- Region16&#45;&gt;If10 -->
+<g id="edge6" class="edge">
+<title>Region16&#45;&gt;If10:p0</title>
+<path fill="none" stroke="red" d="M193,-196.09C193,-205.55 193,-217.77 193,-229.69"/>
+<polygon fill="red" stroke="red" points="189.5,-230 193,-240 196.5,-230 189.5,-230"/>
+<text text-anchor="middle" x="190" y="-198.69" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Region16&#45;&gt;If10 -->
+<g id="edge7" class="edge">
+<title>Region16&#45;&gt;If10:p1</title>
+<path fill="none" stroke="red" d="M213.02,-196.12C221.64,-205.06 230.48,-216.84 233.71,-229.84"/>
+<polygon fill="red" stroke="red" points="230.27,-230.52 235,-240 237.22,-229.64 230.27,-230.52"/>
+<text text-anchor="middle" x="210.02" y="-198.72" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Phi_c17 -->
+<g id="node9" class="node">
+<title>Phi_c17</title>
+<ellipse fill="lightyellow" stroke="black" cx="115" cy="-178" rx="27" ry="18"/>
+<text text-anchor="middle" x="115" y="-174.3" font-family="Times,serif" font-size="14.00">φ_c</text>
+</g>
+<!-- Phi_c17&#45;&gt;Con_6 -->
+<g id="edge10" class="edge">
+<title>Phi_c17&#45;&gt;Con_6</title>
+<path fill="none" stroke="black" d="M102.13,-194.02C91.07,-206.92 74.96,-225.71 62.35,-240.42"/>
+<polygon fill="black" stroke="black" points="59.61,-238.24 55.76,-248.11 64.93,-242.8 59.61,-238.24"/>
+<text text-anchor="middle" x="99.13" y="-196.62" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Phi_c17&#45;&gt;Con_15 -->
+<g id="edge9" class="edge">
+<title>Phi_c17&#45;&gt;Con_15</title>
+<path fill="none" stroke="black" d="M115,-196.4C115,-207.74 115,-222.77 115,-235.68"/>
+<polygon fill="black" stroke="black" points="111.5,-235.9 115,-245.9 118.5,-235.9 111.5,-235.9"/>
+<text text-anchor="middle" x="112" y="-199" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Phi_c17&#45;&gt;Region16 -->
+<g id="edge8" class="edge">
+<title>Phi_c17&#45;&gt;Region16</title>
+<path fill="none" stroke="black" stroke-dasharray="1,5" d="M142.12,-178C144.58,-178 147.04,-178 149.5,-178"/>
+<polygon fill="black" stroke="black" points="149.61,-181.5 159.61,-178 149.61,-174.5 149.61,-181.5"/>
+<text text-anchor="middle" x="145.12" y="-171.6" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Return19&#45;&gt;Region16 -->
+<g id="edge11" class="edge">
+<title>Return19&#45;&gt;Region16</title>
+<path fill="none" stroke="red" d="M163.64,-124.3C168.13,-132.36 173.56,-142.11 178.52,-151.02"/>
+<polygon fill="red" stroke="red" points="175.55,-152.86 183.47,-159.9 181.66,-149.46 175.55,-152.86"/>
+<text text-anchor="middle" x="160.64" y="-126.9" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Return19&#45;&gt;Phi_c17 -->
+<g id="edge12" class="edge">
+<title>Return19&#45;&gt;Phi_c17</title>
+<path fill="none" stroke="black" d="M144.36,-124.3C139.69,-132.68 134,-142.9 128.87,-152.1"/>
+<polygon fill="black" stroke="black" points="125.8,-150.42 123.99,-160.86 131.92,-153.82 125.8,-150.42"/>
+<text text-anchor="middle" x="141.36" y="-126.9" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+</g>
+</svg>
diff --git a/chapter05/docs/05-graph7.gv b/chapter05/docs/05-graph7.gv
new file mode 100644
index 00000000..3abd6455
--- /dev/null
+++ b/chapter05/docs/05-graph7.gv
@@ -0,0 +1,72 @@
+digraph chapter05 {
+/*
+int a=arg+1;
+int b=arg+2;
+if( arg==1 )
+ b=b+a;
+else
+ a=b+1;
+return a+b;
+*/
+ rankdir=BT;
+ ordering="in";
+ concentrate="true";
+ subgraph cluster_Nodes {
+ Start2 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">Start</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">$ctrl</TD><TD PORT="p1">arg</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Stop3 [ shape=box style=filled fillcolor=yellow label="Stop" ];
+ Phi_b37 [ style=filled fillcolor=lightyellow label="&phi;_b" ];
+ Con_10 [ label="#1" ];
+ Add42 [ label="+" ];
+ EQNode11 [ label="==" ];
+ If12 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">If</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">True</TD><TD PORT="p1" BGCOLOR="yellow">False</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Con_46 [ label="#4" ];
+ Con_48 [ label="#5" ];
+ Phi_ab49 [ style=filled fillcolor=lightyellow label="&phi;_ab" ];
+ Add50 [ label="+" ];
+ Con_19 [ label="#2" ];
+ Return51 [ shape=box style=filled fillcolor=yellow label="Return" ];
+ Mul20 [ label="*" ];
+ Region31 [ shape=box style=filled fillcolor=yellow label="Region" ];
+ { rank=same; Region31;Phi_b37;Phi_ab49;}
+ }
+ edge [ fontname=Helvetica, fontsize=8 ];
+ Stop3 -> Return51[taillabel=0 color=red];
+ Phi_b37 -> Region31 [style=dotted taillabel=0];
+ Phi_b37 -> Mul20[taillabel=1];
+ Phi_b37 -> Start2:p1[taillabel=2];
+ Add42 -> Phi_b37[taillabel=1];
+ Add42 -> Start2:p1[taillabel=2];
+ EQNode11 -> Start2:p1[taillabel=1];
+ EQNode11 -> Con_10[taillabel=2];
+ If12 -> Start2:p0[taillabel=0 color=red];
+ If12 -> EQNode11[taillabel=1];
+ Phi_ab49 -> Region31 [style=dotted taillabel=0];
+ Phi_ab49 -> Con_46[taillabel=1];
+ Phi_ab49 -> Con_48[taillabel=2];
+ Add50 -> Add42[taillabel=1];
+ Add50 -> Phi_ab49[taillabel=2];
+ Return51 -> Region31[taillabel=0 color=red];
+ Return51 -> Add50[taillabel=1];
+ Mul20 -> Start2:p1[taillabel=1];
+ Mul20 -> Con_19[taillabel=2];
+ Region31 -> If12:p0[taillabel=1 color=red];
+ Region31 -> If12:p1[taillabel=2 color=red];
+}
diff --git a/chapter05/docs/05-graph7.svg b/chapter05/docs/05-graph7.svg
new file mode 100644
index 00000000..8ba5ebd6
--- /dev/null
+++ b/chapter05/docs/05-graph7.svg
@@ -0,0 +1,269 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<!-- Generated by graphviz version 2.43.0 (0)
+ -->
+<!-- Title: chapter05 Pages: 1 -->
+<svg width="386pt" height="636pt"
+ viewBox="0.00 0.00 386.00 636.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 632)">
+<title>chapter05</title>
+<polygon fill="white" stroke="transparent" points="-4,4 -4,-632 382,-632 382,4 -4,4"/>
+<g id="clust1" class="cluster">
+<title>cluster_Nodes</title>
+<polygon fill="none" stroke="black" points="8,-8 8,-620 370,-620 370,-8 8,-8"/>
+</g>
+<!-- Start2 -->
+<g id="node1" class="node">
+<title>Start2</title>
+<polygon fill="yellow" stroke="transparent" points="187,-583 187,-608 268,-608 268,-583 187,-583"/>
+<polygon fill="none" stroke="black" points="187,-583 187,-608 268,-608 268,-583 187,-583"/>
+<text text-anchor="start" x="209" y="-591.8" font-family="Times,serif" font-size="14.00">Start</text>
+<polygon fill="none" stroke="black" points="187,-552 187,-583 268,-583 268,-552 187,-552"/>
+<polygon fill="yellow" stroke="transparent" points="192,-557 192,-578 232,-578 232,-557 192,-557"/>
+<polygon fill="none" stroke="black" points="192,-557 192,-578 232,-578 232,-557 192,-557"/>
+<text text-anchor="start" x="195" y="-563.8" font-family="Times,serif" font-size="14.00">$ctrl</text>
+<polygon fill="none" stroke="black" points="232,-557 232,-578 263,-578 263,-557 232,-557"/>
+<text text-anchor="start" x="235" y="-563.8" font-family="Times,serif" font-size="14.00">arg</text>
+</g>
+<!-- Stop3 -->
+<g id="node2" class="node">
+<title>Stop3</title>
+<polygon fill="yellow" stroke="black" points="230,-52 176,-52 176,-16 230,-16 230,-52"/>
+<text text-anchor="middle" x="203" y="-30.3" font-family="Times,serif" font-size="14.00">Stop</text>
+</g>
+<!-- Return51 -->
+<g id="node13" class="node">
+<title>Return51</title>
+<polygon fill="yellow" stroke="black" points="236,-124 170,-124 170,-88 236,-88 236,-124"/>
+<text text-anchor="middle" x="203" y="-102.3" font-family="Times,serif" font-size="14.00">Return</text>
+</g>
+<!-- Stop3&#45;&gt;Return51 -->
+<g id="edge1" class="edge">
+<title>Stop3&#45;&gt;Return51</title>
+<path fill="none" stroke="red" d="M203,-52.3C203,-60.02 203,-69.29 203,-77.89"/>
+<polygon fill="red" stroke="red" points="199.5,-77.9 203,-87.9 206.5,-77.9 199.5,-77.9"/>
+<text text-anchor="middle" x="200" y="-54.9" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Phi_b37 -->
+<g id="node3" class="node">
+<title>Phi_b37</title>
+<ellipse fill="lightyellow" stroke="black" cx="63" cy="-322" rx="27.1" ry="18"/>
+<text text-anchor="middle" x="63" y="-318.3" font-family="Times,serif" font-size="14.00">φ_b</text>
+</g>
+<!-- Phi_b37&#45;&gt;Start2 -->
+<g id="edge4" class="edge">
+<title>Phi_b37&#45;&gt;Start2:p1</title>
+<path fill="none" stroke="black" d="M50.14,-338.15C37.78,-354.08 20.49,-380.46 17,-407"/>
+<text text-anchor="middle" x="47.14" y="-340.75" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Mul20 -->
+<g id="node14" class="node">
+<title>Mul20</title>
+<ellipse fill="none" stroke="black" cx="63" cy="-408" rx="27" ry="18"/>
+<text text-anchor="middle" x="63" y="-404.3" font-family="Times,serif" font-size="14.00">*</text>
+</g>
+<!-- Phi_b37&#45;&gt;Mul20 -->
+<g id="edge3" class="edge">
+<title>Phi_b37&#45;&gt;Mul20</title>
+<path fill="none" stroke="black" d="M63,-340.4C63,-351.74 63,-366.77 63,-379.68"/>
+<polygon fill="black" stroke="black" points="59.5,-379.9 63,-389.9 66.5,-379.9 59.5,-379.9"/>
+<text text-anchor="middle" x="60" y="-343" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Region31 -->
+<g id="node15" class="node">
+<title>Region31</title>
+<polygon fill="yellow" stroke="black" points="287,-340 221,-340 221,-304 287,-304 287,-340"/>
+<text text-anchor="middle" x="254" y="-318.3" font-family="Times,serif" font-size="14.00">Region</text>
+</g>
+<!-- Phi_b37&#45;&gt;Region31 -->
+<g id="edge2" class="edge">
+<title>Phi_b37&#45;&gt;Region31</title>
+<path fill="none" stroke="black" stroke-dasharray="1,5" d="M83.07,-309.47C97.9,-300.98 118.92,-290.52 139,-286 166.75,-279.76 175.89,-277.4 203,-286 210.99,-288.54 218.81,-292.83 225.83,-297.58"/>
+<polygon fill="black" stroke="black" points="224.11,-300.66 234.24,-303.75 228.25,-295.01 224.11,-300.66"/>
+<text text-anchor="middle" x="80.07" y="-303.07" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Con_10 -->
+<g id="node4" class="node">
+<title>Con_10</title>
+<ellipse fill="none" stroke="black" cx="321" cy="-580" rx="27" ry="18"/>
+<text text-anchor="middle" x="321" y="-576.3" font-family="Times,serif" font-size="14.00">#1</text>
+</g>
+<!-- Add42 -->
+<g id="node5" class="node">
+<title>Add42</title>
+<ellipse fill="none" stroke="black" cx="63" cy="-250" rx="27" ry="18"/>
+<text text-anchor="middle" x="63" y="-246.3" font-family="Times,serif" font-size="14.00">+</text>
+</g>
+<!-- Add42&#45;&gt;Start2 -->
+<g id="edge6" class="edge">
+<title>Add42&#45;&gt;Start2:p1</title>
+<path fill="none" stroke="black" d="M49.72,-266.09C41.69,-276.12 32.07,-289.98 27,-304 11.37,-347.26 22.99,-361.4 17,-407"/>
+<path fill="none" stroke="black" d="M17,-409C11.54,-445.93 0.41,-459.55 17,-493"/>
+<path fill="none" stroke="black" d="M17,-495C20.89,-502.85 19.85,-506.92 27,-512 102.92,-565.95 228.75,-471 246.01,-537.97"/>
+<polygon fill="black" stroke="black" points="242.59,-538.7 247.67,-548 249.49,-537.56 242.59,-538.7"/>
+<text text-anchor="middle" x="46.72" y="-268.69" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Add42&#45;&gt;Phi_b37 -->
+<g id="edge5" class="edge">
+<title>Add42&#45;&gt;Phi_b37</title>
+<path fill="none" stroke="black" d="M63,-268.3C63,-276.02 63,-285.29 63,-293.89"/>
+<polygon fill="black" stroke="black" points="59.5,-293.9 63,-303.9 66.5,-293.9 59.5,-293.9"/>
+<text text-anchor="middle" x="60" y="-270.9" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- EQNode11 -->
+<g id="node6" class="node">
+<title>EQNode11</title>
+<ellipse fill="none" stroke="black" cx="307" cy="-494" rx="27" ry="18"/>
+<text text-anchor="middle" x="307" y="-490.3" font-family="Times,serif" font-size="14.00">==</text>
+</g>
+<!-- EQNode11&#45;&gt;Start2 -->
+<g id="edge7" class="edge">
+<title>EQNode11&#45;&gt;Start2:p1</title>
+<path fill="none" stroke="black" d="M300.78,-511.7C294.25,-528.15 283.48,-552.23 273.01,-562.3"/>
+<polygon fill="black" stroke="black" points="271.25,-559.27 264,-567 274.49,-565.48 271.25,-559.27"/>
+<text text-anchor="middle" x="297.78" y="-514.3" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- EQNode11&#45;&gt;Con_10 -->
+<g id="edge8" class="edge">
+<title>EQNode11&#45;&gt;Con_10</title>
+<path fill="none" stroke="black" d="M309.83,-512C311.75,-523.5 314.32,-538.93 316.51,-552.08"/>
+<polygon fill="black" stroke="black" points="313.07,-552.74 318.17,-562.03 319.98,-551.59 313.07,-552.74"/>
+<text text-anchor="middle" x="306.83" y="-514.6" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- If12 -->
+<g id="node7" class="node">
+<title>If12</title>
+<polygon fill="yellow" stroke="transparent" points="260,-411 260,-436 354,-436 354,-411 260,-411"/>
+<polygon fill="none" stroke="black" points="260,-411 260,-436 354,-436 354,-411 260,-411"/>
+<text text-anchor="start" x="301.5" y="-419.8" font-family="Times,serif" font-size="14.00">If</text>
+<polygon fill="none" stroke="black" points="260,-380 260,-411 354,-411 354,-380 260,-380"/>
+<polygon fill="yellow" stroke="transparent" points="265,-385 265,-406 305,-406 305,-385 265,-385"/>
+<polygon fill="none" stroke="black" points="265,-385 265,-406 305,-406 305,-385 265,-385"/>
+<text text-anchor="start" x="268" y="-391.8" font-family="Times,serif" font-size="14.00">True</text>
+<polygon fill="yellow" stroke="transparent" points="305,-385 305,-406 349,-406 349,-385 305,-385"/>
+<polygon fill="none" stroke="black" points="305,-385 305,-406 349,-406 349,-385 305,-385"/>
+<text text-anchor="start" x="308" y="-391.8" font-family="Times,serif" font-size="14.00">False</text>
+</g>
+<!-- If12&#45;&gt;Start2 -->
+<g id="edge9" class="edge">
+<title>If12&#45;&gt;Start2:p0</title>
+<path fill="none" stroke="red" d="M271.9,-440.02C246.84,-465.46 216.84,-504 212.53,-545.87"/>
+<polygon fill="red" stroke="red" points="209.02,-545.83 212,-556 216.01,-546.2 209.02,-545.83"/>
+<text text-anchor="middle" x="268.9" y="-442.62" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- If12&#45;&gt;EQNode11 -->
+<g id="edge10" class="edge">
+<title>If12&#45;&gt;EQNode11</title>
+<path fill="none" stroke="black" d="M307,-440.28C307,-448.58 307,-457.48 307,-465.56"/>
+<polygon fill="black" stroke="black" points="303.5,-465.6 307,-475.6 310.5,-465.6 303.5,-465.6"/>
+<text text-anchor="middle" x="304" y="-442.88" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Con_46 -->
+<g id="node8" class="node">
+<title>Con_46</title>
+<ellipse fill="none" stroke="black" cx="135" cy="-408" rx="27" ry="18"/>
+<text text-anchor="middle" x="135" y="-404.3" font-family="Times,serif" font-size="14.00">#4</text>
+</g>
+<!-- Con_48 -->
+<g id="node9" class="node">
+<title>Con_48</title>
+<ellipse fill="none" stroke="black" cx="207" cy="-408" rx="27" ry="18"/>
+<text text-anchor="middle" x="207" y="-404.3" font-family="Times,serif" font-size="14.00">#5</text>
+</g>
+<!-- Phi_ab49 -->
+<g id="node10" class="node">
+<title>Phi_ab49</title>
+<ellipse fill="lightyellow" stroke="black" cx="171" cy="-322" rx="32.49" ry="18"/>
+<text text-anchor="middle" x="171" y="-318.3" font-family="Times,serif" font-size="14.00">φ_ab</text>
+</g>
+<!-- Phi_ab49&#45;&gt;Con_46 -->
+<g id="edge12" class="edge">
+<title>Phi_ab49&#45;&gt;Con_46</title>
+<path fill="none" stroke="black" d="M163.89,-339.6C158.81,-351.45 151.88,-367.62 146.08,-381.15"/>
+<polygon fill="black" stroke="black" points="142.82,-379.87 142.1,-390.44 149.25,-382.63 142.82,-379.87"/>
+<text text-anchor="middle" x="160.89" y="-342.2" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Phi_ab49&#45;&gt;Con_48 -->
+<g id="edge13" class="edge">
+<title>Phi_ab49&#45;&gt;Con_48</title>
+<path fill="none" stroke="black" d="M178.11,-339.6C183.19,-351.45 190.12,-367.62 195.92,-381.15"/>
+<polygon fill="black" stroke="black" points="192.75,-382.63 199.9,-390.44 199.18,-379.87 192.75,-382.63"/>
+<text text-anchor="middle" x="175.11" y="-342.2" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Phi_ab49&#45;&gt;Region31 -->
+<g id="edge11" class="edge">
+<title>Phi_ab49&#45;&gt;Region31</title>
+<path fill="none" stroke="black" stroke-dasharray="1,5" d="M203.75,-322C206.03,-322 208.32,-322 210.6,-322"/>
+<polygon fill="black" stroke="black" points="210.63,-325.5 220.63,-322 210.63,-318.5 210.63,-325.5"/>
+<text text-anchor="middle" x="206.75" y="-315.6" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Add50 -->
+<g id="node11" class="node">
+<title>Add50</title>
+<ellipse fill="none" stroke="black" cx="171" cy="-178" rx="27" ry="18"/>
+<text text-anchor="middle" x="171" y="-174.3" font-family="Times,serif" font-size="14.00">+</text>
+</g>
+<!-- Add50&#45;&gt;Add42 -->
+<g id="edge14" class="edge">
+<title>Add50&#45;&gt;Add42</title>
+<path fill="none" stroke="black" d="M152.19,-191.19C135,-202.33 109.38,-218.94 90.01,-231.5"/>
+<polygon fill="black" stroke="black" points="88.08,-228.57 81.6,-236.95 91.89,-234.44 88.08,-228.57"/>
+<text text-anchor="middle" x="149.19" y="-193.79" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Add50&#45;&gt;Phi_ab49 -->
+<g id="edge15" class="edge">
+<title>Add50&#45;&gt;Phi_ab49</title>
+<path fill="none" stroke="black" d="M171,-196.13C171,-220.33 171,-264.79 171,-293.61"/>
+<polygon fill="black" stroke="black" points="167.5,-293.81 171,-303.81 174.5,-293.81 167.5,-293.81"/>
+<text text-anchor="middle" x="168" y="-198.73" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Con_19 -->
+<g id="node12" class="node">
+<title>Con_19</title>
+<ellipse fill="none" stroke="black" cx="63" cy="-494" rx="27" ry="18"/>
+<text text-anchor="middle" x="63" y="-490.3" font-family="Times,serif" font-size="14.00">#2</text>
+</g>
+<!-- Return51&#45;&gt;Add50 -->
+<g id="edge17" class="edge">
+<title>Return51&#45;&gt;Add50</title>
+<path fill="none" stroke="black" d="M195.09,-124.3C191.39,-132.39 186.91,-142.19 182.83,-151.13"/>
+<polygon fill="black" stroke="black" points="179.57,-149.83 178.6,-160.38 185.94,-152.74 179.57,-149.83"/>
+<text text-anchor="middle" x="192.09" y="-126.9" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Return51&#45;&gt;Region31 -->
+<g id="edge16" class="edge">
+<title>Return51&#45;&gt;Region31</title>
+<path fill="none" stroke="red" d="M207.09,-124.15C215.93,-161.25 236.89,-249.19 247.54,-293.9"/>
+<polygon fill="red" stroke="red" points="244.17,-294.85 249.89,-303.77 250.98,-293.23 244.17,-294.85"/>
+<text text-anchor="middle" x="204.09" y="-126.75" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Mul20&#45;&gt;Start2 -->
+<g id="edge18" class="edge">
+<title>Mul20&#45;&gt;Start2:p1</title>
+<path fill="none" stroke="black" d="M46.66,-422.5C28.85,-438.94 4.44,-467.68 17,-493"/>
+<text text-anchor="middle" x="43.66" y="-425.1" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Mul20&#45;&gt;Con_19 -->
+<g id="edge19" class="edge">
+<title>Mul20&#45;&gt;Con_19</title>
+<path fill="none" stroke="black" d="M63,-426.4C63,-437.74 63,-452.77 63,-465.68"/>
+<polygon fill="black" stroke="black" points="59.5,-465.9 63,-475.9 66.5,-465.9 59.5,-465.9"/>
+<text text-anchor="middle" x="60" y="-429" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Region31&#45;&gt;If12 -->
+<g id="edge20" class="edge">
+<title>Region31&#45;&gt;If12:p0</title>
+<path fill="none" stroke="red" d="M268.23,-340.25C274.66,-349.42 281.38,-361.37 283.93,-373.89"/>
+<polygon fill="red" stroke="red" points="280.47,-374.42 285,-384 287.43,-373.69 280.47,-374.42"/>
+<text text-anchor="middle" x="265.23" y="-342.85" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Region31&#45;&gt;If12 -->
+<g id="edge21" class="edge">
+<title>Region31&#45;&gt;If12:p1</title>
+<path fill="none" stroke="red" d="M287.08,-335.84C303.38,-344.18 320.59,-356.74 325.57,-373.96"/>
+<polygon fill="red" stroke="red" points="322.13,-374.59 327,-384 329.06,-373.61 322.13,-374.59"/>
+<text text-anchor="middle" x="290.08" y="-329.44" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+</g>
+</svg>
diff --git a/chapter05/docs/05-graph8.gv b/chapter05/docs/05-graph8.gv
new file mode 100644
index 00000000..bef29b93
--- /dev/null
+++ b/chapter05/docs/05-graph8.gv
@@ -0,0 +1,129 @@
+digraph chapter05 {
+/*
+int a=1;
+if( arg==1 )
+ if( arg==2 )
+ a=2;
+ else
+ a=3;
+else if( arg==3 )
+ a=4;
+else
+ a=5;
+return a;
+#showGraph;
+*/
+ rankdir=BT;
+ ordering="in";
+ concentrate="true";
+ subgraph cluster_Nodes {
+ Start2 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">Start</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">$ctrl</TD><TD PORT="p1">arg</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Stop3 [ shape=box style=filled fillcolor=yellow label="Stop" ];
+ Con_7 [ label="#1" ];
+ EQNode8 [ label="==" ];
+ If9 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">If</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">True</TD><TD PORT="p1" BGCOLOR="yellow">False</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Con_13 [ label="#2" ];
+ EQNode14 [ label="==" ];
+ If15 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">If</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">True</TD><TD PORT="p1" BGCOLOR="yellow">False</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Con_19 [ label="#2" ];
+ Con_20 [ label="#3" ];
+ Region21 [ shape=box style=filled fillcolor=yellow label="Region" ];
+ Phi_a22 [ style=filled fillcolor=lightyellow label="&phi;_a" ];
+ Con_23 [ label="#3" ];
+ EQNode24 [ label="==" ];
+ If25 [ shape=plaintext label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
+ <TR><TD BGCOLOR="yellow">If</TD></TR>
+ <TR><TD>
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD PORT="p0" BGCOLOR="yellow">True</TD><TD PORT="p1" BGCOLOR="yellow">False</TD></TR>
+ </TABLE>
+ </TD></TR>
+ </TABLE>>
+ ];
+ Con_29 [ label="#4" ];
+ Con_30 [ label="#5" ];
+ Region31 [ shape=box style=filled fillcolor=yellow label="Region" ];
+ Phi_a32 [ style=filled fillcolor=lightyellow label="&phi;_a" ];
+ Region33 [ shape=box style=filled fillcolor=yellow label="Region" ];
+ Phi_a34 [ style=filled fillcolor=lightyellow label="&phi;_a" ];
+ Return35 [ shape=box style=filled fillcolor=yellow label="Return" ];
+ { rank=same; Region21;Phi_a22;}
+ { rank=same; Region31;Phi_a32;}
+ { rank=same; Region33;Phi_a34;}
+ }
+ node [shape=plaintext];
+ subgraph cluster_Scope1_0 {
+ Scope1_0 [label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD BGCOLOR="cyan">0</TD><TD PORT="Scope1_0_$ctrl">$ctrl</TD><TD PORT="Scope1_0_arg">arg</TD></TR>
+ </TABLE>>];
+ subgraph cluster_Scope1_1 {
+ Scope1_1 [label=<
+ <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
+ <TR><TD BGCOLOR="cyan">1</TD><TD PORT="Scope1_1_a">a</TD></TR>
+ </TABLE>>];
+ }
+ }
+ edge [ fontname=Helvetica, fontsize=8 ];
+ Stop3 -> Return35[taillabel=0 color=red];
+ EQNode8 -> Start2:p1[taillabel=1];
+ EQNode8 -> Con_7[taillabel=2];
+ If9 -> Start2:p0[taillabel=0 color=red];
+ If9 -> EQNode8[taillabel=1];
+ EQNode14 -> Start2:p1[taillabel=1];
+ EQNode14 -> Con_13[taillabel=2];
+ If15 -> If9:p0[taillabel=0 color=red];
+ If15 -> EQNode14[taillabel=1];
+ Region21 -> If15:p0[taillabel=1 color=red];
+ Region21 -> If15:p1[taillabel=2 color=red];
+ Phi_a22 -> Region21 [style=dotted taillabel=0];
+ Phi_a22 -> Con_19[taillabel=1];
+ Phi_a22 -> Con_20[taillabel=2];
+ EQNode24 -> Start2:p1[taillabel=1];
+ EQNode24 -> Con_23[taillabel=2];
+ If25 -> If9:p1[taillabel=0 color=red];
+ If25 -> EQNode24[taillabel=1];
+ Region31 -> If25:p0[taillabel=1 color=red];
+ Region31 -> If25:p1[taillabel=2 color=red];
+ Phi_a32 -> Region31 [style=dotted taillabel=0];
+ Phi_a32 -> Con_29[taillabel=1];
+ Phi_a32 -> Con_30[taillabel=2];
+ Region33 -> Region21[taillabel=1 color=red];
+ Region33 -> Region31[taillabel=2 color=red];
+ Phi_a34 -> Region33 [style=dotted taillabel=0];
+ Phi_a34 -> Phi_a22[taillabel=1];
+ Phi_a34 -> Phi_a32[taillabel=2];
+ Return35 -> Region33[taillabel=0 color=red];
+ Return35 -> Phi_a34[taillabel=1];
+ edge [style=dashed color=cornflowerblue];
+ Scope1_0:"Scope1_0_arg" -> Start2:p1;
+ Scope1_1:"Scope1_1_a" -> Phi_a34;
+} \ No newline at end of file
diff --git a/chapter05/docs/05-graph8.svg b/chapter05/docs/05-graph8.svg
new file mode 100644
index 00000000..e5310db4
--- /dev/null
+++ b/chapter05/docs/05-graph8.svg
@@ -0,0 +1,430 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<!-- Generated by graphviz version 2.43.0 (0)
+ -->
+<!-- Title: chapter05 Pages: 1 -->
+<svg width="774pt" height="664pt"
+ viewBox="0.00 0.00 774.00 664.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 660)">
+<title>chapter05</title>
+<polygon fill="white" stroke="transparent" points="-4,4 -4,-660 770,-660 770,4 -4,4"/>
+<g id="clust1" class="cluster">
+<title>cluster_Nodes</title>
+<polygon fill="none" stroke="black" points="8,-8 8,-648 550,-648 550,-8 8,-8"/>
+</g>
+<g id="clust5" class="cluster">
+<title>cluster_Scope1_0</title>
+<polygon fill="none" stroke="black" points="558,-72 558,-140 758,-140 758,-72 558,-72"/>
+</g>
+<g id="clust6" class="cluster">
+<title>cluster_Scope1_1</title>
+<polygon fill="none" stroke="black" points="566,-80 566,-132 636,-132 636,-80 566,-80"/>
+</g>
+<!-- Start2 -->
+<g id="node1" class="node">
+<title>Start2</title>
+<polygon fill="yellow" stroke="transparent" points="190,-611 190,-636 271,-636 271,-611 190,-611"/>
+<polygon fill="none" stroke="black" points="190,-611 190,-636 271,-636 271,-611 190,-611"/>
+<text text-anchor="start" x="212" y="-619.8" font-family="Times,serif" font-size="14.00">Start</text>
+<polygon fill="none" stroke="black" points="190,-580 190,-611 271,-611 271,-580 190,-580"/>
+<polygon fill="yellow" stroke="transparent" points="195,-585 195,-606 235,-606 235,-585 195,-585"/>
+<polygon fill="none" stroke="black" points="195,-585 195,-606 235,-606 235,-585 195,-585"/>
+<text text-anchor="start" x="198" y="-591.8" font-family="Times,serif" font-size="14.00">$ctrl</text>
+<polygon fill="none" stroke="black" points="235,-585 235,-606 266,-606 266,-585 235,-585"/>
+<text text-anchor="start" x="238" y="-591.8" font-family="Times,serif" font-size="14.00">arg</text>
+</g>
+<!-- Stop3 -->
+<g id="node2" class="node">
+<title>Stop3</title>
+<polygon fill="yellow" stroke="black" points="286,-52 232,-52 232,-16 286,-16 286,-52"/>
+<text text-anchor="middle" x="259" y="-30.3" font-family="Times,serif" font-size="14.00">Stop</text>
+</g>
+<!-- Return35 -->
+<g id="node22" class="node">
+<title>Return35</title>
+<polygon fill="yellow" stroke="black" points="292,-124 226,-124 226,-88 292,-88 292,-124"/>
+<text text-anchor="middle" x="259" y="-102.3" font-family="Times,serif" font-size="14.00">Return</text>
+</g>
+<!-- Stop3&#45;&gt;Return35 -->
+<g id="edge1" class="edge">
+<title>Stop3&#45;&gt;Return35</title>
+<path fill="none" stroke="red" d="M259,-52.3C259,-60.02 259,-69.29 259,-77.89"/>
+<polygon fill="red" stroke="red" points="255.5,-77.9 259,-87.9 262.5,-77.9 255.5,-77.9"/>
+<text text-anchor="middle" x="256" y="-54.9" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Con_7 -->
+<g id="node3" class="node">
+<title>Con_7</title>
+<ellipse fill="none" stroke="black" cx="136" cy="-608" rx="27" ry="18"/>
+<text text-anchor="middle" x="136" y="-604.3" font-family="Times,serif" font-size="14.00">#1</text>
+</g>
+<!-- EQNode8 -->
+<g id="node4" class="node">
+<title>EQNode8</title>
+<ellipse fill="none" stroke="black" cx="169" cy="-522" rx="27" ry="18"/>
+<text text-anchor="middle" x="169" y="-518.3" font-family="Times,serif" font-size="14.00">==</text>
+</g>
+<!-- EQNode8&#45;&gt;Start2 -->
+<g id="edge2" class="edge">
+<title>EQNode8&#45;&gt;Start2:p1</title>
+<path fill="none" stroke="black" d="M190.12,-533.69C209.67,-544.17 237.18,-560.54 247.18,-574.44"/>
+<polygon fill="black" stroke="black" points="244.04,-576.01 251,-584 250.54,-573.42 244.04,-576.01"/>
+<text text-anchor="middle" x="187.12" y="-536.29" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- EQNode8&#45;&gt;Con_7 -->
+<g id="edge3" class="edge">
+<title>EQNode8&#45;&gt;Con_7</title>
+<path fill="none" stroke="black" d="M162.48,-539.6C157.87,-551.33 151.59,-567.3 146.31,-580.76"/>
+<polygon fill="black" stroke="black" points="142.91,-579.85 142.51,-590.44 149.42,-582.41 142.91,-579.85"/>
+<text text-anchor="middle" x="159.48" y="-542.2" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- If9 -->
+<g id="node5" class="node">
+<title>If9</title>
+<polygon fill="yellow" stroke="transparent" points="124,-439 124,-464 218,-464 218,-439 124,-439"/>
+<polygon fill="none" stroke="black" points="124,-439 124,-464 218,-464 218,-439 124,-439"/>
+<text text-anchor="start" x="165.5" y="-447.8" font-family="Times,serif" font-size="14.00">If</text>
+<polygon fill="none" stroke="black" points="124,-408 124,-439 218,-439 218,-408 124,-408"/>
+<polygon fill="yellow" stroke="transparent" points="129,-413 129,-434 169,-434 169,-413 129,-413"/>
+<polygon fill="none" stroke="black" points="129,-413 129,-434 169,-434 169,-413 129,-413"/>
+<text text-anchor="start" x="132" y="-419.8" font-family="Times,serif" font-size="14.00">True</text>
+<polygon fill="yellow" stroke="transparent" points="169,-413 169,-434 213,-434 213,-413 169,-413"/>
+<polygon fill="none" stroke="black" points="169,-413 169,-434 213,-434 213,-413 169,-413"/>
+<text text-anchor="start" x="172" y="-419.8" font-family="Times,serif" font-size="14.00">False</text>
+</g>
+<!-- If9&#45;&gt;Start2 -->
+<g id="edge4" class="edge">
+<title>If9&#45;&gt;Start2:p0</title>
+<path fill="none" stroke="red" d="M189.59,-468.09C195.4,-479.09 201.26,-491.78 205,-504 214.42,-534.78 214.99,-545.9 215,-573.83"/>
+<polygon fill="red" stroke="red" points="211.5,-574 215,-584 218.5,-574 211.5,-574"/>
+<text text-anchor="middle" x="186.59" y="-470.69" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- If9&#45;&gt;EQNode8 -->
+<g id="edge5" class="edge">
+<title>If9&#45;&gt;EQNode8</title>
+<path fill="none" stroke="black" d="M170.26,-468.28C170.06,-476.58 169.85,-485.48 169.65,-493.56"/>
+<polygon fill="black" stroke="black" points="166.15,-493.51 169.41,-503.6 173.15,-493.68 166.15,-493.51"/>
+<text text-anchor="middle" x="167.26" y="-470.88" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Con_13 -->
+<g id="node6" class="node">
+<title>Con_13</title>
+<ellipse fill="none" stroke="black" cx="71" cy="-522" rx="27" ry="18"/>
+<text text-anchor="middle" x="71" y="-518.3" font-family="Times,serif" font-size="14.00">#2</text>
+</g>
+<!-- EQNode14 -->
+<g id="node7" class="node">
+<title>EQNode14</title>
+<ellipse fill="none" stroke="black" cx="71" cy="-436" rx="27" ry="18"/>
+<text text-anchor="middle" x="71" y="-432.3" font-family="Times,serif" font-size="14.00">==</text>
+</g>
+<!-- EQNode14&#45;&gt;Start2 -->
+<g id="edge6" class="edge">
+<title>EQNode14&#45;&gt;Start2:p1</title>
+<path fill="none" stroke="black" d="M79.96,-453.18C95.23,-480.56 125.41,-533.7 133,-540 173.12,-573.31 240.9,-534.16 249.98,-573.92"/>
+<polygon fill="black" stroke="black" points="246.51,-574.4 251,-584 253.48,-573.7 246.51,-574.4"/>
+<text text-anchor="middle" x="76.96" y="-455.78" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- EQNode14&#45;&gt;Con_13 -->
+<g id="edge7" class="edge">
+<title>EQNode14&#45;&gt;Con_13</title>
+<path fill="none" stroke="black" d="M71,-454.4C71,-465.74 71,-480.77 71,-493.68"/>
+<polygon fill="black" stroke="black" points="67.5,-493.9 71,-503.9 74.5,-493.9 67.5,-493.9"/>
+<text text-anchor="middle" x="68" y="-457" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- If15 -->
+<g id="node8" class="node">
+<title>If15</title>
+<polygon fill="yellow" stroke="transparent" points="24,-339 24,-364 118,-364 118,-339 24,-339"/>
+<polygon fill="none" stroke="black" points="24,-339 24,-364 118,-364 118,-339 24,-339"/>
+<text text-anchor="start" x="65.5" y="-347.8" font-family="Times,serif" font-size="14.00">If</text>
+<polygon fill="none" stroke="black" points="24,-308 24,-339 118,-339 118,-308 24,-308"/>
+<polygon fill="yellow" stroke="transparent" points="29,-313 29,-334 69,-334 69,-313 29,-313"/>
+<polygon fill="none" stroke="black" points="29,-313 29,-334 69,-334 69,-313 29,-313"/>
+<text text-anchor="start" x="32" y="-319.8" font-family="Times,serif" font-size="14.00">True</text>
+<polygon fill="yellow" stroke="transparent" points="69,-313 69,-334 113,-334 113,-313 69,-313"/>
+<polygon fill="none" stroke="black" points="69,-313 69,-334 113,-334 113,-313 69,-313"/>
+<text text-anchor="start" x="72" y="-319.8" font-family="Times,serif" font-size="14.00">False</text>
+</g>
+<!-- If15&#45;&gt;If9 -->
+<g id="edge8" class="edge">
+<title>If15&#45;&gt;If9:p0</title>
+<path fill="none" stroke="red" d="M88.21,-368.05C98.39,-385.75 110.98,-406.4 119.78,-416.61"/>
+<polygon fill="red" stroke="red" points="117.96,-419.62 128,-423 122.25,-414.1 117.96,-419.62"/>
+<text text-anchor="middle" x="85.21" y="-370.65" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- If15&#45;&gt;EQNode14 -->
+<g id="edge9" class="edge">
+<title>If15&#45;&gt;EQNode14</title>
+<path fill="none" stroke="black" d="M71,-368.01C71,-380.76 71,-395.4 71,-407.73"/>
+<polygon fill="black" stroke="black" points="67.5,-407.87 71,-417.87 74.5,-407.87 67.5,-407.87"/>
+<text text-anchor="middle" x="68" y="-370.61" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Con_19 -->
+<g id="node9" class="node">
+<title>Con_19</title>
+<ellipse fill="none" stroke="black" cx="443" cy="-336" rx="27" ry="18"/>
+<text text-anchor="middle" x="443" y="-332.3" font-family="Times,serif" font-size="14.00">#2</text>
+</g>
+<!-- Con_20 -->
+<g id="node10" class="node">
+<title>Con_20</title>
+<ellipse fill="none" stroke="black" cx="515" cy="-336" rx="27" ry="18"/>
+<text text-anchor="middle" x="515" y="-332.3" font-family="Times,serif" font-size="14.00">#3</text>
+</g>
+<!-- Region21 -->
+<g id="node11" class="node">
+<title>Region21</title>
+<polygon fill="yellow" stroke="black" points="147,-268 81,-268 81,-232 147,-232 147,-268"/>
+<text text-anchor="middle" x="114" y="-246.3" font-family="Times,serif" font-size="14.00">Region</text>
+</g>
+<!-- Region21&#45;&gt;If15 -->
+<g id="edge10" class="edge">
+<title>Region21&#45;&gt;If15:p0</title>
+<path fill="none" stroke="red" d="M80.74,-267.13C67.62,-275.57 54.67,-287.24 50.44,-301.92"/>
+<polygon fill="red" stroke="red" points="46.94,-301.61 49,-312 53.87,-302.59 46.94,-301.61"/>
+<text text-anchor="middle" x="77.74" y="-260.73" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Region21&#45;&gt;If15 -->
+<g id="edge11" class="edge">
+<title>Region21&#45;&gt;If15:p1</title>
+<path fill="none" stroke="red" d="M103.71,-268.24C98.93,-277.52 93.86,-289.54 91.87,-301.76"/>
+<polygon fill="red" stroke="red" points="88.36,-301.74 91,-312 95.34,-302.33 88.36,-301.74"/>
+<text text-anchor="middle" x="100.71" y="-270.84" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Phi_a22 -->
+<g id="node12" class="node">
+<title>Phi_a22</title>
+<ellipse fill="lightyellow" stroke="black" cx="407" cy="-250" rx="27" ry="18"/>
+<text text-anchor="middle" x="407" y="-246.3" font-family="Times,serif" font-size="14.00">φ_a</text>
+</g>
+<!-- Phi_a22&#45;&gt;Con_19 -->
+<g id="edge13" class="edge">
+<title>Phi_a22&#45;&gt;Con_19</title>
+<path fill="none" stroke="black" d="M414.11,-267.6C419.19,-279.45 426.12,-295.62 431.92,-309.15"/>
+<polygon fill="black" stroke="black" points="428.75,-310.63 435.9,-318.44 435.18,-307.87 428.75,-310.63"/>
+<text text-anchor="middle" x="411.11" y="-270.2" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Phi_a22&#45;&gt;Con_20 -->
+<g id="edge14" class="edge">
+<title>Phi_a22&#45;&gt;Con_20</title>
+<path fill="none" stroke="black" d="M425.04,-263.7C439.78,-274.21 461.03,-289.69 479,-304 483.17,-307.32 487.52,-310.94 491.71,-314.49"/>
+<polygon fill="black" stroke="black" points="489.59,-317.28 499.45,-321.15 494.15,-311.98 489.59,-317.28"/>
+<text text-anchor="middle" x="422.04" y="-266.3" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Phi_a22&#45;&gt;Region21 -->
+<g id="edge12" class="edge">
+<title>Phi_a22&#45;&gt;Region21</title>
+<path fill="none" stroke="black" stroke-dasharray="1,5" d="M386.5,-238C370.6,-229.42 347.68,-218.6 326,-214 265.57,-201.18 247.16,-199.97 187,-214 175.19,-216.75 163.08,-221.71 152.22,-227.08"/>
+<polygon fill="black" stroke="black" points="150.28,-224.14 143.03,-231.86 153.51,-230.35 150.28,-224.14"/>
+<text text-anchor="middle" x="383.5" y="-231.6" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Con_23 -->
+<g id="node13" class="node">
+<title>Con_23</title>
+<ellipse fill="none" stroke="black" cx="297" cy="-522" rx="27" ry="18"/>
+<text text-anchor="middle" x="297" y="-518.3" font-family="Times,serif" font-size="14.00">#3</text>
+</g>
+<!-- EQNode24 -->
+<g id="node14" class="node">
+<title>EQNode24</title>
+<ellipse fill="none" stroke="black" cx="271" cy="-436" rx="27" ry="18"/>
+<text text-anchor="middle" x="271" y="-432.3" font-family="Times,serif" font-size="14.00">==</text>
+</g>
+<!-- EQNode24&#45;&gt;Start2 -->
+<g id="edge15" class="edge">
+<title>EQNode24&#45;&gt;Start2:p1</title>
+<path fill="none" stroke="black" d="M267.14,-454.1C261.74,-479.48 252.43,-528.98 251.15,-573.9"/>
+<polygon fill="black" stroke="black" points="247.65,-573.95 251,-584 254.65,-574.05 247.65,-573.95"/>
+<text text-anchor="middle" x="264.14" y="-456.7" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- EQNode24&#45;&gt;Con_23 -->
+<g id="edge16" class="edge">
+<title>EQNode24&#45;&gt;Con_23</title>
+<path fill="none" stroke="black" d="M276.26,-454C279.88,-465.69 284.76,-481.44 288.87,-494.73"/>
+<polygon fill="black" stroke="black" points="285.53,-495.8 291.84,-504.31 292.22,-493.73 285.53,-495.8"/>
+<text text-anchor="middle" x="273.26" y="-456.6" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- If25 -->
+<g id="node15" class="node">
+<title>If25</title>
+<polygon fill="yellow" stroke="transparent" points="152,-339 152,-364 246,-364 246,-339 152,-339"/>
+<polygon fill="none" stroke="black" points="152,-339 152,-364 246,-364 246,-339 152,-339"/>
+<text text-anchor="start" x="193.5" y="-347.8" font-family="Times,serif" font-size="14.00">If</text>
+<polygon fill="none" stroke="black" points="152,-308 152,-339 246,-339 246,-308 152,-308"/>
+<polygon fill="yellow" stroke="transparent" points="157,-313 157,-334 197,-334 197,-313 157,-313"/>
+<polygon fill="none" stroke="black" points="157,-313 157,-334 197,-334 197,-313 157,-313"/>
+<text text-anchor="start" x="160" y="-319.8" font-family="Times,serif" font-size="14.00">True</text>
+<polygon fill="yellow" stroke="transparent" points="197,-313 197,-334 241,-334 241,-313 197,-313"/>
+<polygon fill="none" stroke="black" points="197,-313 197,-334 241,-334 241,-313 197,-313"/>
+<text text-anchor="start" x="200" y="-319.8" font-family="Times,serif" font-size="14.00">False</text>
+</g>
+<!-- If25&#45;&gt;If9 -->
+<g id="edge17" class="edge">
+<title>If25&#45;&gt;If9:p1</title>
+<path fill="none" stroke="red" d="M194.16,-368.3C192.87,-378.58 191.7,-390.29 191.23,-401.68"/>
+<polygon fill="red" stroke="red" points="187.72,-401.93 191,-412 194.72,-402.08 187.72,-401.93"/>
+<text text-anchor="middle" x="191.16" y="-370.9" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- If25&#45;&gt;EQNode24 -->
+<g id="edge18" class="edge">
+<title>If25&#45;&gt;EQNode24</title>
+<path fill="none" stroke="black" d="M221.78,-368.01C232.02,-381.95 243.93,-398.15 253.46,-411.12"/>
+<polygon fill="black" stroke="black" points="250.89,-413.54 259.63,-419.53 256.53,-409.39 250.89,-413.54"/>
+<text text-anchor="middle" x="218.78" y="-370.61" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Con_29 -->
+<g id="node16" class="node">
+<title>Con_29</title>
+<ellipse fill="none" stroke="black" cx="299" cy="-336" rx="27" ry="18"/>
+<text text-anchor="middle" x="299" y="-332.3" font-family="Times,serif" font-size="14.00">#4</text>
+</g>
+<!-- Con_30 -->
+<g id="node17" class="node">
+<title>Con_30</title>
+<ellipse fill="none" stroke="black" cx="371" cy="-336" rx="27" ry="18"/>
+<text text-anchor="middle" x="371" y="-332.3" font-family="Times,serif" font-size="14.00">#5</text>
+</g>
+<!-- Region31 -->
+<g id="node18" class="node">
+<title>Region31</title>
+<polygon fill="yellow" stroke="black" points="253,-268 187,-268 187,-232 253,-232 253,-268"/>
+<text text-anchor="middle" x="220" y="-246.3" font-family="Times,serif" font-size="14.00">Region</text>
+</g>
+<!-- Region31&#45;&gt;If25 -->
+<g id="edge19" class="edge">
+<title>Region31&#45;&gt;If25:p0</title>
+<path fill="none" stroke="red" d="M199.51,-268.03C190.68,-276.94 181.63,-288.71 178.32,-301.78"/>
+<polygon fill="red" stroke="red" points="174.81,-301.63 177,-312 181.75,-302.53 174.81,-301.63"/>
+<text text-anchor="middle" x="196.51" y="-270.63" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Region31&#45;&gt;If25 -->
+<g id="edge20" class="edge">
+<title>Region31&#45;&gt;If25:p1</title>
+<path fill="none" stroke="red" d="M219.57,-268.09C219.36,-277.55 219.13,-289.77 219.04,-301.69"/>
+<polygon fill="red" stroke="red" points="215.54,-301.99 219,-312 222.54,-302.01 215.54,-301.99"/>
+<text text-anchor="middle" x="216.57" y="-270.69" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Phi_a32 -->
+<g id="node19" class="node">
+<title>Phi_a32</title>
+<ellipse fill="lightyellow" stroke="black" cx="299" cy="-250" rx="27" ry="18"/>
+<text text-anchor="middle" x="299" y="-246.3" font-family="Times,serif" font-size="14.00">φ_a</text>
+</g>
+<!-- Phi_a32&#45;&gt;Con_29 -->
+<g id="edge22" class="edge">
+<title>Phi_a32&#45;&gt;Con_29</title>
+<path fill="none" stroke="black" d="M299,-268.4C299,-279.74 299,-294.77 299,-307.68"/>
+<polygon fill="black" stroke="black" points="295.5,-307.9 299,-317.9 302.5,-307.9 295.5,-307.9"/>
+<text text-anchor="middle" x="296" y="-271" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Phi_a32&#45;&gt;Con_30 -->
+<g id="edge23" class="edge">
+<title>Phi_a32&#45;&gt;Con_30</title>
+<path fill="none" stroke="black" d="M311.87,-266.02C322.93,-278.92 339.04,-297.71 351.65,-312.42"/>
+<polygon fill="black" stroke="black" points="349.07,-314.8 358.24,-320.11 354.39,-310.24 349.07,-314.8"/>
+<text text-anchor="middle" x="308.87" y="-268.62" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Phi_a32&#45;&gt;Region31 -->
+<g id="edge21" class="edge">
+<title>Phi_a32&#45;&gt;Region31</title>
+<path fill="none" stroke="black" stroke-dasharray="1,5" d="M271.7,-250C268.88,-250 266.06,-250 263.23,-250"/>
+<polygon fill="black" stroke="black" points="263.02,-246.5 253.02,-250 263.02,-253.5 263.02,-246.5"/>
+<text text-anchor="middle" x="268.7" y="-243.6" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Region33 -->
+<g id="node20" class="node">
+<title>Region33</title>
+<polygon fill="yellow" stroke="black" points="253,-196 187,-196 187,-160 253,-160 253,-196"/>
+<text text-anchor="middle" x="220" y="-174.3" font-family="Times,serif" font-size="14.00">Region</text>
+</g>
+<!-- Region33&#45;&gt;Region21 -->
+<g id="edge24" class="edge">
+<title>Region33&#45;&gt;Region21</title>
+<path fill="none" stroke="red" d="M194.07,-196.12C180.34,-205.19 163.29,-216.45 148.46,-226.24"/>
+<polygon fill="red" stroke="red" points="146.45,-223.38 140.03,-231.81 150.3,-229.22 146.45,-223.38"/>
+<text text-anchor="middle" x="191.07" y="-198.72" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Region33&#45;&gt;Region31 -->
+<g id="edge25" class="edge">
+<title>Region33&#45;&gt;Region31</title>
+<path fill="none" stroke="red" d="M220,-196.3C220,-204.02 220,-213.29 220,-221.89"/>
+<polygon fill="red" stroke="red" points="216.5,-221.9 220,-231.9 223.5,-221.9 216.5,-221.9"/>
+<text text-anchor="middle" x="217" y="-198.9" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Phi_a34 -->
+<g id="node21" class="node">
+<title>Phi_a34</title>
+<ellipse fill="lightyellow" stroke="black" cx="299" cy="-178" rx="27" ry="18"/>
+<text text-anchor="middle" x="299" y="-174.3" font-family="Times,serif" font-size="14.00">φ_a</text>
+</g>
+<!-- Phi_a34&#45;&gt;Phi_a22 -->
+<g id="edge27" class="edge">
+<title>Phi_a34&#45;&gt;Phi_a22</title>
+<path fill="none" stroke="black" d="M317.81,-191.19C335,-202.33 360.62,-218.94 379.99,-231.5"/>
+<polygon fill="black" stroke="black" points="378.11,-234.44 388.4,-236.95 381.92,-228.57 378.11,-234.44"/>
+<text text-anchor="middle" x="314.81" y="-193.79" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Phi_a34&#45;&gt;Phi_a32 -->
+<g id="edge28" class="edge">
+<title>Phi_a34&#45;&gt;Phi_a32</title>
+<path fill="none" stroke="black" d="M299,-196.3C299,-204.02 299,-213.29 299,-221.89"/>
+<polygon fill="black" stroke="black" points="295.5,-221.9 299,-231.9 302.5,-221.9 295.5,-221.9"/>
+<text text-anchor="middle" x="296" y="-198.9" font-family="Helvetica,sans-Serif" font-size="8.00">2</text>
+</g>
+<!-- Phi_a34&#45;&gt;Region33 -->
+<g id="edge26" class="edge">
+<title>Phi_a34&#45;&gt;Region33</title>
+<path fill="none" stroke="black" stroke-dasharray="1,5" d="M271.7,-178C268.88,-178 266.06,-178 263.23,-178"/>
+<polygon fill="black" stroke="black" points="263.02,-174.5 253.02,-178 263.02,-181.5 263.02,-174.5"/>
+<text text-anchor="middle" x="268.7" y="-171.6" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Return35&#45;&gt;Region33 -->
+<g id="edge29" class="edge">
+<title>Return35&#45;&gt;Region33</title>
+<path fill="none" stroke="red" d="M249.36,-124.3C244.87,-132.36 239.44,-142.11 234.48,-151.02"/>
+<polygon fill="red" stroke="red" points="231.34,-149.46 229.53,-159.9 237.45,-152.86 231.34,-149.46"/>
+<text text-anchor="middle" x="246.36" y="-126.9" font-family="Helvetica,sans-Serif" font-size="8.00">0</text>
+</g>
+<!-- Return35&#45;&gt;Phi_a34 -->
+<g id="edge30" class="edge">
+<title>Return35&#45;&gt;Phi_a34</title>
+<path fill="none" stroke="black" d="M268.89,-124.3C273.68,-132.68 279.52,-142.9 284.77,-152.1"/>
+<polygon fill="black" stroke="black" points="281.77,-153.91 289.77,-160.86 287.85,-150.44 281.77,-153.91"/>
+<text text-anchor="middle" x="265.89" y="-126.9" font-family="Helvetica,sans-Serif" font-size="8.00">1</text>
+</g>
+<!-- Scope1_0 -->
+<g id="node23" class="node">
+<title>Scope1_0</title>
+<polygon fill="cyan" stroke="transparent" points="655,-95 655,-116 671,-116 671,-95 655,-95"/>
+<polygon fill="none" stroke="black" points="655,-95 655,-116 671,-116 671,-95 655,-95"/>
+<text text-anchor="start" x="658" y="-101.8" font-family="Times,serif" font-size="14.00">0</text>
+<polygon fill="none" stroke="black" points="671,-95 671,-116 711,-116 711,-95 671,-95"/>
+<text text-anchor="start" x="674" y="-101.8" font-family="Times,serif" font-size="14.00">$ctrl</text>
+<polygon fill="none" stroke="black" points="711,-95 711,-116 742,-116 742,-95 711,-95"/>
+<text text-anchor="start" x="714" y="-101.8" font-family="Times,serif" font-size="14.00">arg</text>
+</g>
+<!-- Scope1_0&#45;&gt;Start2 -->
+<g id="edge31" class="edge">
+<title>Scope1_0:Scope1_0_arg&#45;&gt;Start2:p1</title>
+<path fill="none" stroke="cornflowerblue" stroke-dasharray="5,2" d="M727,-117C727,-185.37 648,-180.63 648,-249 648,-249 648,-249 648,-437 648,-525.53 378.1,-590.44 277.07,-594.77"/>
+<polygon fill="cornflowerblue" stroke="cornflowerblue" points="276.92,-591.27 267,-595 277.08,-598.27 276.92,-591.27"/>
+</g>
+<!-- Scope1_1 -->
+<g id="node24" class="node">
+<title>Scope1_1</title>
+<polygon fill="cyan" stroke="transparent" points="586,-95 586,-116 602,-116 602,-95 586,-95"/>
+<polygon fill="none" stroke="black" points="586,-95 586,-116 602,-116 602,-95 586,-95"/>
+<text text-anchor="start" x="589" y="-101.8" font-family="Times,serif" font-size="14.00">1</text>
+<polygon fill="none" stroke="black" points="602,-95 602,-116 617,-116 617,-95 602,-95"/>
+<text text-anchor="start" x="605" y="-101.8" font-family="Times,serif" font-size="14.00">a</text>
+</g>
+<!-- Scope1_1&#45;&gt;Phi_a34 -->
+<g id="edge32" class="edge">
+<title>Scope1_1:Scope1_1_a&#45;&gt;Phi_a34</title>
+<path fill="none" stroke="cornflowerblue" stroke-dasharray="5,2" d="M610,-117C610,-172.18 418.84,-177.72 336.26,-177.53"/>
+<polygon fill="cornflowerblue" stroke="cornflowerblue" points="336.07,-174.03 326.06,-177.48 336.04,-181.03 336.07,-174.03"/>
+</g>
+</g>
+</svg>
diff --git a/chapter05/src/main/java/com/seaofnodes/simple/GraphVisualizer.java b/chapter05/src/main/java/com/seaofnodes/simple/GraphVisualizer.java
index f3942edb..01b5aeeb 100644
--- a/chapter05/src/main/java/com/seaofnodes/simple/GraphVisualizer.java
+++ b/chapter05/src/main/java/com/seaofnodes/simple/GraphVisualizer.java
@@ -146,7 +146,7 @@ public class GraphVisualizer {
// Walk the node edges
private void nodeEdges(StringBuilder sb, Collection<Node> all) {
// All them edge labels
- sb.append("\tedge [ fontname=Helvetica, fontsize=8 ];\n");
+ sb.append("\tedge [ fontname=Helvetica, fontsize=8 ];\n");
for( Node n : all ) {
// Do not display the Constant->Start edge;
// ProjNodes handled by Multi;
@@ -155,16 +155,12 @@ public class GraphVisualizer {
continue;
int i=0;
for( Node def : n._inputs ) {
- // Do not draw the Phi->Region edge (in red); instead Phis are
- // on a line with their Region, and we draw an invisible line
- // from the Region to the Phi, to force all the Phis to the
- // right of the Region.
if( n instanceof PhiNode && def instanceof RegionNode ) {
- sb.append('\t').append(def.uniqueName());
+ // Draw a dotted use->def edge from Phi to Region.
+ sb.append('\t').append(n.uniqueName());
sb.append(" -> ");
- sb.append(n.uniqueName());
- sb.append(" [style=invis]\n");
-
+ sb.append(def.uniqueName());
+ sb.append(" [style=dotted taillabel=").append(i).append("];\n");
} else if( def != null ) {
// Most edges land here use->def
sb.append('\t').append(n.uniqueName()).append(" -> ");
@@ -176,7 +172,7 @@ public class GraphVisualizer {
sb.append("[taillabel=").append(i);
// control edges are colored red
if( def.isCFG() )
- sb.append("; color=red");
+ sb.append(" color=red");
sb.append("];\n");
}
i++;
diff --git a/chapter05/src/main/java/com/seaofnodes/simple/Parser.java b/chapter05/src/main/java/com/seaofnodes/simple/Parser.java
index 8bf343b3..a132fce0 100644
--- a/chapter05/src/main/java/com/seaofnodes/simple/Parser.java
+++ b/chapter05/src/main/java/com/seaofnodes/simple/Parser.java
@@ -94,6 +94,7 @@ public class Parser {
_scope.define(CTRL , new ProjNode(START, 0, CTRL ).peephole());
_scope.define("arg", new ProjNode(START, 1, "arg").peephole());
parseBlock();
+ if (!_lexer.isEOF()) throw error("Syntax error, unexpected " + _lexer.getAnyNextToken());
return STOP;
}
finally {
@@ -129,7 +130,7 @@ public class Parser {
* Parses a statement
*
* <pre>
- * returnStatement | declStatement | blockStatement | expressionStatement
+ * returnStatement | declStatement | blockStatement | ifStatement | expressionStatement
* </pre>
* @return a {@link Node} or {@code null}
*/
diff --git a/chapter05/src/main/java/com/seaofnodes/simple/node/MinusNode.java b/chapter05/src/main/java/com/seaofnodes/simple/node/MinusNode.java
index 834f4c11..533155d9 100644
--- a/chapter05/src/main/java/com/seaofnodes/simple/node/MinusNode.java
+++ b/chapter05/src/main/java/com/seaofnodes/simple/node/MinusNode.java
@@ -20,7 +20,7 @@ public class MinusNode extends Node {
@Override
public Type compute() {
if (in(1)._type instanceof TypeInteger i0)
- return TypeInteger.constant(-i0.value());
+ return i0.isConstant() ? TypeInteger.constant(-i0.value()) : i0;
return TypeBot.BOTTOM;
}
diff --git a/chapter05/src/main/java/com/seaofnodes/simple/node/ScopeNode.java b/chapter05/src/main/java/com/seaofnodes/simple/node/ScopeNode.java
index 64061030..61fac118 100644
--- a/chapter05/src/main/java/com/seaofnodes/simple/node/ScopeNode.java
+++ b/chapter05/src/main/java/com/seaofnodes/simple/node/ScopeNode.java
@@ -105,6 +105,10 @@ public class ScopeNode extends Node {
* The new Scope is a full-fledged Node with proper use<->def edges.
*/
public ScopeNode dup() {
+ // Our goals are:
+ // 1) duplicate the name bindings of the ScopeNode across all stack levels
+ // 2) Make the new ScopeNode a user of all the nodes bound
+ // 3) Ensure that the order of defs is the same to allow easy merging
ScopeNode dup = new ScopeNode();
for( HashMap<String, Integer> tab : _scopes )
dup._scopes.push(new HashMap<>(tab));
@@ -114,6 +118,14 @@ public class ScopeNode extends Node {
return dup;
}
+ /**
+ * Merges the names whose node bindings differ, by creating Phi node for such names
+ * The names could occur at all stack levels, but a given name can only differ in the
+ * innermost stack level where the name is bound.
+ *
+ * @param that The ScopeNode to be merged into this
+ * @return A new Region node representing the merge point
+ */
public RegionNode mergeScopes(ScopeNode that) {
RegionNode r = (RegionNode)ctrl(new RegionNode(null,ctrl(), that.ctrl()).peephole());
for( int i=1; i<nIns(); i++ )
diff --git a/chapter05/src/test/java/com/seaofnodes/simple/Chapter05Test.java b/chapter05/src/test/java/com/seaofnodes/simple/Chapter05Test.java
index 0516fb73..e40136bd 100644
--- a/chapter05/src/test/java/com/seaofnodes/simple/Chapter05Test.java
+++ b/chapter05/src/test/java/com/seaofnodes/simple/Chapter05Test.java
@@ -21,8 +21,7 @@ else {
#showGraph;
}
#showGraph;
-return a;
-""");
+return a;""");
StopNode ret = parser.parse(true);
assertEquals("return Phi(Region17,(arg+2),(arg-3));", ret.toString());
}
@@ -36,50 +35,94 @@ if (arg == 1) {
b = 3;
c = 4;
}
-return c;
- """, TypeInteger.BOT);
- StopNode ret = parser.parse();
+return c;""", TypeInteger.BOT);
+ StopNode ret = parser.parse(true);
assertEquals("return Phi(Region16,4,3);", ret.toString());
}
@Test
public void testChapter5Return2() {
- Parser parser = new Parser("if( arg==1 ) return 3; else return 4; #showGraph;", TypeInteger.BOT);
+ Parser parser = new Parser("""
+if( arg==1 )
+ return 3;
+else
+ return 4;
+#showGraph;""", TypeInteger.BOT);
StopNode stop = parser.parse();
assertEquals("Stop[ return 3; return 4; ]", stop.toString());
}
@Test
public void testChapter5IfMergeB() {
- Parser parser = new Parser("int a=arg+1; int b=0; if( arg==1 ) b=a; else b=a+1; return a+b;");
+ Parser parser = new Parser("""
+int a=arg+1;
+int b=0;
+if( arg==1 )
+ b=a;
+else
+ b=a+1;
+return a+b;""");
StopNode ret = parser.parse(true);
assertEquals("return ((arg*2)+Phi(Region20,2,3));", ret.toString());
}
@Test
public void testChapter5IfMerge2() {
- Parser parser = new Parser("int a=arg+1; int b=arg+2; if( arg==1 ) b=b+a; else a=b+1; return a+b;");
+ Parser parser = new Parser("""
+int a=arg+1;
+int b=arg+2;
+if( arg==1 )
+ b=b+a;
+else
+ a=b+1;
+return a+b;""");
StopNode ret = parser.parse(true);
assertEquals("return ((Phi(Region31,(arg*2),arg)+arg)+Phi(Region31,4,5));", ret.toString());
}
@Test
public void testChapter5Merge3() {
- Parser parser = new Parser("int a=1; if( arg==1 ) if( arg==2 ) a=2; else a=3; else if( arg==3 ) a=4; else a=5; return a; #showGraph;", TypeInteger.BOT);
+ Parser parser = new Parser("""
+int a=1;
+if( arg==1 )
+ if( arg==2 )
+ a=2;
+ else
+ a=3;
+else if( arg==3 )
+ a=4;
+else
+ a=5;
+return a;
+#showGraph;""", TypeInteger.BOT);
StopNode stop = parser.parse();
assertEquals("return Phi(Region33,Phi(Region21,2,3),Phi(Region31,4,5));", stop.toString());
}
@Test
public void testChapter5Merge4() {
- Parser parser = new Parser("int a=0;int b=0;if(arg)a=1;if(arg==0)b=2;return arg+a+b;#showGraph;", TypeInteger.BOT);
+ Parser parser = new Parser("""
+int a=0;
+int b=0;
+if( arg )
+ a=1;
+if( arg==0 )
+ b=2;
+return arg+a+b;
+#showGraph;""", TypeInteger.BOT);
StopNode stop = parser.parse();
assertEquals("return ((arg+Phi(Region13,1,0))+Phi(Region22,2,0));", stop.toString());
}
@Test
public void testChapter5Merge5() {
- Parser parser = new Parser("int a=arg==2;if(arg==1)a=arg==3;return a;");
+ Parser parser = new Parser("""
+int a=arg==2;
+if( arg==1 )
+{
+ a=arg==3;
+}
+return a;""");
StopNode ret = parser.parse(true);
assertEquals("return (arg==Phi(Region16,3,2));", ret.toString());
}
@@ -259,6 +302,13 @@ return c;
assertEquals("Undefined name 'inta'",e.getMessage());
}
}
+
+ @Test
+ public void testChapter4Bug4() {
+ Parser parser = new Parser("return -arg;");
+ StopNode ret = parser.parse();
+ assertEquals("return (-arg);", ret.print());
+ }
@Test
public void testVarDecl() {
@@ -440,4 +490,15 @@ return c;
assertEquals("Syntax error, expected }: ",e.getMessage());
}
}
+
+ @Test
+ public void testBad7() {
+ try {
+ new Parser("return 1;}").parse();
+ fail();
+ } catch( RuntimeException e ) {
+ assertEquals("Syntax error, unexpected }",e.getMessage());
+ }
+ }
+
}