The original code is computes inner product of vectors i.e., a[1]*b[1] + a[2]*b[2] + ...... + a[20]*b[20].
So, it can be re-written as $\Rightarrow$
int prod = 0;
for(i=1;i<=20;i++) prod += a[i]*b[i];
Now, Intermediate representations can be in many ways, but if the IR given in question is considered, then we Find Basic Blocks and CFG by finding leaders first.
- First statement is a leader.
- Target of goto is a leader
- Statement that immediatedly follows goto is a leader.
And a Basic block starts from one leader and continues till starting of next leader without including that leader. So, statement $1,3$ and $13$ are leaders here.
And Basic blocks are $(1-2)$, $(3-12)$ and $13$ onwards till program exits. Flow graph looks like $\Rightarrow$
And Cycle in program detects the presence of a loop. Further optimization like Loop Unrolling can be done here.