GATE Computer ScienceVery hardGATE CSE

Three-address code: 1: x = 0; 2: if a > b goto 8; 3: x = x + 1; 4: if x > 5 goto 7; 5: y = y * 2; 6: goto 2; 7: y = y + 1; 8: if y < 100 goto 2; 9: print y; 10: halt. The program is partitioned into basic blocks and a control-flow graph is built (an edge is added for each jump target and for each fall-through; duplicate edges are counted once; the entry and exit pseudo-nodes are ignored). How many edges does the CFG have?

  1. A. 9
  2. B. 8
  3. C. 10
  4. D. 11

Correct answer: A. 9

Blocks start at instructions 1, 2, 3, 5, 7, 8, 9; counting conditional (two successors), unconditional and fall-through edges gives 9.

More Compiler Design questions

Exams that ask this topic