projects
/
libfirm
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
fixed comments
[libfirm]
/
ir
/
be
/
test
/
gcd_bench.c
1
#include <stdio.h>
2
#include <limits.h>
3
4
int gcd(int a, int b)
5
{
6
int i = 0;
7
8
while(a != b)
9
{
10
if(a > b) {
11
a = a - b;
12
}
13
else {
14
b = b - a;
15
}
16
++i;
17
}
18
return a;
19
}
20
21
void gcd_no_out(void) {
22
int i, j;
23
24
for (i = 1; i < 10000; i++) {
25
for (j = 1; j < 10000; j++) {
26
gcd(i, j);
27
}
28
}
29
}
30
31
void gcd_out(void) {
32
int i, j;
33
34
for (i = 1; i < 1000; i++) {
35
for (j = 1; j < 1000; j++) {
36
printf("gcd(%d, %d) = %d\n", i, j, gcd(i, j));
37
}
38
}
39
}
40
41
int main(int argc)
42
{
43
printf("gcd.c\n");
44
45
if (argc > 1) {
46
gcd_no_out();
47
}
48
else {
49
gcd_out();
50
}
51
52
return 0;
53
}