- for (i = 0; i < 8; i++) {
- r->QWORD[i] = x->QWORD[i] + y->QWORD[i];
- if (r->QWORD[i] < y->QWORD[i] || r->QWORD[i] < x->QWORD[i])
+ for (i = 0; i < 8; i++)
+ {
+ /* Detecting integer overflow condition for three numbers
+ * in a portable way is tricky a little. */
+
+ /* Step 1: numbers cause overflow */
+ tmp = x->QWORD[i] + y->QWORD[i];
+
+ /* Compare with any of two summands, no need to check both */
+ if (tmp < x->QWORD[i])