From d778b2da522f459118a98faff7f9d57918b7986c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se>
Date: Tue, 7 Jun 2011 22:33:05 +0200
Subject: [PATCH] (SBOX3): Renamed arguments. Eliminated temporaries.

Rev: nettle/ChangeLog:1.180
Rev: nettle/serpent-encrypt.c:1.5
---
 ChangeLog         |  1 +
 serpent-encrypt.c | 42 ++++++++++++++++++++----------------------
 2 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9ae8bd7d..5a4873a4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,7 @@
 	temporaries.
 	(SBOX1): Likewise.
 	(SBOX2): Likewise.
+	(SBOX3): Likewise.
 
 2011-06-06  Niels M�ller  <nisse@lysator.liu.se>
 
diff --git a/serpent-encrypt.c b/serpent-encrypt.c
index 634b883d..4ce869fd 100644
--- a/serpent-encrypt.c
+++ b/serpent-encrypt.c
@@ -141,28 +141,26 @@
   } while (0)
 
 /* S3:  0 15 11  8 12  9  6  3 13  1  2  4 10  7  5 14 */
-#define SBOX3(type, a, b, c, d, w, x, y, z) \
-  do {						\
-    type t02, t03, t04, t05, t06, t07, t08; \
-    type t09, t10, t11, t13, t14, t15, t01; \
-    t01 = a   ^ c  ; \
-    t02 = a   | d  ; \
-    t03 = a   & d  ; \
-    t04 = t01 & t02; \
-    t05 = b   | t03; \
-    t06 = a   & b  ; \
-    t07 = d   ^ t04; \
-    t08 = c   | t06; \
-    t09 = b   ^ t07; \
-    t10 = d   & t05; \
-    t11 = t02 ^ t10; \
-    z   = t08 ^ t09; \
-    t13 = d   | z  ; \
-    t14 = a   | t07; \
-    t15 = b   & t13; \
-    y   = t08 ^ t11; \
-    w   = t14 ^ t15; \
-    x   = t05 ^ t04; \
+#define SBOX3(type, x0, x1, x2, x3, y0, y1, y2, y3)	\
+  do {							\
+    y2  = x0 ^ x2;					\
+    y0  = x0 | x3;					\
+    y3  = x0 & x3;					\
+    y1  = y2 & y0;					\
+    y3 |= x1;						\
+    y2  = x0   & x1;					\
+    y2 |= x2;						\
+    x2  = x3   ^ y1;					\
+    y1 ^= y3;						\
+    x0 |= x2;						\
+    x2 ^= x1;						\
+    y3 &= x3;						\
+    y0 ^= y3;						\
+    y3  = y2 ^ x2;					\
+    y2 ^= y0;						\
+    x3 |= y3;						\
+    x1 &= x3;						\
+    y0  = x0 ^ x1;					\
   } while (0)
 
 /* S4:  1 15  8  3 12  0 11  6  2  5  4 10  9 14  7 13 */
-- 
GitLab