Superconductivity out of a non-Fermi liquid: Free energy analysis