Analysis and optimization of energy flow in the full chain of carbon dioxide capture and oil recovery