Found the code. Here are some of the key pieces of the code/logic.
Again, for every webapplication, I get every site collection. The code starts on a given site collection.
Get the site collection user list.
For each user, check if user exist in AD via LoginName (samAccountName). If user exist skip (migrateuser not needed). If user doesn't exist, get the user's SID and look up AD based on SID.
If found, get the new login name and generate migrate user command to the batch file.
Note that the batch file will have multiple repeating lines for the same user across the site collections. I use a powershell sort command to remove the duplicates in the end (GC C:\migrateUsers.txt| Sort | GU > C:\migrateUsers.bat)