Critical scalarization and descalarization of black holes in a generalized scalar-tensor theory