--------------------------------------------- A-2 Conditional Jumps and Control Flow Graphs --------------------------------------------- int Z; | | void f() |f () { |{ int a, b, c; | int D.1715; a = Z; | int Z.0; if (a < 10) { | int a; b = 5; | int b; c = 17; | int c; } else { | b = 6; | a = Z; c = 20; | if (a == 0) { | if (a <= 9) goto ; else goto ; c = 0; | } | : } | b = 5; Z = b * 10 + c; | c = 17; } | goto ; | | : | b = 6; | c = 20; | if (a == 0) goto ; else goto ; | | : | c = 0; | | : | | : | D.1715 = b * 10; | Z.0 = D.1715 + c; | Z = Z.0; |} Solutions --------- 1 If-blocks have been broken down into distinct sections of code with labels (named similar to temporary variables). Control transfer occurs with unconditional jumps (e.g. "goto X") or conditional jumps (e.g. "if Z then goto X else goto Y"). 2 The control-flow graph dump shows distinct basic blocks which are named sequentially starting from 1. Basic blocks roughly correspond to labels that are created during the gimplification of control statements. f () { int c; int b; int a; int Z.0; int D.1715; : a = Z; if (a <= 9) goto ; else goto ; : b = 5; c = 17; goto ; : b = 6; c = 20; if (a == 0) goto ; else goto ; : c = 0; : D.1715 = b * 10; Z.0 = D.1715 + c; Z = Z.0; return; }