Chosen Solution
Can one replace the 4771 with a 4790 (non-K) in a late 2013 27" iMac? We’re upgrading from an i5 and the 4790 is a more popular processor and therefore cheaper than the 4771 (and more powerful). They both have the same wattage and I’ve read that as long as that and the physical socket is the same that it should work as Apple doesn’t actually have firmware restrictions on processors.
You choice for CPU is limited to what Apple has used in this series: iMac14,2. You do realize the 4771 is an i7 chip not a i5. First here’s the IFIXIT guide to replace the CPU: iMac Intel 27" EMC 2639 CPU Replacement. Frankly, the amount of gain here given the risks of damaging your system in my mind doesn’t make it worth it. Many people (including me) have damaged the display just trying to open the system if you’ve never done one. Frankly, I would look for a used or newer system that met your needs Vs trying to upgrade the CPU in this series. in the long haul it will be cheaper.