Assignment III

Represent the following program as a series of basic blocks (fragments of straight line code with one entry and one exit, possibly a conditional exit).
   procedure Junk (x : Integer) return Integer is
      a : integer;
      b : integer;
      c : integer;

   begin
      a := x + 1;
      b := x + 2;

      if a > 3 then
         a := a + b;
      elsif b = 3 then 
         a := a + b
      end if;

      while b > a loop
         b := b - a;
      end loop;
   
      return a + b;
   end Junk;


Recall the following definitions:

A "def" is a definition of a variable
A "use" is a use of a variable

A def-use chain is a static path from a def to a use which has no other def's along the way.

Identify all the def-use chains in the above program. Note that you are not being asked to solve data flow equations in a formal manner. All you have to do is to identify the def-use chains, and you can find them by informal inspection.

Give at least one informal motivation for the usefulness of def-use chains in code generation.