Limit cycles bifurcating from periodic orbits near a centre and a homoclinic loop with a nilpotent singularity of Hamiltonian systems