namespace; include rt; // loop invariants are built once in front of the loop, and a value two blocks both build is shared. // every result below has to match the plain run (ZYNOSHARE=1 turns the pass off). unchecked o3 int nest(int n, int k) { int s = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { s = s + (k * 37 + 11) * (i + j); } } return s; } unchecked o3 int loads(int* a, int n) { int s = 0; for (int i = 0; i < n; i++) s = s + a[0] * a[1] + i; return s; } unchecked o3 int stores(int* a, int n) { int s = 0; for (int i = 0; i < n; i++) { a[0] = a[0] + 1; s = s + a[0] * 3; } return s; } unchecked o3 int branchy(int x, int y, int n) { int s = 0; for (int i = 0; i < n; i++) { if (i & 1) s = s + x * y * 5; else s = s - x * y * 5 + i; } return s; } unchecked o3 int twice(int x, int y) { int r = 0; if (x > 0) r = (x * y + 3) * (x * y + 3); else r = x * y + 3; return r + (x * y + 3) * 7; } unchecked fn main() { int* a = rt.new(int, 4); a[0] = 5; a[1] = 6; rt.put_n(nest(30, 3)); rt.put_c(' '); rt.put_n(loads(a, 100)); rt.put_c(' '); rt.put_n(stores(a, 10)); rt.put_c(' '); rt.put_n(branchy(3, 4, 21)); rt.put_c(' '); rt.put_n(twice(5, 2)); rt.put_c(' '); rt.put_n(twice(-5, 2)); rt.put_c(10); return 0; }