How to print ‘optimized out’ value in gdb

Modern compilers such as gcc are able to perform various optimizations based on syntax and semantic analysis of the code at compile time. The goal of such optimizations is to improve program execution speed and/or reduce binary size, and they typically come with the cost of extra compilation time or reduced debuggability of the program.