-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmemoryTrace3.c
80 lines (66 loc) · 811 Bytes
/
memoryTrace3.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
#include <stdio.h>
#include <stdlib.h>
int counter;
void foo();
void f1();
void f2();
void f3();
void f4();
void f4(){
printf("f4\n");
}
void f3(){
printf("f3\n");
f1();
}
void f2(){
printf("f2\n");
int r = rand() % 3;
if (r == 1 || r == 2)
f4();
f3();
}
void f1(){
printf("f1\n");
int r = rand() % 3;
if(r == 1 || r == 2)
f2();
}
long fac(int n){
long res = 1;
while (n > 0){
res *= n;
n--;
}
return res;
}
void baz(){
int i = 0;
while ( i < 10){
fac(15);
i++;
}
}
void barbaz(){
baz();
}
void foobar() {
barbaz();
printf("foobar\n");
}
void bar() {
foo();
}
void foo() {
counter--;
if(counter > 0)
bar();
else
foobar();
}
int main(int argc, char *argv[]) {
if(argc != 2) {printf("Wrong args\n"); return 1;}
counter = atoi(argv[1]);
bar();
return 0;
}