[TRACE:Driver.1] 

HIR-C 

 (prog     0
  <null 0 void>
  <nullNode 0>
  (subpDef  0 void
   <subp     0 <SUBP <> false int> main>
  <null 0 void>
   (labeldSt 0 void
    (list 
     <labelDef _lab1>)
    (block    0 void
     (expStmt  0 int
      (call     0 int
       (addr     0 <PTR <SUBP <<PTR _u_char> > true int>>
        <subp     0 <SUBP <<PTR _u_char> > true int> printf>)
       (list 
        (decay    0 <PTR _u_char>
         <const    0 <VECT 19 _u_char> "type two numbers: ">))))
     (expStmt  0 int
      (call     0 int
       (addr     0 <PTR <SUBP <<PTR _u_char> > true int>>
        <subp     0 <SUBP <<PTR _u_char> > true int> scanf>)
       (list 
        (decay    0 <PTR _u_char>
         <const    0 <VECT 5 _u_char> "%d%d">)
        (addr     0 <PTR int>
         <var      0 int x>)
        (addr     0 <PTR int>
         <var      0 int y>))))
     (expStmt  0 int
      (call     0 int
       (addr     0 <PTR <SUBP <<PTR _u_char> > true int>>
        <subp     0 <SUBP <<PTR _u_char> > true int> printf>)
       (list 
        (decay    0 <PTR _u_char>
         <const    0 <VECT 15 _u_char> "GCD(%d, %d) = ">)
        <var      0 int x>
        <var      0 int y>)))
     (expStmt  0 int
      (assign   0 int
       <var      0 int noofiteration>
       <const    0 int 0>))
     (while    0 void
     <null 0 void>
     <null 0 void>
      (labeldSt 0 boolean
       (list 
        <labelDef _lab5>)
       (expStmt  0 boolean
        (cmpGt    0 boolean
         <var      0 int y>
         <const    0 int 0>)))
      (labeldSt 0 void
       (list 
        <labelDef _lab6>)
       (block    0 void
        (expStmt  0 int
         (assign   0 int
          <var      0 int r>
          (mod      0 int
           <var      0 int x>
           <var      0 int y>)))
        (expStmt  0 int
         (assign   0 int
          <var      0 int x>
          <var      0 int y>))
        (expStmt  0 int
         (assign   0 int
          <var      0 int y>
          <var      0 int r>))
        (expStmt  0 int
         (assign   0 int
          <var      0 int noofiteration>
          (add      0 int
           <var      0 int noofiteration>
           <const    0 int 1>)))))
      (labeldSt 0 void
       (list 
        <labelDef _lab3>)
      <null 0 void>)
     <null 0 void>
      (labeldSt 0 void
       (list 
        <labelDef _lab4>)
      <null 0 void>)
     <null 0 void>)
     (expStmt  0 int
      (call     0 int
       (addr     0 <PTR <SUBP <<PTR _u_char> > true int>>
        <subp     0 <SUBP <<PTR _u_char> > true int> printf>)
       (list 
        (decay    0 <PTR _u_char>
         <const    0 <VECT 5 _u_char> " %d\n">)
        <var      0 int x>)))
     (expStmt  0 int
      (call     0 int
       (addr     0 <PTR <SUBP <<PTR _u_char> > true int>>
        <subp     0 <SUBP <<PTR _u_char> > true int> printf>)
       (list 
        (decay    0 <PTR _u_char>
         <const    0 <VECT 24 _u_char> "no. of iteration is %d\n">)
        <var      0 int noofiteration>)))
     (return   0 int
      <const    0 int 0>)))))

[TRACE:Driver.1] 

