$S'(x_i)=m_i, i=0,1,...,n-1$
$S'(x)=m_i+\frac{m_{i+1}-m_i}{h}(x-x_i), x\in [x_i,x_{i+1}]$
so integrate from $x_i$ to x
$S(x)-S(x_i)=m_i(x-x_i)+\frac{m_{i+1}-m_i}{h} \frac{(x-x_i)(x-x_i)}{2}$