In this case, A and B are 40-bit numbers, and C is a 50-bit number, which is not a problem in 64-bit mode, if you have built-in code or you can write assembly code to use 64-bit 64- bit multiplication, which gives a result of 128 bits (the product is actually 80 bits), after which you divide the 128-bit dividend into a 50-bit divider to create a 50-bit remainder (modulo).
Depending on the processor, it may be faster to implement division by a 50-bit constant by multiplying by 81 bits (or less) of the constant. Again, assuming a 64-bit processor, it will take 4 multiplications and some additions, followed by a shift of the upper bits of the 4 multiplied product to get the quotient. Then, to obtain a 50-bit remainder, time multiplication of 50 bits modulo and subtraction (from an 80-bit product) is used.
source share