RIO DE JANEIRO — Michael Phelps belongs to that separate species of all-time greats, and they’re the most discontented people on earth, restive and incapable of leaving their energy unspent.

You saw his face when he was taunted, and you saw him leap through the water like a marlin to get to the wall. If Phelps thinks he has even an eighth of a tank left in that long body, we will see him in four years in Tokyo. You can be sure of it.

“The itches” was how Michael Jordan once described the urge to compete. What if Phelps decides he hasn’t yet touched the bottom of his talent?

Picture him in a swim cap and trunks four years from now, threshing through the water at the age of 35 trying to make the next young things, the Joseph Schoolings, feel his splash in a sixth Summer Games.

He swears it won’t happen, but he has sworn he was done before, and it turned out he was just bored.

That’s why his teammates on the USA swimming team, from Ryan Lochte to Katie Ledecky, don’t take him at his word when he says, “I’m ready to retire.”

“Last time was his last, this time was his last, and I get to say I was on the same team twice when he retired,” Ledecky said teasingly Saturday afternoon, shortly before Phelps made his final relay swim in the Rio Games. “Maybe there will be a third time. All records are made to be broken.”

Lochte even went so far as to tell NBC that he “guaranteed” Phelps would appear in a sixth Olympics. Lochte, who has been rooming with Phelps, has been saying throughout these Games that he has a “weird feeling” that these aren’t Phelps’s last races.

“He said he was going to retire after 2012, and I was the only person who said he was going to come back again,” Lochte said.

For an example of what’s possible, look no further than the United States’ Anthony Ervin, who at 35 reclaimed the Olympic 50-meter title, fully 16 years after he first won gold in Sydney. Ervin’s case of burnout followed by a new competitive surge is not unlike Phelps’s, just a little more extreme.

Ervin was 19 when he won gold in Sydney, where Phelps was a 15-year-old comer. But by 2003 Ervin was tired of the grind, and he realized he didn’t know how to do anything but swim.

He walked away, took up the guitar, joined a band and became a wayfarer who abused drink and various chemical substances. His odyssey led to this exchange between Dan Hicks and Rowdy Gaines on NBC:

Hicks: “This really is a unique Olympic journey for Anthony Ervin. He got gold 16 years ago, and then left the sport for some eight years.”

Gaines: “I know, he was on my couch for a while.”

Now that Ervin has regained his enthusiasm for the water, he has no intention of announcing his retirement and will try to make the Tokyo team.

“There’s a lot of talk about this perplexing question of retirement,” Ervin said. “. . . But I love this lifestyle. Being in the water is a sanctuary for me, and I’m not going to give it up, regardless of whether I’m the best in the world or not relevant.”

Phelps was in a similar place a few years back, a half-hearted swimmer whose only form of relaxation seemed to come from a pipe or a bottle and who went days at a time without showing up at the pool.

When he competed, other swimmers regarded him as apart and unsociable. “Being Michael required such isolation,” Ervin observed.

About halfway through 2012, in the run-up to the London Games, I visited Phelps at his aquatic club in Baltimore. It was obvious swimming was a job, an unwanted obligation. I asked him about the monotony, and he answered shortly, “Brutal. I have 170 more days of this.”

Then he added: “I think the hardest thing to do, the hardest time to do something, is when you’re tired,” he said. “When you’re tired, it’s just sort of easy to fall apart and not care and kind of just give up.”

Even so, he got four more gold medals in London. The not caring and the giving up came after 18 months of playing golf and going to Ravens games, followed by deep depression and rehab. Phelps discovered what a lot of high-functioning retirees do: that too much leisure time can come with a certain sense of rot.

The results of personal healing and sobriety are obvious: The Phelps who came to Rio is a far more buoyant person – and swimmer.

It’s not just a matter of his personal happiness, as father to infant son Boomer and soon-to-be-husband to Nicole Johnson. Phelps has discovered that he can swim without his old grim concentrated defenses – and binges.

This time around, he reached out to his fellow swimmers, especially younger Americans, and engaged with them in the Athletes’ Village.

“Before, I would really have my headphones on and not really talk to anybody. I’m much more open and relaxed now,” he said last week.

He found out he could actually enjoy the Olympic experience, even laugh about it.

“It wasn’t like a fake laugh or this or that,” he said. “I was actually enjoying myself, and we were telling jokes with one another. That’s what I didn’t have in 2012. That was nowhere to be found.”

Phelps had never been looser or more explosive in the water than in Rio.

“He came back with more purpose,” Lochte observed.

Which is why it’s so tantalizing to imagine him still swimming in four years. If Phelps genuinely believes that he has no more of these efforts in him, that he wants to turn his energy and attention now to his family, then he is right to retire.

But Ervin believes that Phelps can still be viable in four years – and more importantly, that his titanic presence could be valuable to younger swimmers.