The compatibility of an amine-based foaming agent, Duomeen CTM [C12-14 N(CH3)C3N(CH3)(2)], and crude oil on supercritical CO2 foam transport are evaluated for a carbonate reservoir with high pressure and high temperatures (HPHT) and ultrahigh salinities. The CTM solubility in the formation brine (FB) with ultrahigh salinity is evaluated as a function of temperature and pH. CTM is a switchable surfactant, whereby it is soluble in FB when its pH is adjusted to or below a critical pH where protonation has occurred. The thermal stability of CTM at pH 6 was demonstrated at 135 degrees C with an oxygen scavenger. The adsorption of CTM was evaluated on pure calcite and reservoir carbonate rock. CTM adsorption was determined to be low on calcite, but moderate on reservoir carbonate, due to the presence of siliceous minerals. As expected, the phase behavior of protonated CTM in FB at pH = 4 with crude oil was characteristic of a Winsor Type I phase. The surfactant preferentially propagates with the aqueous phase in the presence of crude oil. The CTM foamability was evaluated in Indiana limestone cores in the: (1) absence of crude oil in a water-wet core, (2) presence of residual oil in a mixed-wet core, and (3) presence of residual oil in oil-wet cores. The foam strength remained stable with 13% residual oil in a mixed-wet core without requiring a minimum pressure gradient (MPG) for starting foam generation. However, at a higher residual oil saturation of 20% in an oil-wet core, the foam strength weakened significantly, and a MPG of 3 psi/ft was necessary for foam generation. These findings provide a framework for the application of CTM-based foams to provide CO2 mobility control and recover crude oil in carbonate reservoirs at HPHT conditions.