# Code generation of static link, referencing variables which redefines
# outer variables and the calling a function in an outer scope
# The references to the variable 'a' in the inner function 'sub'
# should refer to the 'a' declared in 'b'
# However, when 'sub' calls 'c', the 'a' in 'c' refers to the outer 'a'
var a : int, temp : int;

func b() : int
  func sub(input : int) : int
    var a : int;
    a = 0;
    write a;
    d = d * 2;
    temp = c();
    return temp + input;
  end sub
  var a : int, d : int;
  a = 3;
  d = 1;
  write temp;
  return sub(a) + d;
end b

func c() : int
  write a;
  return 5;  
end c

a = 7;
temp = 9;
write a;
a = b();
write a;
write temp;

