The code that computes the known bits wasn't taking into account the possibility of an incoming carry. So I don't think this code was valid. Certainly not the code that assumed the number of low zero bits in each input determined the low zero bits of the output.
I found this purely by inspection so I don't have a test case.