// inside total()
while(v) {
count += v&1; \\ check the lowest bit of v
v >>= 1; \\ or v = v >> 1 : right shift the bit pattern of v
}

This piece of code will count the no of set bits in $v$.
In the main function, i values goes from $5$ to $1$, So there will be $5$ calls to total().
Each call to total(i) counts the no of set bits in i. But the count is a static variable,
So, total(i) = Total no of set bits in all $i \leq 5$.

$\begin{align*} & \text{x} = \sum_{i=1}^{5}\left [ \text{ total}\left ( i \right ) \right ] = \color{blue}{2+3+5+6+7} = \color{red}{\bf 23}\\ \end{align*}$