1 #include <stdio.h>
2 
3 #if defined(__arm__) || defined(__aarch64__) || defined (__mips__) || defined(__powerpc64__)
4 // Clang does not accept regparm attribute on these platforms.
5 // Fortunately, the default calling convention passes arguments in registers
6 // anyway.
7 #define REGPARM(N)
8 #else
9 #define REGPARM(N) __attribute__((regparm(N)))
10 #endif
11 
12 struct bar {
13   int m1;
14   int m2;
15 };
16 
17 void f1(int a, struct bar *b) __attribute__((noinline)) REGPARM(2);
f1(int a,struct bar * b)18 void f1(int a, struct bar *b)
19 {
20   b->m2 = b->m1 + a; // set breakpoint here
21 }
22 
23 void f2(struct bar *b) __attribute__((noinline)) REGPARM(1);
f2(struct bar * b)24 void f2(struct bar *b)
25 {
26   int c = b->m2;
27   printf("%d\n", c); // set breakpoint here
28 }
29 
30 float f3() __attribute__((noinline));
f3()31 float f3() {
32   return 3.14f;
33 }
34 
main()35 int main()
36 {
37   struct bar myBar = { 3, 4 };
38   f1(2, &myBar);
39   f2(&myBar);
40 
41   float f = f3();
42   printf("%f\n", f); // set breakpoint here
43   return 0;
44 }
45