manually merged shifter code