To determine the number of basic blocks, we identify the leaders using the standard rules:
Rule 1 (First instruction): The first three-address instruction is a leader.
Rule 2 (Target of a jump): Any instruction that is the target of a conditional or unconditional jump is a leader.
Instruction 1009 jumps to 1003.
Instruction 1011 jumps to 1002.
Instruction 1017 jumps to 1013.
Rule 3 (Follows a jump): Any instruction that immediately follows a conditional or unconditional jump is a leader.
Instruction immediately following 1009 is 1010.
Instruction immediately following 1011 is 1012.
Thus, the set of leader instructions is:
{1001,1002,1003,1010,1012,1013} Each leader begins a new basic block extending up to (but not including) the next leader or the end of the code:
Block 3 (B3):1003 to 1009
Block 4 (B4):1010 to 1011
Block 6 (B6):1013 to 1017
Therefore, the total number of basic blocks is 6.