Let $S_t=\max_{0\leq s\leq t}B_s$ for $t\geq0$ and apply Ito formula to $f(B_t,S_t)=(S_t-B_t)^2$ for $t\geq0$. Determine the continuous local martingale part and the bounded variation part in the resulting semi-martingale.
First, I apply Ito formula to $f(B_t,S_t)$: $$ \begin{align} df&=-2(S_t-B_t)dB_t+2(S_t-B_t)dS_t+(dB_t)^2+(dS_t)^2-2dB_tdS_t\\ &=-2(S_t-B_t)dB_t+2(S_t-B_t)dS_t+dt+(dS_t)^2-2dB_tdS_t \end{align} $$ I couldn't get how to simplify $(dS_t)^2$ and $dB_tdS_t$, because I haven't introduced max/sup/inf $B_t$ related process. It will be great help if anyone explain that.
Since $S_t$ is an increasing process, it is of bounded variation. This implies that it has zero quadratic variation and its covariation with Brownian motion is zero. In terms of stochastic differentials, this means that$$(dS_t)^2 = dS_t dB_t = 0$$Thus Itô's formula gives you $$df = \underbrace{-2(S_t-B_t)dB_t}_{\text{local martingale}}+\underbrace{2(S_t-B_t)dS_t+dt}_{\text{bounded variation}}$$