#test nested control structure
#should return 123

module main;

const w:bool = true;
const x:bool = false;
var y: int;

#should always return false
procedure bar(y:int) : bool;
begin
  if y = 1 and false then
    return true;
  else
    if y=1 or true then
      return false;
    end;
    return true;
  end;
end bar;

procedure foo(x:int);
var b:bool;
var i:int;
begin
  for i:=1 to x do
    b:=bar(i);
    if b = true then
      break;
    end;
  end;
  output := x;
end foo;    

    
begin
  #should output 1
  foo(1);
  if bar(2) or w then
     output := 2;
  end;
  foo(3);
end main.