IR: copied the first step of canonicalize from the slides