Solution
The correct answer is Option 4) 100, 103, 104, 105, 106, 107, 111
Given Three-Address Code (TAC)
100: t1 = y + 2
101: initial = x / t1
102: limit = 10
103: if i > j goto 105
104: goto 111
105: if num > b goto 107
106: goto 111
107: num = limit - 1
108: b = y + 2
109: ii = num
110: goto 103
111: j = num
112: k = j + b
Rule for finding LEADERS (leading statements)
- (R1) The first statement of the TAC is a leader.
- (R2) Any statement that is the target of a jump (conditional or unconditional) is a leader.
- (R3) Any statement that immediately follows a jump (conditional or unconditional) is also a leader (it begins a new basic block for the fall-through path).
Apply the rules step by step
- R1: First statement → 100 is a leader.
- R2 (targets of jumps):
- Line 103 jumps to 105.
- Line 105 jumps to 107.
- Lines 104 and 106 jump to 111.
- Line 110 jumps to 103.
So 103, 105, 107, 111 are leaders.
- R3 (statements after jumps):
- After 103 (conditional jump) → 104 is a leader.
- After 104 (goto) → 105 (already marked).
- After 105 (conditional jump) → 106 is a leader.
- After 106 (goto) → 107 (already marked).
- After 110 (goto) → 111 (already marked).
Collect all unique leaders: 100, 103, 104, 105, 106, 107, 111.
Why others are not leaders
- 101, 102, 108, 109, 110, 112 are neither the first statement, nor jump targets, nor immediately after jumps.
- Note: line 110 is itself a jump, but a line becomes a leader only if it is a target or follows a jump—not merely because it is a jump.
Therefore, the set of LEADERS is exactly 100, 103, 104, 105, 106, 107, 111, matching Option 4.