Intermediate representations are used in compilers to represent programs between the source and target languages. Control flow graphs (CFG) are a common intermediate representation that represent a program as a directed graph with basic blocks as nodes and edges showing possible control transfers. CFGs are useful for optimizations and analyzing unreachable code. They are built by dividing a program into basic blocks - sections with no jumps in or out - and connecting them based on the control flow.