HIR-base 

 (prog     0
  <null 0 void>
  <nullNode 0>
  (subpDef  0 void
   <subp     0 <SUBP <> false int> main>
  <null 0 void>
   (labeldSt 0 void
    (list 
     <labelDef _lab1>)
    (block    0 void
     (expStmt  0 int
      (call     0 int
       (addr     0 <PTR <SUBP <<PTR _u_char> > true int>>
        <subp     0 <SUBP <<PTR _u_char> > true int> printf>)
       (list 
        (decay    0 <PTR _u_char>
         <const    0 <VECT 19 _u_char> "type two numbers: ">))))
     (expStmt  0 int
      (call     0 int
       (addr     0 <PTR <SUBP <<PTR _u_char> > true int>>
        <subp     0 <SUBP <<PTR _u_char> > true int> scanf>)
       (list 
        (decay    0 <PTR _u_char>
         <const    0 <VECT 5 _u_char> "%d%d">)
        (conv     0 int
         (addr     0 <PTR int>
          <var      0 int x>))
        (conv     0 int
         (addr     0 <PTR int>
          <var      0 int y>)))))
     (expStmt  0 int
      (call     0 int
       (addr     0 <PTR <SUBP <<PTR _u_char> > true int>>
        <subp     0 <SUBP <<PTR _u_char> > true int> printf>)
       (list 
        (decay    0 <PTR _u_char>
         <const    0 <VECT 15 _u_char> "GCD(%d, %d) = ">)
        <var      0 int x>
        <var      0 int y>)))
     (assign   0 int
      <var      0 int noofiteration>
      <const    0 int 0>)
     (while    0 void
     <null 0 void>
     <null 0 void>
      (labeldSt 0 boolean
       (list 
        <labelDef _lab5>)
       (expStmt  0 boolean
        (cmpGt    0 boolean
         <var      0 int y>
         <const    0 int 0>)))
      (labeldSt 0 void
       (list 
        <labelDef _lab6>)
       (block    0 void
        (assign   0 int
         <var      0 int r>
         (mod      0 int
          <var      0 int x>
          <var      0 int y>))
        (assign   0 int
         <var      0 int x>
         <var      0 int y>)
        (assign   0 int
         <var      0 int y>
         <var      0 int r>)
        (assign   0 int
         <var      0 int noofiteration>
         (add      0 int
          <var      0 int noofiteration>
          <const    0 int 1>))))
      (labeldSt 0 void
       (list 
        <labelDef _lab3>)
      <null 0 void>)
     <null 0 void>
      (labeldSt 0 void
       (list 
        <labelDef _lab4>)
      <null 0 void>)
     <null 0 void>)
     (expStmt  0 int
      (call     0 int
       (addr     0 <PTR <SUBP <<PTR _u_char> > true int>>
        <subp     0 <SUBP <<PTR _u_char> > true int> printf>)
       (list 
        (decay    0 <PTR _u_char>
         <const    0 <VECT 5 _u_char> " %d\n">)
        <var      0 int x>)))
     (expStmt  0 int
      (call     0 int
       (addr     0 <PTR <SUBP <<PTR _u_char> > true int>>
        <subp     0 <SUBP <<PTR _u_char> > true int> printf>)
       (list 
        (decay    0 <PTR _u_char>
         <const    0 <VECT 24 _u_char> "no. of iteration is %d\n">)
        <var      0 int noofiteration>)))
     (return   0 int
      <const    0 int 0>)))))

[TRACE:Driver.1] 

