Consider the following Three Address code sample for solving the questions:
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: i = i - num
110: goto 103
111: j = i - num
112: k= j+b
This solution explains how to identify the leaders (also known as leading statements) in a given sample of Three Address Code (TAC). Leaders are crucial for defining basic blocks, which are fundamental units in compiler design for control flow analysis and optimization.
Three Address Code (TAC) is an intermediate representation (IR) form used in compilers. Each instruction in TAC generally has at most three operands (two source operands and one destination operand). It simplifies complex expressions into a sequence of simple statements.
A basic block is a straight-line sequence of code that has exactly one entry point and one exit point. Control flow can only enter the block at the beginning and leave at the end, without any jumps in or out of the middle of the block.
The leaders are the first statements of the basic blocks. They are identified based on the control flow of the program. Specifically, the leaders are:
Let's analyze the provided Three Address Code step by step to find the leaders:
| Line No. | TAC Instruction | Reason for being a Leader |
| $100$ | $t1 = y + 2$ | First instruction of the entire code. Starts the first basic block. |
| $101$ | $initial = x / t1$ | Part of the first basic block. Not a leader. |
| $102$ | $limit = 10$ | Part of the first basic block. Not a leader. |
| $103$ | $if i > j goto 105$ | Target of jump from line 110. Starts a new basic block. |
| $104$ | $goto 111$ | Instruction immediately following a conditional jump (line 103). It's not the target ($105$) of the jump in line 103. Starts a new basic block. |
| $105$ | $if num > b goto 107$ | Target of jump from line 103. Starts a new basic block. |
| $106$ | $goto 111$ | Instruction immediately following a conditional jump (line 105). It's not the target ($107$) of the jump in line 105. Starts a new basic block. |
| $107$ | $num = limit - 1$ | Target of jump from line 105. Starts a new basic block. |
| $108$ | $b = y + 2$ | Part of the basic block starting at $107$. Not a leader. |
| $109$ | $i = i - num$ | Part of the basic block starting at $107$. Not a leader. |
| $110$ | $goto 103$ | This is an unconditional jump instruction. The block it belongs to ends here. It doesn't start a new block itself based on the leader rules. |
| $111$ | $j = i - num$ | Target of jumps from line 104 and line 106. Starts a new basic block. |
| $112$ | $k = j + b$ | Part of the basic block starting at $111$. This is the last instruction; it doesn't start a new block. Not a leader. |
Based on the analysis of the control flow:
Combining these identified statements, the set of leaders for the given Three Address Code is:
$100, 103, 104, 105, 106, 107, 111$
Consider the control flow graph shown in the figure.

Which one of the following options correctly lists the set of redundant expressions (common subexpressions) in the basic blocks B4 and B5?
Note: All the variables are integers.
Consider the control flow graph given below.
Which one of the following options is the set of live variables at the exit point of each basic block?