repo.or.cz
/
qbe.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
no mul->shl as it confuses address matching
[qbe.git]
/
minic
/
test
/
collatz.c
blob
1d8a96c0cd833ff9427b6681c321ca3ae10d7f35
1
void
*
malloc
();
2
3
main
()
4
{
5
int
n
;
6
int
nv
;
7
int
c
;
8
int
cmax
;
9
int
*
mem
;
10
11
mem
=
malloc
(
sizeof
(
int
) *
4000
);
12
13
cmax
=
0
;
14
for
(
nv
=
1
;
nv
<
1000
;
nv
++) {
15
n
=
nv
;
16
c
=
0
;
17
while
(
n
!=
1
) {
18
if
(
n
<
nv
) {
19
c
=
c
+
mem
[
n
];
20
break
;
21
}
22
if
(
n
&
1
)
23
n
=
3
*
n
+
1
;
24
else
25
n
=
n
/
2
;
26
c
++;
27
}
28
mem
[
nv
] =
c
;
29
if
(
c
>
cmax
)
30
cmax
=
c
;
31
}
32
printf
(
"should print 178: %d
\n
"
,
cmax
);
33
}