Recover cost function from profit function

How do I recover the cost function from the profit function?

Suppose I have $$\pi(p, w_1, w_2) = p^3 \cdot w_1 \cdot w_2$$.

How do I get the cost function?

Using Hotelling's lemma I get the supply function: $$y_s(p) = \frac{\partial \pi(p, w_1, w_2)}{\partial p} = 3 p^2 \cdot w_1 \cdot w_2$$ and the input demands: $$z_1(p, w)= - \frac{\partial \pi(p, w_1, w_2)}{\partial w_l} = - p^3 w_2$$ and $$z_2(p, w)= - \frac{\partial \pi(p, w_1, w_2)}{\partial w_2} = - p^3 w_1$$but what is the next step?

Note that the functional forms are hypothetical and highly probable to be invalid.

• If $\tilde{z}(y;w)$ is the input demand from cost minimization, can there be any difference between $\tilde{z}\big(y(p);w\big) \equiv \hat{z} (p;w)$ and $z(p;w)$ from Hotelling's lemma and profit maximization?
• Even if $\tilde{z}(y;w)$ is a correspondance rather than a function, is there any difference between $p \hat{z} (p;w) = p \tilde{z}\big(y(p);w\big) = c(y;w)$ and $p z(p;w)$ (where the later are dot products).
If you have recovered the supply function $$y_s(\bullet)$$, from the equation $$Q=y_s(p,\mathbf{r})$$ hopefully you could solve for p, e.g. $$p=f\left(Q,\mathbf{r}\right)$$. If the firm is maximizing profits, the equation $$p=f\left(Q,\mathbf{r}\right)$$ is equivalent to the condition $$p=C'\left(Q,\mathbf{r}\right)$$. So, one recovers $$C\left(Q,\mathbf{r}\right)=\int {f\left(Q,\mathbf{r}\right)dQ}$$