Created
July 17, 2017 21:21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
#include <initializer_list> | |
typedef uint64_t u64; | |
template <class T> | |
class w { | |
T t; | |
public: | |
w (T t): t(t) { } | |
friend w<T> operator+(w<T> lhs, const w<T>& rhs) { | |
lhs.t += rhs.t; | |
return lhs; | |
} | |
friend w<T> operator-(w<T> lhs, const w<T>& rhs) { | |
lhs.t -= rhs.t; | |
return lhs; | |
} | |
friend w<T> operator^(w<T> lhs, const w<T>& rhs) { | |
lhs.t ^= rhs.t; | |
return lhs; | |
} | |
friend w<T> operator<<(w<T> lhs, const int& rhs) { | |
lhs.t <<= rhs; | |
return lhs; | |
} | |
friend w<T> operator>>(w<T> lhs, const int& rhs) { | |
lhs.t >>= rhs; | |
return lhs; | |
} | |
}; | |
extern "C" | |
void foo() { | |
auto a = w<u64>(0x9e3779b97f4a7c13); | |
auto b = w<u64>(0x9e3779b97f4a7c13); | |
auto c = w<u64>(0x9e3779b97f4a7c13); | |
auto d = w<u64>(0x9e3779b97f4a7c13); | |
auto e = w<u64>(0x9e3779b97f4a7c13); | |
auto f = w<u64>(0x9e3779b97f4a7c13); | |
auto g = w<u64>(0x9e3779b97f4a7c13); | |
auto h = w<u64>(0x9e3779b97f4a7c13); | |
for (int n : {0, 1, 2, 3}) { | |
a=a-e; f=f^(h>>9); h=h+a; | |
b=b-f; g=g^(a<<9); a=a+b; | |
c=c-g; h=h^(b>>23); b=b+c; | |
d=d-h; a=a^(c<<15); c=c+d; | |
e=e-a; b=b^(d>>14); d=d+e; | |
f=f-b; c=c^(e<<20); e=e+f; | |
g=g-c; d=d^(f>>17); f=f+g; | |
h=h-d; e=e^(g<<14); g=g+h; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment