Our mechanism can be thought of comprising four separate steps: immine formation, reductive alkylation, SN2 substitution, and finally amine protection. In the first step, the secondary alcohol in our starting material is protonated by acetic acid and leaves via assisted ionization in the formation of an immine. Next, sodium cyanoborohydride provides a hydride ion to reduce the double bond of the immine, adding in where the alcohol group had previously been. Due to the basicity of nitrogen, its lone pair then resonates over to create another immine, kicking the double bond of the carbonyl group up to oxygen. This step creates a good leaving group, allowing our second starting molecule to attack from the backside, kicking off the nitrogen containing ring via an SN2 reaction. The new intermediate undergoes deprotonation at the nitrogen creating a lone pair which is used in the protection of the amine with tert-butyloxycarbonyl (BOC) in preparation for subsequent steps in the synthesis of lysergic acid.
