-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfor.c
106 lines (89 loc) · 1.72 KB
/
for.c
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
float ffor(int a) {
int s = 0;
for (int i = 0; i < a; i += 4) {
s += i;
}
return s;
}
float ffor_postincr(int a) {
int s = 0;
for (int i = 0; i < a; i++) {
s += i;
}
return s;
}
float ffor_preincr(int a) {
int s = 0;
for (int i = 0; i < a; ++i) {
s += i;
}
return s;
}
float ffor_noblock(int a) {
int s = 0;
for (int i = 0; i < 10; i += 4)
s += i;
return s;
}
float ffor_nobody(int a) {
int s = 0;
for (int i = 0; i < 10; i += 4, s += 8);
return s;
}
float ffor_nodecl(int a) {
int s = 0;
int i = 0;
for (; i < 10; i += 4) {
s += i;
}
return s;
}
float ffor_noincr(int a) {
int s = 0;
for (int i = 0; i < 10; ) {
s += i++;
}
return s;
}
// XXX test returns inside for
float ffor_nocond(int a) {
int s = 0;
for (int i = 0; ; i++) {
if (i > 10) {
break;
}
s += i;
}
return s;
}
float ffor_continue(int a) {
int s = 0;
for (int i = 0; ; i++) {
if ((i % 2) == 0) {
continue;
}
s += i;
}
return s;
}
float ffor_decl(int a) {
int s = 0;
int i = 0;
// test that the loop declaration can be hidden (note cannot declare without
// a block, son no need to test without a block)
for (int i = 0; i < 10; i += 4) {
int i = 0;
s += i;
}
return s;
}
float ffor_nested(int a, int b) {
int s = 0;
for (int i = 0; i < a; i += 4) {
for (int j = 0; j < i; j += 8) {
s += i * j;
}
s += i;
}
return s;
}