title: Diagrams of recursive functions. Drawing recursion
body: <p>I want to draw a diagram similar to this one for code below.</p>
  <p><a href="https://i.stack.imgur.com/wZvKB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wZvKB.png" alt="diagram of factorial(6)" /></a></p>
  <p>My code:</p>
  <pre><code>#include &lt;stdio.h&gt;
  void f(int x){
      if(x&lt;3)f(x+1);
      printf(&quot;%d\n&quot;, x);
      if(x&lt;5)f(x+2);
  }
  int main(void){
      f(2);
      return 0;
  }
  </code></pre>
  <p>Second example</p>
  <pre><code>#include &lt;stdio.h&gt;
  void f(int n){
      int x=0;
      static int y=1;
      --y; x+=y;
      if (n &lt; 4) f(n+2);
      printf (&quot;n=%d \t x=%d \t y=%d \n&quot;, n, x, y);
  }
  int main(void){
      f(0);
      return 0;
  }
  </code></pre>
  <p>This is what I've tried (first function).<a href="https://i.stack.imgur.com/6jS1f.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6jS1f.jpg" alt="diagram of f(2)" /></a></p>
  <p>But I need a diagram or some other way which will help me to determine what will be printed. I can't just run the code but I'd like to see the output.</p>