Existence and regularity of the quasi-potential function in LDP