We completely classify the Kubo–Martin–Schwinger (KMS) states for the gauge action on a C*-algebra associated with a rational function R introduced in our previous work. The gauge action has a phase transition at β=log deg R. We can recover the degree of R, the number of branched points, the number of exceptional points and the orbits of exceptional points from the structure of the KMS states. We also classify the KMS states for C*-algebras associated with some self-similar sets, including the full tent map and the Sierpinski gasket by a similar method.