HIR before HirToLir conversion

 (prog     0
  <null 0 void>
  <nullNode 0 (flags 3)>
  (subpDef  0 void
   <subp     0 <SUBP <> false int> main>
  <null 0 void>
   (labeldSt 0 void
    (list 
     <labelDef _lab1>)
    (block    0 void
     (expStmt  0 int
      (call     0 int
       (addr     0 <PTR <SUBP <<PTR _u_char> > true int>> (flags 3)
        <subp     0 <SUBP <<PTR _u_char> > true int> printf>)
       (list 
        (decay    0 <PTR _u_char> (flags 3)
         <const    0 <VECT 19 _u_char> "type two numbers: " (flags 3)>))))
     (expStmt  0 int
      (call     0 int
       (addr     0 <PTR <SUBP <<PTR _u_char> > true int>> (flags 3)
        <subp     0 <SUBP <<PTR _u_char> > true int> scanf>)
       (list 
        (decay    0 <PTR _u_char> (flags 3)
         <const    0 <VECT 5 _u_char> "%d%d" (flags 3)>)
        (conv     0 int (flags 3)
         (addr     0 <PTR int> (flags 3)
          <var      0 int x>))
        (conv     0 int (flags 3)
         (addr     0 <PTR int> (flags 3)
          <var      0 int y>)))))
     (expStmt  0 int
      (call     0 int
       (addr     0 <PTR <SUBP <<PTR _u_char> > true int>> (flags 3)
        <subp     0 <SUBP <<PTR _u_char> > true int> printf>)
       (list 
        (decay    0 <PTR _u_char> (flags 3)
         <const    0 <VECT 15 _u_char> "GCD(%d, %d) = " (flags 3)>)
        <var      0 int x>
        <var      0 int y>)))
     (assign   0 int
      <var      0 int noofiteration>
      <const    0 int 0 (flags 3)>)
     (while    0 void
     <null 0 void>
     <null 0 void>
      (labeldSt 0 boolean
       (list 
        <labelDef _lab5>)
       (expStmt  0 boolean
        (cmpGt    0 boolean
         <var      0 int y>
         <const    0 int 0 (flags 3)>)))
      (labeldSt 0 void
       (list 
        <labelDef _lab6>)
       (block    0 void
        (assign   0 int
         <var      0 int r>
         (mod      0 int
          <var      0 int x>
          <var      0 int y>))
        (assign   0 int
         <var      0 int x>
         <var      0 int y>)
        (assign   0 int
         <var      0 int y>
         <var      0 int r>)
        (assign   0 int
         <var      0 int noofiteration>
         (add      0 int
          <var      0 int noofiteration>
          <const    0 int 1 (flags 3)>))))
      (labeldSt 0 void
       (list 
        <labelDef _lab3>)
      <null 0 void>)
     <null 0 void>
      (labeldSt 0 void
       (list 
        <labelDef _lab4>)
      <null 0 void>)
     <null 0 void>)
     (expStmt  0 int
      (call     0 int
       (addr     0 <PTR <SUBP <<PTR _u_char> > true int>> (flags 3)
        <subp     0 <SUBP <<PTR _u_char> > true int> printf>)
       (list 
        (decay    0 <PTR _u_char> (flags 3)
         <const    0 <VECT 5 _u_char> " %d\n" (flags 3)>)
        <var      0 int x>)))
     (expStmt  0 int
      (call     0 int
       (addr     0 <PTR <SUBP <<PTR _u_char> > true int>> (flags 3)
        <subp     0 <SUBP <<PTR _u_char> > true int> printf>)
       (list 
        (decay    0 <PTR _u_char> (flags 3)
         <const    0 <VECT 24 _u_char> "no. of iteration is %d\n" (flags 3)>)
        <var      0 int noofiteration>)))
     (return   0 int
      <const    0 int 0 (flags 3)>)))))

[TRACE:Driver.1] 

LIR after conversion

   (subpDef  0 void
    <subp     0 <SUBP <> false int> main>
   <null 0 void>
    (labeldSt 0 void
     (list 
      <labelDef _lab1>)
     (block    0 void
     <null 0 void>))
LIR of main
     (PROLOGUE "main")
     (LABELDEF "_lab1")
     (CALL:I32 "printf" (LISTA:I32 (CONST:I32 ""type two numbers: "")))
     (CALL:I32 "scanf" (LISTA:I32 (CONST:I32 ""%d%d"") (LISTA:I32 (FRAME:I32 (VAR:I32 "x")) (LISTA:I32 (FRAME:I32 (VAR:I32 "y"))))))
     (CALL:I32 "printf" (LISTA:I32 (CONST:I32 ""GCD(%d, %d) = "") (LISTA:I32 (MEM:I32 (FRAME:I32 (VAR:I32 "x"))) (LISTA:I32 (MEM:I32 (FRAME:I32 (VAR:I32 "y")))))))
     (SET:I32 (MEM:I32 (FRAME:I32 (VAR:I32 "noofiteration"))) (CONST:I32 0))
     (LABELDEF "_lab5")
     (JUMPC (TSTGT:I32 (MEM:I32 (FRAME:I32 (VAR:I32 "y"))) (CONST:I32 0)) (LISTD (LABEL "_lab6") (LISTD (LABEL "_lab4"))))
     (LABELDEF "_lab6")
     (SET:I32 (MEM:I32 (FRAME:I32 (VAR:I32 "r"))) (MOD:I32 (MEM:I32 (FRAME:I32 (VAR:I32 "x"))) (MEM:I32 (FRAME:I32 (VAR:I32 "y")))))
     (SET:I32 (MEM:I32 (FRAME:I32 (VAR:I32 "x"))) (MEM:I32 (FRAME:I32 (VAR:I32 "y"))))
     (SET:I32 (MEM:I32 (FRAME:I32 (VAR:I32 "y"))) (MEM:I32 (FRAME:I32 (VAR:I32 "r"))))
     (SET:I32 (MEM:I32 (FRAME:I32 (VAR:I32 "noofiteration"))) (ADD:I32 (MEM:I32 (FRAME:I32 (VAR:I32 "noofiteration"))) (CONST:I32 1)))
     (LABELDEF "_lab3")
     (JUMP (LABEL "_lab5"))
     (LABELDEF "_lab4")
     (CALL:I32 "printf" (LISTA:I32 (CONST:I32 "" %d
"") (LISTA:I32 (MEM:I32 (FRAME:I32 (VAR:I32 "x"))))))
     (CALL:I32 "printf" (LISTA:I32 (CONST:I32 ""no. of iteration is %d
"") (LISTA:I32 (MEM:I32 (FRAME:I32 (VAR:I32 "noofiteration"))))))
     (RETURN:I32 (CONST:I32 0))
     (JUMP (LABEL "_lab2"))
     (LABELDEF "_lab2")
     (EPILOGUE "main")
)

