aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/o3copy.zc
blob: 29ac2782fe174731daa0bb5d3d4d64498b92811d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
namespace;
include rt;

// copies of a variable that a loop reads again: the global pass reads the variable itself
o3 int g(int n, int b) {
	int s = 0, c = b, i = 0;
	while (i < n) { c = b; s = s + c * 3 + i; i++; }
	return s + c;
}
o3 int h(int n, int k) {
	int a = k, t = 0, i = 0;
	while (i < n) { t = t + a; if (t > 1000) t = t - 1000; a = k; i++; }
	return t + a;
}
fn main() { rt.put_n(g(1000, 7)); rt.put_c(32); rt.put_n(h(1000, 5)); rt.put_c(10); return 0; }