Implement atom_number/2 like SWI-Prolog