Consistent mean-field description of the C12 + C12 optical potential at low energies and the astrophysical S factor