Bifurcation of degenerate homoclinic orbits in reversible and conservative systems