1 //===-- main.c --------------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 #include <stdio.h>
10 #include <stdlib.h>
11 
12 int a(int);
13 int b(int);
14 int c(int);
15 
a(int val)16 int a(int val)
17 {
18     if (val <= 1)
19         return b(val);
20     else if (val >= 3)
21         return c(val);
22 
23     return val;
24 }
25 
b(int val)26 int b(int val)
27 {
28     int rc = c(val);
29     void *ptr = malloc(1024); // thread step-out of malloc into function b.
30     if (!ptr)
31         return -1;
32     else
33         printf("ptr=%p\n", ptr);
34     return rc;                // we should reach here after 3 step-over's.
35 }
36 
c(int val)37 int c(int val)
38 {
39     return val + 3;
40 }
41 
main(int argc,char const * argv[])42 int main (int argc, char const *argv[])
43 {
44     int A1 = a(1);
45     printf("a(1) returns %d\n", A1);
46 
47     int B2 = b(2);
48     printf("b(2) returns %d\n", B2);
49 
50     int A3 = a(3);
51     printf("a(3) returns %d\n", A3);
52 
53     return 0;
54 }
55