aboutsummaryrefslogtreecommitdiff
path: root/tests/performance/23_pure_function2.sy
blob: 07bc87f54dd15b30b784b7935226f26d6c2235a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// has side effect
void f1() {
  putint(1); putch(10);
}

int glob;

// no side effect, load glob
int f2(int x[]) {
  return x[0] + glob;
}

int f3(int x[]) {
  return x[0] + x[1];
}

int main() {
  f1();
  int i = 0;
  int x[2] = {getint(), getint()};
  f2(x);
  while (i < f3(x)) {
    x[0] = x[0] + 1;
    x[1] = x[1] * 2;
    i = i + f2(x);
  }
  putint(i); putch(10);
  return 0;
}