Here, $\texttt{x}$ is a static variable.
A static variable is initialized only once and keeps its value across recursive calls.

Initially, $\texttt{x = 0}$.
For $\texttt{fun(3)}$, $\texttt{x++}$ makes $\texttt{x = 1}$, then it calls $\texttt{fun(2)}$.
For $\texttt{fun(2)}$, $\texttt{x++}$ makes $\texttt{x = 2}$, then it calls $\texttt{fun(1)}$.
For $\texttt{fun(1)}$, $\texttt{x++}$ makes $\texttt{x = 3}$, then it calls $\texttt{fun(0)}$.
For $\texttt{fun(0)}$, the base condition becomes true and it returns $\texttt{0}$.
Now returning starts.
In $\texttt{fun(1)}$, $\texttt{y = 0}$ and current $\texttt{x = 3}$.
So, it returns $\texttt{0 + 3 = 3}$.
In $\texttt{fun(2)}$, $\texttt{y = 3}$ and current $\texttt{x = 3}$.
So, it returns $\texttt{3 + 3 = 6}$.
In $\texttt{fun(3)}$, $\texttt{y = 6}$ and current $\texttt{x = 3}$.
So, it returns $\texttt{6 + 3 = 9}$.
$\therefore$ Output $:\texttt{9}$