The maximal-density mass function for primordial black hole dark matter