Diazotization cum pinacol rearrangement..
You can see the rotation of those groups more easily in sawhorse projection. In case rotation across the bond carbon-carbon bond is HINDERED, ONLY migratory aptitude decides which group will replace the leaving group, as compound cannot rotate freely for a certain group to obtain anti-conformation wrt leaving group. If no hindrance, anti conformation is ALWAYS preferred.