optimize ctlz and add cttz; fixes #797