Vidqun
The structure of the verse, with two kings acting against a "him," suggests a separate entity. Now if this verse is all we had to go with it would be difficult to identify the HIM but thankfully we have the immediate few verses 36-39 that talk about this 3rd king as HE many times.Read verses 36 to 40 as one single verse and then it all makes sense.
And the king shall do as HE wills. He shall exalt himself and magnify HIMSELF above every god, and shall speak astonishing things against the God of gods. HE shall prosper till the indignation is accomplished; for what is decreed shall be done. 37 HE shall pay no attention to the gods of his fathers, or to the one beloved by women. HE shall not pay attention to any other god, for HE shall magnify himself above all. 38 HE shall honor the god of fortresses instead of these. A god whom his fathers did not know HE shall honor with gold and silver, with precious stones and costly gifts. 39 HE shall deal with the strongest fortresses with the help of a foreign god. Those who acknowledge HIM HE shall load with honor. HE shall make them rulers over many and shall divide the land for a price.[f]40 “At the time of the end, the king of the south shall attack[g] HIM, but the king of the north shall rush upon HIM like a whirlwind, with chariots and horsemen, and with many ships. And HE shall come into countries and shall overflow and pass through.
After reading these verses as one isn't it obvious that the HIM of verse 40 refers the king of 36-39?