Coming from the idea of other programmers around the net I have coded this tower of hanoi solver using recursive function. The problem i'm facing is analyzing how the recursion processed the solution. As you can see I'm tracing it but I'm kinda lost now, I can only analyze the output of a recursive function using one function call but with 2 function calls ( like the code below ) I can't understand how it provided the output.



Code:
                //4                1              2              3
void hanoi( int disc_num, int peg1, int peg2, int peg3 )
{
   if( disc_num != 0 )
   {
      hanoi( disc_num - 1, peg1, peg3, peg2 ); 
      //printf( "Move the place from %d to %d\n", peg1, peg3 );
      printf( "Bottom first function call %d\n ", disc_num );
      hanoi( disc_num - 1, peg2, peg1, peg3 );
      printf( "Bottom of second call %d\n", disc_num );
   }
}
The output I have when I compiled and run it:

Code:
Bottom first function call 3
 Bottom first function call 1
 Bottom of second call 1
Bottom first function call 2
 Bottom first function call 1
 Bottom of second call 1
Bottom of second call 2
Bottom of second call 3
Bottom first function call 4
 Bottom first function call 1
 Bottom of second call 1
Bottom first function call 2
 Bottom first function call 1
 Bottom of second call 1
Bottom of second call 2
Bottom first function call 3
 Bottom first function call 1
 Bottom of second call 1
Bottom first function call 2
 Bottom first function call 1
 Bottom of second call 1
Bottom of second call 2
Bottom of second call 3
Bottom of second call 4
This is different to what I've analyzed, so I'm wrong with my analysis.