[TRACE:Driver.1] 

LIR under program root

 (prog     0
  <null 0 void>
  <nullNode 0 (flags 3)>
  (subpDef  0 void
   <subp     0 <SUBP <> false int> main>
  <null 0 void>
   (labeldSt 0 void
    (list 
     <labelDef _lab1>)
    (block    0 void
    <null 0 void>))
LIR of main
    (PROLOGUE "main")
    (LABELDEF "_lab1")
    (CALL:I32 "printf" (LISTA:I32 (CONST:I32 ""type two numbers: "")))
    (CALL:I32 "scanf" (LISTA:I32 (CONST:I32 ""%d%d"") (LISTA:I32 (FRAME:I32 (VAR:I32 "x")) (LISTA:I32 (FRAME:I32 (VAR:I32 "y"))))))
    (CALL:I32 "printf" (LISTA:I32 (CONST:I32 ""GCD(%d, %d) = "") (LISTA:I32 (MEM:I32 (FRAME:I32 (VAR:I32 "x"))) (LISTA:I32 (MEM:I32 (FRAME:I32 (VAR:I32 "y")))))))
    (SET:I32 (MEM:I32 (FRAME:I32 (VAR:I32 "noofiteration"))) (CONST:I32 0))
    (LABELDEF "_lab5")
    (JUMPC (TSTGT:I32 (MEM:I32 (FRAME:I32 (VAR:I32 "y"))) (CONST:I32 0)) (LISTD (LABEL "_lab6") (LISTD (LABEL "_lab4"))))
    (LABELDEF "_lab6")
    (SET:I32 (MEM:I32 (FRAME:I32 (VAR:I32 "r"))) (MOD:I32 (MEM:I32 (FRAME:I32 (VAR:I32 "x"))) (MEM:I32 (FRAME:I32 (VAR:I32 "y")))))
    (SET:I32 (MEM:I32 (FRAME:I32 (VAR:I32 "x"))) (MEM:I32 (FRAME:I32 (VAR:I32 "y"))))
    (SET:I32 (MEM:I32 (FRAME:I32 (VAR:I32 "y"))) (MEM:I32 (FRAME:I32 (VAR:I32 "r"))))
    (SET:I32 (MEM:I32 (FRAME:I32 (VAR:I32 "noofiteration"))) (ADD:I32 (MEM:I32 (FRAME:I32 (VAR:I32 "noofiteration"))) (CONST:I32 1)))
    (LABELDEF "_lab3")
    (JUMP (LABEL "_lab5"))
    (LABELDEF "_lab4")
    (CALL:I32 "printf" (LISTA:I32 (CONST:I32 "" %d
"") (LISTA:I32 (MEM:I32 (FRAME:I32 (VAR:I32 "x"))))))
    (CALL:I32 "printf" (LISTA:I32 (CONST:I32 ""no. of iteration is %d
"") (LISTA:I32 (MEM:I32 (FRAME:I32 (VAR:I32 "noofiteration"))))))
    (RETURN:I32 (CONST:I32 0))
    (JUMP (LABEL "_lab2"))
    (LABELDEF "_lab2")
    (EPILOGUE "main")
))