First of all understand what both of the functions are really doing.
int bar(int n)
{
if (n == 1) return 0;
else return 1 + bar(n/2);
}Each call divides $n$ by $2$ and adds $1$ until it reaches $1.$
So, basically, it is finding $\lfloor \log_2n \rfloor.$
$\therefore \bbox[4pt, border: 1px solid black]{bar(n) = \lfloor \log_2n \rfloor}$ $-$ $(1)$
int foo(int n)
{
if (n == 0) return 0;
else return 1 + foo(bar(n));
}So, $foo(n) = 1 + foo(bar(n))$, using first equation we can write,
$\therefore \bbox[4pt, border: 1px solid black]{foo(n) = 1 + foo(\lfloor \log_2n \rfloor)}$ $-$ $(2)$
Base case : $foo(0) = 0$
Now, we need to find $n$ such that, $foo(n)=5$. So, we can open up $foo(n)$ in following way :

Now, using base case we can say that, for $foo(log~log~log~log~log~n) = 0 $
$log~log~log~log~log~n = 0$
So, from this we can find $n$ as follows :
$\mathbf{\therefore n = 2^{16} = 65536}$