Generating instructions for accessing the data and retain stacks