Return smaller of ret and f.