Real and imaginary parts of the microscopic optical potential between nuclei in the sudden and adiabatic approximation and its application to medium energy 12C-12C scattering