{"id":296710,"date":"2020-01-03T15:00:25","date_gmt":"2020-01-03T15:00:25","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=296710"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=296710","title":{"rendered":"Compile time \u043e\u0431\u0444\u0443\u0441\u043a\u0430\u0446\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f NAND\/NOR"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/482734\/\">\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435.<\/h2>\n<p>  \u0412\u0441\u0435, \u043a\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0437\u043d\u0430\u043a\u043e\u043c \u0441 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u0421++ \u0441\u043b\u044b\u0448\u0430\u043b, \u0447\u0442\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0421++11 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442 \u0431\u044b\u043b \u0432\u0432\u0435\u0434\u0435\u043d \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 constexpr, \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u043b\u0438\u043c\u0438\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 compile-time \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f. \u0412 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u044b \u0431\u044b\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b <a href=\"http:\/\/www.open-std.org\/jtc1\/sc22\/wg21\/docs\/papers\/2016\/p0292r2.html\">if constexpr<\/a> \u0438 <a href=\"http:\/\/www.open-std.org\/jtc1\/sc22\/wg21\/docs\/papers\/2016\/p0170r1.pdf\">constexpr lambdas<\/a> \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0441\u043d\u0438\u043c\u0430\u044e\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434 \u0441 compile time \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f\u043c\u0438. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e\u0431 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0439 \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0432 compile time.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>\u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0431\u0430\u0437\u0443 \u0434\u043b\u044f compile-time \u0413\u041f\u0421\u0427<\/h2>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 path \u0434\u043b\u044f \u043a\u043e\u0434\u0430 \u0432 compile time, \u043d\u0443\u0436\u0435\u043d constexpr <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%93%D0%B5%D0%BD%D0%B5%D1%80%D0%B0%D1%82%D0%BE%D1%80_%D0%BF%D1%81%D0%B5%D0%B2%D0%B4%D0%BE%D1%81%D0%BB%D1%83%D1%87%D0%B0%D0%B9%D0%BD%D1%8B%D1%85_%D1%87%D0%B8%D1%81%D0%B5%D0%BB\">\u0413\u041f\u0421\u0427<\/a> c \u0445\u043e\u0440\u043e\u0448\u0438\u043c\u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u044f \u0432\u044b\u0431\u0440\u0430\u043b \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 <a href=\"http:\/\/prng.di.unimi.it\/\">xorshift<\/a>, \u043a\u0441\u0442\u0430\u0442\u0438 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Xorshift\">xorshift <\/a>\u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u044d\u043c\u043f\u0438\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0442\u0435\u0441\u0442\u044b <a href=\"http:\/\/simul.iro.umontreal.ca\/testu01\/tu01.html\">BigCrush (TestU01)<\/a>.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">xorshift256++<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &lt;stdint.h&gt;  \/* This is xoshiro256++ 1.0, one of our all-purpose, rock-solid generators.    It has excellent (sub-ns) speed, a state (256 bits) that is large    enough for any parallel application, and it passes all tests we are    aware of.     For generating just floating-point numbers, xoshiro256+ is even faster.     The state must be seeded so that it is not everywhere zero. If you have    a 64-bit seed, we suggest to seed a splitmix64 generator and use its    output to fill s. *\/  static inline uint64_t rotl(const uint64_t x, int k) { \treturn (x &lt;&lt; k) | (x &gt;&gt; (64 - k)); }   static uint64_t s[4];  uint64_t next(void) { \tconst uint64_t result = rotl(s[0] + s[3], 23) + s[0];  \tconst uint64_t t = s[1] &lt;&lt; 17;  \ts[2] ^= s[0]; \ts[3] ^= s[1]; \ts[1] ^= s[2]; \ts[0] ^= s[3];  \ts[2] ^= t;  \ts[3] = rotl(s[3], 45);  \treturn result; }   \/* This is the jump function for the generator. It is equivalent    to 2^128 calls to next(); it can be used to generate 2^128    non-overlapping subsequences for parallel computations. *\/  void jump(void) { \tstatic const uint64_t JUMP[] = { 0x180ec6d33cfd0aba, 0xd5a61266f0c9392c, 0xa9582618e03fc9aa, 0x39abdc4529b1661c };  \tuint64_t s0 = 0; \tuint64_t s1 = 0; \tuint64_t s2 = 0; \tuint64_t s3 = 0; \tfor(int i = 0; i &lt; sizeof JUMP \/ sizeof *JUMP; i++) \t\tfor(int b = 0; b &lt; 64; b++) { \t\t\tif (JUMP[i] &amp; UINT64_C(1) &lt;&lt; b) { \t\t\t\ts0 ^= s[0]; \t\t\t\ts1 ^= s[1]; \t\t\t\ts2 ^= s[2]; \t\t\t\ts3 ^= s[3]; \t\t\t} \t\t\tnext();\t \t\t} \t\t \ts[0] = s0; \ts[1] = s1; \ts[2] = s2; \ts[3] = s3; }    \/* This is the long-jump function for the generator. It is equivalent to    2^192 calls to next(); it can be used to generate 2^64 starting points,    from each of which jump() will generate 2^64 non-overlapping    subsequences for parallel distributed computations. *\/  void long_jump(void) { \tstatic const uint64_t LONG_JUMP[] = { 0x76e15d3efefdcbbf, 0xc5004e441c522fb3, 0x77710069854ee241, 0x39109bb02acbe635 };  \tuint64_t s0 = 0; \tuint64_t s1 = 0; \tuint64_t s2 = 0; \tuint64_t s3 = 0; \tfor(int i = 0; i &lt; sizeof LONG_JUMP \/ sizeof *LONG_JUMP; i++) \t\tfor(int b = 0; b &lt; 64; b++) { \t\t\tif (LONG_JUMP[i] &amp; UINT64_C(1) &lt;&lt; b) { \t\t\t\ts0 ^= s[0]; \t\t\t\ts1 ^= s[1]; \t\t\t\ts2 ^= s[2]; \t\t\t\ts3 ^= s[3]; \t\t\t} \t\t\tnext();\t \t\t} \t\t \ts[0] = s0; \ts[1] = s1; \ts[2] = s2; \ts[3] = s3; } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0418\u0437 \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 rotl \u0438 next, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0434\u043e\u043b\u0433\u0438\u043c\u0438. \u041f\u0435\u0440\u0435\u0434\u0430\u044e \u043f\u043b\u0430\u043c\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u0432\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 MSVC, \u0432\u0432\u0438\u0434\u0443 \u0431\u0430\u0433\u043e\u0432 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b\u0438\u0441\u044c \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f, \u043e\u0431 \u044d\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435.<\/p>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043a\u043e\u0434\u0430 \u0432\u044b\u0448\u0435, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0447\u0435\u0442\u044b\u0440\u0435 64 \u0431\u0438\u0442\u043d\u044b\u0445 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f, \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0432 compile time, \u043d\u0443\u0436\u043d\u043e \u043e\u0442 \u043d\u0438\u0445 \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432. \u041e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f constexpr hash fnv1 \u0438 \u043c\u0430\u043a\u0440\u043e\u0441 <a href=\"https:\/\/gcc.gnu.org\/onlinedocs\/cpp\/Common-Predefined-Macros.html\">__COUNTER__ <\/a>, \u043f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c \u043a\u043e\u0434 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u044d\u0442\u0438\u043c \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">compile time \u0413\u041f\u0421\u0427<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &lt;cstdint&gt; #define STRING(s) #s  \/\/ an enumeration can also be used here template &lt;typename T, T value&gt; constexpr T ensure_constexpr() {   return value; } #define CONSTEXPR(x) ensure_constexpr&lt;decltype(x), x&gt;()  constexpr uint64_t fnv1impl(uint64_t h, const char* s) {   return (*s == 0)              ? h              : fnv1impl((h * 1099511628211ull) ^ static_cast&lt;uint64_t&gt;(*s),                         s + 1); }  constexpr uint64_t fnv1(const char* s) {   return fnv1impl(14695981039346656037ull, s); }  template &lt;uint64_t n&gt; constexpr uint64_t get_seed(const uint64_t x,                             const uint64_t y = CONSTEXPR(fnv1(STRING(n)))) {   return x ^ y * n; }  #define SEED CONSTEXPR(get_seed&lt;__COUNTER__ + 1&gt;(fnv1(__TIME__)))  \/\/! Rotate left by constexpr uint64_t rotl(uint64_t x, int k) {   return (x &lt;&lt; k) | (x &gt;&gt; (64 - k)); }  \/\/! XorShift 256 compile time random implementation template &lt;uint64_t a, uint64_t b, uint64_t c, uint64_t d&gt; constexpr uint64_t xorshift256_next() {   uint64_t s[4] = {a, b, c, d};   const uint64_t t = s[1] &lt;&lt; 17;    s[2] ^= s[0];   s[3] ^= s[1];   s[1] ^= s[2];   s[0] ^= s[3];    s[2] ^= t;    s[3] = rotl(s[3], 45);    return rotl(s[0] + s[3], 23) + s[0]; }  #define RND                                                         \\   xorshift256_next&lt;                                                 \\       CONSTEXPR(SEED + __COUNTER__), CONSTEXPR(SEED + __COUNTER__), \\       CONSTEXPR(SEED + __COUNTER__), CONSTEXPR(SEED + __COUNTER__)&gt;() <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<h2>\u041f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c<\/h2>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u00ab\u0441\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u044e\u0442\u00bb \u043a\u043e\u0434 \u0432 compile time.<br \/>  \u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u043a\u043e\u0434 \u043d\u0438\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f GCC 9.2.1 \u0432 \u0434\u0435\u0431\u0430\u0433\u0435 g++ _.cpp -S -masm=intel<\/p>\n<pre><code class=\"cpp\">#include \"compile_random.h\" #include &lt;iostream&gt;  int main() {   std::cout &lt;&lt; RND &lt;&lt; std::endl;   std::cout &lt;&lt; RND &lt;&lt; std::endl; } <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0425\u043e\u0447\u0443 \u0432\u0438\u0434\u0435\u0442\u044c \u0441\u0442\u0440\u0430\u0448\u0438\u043b\u043a\u0438<\/b><\/p>\n<div class=\"spoiler_text\"><code> .file \"_.cpp\"<br \/>   .intel_syntax noprefix<br \/>   .text<br \/>   .section .text._Z4rotlmi,\"axG\",@progbits,_Z4rotlmi,comdat<br \/>   .weak _Z4rotlmi<br \/>   .type _Z4rotlmi, @function<br \/>  _Z4rotlmi:<br \/>  .LFB4:<br \/>   .cfi_startproc<br \/>   push rbp<br \/>   .cfi_def_cfa_offset 16<br \/>   .cfi_offset 6, -16<br \/>   mov rbp, rsp<br \/>   .cfi_def_cfa_register 6<br \/>   mov QWORD PTR [rbp-8], rdi<br \/>   mov DWORD PTR [rbp-12], esi<br \/>   mov eax, DWORD PTR [rbp-12]<br \/>   mov rdx, QWORD PTR [rbp-8]<br \/>   mov ecx, eax<br \/>   rol rdx, cl<br \/>   mov rax, rdx<br \/>   pop rbp<br \/>   .cfi_def_cfa 7, 8<br \/>   ret<br \/>   .cfi_endproc<br \/>  .LFE4:<br \/>   .size _Z4rotlmi, .-_Z4rotlmi<br \/>   .section .rodata<br \/>   .type _ZStL19piecewise_construct, @object<br \/>   .size _ZStL19piecewise_construct, 1<br \/>  _ZStL19piecewise_construct:<br \/>   .zero 1<br \/>   .local _ZStL8__ioinit<br \/>   .comm _ZStL8__ioinit,1,1<br \/>   .text<br \/>   .globl main<br \/>   .type main, @function<br \/>  main:<br \/>  .LFB1528:<br \/>   .cfi_startproc<br \/>   push rbp<br \/>   .cfi_def_cfa_offset 16<br \/>   .cfi_offset 6, -16<br \/>   mov rbp, rsp<br \/>   .cfi_def_cfa_register 6<br \/>  <b> call _Z16xorshift256_nextILm5485350875583313748ELm17102255921242957812ELm10344467890162128540ELm2938160962983216444EEmv<\/b><br \/>   mov rsi, rax<br \/>   mov edi, OFFSET FLAT:_ZSt4cout<br \/>   call _ZNSolsEm<br \/>   mov esi, OFFSET FLAT:_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_<br \/>   mov rdi, rax<br \/>   call _ZNSolsEPFRSoS_E<br \/>  <b> call _Z16xorshift256_nextILm14555066043003024868ELm7653162274090525828ELm823244081203417900ELm11935748167621739468EEmv<\/b><br \/>   mov rsi, rax<br \/>   mov edi, OFFSET FLAT:_ZSt4cout<br \/>   call _ZNSolsEm<br \/>   mov esi, OFFSET FLAT:_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_<br \/>   mov rdi, rax<br \/>   call _ZNSolsEPFRSoS_E<br \/>   mov eax, 0<br \/>   pop rbp<br \/>   .cfi_def_cfa 7, 8<br \/>   ret<br \/>   .cfi_endproc<br \/>  .LFE1528:<br \/>   .size main, .-main<br \/>   .section .text._Z16xorshift256_nextILm5485350875583313748ELm17102255921242957812ELm10344467890162128540ELm2938160962983216444EEmv,\"axG\",@progbits,_Z16xorshift256_nextILm5485350875583313748ELm17102255921242957812ELm10344467890162128540ELm2938160962983216444EEmv,comdat<br \/>   .weak _Z16xorshift256_nextILm5485350875583313748ELm17102255921242957812ELm10344467890162128540ELm2938160962983216444EEmv<br \/>   .type _Z16xorshift256_nextILm5485350875583313748ELm17102255921242957812ELm10344467890162128540ELm2938160962983216444EEmv, @function<br \/>  _Z16xorshift256_nextILm5485350875583313748ELm17102255921242957812ELm10344467890162128540ELm2938160962983216444EEmv:<br \/>  .LFB1790:<br \/>   .cfi_startproc<br \/>   push rbp<br \/>   .cfi_def_cfa_offset 16<br \/>   .cfi_offset 6, -16<br \/>   mov rbp, rsp<br \/>   .cfi_def_cfa_register 6<br \/>   sub rsp, 48<br \/>   movabs rax, 5485350875583313748<br \/>   mov QWORD PTR [rbp-48], rax<br \/>   movabs rax, -1344488152466593804<br \/>   mov QWORD PTR [rbp-40], rax<br \/>   movabs rax, -8102276183547423076<br \/>   mov QWORD PTR [rbp-32], rax<br \/>   movabs rax, 2938160962983216444<br \/>   mov QWORD PTR [rbp-24], rax<br \/>   mov rax, QWORD PTR [rbp-40]<br \/>   sal rax, 17<br \/>   mov QWORD PTR [rbp-8], rax<br \/>   mov rdx, QWORD PTR [rbp-32]<br \/>   mov rax, QWORD PTR [rbp-48]<br \/>   xor rax, rdx<br \/>   mov QWORD PTR [rbp-32], rax<br \/>   mov rdx, QWORD PTR [rbp-24]<br \/>   mov rax, QWORD PTR [rbp-40]<br \/>   xor rax, rdx<br \/>   mov QWORD PTR [rbp-24], rax<br \/>   mov rdx, QWORD PTR [rbp-40]<br \/>   mov rax, QWORD PTR [rbp-32]<br \/>   xor rax, rdx<br \/>   mov QWORD PTR [rbp-40], rax<br \/>   mov rdx, QWORD PTR [rbp-48]<br \/>   mov rax, QWORD PTR [rbp-24]<br \/>   xor rax, rdx<br \/>   mov QWORD PTR [rbp-48], rax<br \/>   mov rax, QWORD PTR [rbp-32]<br \/>   xor rax, QWORD PTR [rbp-8]<br \/>   mov QWORD PTR [rbp-32], rax<br \/>   mov rax, QWORD PTR [rbp-24]<br \/>   mov esi, 45<br \/>   mov rdi, rax<br \/>   call _Z4rotlmi<br \/>   mov QWORD PTR [rbp-24], rax<br \/>   mov rdx, QWORD PTR [rbp-48]<br \/>   mov rax, QWORD PTR [rbp-24]<br \/>   add rax, rdx<br \/>   mov esi, 23<br \/>   mov rdi, rax<br \/>   call _Z4rotlmi<br \/>   mov rdx, QWORD PTR [rbp-48]<br \/>   add rax, rdx<br \/>   leave<br \/>   .cfi_def_cfa 7, 8<br \/>   ret<br \/>   .cfi_endproc<br \/>  .LFE1790:<br \/>   .size _Z16xorshift256_nextILm5485350875583313748ELm17102255921242957812ELm10344467890162128540ELm2938160962983216444EEmv, .-_Z16xorshift256_nextILm5485350875583313748ELm17102255921242957812ELm10344467890162128540ELm2938160962983216444EEmv<br \/>   .section .text._Z16xorshift256_nextILm14555066043003024868ELm7653162274090525828ELm823244081203417900ELm11935748167621739468EEmv,\"axG\",@progbits,_Z16xorshift256_nextILm14555066043003024868ELm7653162274090525828ELm823244081203417900ELm11935748167621739468EEmv,comdat<br \/>   .weak _Z16xorshift256_nextILm14555066043003024868ELm7653162274090525828ELm823244081203417900ELm11935748167621739468EEmv<br \/>   .type _Z16xorshift256_nextILm14555066043003024868ELm7653162274090525828ELm823244081203417900ELm11935748167621739468EEmv, @function<br \/>  _Z16xorshift256_nextILm14555066043003024868ELm7653162274090525828ELm823244081203417900ELm11935748167621739468EEmv:<br \/>  .LFB1794:<br \/>   .cfi_startproc<br \/>   push rbp<br \/>   .cfi_def_cfa_offset 16<br \/>   .cfi_offset 6, -16<br \/>   mov rbp, rsp<br \/>   .cfi_def_cfa_register 6<br \/>   sub rsp, 48<br \/>   movabs rax, -3891678030706526748<br \/>   mov QWORD PTR [rbp-48], rax<br \/>   movabs rax, 7653162274090525828<br \/>   mov QWORD PTR [rbp-40], rax<br \/>   movabs rax, 823244081203417900<br \/>   mov QWORD PTR [rbp-32], rax<br \/>   movabs rax, -6510995906087812148<br \/>   mov QWORD PTR [rbp-24], rax<br \/>   mov rax, QWORD PTR [rbp-40]<br \/>   sal rax, 17<br \/>   mov QWORD PTR [rbp-8], rax<br \/>   mov rdx, QWORD PTR [rbp-32]<br \/>   mov rax, QWORD PTR [rbp-48]<br \/>   xor rax, rdx<br \/>   mov QWORD PTR [rbp-32], rax<br \/>   mov rdx, QWORD PTR [rbp-24]<br \/>   mov rax, QWORD PTR [rbp-40]<br \/>   xor rax, rdx<br \/>   mov QWORD PTR [rbp-24], rax<br \/>   mov rdx, QWORD PTR [rbp-40]<br \/>   mov rax, QWORD PTR [rbp-32]<br \/>   xor rax, rdx<br \/>   mov QWORD PTR [rbp-40], rax<br \/>   mov rdx, QWORD PTR [rbp-48]<br \/>   mov rax, QWORD PTR [rbp-24]<br \/>   xor rax, rdx<br \/>   mov QWORD PTR [rbp-48], rax<br \/>   mov rax, QWORD PTR [rbp-32]<br \/>   xor rax, QWORD PTR [rbp-8]<br \/>   mov QWORD PTR [rbp-32], rax<br \/>   mov rax, QWORD PTR [rbp-24]<br \/>   mov esi, 45<br \/>   mov rdi, rax<br \/>   call _Z4rotlmi<br \/>   mov QWORD PTR [rbp-24], rax<br \/>   mov rdx, QWORD PTR [rbp-48]<br \/>   mov rax, QWORD PTR [rbp-24]<br \/>   add rax, rdx<br \/>   mov esi, 23<br \/>   mov rdi, rax<br \/>   call _Z4rotlmi<br \/>   mov rdx, QWORD PTR [rbp-48]<br \/>   add rax, rdx<br \/>   leave<br \/>   .cfi_def_cfa 7, 8<br \/>   ret<br \/>   .cfi_endproc<br \/>  .LFE1794:<br \/>   .size _Z16xorshift256_nextILm14555066043003024868ELm7653162274090525828ELm823244081203417900ELm11935748167621739468EEmv, .-_Z16xorshift256_nextILm14555066043003024868ELm7653162274090525828ELm823244081203417900ELm11935748167621739468EEmv<br \/>   .text<br \/>   .type _Z41__static_initialization_and_destruction_0ii, @function<br \/>  _Z41__static_initialization_and_destruction_0ii:<br \/>  .LFB2042:<br \/>   .cfi_startproc<br \/>   push rbp<br \/>   .cfi_def_cfa_offset 16<br \/>   .cfi_offset 6, -16<br \/>   mov rbp, rsp<br \/>   .cfi_def_cfa_register 6<br \/>   sub rsp, 16<br \/>   mov DWORD PTR [rbp-4], edi<br \/>   mov DWORD PTR [rbp-8], esi<br \/>   cmp DWORD PTR [rbp-4], 1<br \/>   jne .L11<br \/>   cmp DWORD PTR [rbp-8], 65535<br \/>   jne .L11<br \/>   mov edi, OFFSET FLAT:_ZStL8__ioinit<br \/>   call _ZNSt8ios_base4InitC1Ev<br \/>   mov edx, OFFSET FLAT:__dso_handle<br \/>   mov esi, OFFSET FLAT:_ZStL8__ioinit<br \/>   mov edi, OFFSET FLAT:_ZNSt8ios_base4InitD1Ev<br \/>   call __cxa_atexit<br \/>  .L11:<br \/>   nop<br \/>   leave<br \/>   .cfi_def_cfa 7, 8<br \/>   ret<br \/>   .cfi_endproc<br \/>  .LFE2042:<br \/>   .size _Z41__static_initialization_and_destruction_0ii, .-_Z41__static_initialization_and_destruction_0ii<br \/>   .type _GLOBAL__sub_I_main, @function<br \/>  _GLOBAL__sub_I_main:<br \/>  .LFB2043:<br \/>   .cfi_startproc<br \/>   push rbp<br \/>   .cfi_def_cfa_offset 16<br \/>   .cfi_offset 6, -16<br \/>   mov rbp, rsp<br \/>   .cfi_def_cfa_register 6<br \/>   mov esi, 65535<br \/>   mov edi, 1<br \/>   call _Z41__static_initialization_and_destruction_0ii<br \/>   pop rbp<br \/>   .cfi_def_cfa 7, 8<br \/>   ret<br \/>   .cfi_endproc<br \/>  .LFE2043:<br \/>   .size _GLOBAL__sub_I_main, .-_GLOBAL__sub_I_main<br \/>   .section .init_array,\"aw\"<br \/>   .align 8<br \/>   .quad _GLOBAL__sub_I_main<br \/>   .hidden __dso_handle<br \/>   .ident \"GCC: (GNU) 9.2.1 20190827 (Red Hat 9.2.1-1)\"<br \/>   .section .note.GNU-stack,\"\",@progbits<br \/>  <\/code>  <\/div>\n<\/div>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0432\u044b\u0448\u0435, \u0444\u0443\u043d\u043a\u0446\u0438\u0438 rotl \u0438 xorshift256_next \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0432 \u043a\u043e\u0434\u0435, \u043d\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u044d\u0442\u043e \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u044b\u043b\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u044b.<\/p>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0441 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u043c\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f\u043c\u0438 g++ _.cpp -S -masm=intel -O2<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041c\u043d\u0435 \u0443\u0436\u0435 \u043d\u0435 \u0441\u0442\u0440\u0430\u0448\u043d\u043e, \u044f \u0432\u0438\u0434\u0435\u043b \u0432\u0441\u0451<\/b><\/p>\n<div class=\"spoiler_text\"><code> .file \"_.cpp\"<br \/>   .intel_syntax noprefix<br \/>   .text<br \/>   .section .text.startup,\"ax\",@progbits<br \/>   .p2align 4<br \/>   .globl main<br \/>   .type main, @function<br \/>  main:<br \/>  .LFB1550:<br \/>   .cfi_startproc<br \/>   sub rsp, 8<br \/>   .cfi_def_cfa_offset 16<br \/>   mov edi, OFFSET FLAT:_ZSt4cout<br \/>   <b>movabs rsi, 6340608927850167019<\/b><br \/>   call _ZNSo9_M_insertImEERSoT_<br \/>   mov rdi, rax<br \/>   call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_<br \/>   mov edi, OFFSET FLAT:_ZSt4cout<br \/>   <b>movabs rsi, -1433878323375531419<\/b><br \/>   call _ZNSo9_M_insertImEERSoT_<br \/>   mov rdi, rax<br \/>   call _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_<br \/>   xor eax, eax<br \/>   add rsp, 8<br \/>   .cfi_def_cfa_offset 8<br \/>   ret<br \/>   .cfi_endproc<br \/>  .LFE1550:<br \/>   .size main, .-main<br \/>   .p2align 4<br \/>   .type _GLOBAL__sub_I_main, @function<br \/>  _GLOBAL__sub_I_main:<br \/>  .LFB2064:<br \/>   .cfi_startproc<br \/>   sub rsp, 8<br \/>   .cfi_def_cfa_offset 16<br \/>   mov edi, OFFSET FLAT:_ZStL8__ioinit<br \/>   call _ZNSt8ios_base4InitC1Ev<br \/>   mov edx, OFFSET FLAT:__dso_handle<br \/>   mov esi, OFFSET FLAT:_ZStL8__ioinit<br \/>   mov edi, OFFSET FLAT:_ZNSt8ios_base4InitD1Ev<br \/>   add rsp, 8<br \/>   .cfi_def_cfa_offset 8<br \/>   jmp __cxa_atexit<br \/>   .cfi_endproc<br \/>  .LFE2064:<br \/>   .size _GLOBAL__sub_I_main, .-_GLOBAL__sub_I_main<br \/>   .section .init_array,\"aw\"<br \/>   .align 8<br \/>   .quad _GLOBAL__sub_I_main<br \/>   .local _ZStL8__ioinit<br \/>   .comm _ZStL8__ioinit,1,1<br \/>   .hidden __dso_handle<br \/>   .ident \"GCC: (GNU) 9.2.1 20190827 (Red Hat 9.2.1-1)\"<br \/>   .section .note.GNU-stack,\"\",@progbits<br \/>  <\/code>  <\/div>\n<\/div>\n<p>  \u0423\u0440\u0430! \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u043e, \u0447\u0442\u043e \u043e\u0436\u0438\u0434\u0430\u043b\u0438, \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u043b 2 \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0430\u043a\u0440\u043e\u0441\u0430 RND \u0432 2 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 mov. \u041f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u0432 clang \u0438 MSVC \u0432 RELEASE MODE \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0435. \u041c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a compile time \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438.<\/p>\n<p>  \u0414\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f, \u043d\u0443\u0436\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438<br \/>  <a href=\"https:\/\/en.wikipedia.org\/wiki\/Logical_NOR\">NOR <\/a>(\u0421\u0442\u0440\u0435\u043b\u043a\u0430 \u043f\u0438\u0440\u0441\u0430) <a href=\"https:\/\/en.wikipedia.org\/wiki\/Sheffer_stroke\">NAND <\/a>(\u0428\u0442\u0440\u0438\u0445 \u0428\u0435\u0444\u0444\u0435\u0440\u0430) \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0432\u0441\u044e \u043b\u043e\u0433\u0438\u043a\u0443. \u042f \u043d\u0435 \u0431\u0443\u0434\u0443 \u043f\u0440\u0438\u043b\u0430\u0433\u0430\u0442\u044c \u0432\u0435\u0441\u044c \u043a\u043e\u0434 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 &amp; | ^ ++ \u2014 , \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 NAND, \u0432 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u0445 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0442\u0430\u043a\u043e\u0439 \u0436\u0435.<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c 5 template \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0439 NAND \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0440\u0430\u043d\u0434\u043e\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<pre><code class=\"cpp\">\/\/! (Not a) Or (Not b) template &lt;typename T&gt; FORCEINLINE T Nand_1(volatile T a, volatile T b) {   return Or&lt;T&gt;(Not&lt;T&gt;(a), Not&lt;T&gt;(b)); } \/\/! Not(a And b) template &lt;typename T&gt; FORCEINLINE T Nand_2(volatile T a, volatile T b) {   return Not&lt;T&gt;(And&lt;T&gt;(a, b)); } \/\/! Not ((Not a) Nor (Not b)) template &lt;typename T&gt; FORCEINLINE T Nand_3(volatile T a, volatile T b) {   return Not&lt;T&gt;(Nor&lt;T&gt;(Not&lt;T&gt;(a), Not&lt;T&gt;(b))); } \/\/! (Not a) Or (Not b) template &lt;typename T&gt; FORCEINLINE T Nand_4(volatile T a, volatile T b) {   return Or&lt;T&gt;(Not&lt;T&gt;(a), Not&lt;T&gt;(b)); } \/\/! ((Not a) And b) Xor (Not b) template &lt;typename T&gt; FORCEINLINE T Nand_5(volatile T a, volatile T b) {   return Xor&lt;T&gt;(And&lt;T&gt;(Not&lt;T&gt;(a), b), Not&lt;T&gt;(b)); } <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"cpp\">template &lt;typename T, const uint64_t n&gt; FORCEINLINE volatile T NandR(volatile T a, volatile T b) {   switch (n % 5) {     case 0:       return Nand_1&lt;T&gt;(a, b);     case 1:       return Nand_2&lt;T&gt;(a, b);     case 2:       return Nand_3&lt;T&gt;(a, b);     case 3:       return Nand_4&lt;T&gt;(a, b);     case 4:       return Nand_5&lt;T&gt;(a, b);     default:       return Nand_1&lt;T&gt;(a, b);   } } <\/code><\/pre>\n<p>  \u0412\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u0434\u0435 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\">NandR&lt;uint64_t, RND&gt;(a,b) <\/code><\/pre>\n<p>  \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e 1 \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0431\u0440\u0430\u043d \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u043e\u0442 \u043c\u0430\u043a\u0440\u043e\u0441\u0430 RND, \u0442\u0430\u043a \u043a\u0430\u043a \u0447\u0438\u0441\u043b\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438. RND \u2014 \u044d\u0442\u043e \u043c\u0430\u043a\u0440\u043e\u0441 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c xorshift + fnv1 + __COUNTER__ \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u0441\u0443\u0436\u0434\u0430\u043b\u0441\u044f \u0432\u044b\u0448\u0435. \u0422\u0430\u043a \u0436\u0435 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u044b\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 CNNInt&lt;&gt; \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u0435\u0431\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430.<\/p>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434 \u0438 DIFF \u0434\u0432\u0443\u0445 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0439 \u0434\u043b\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"cpp\">uint64_t diff_me(uint64_t x) {   using u64 = uint64_t;   CNNInt&lt;u64&gt; r(std::chrono::system_clock::now().time_since_epoch().count());   CNNInt&lt;u64&gt; test(x);   test++;   test--;   test|=r;   test^=r;   test&amp;=r;   test^=r;   test = ~test;   return test.value(); } <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/d8b\/a58\/3d9\/d8ba583d9c369bf0ff73adce4ac76760.png\" alt=\"image\"><\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/2b6\/704\/2c3\/2b67042c31b18efac480926eb4f13032.png\" alt=\"image\"><\/p>\n<p>  \u0410\u043d\u0430\u043b\u0438\u0437 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043b\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u0443 relyze, DIFF \u0434\u0432\u0443\u0445 \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u043e\u0432 \u043f\u043e\u043a\u0430\u0437\u0430\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code class=\"plaintext\">81.13%  diff_me  -  diff_me<\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e diff_me \u043f\u043e\u0434 \u0434\u0435\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430\u043c\u0438:<\/p>\n<p>  1. <a href=\"https:\/\/www.nsa.gov\/resources\/everyone\/ghidra\/\">Ghidra<\/a><\/p>\n<pre><code class=\"cpp\">ulong diff_me(ulong param_1)  {   ulong uVar1;   ulong uVar2;   ulong uVar3;   ulong uVar4;      uVar1 = now();   uVar2 = ~uVar1;   uVar3 = ~(param_1 &amp; ~param_1 &amp; uVar1) &amp; (param_1 | ~param_1 &amp; uVar1);   uVar4 = ~uVar3;   uVar3 = (~(uVar3 &amp; uVar2 | uVar4) | uVar3 &amp; uVar2 &amp; uVar4 | uVar2) &amp; (uVar1 &amp; uVar3 | uVar4) |           uVar2;   uVar4 = ~uVar3 &amp; uVar2;   return (uVar1 &amp; ~uVar3 | uVar3) &amp; (~(uVar4 | uVar3) | uVar4 &amp; uVar3 | uVar2); } <\/code><\/pre>\n<p>  \u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0435\u0441\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f execute_code, \u0435\u0435 Ghidra \u0434\u0435\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u0441\u043c\u043e\u0433\u043b\u0430.<\/p>\n<p>  2. <a href=\"https:\/\/www.hopperapp.com\/\">Hopper<\/a><\/p>\n<pre><code class=\"cpp\">int _Z7diff_mem(long arg0) {     rax = std::chrono::_V2::system_clock::now();     rax = (rax &amp; !((!(!(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax) &amp; !rax | !(!(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax))) | !(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax) &amp; !rax &amp; !(!(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax)) | !rax) &amp; (rax &amp; !(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax) | !(!(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax))) | !rax) | !!((!(!(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax) &amp; !rax | !(!(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax))) | !(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax) &amp; !rax &amp; !(!(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax)) | !rax) &amp; (rax &amp; !(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax) | !(!(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax))) | !rax)) &amp; (!(!((!(!(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax) &amp; !rax | !(!(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax))) | !(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax) &amp; !rax &amp; !(!(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax)) | !rax) &amp; (rax &amp; !(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax) | !(!(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax))) | !rax) &amp; !rax | !!((!(!(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax) &amp; !rax | !(!(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax))) | !(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax) &amp; !rax &amp; !(!(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax)) | !rax) &amp; (rax &amp; !(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax) | !(!(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax))) | !rax)) | !((!(!(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax) &amp; !rax | !(!(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax))) | !(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax) &amp; !rax &amp; !(!(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax)) | !rax) &amp; (rax &amp; !(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax) | !(!(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax))) | !rax) &amp; !rax &amp; !!((!(!(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax) &amp; !rax | !(!(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax))) | !(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax) &amp; !rax &amp; !(!(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax)) | !rax) &amp; (rax &amp; !(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax) | !(!(arg0 &amp; !arg0 &amp; rax) &amp; (arg0 | !arg0 &amp; rax))) | !rax) | !rax);     return rax; } <\/code><\/pre>\n<p>  3. <a href=\"https:\/\/github.com\/avast\/retdec\/releases\">RetDec <\/a><\/p>\n<pre><code class=\"cpp\">\/\/ Address range: 0x401320 - 0x4013a3 \/\/ Demangled:     diff_me(unsigned long) int64_t _Z7diff_mem(int64_t a1) {     \/\/ 0x401320     g14 = a1;     int64_t v1 = g14; \/\/ 0x401321     int64_t v2 = function_401030(); \/\/ 0x401324 _ZNSt6chrono3_V212system_clock3nowEv();     g14 = 0;     return -1 - ((v2 &amp; -1 - v1 | v1) &amp; v2); } <\/code><\/pre>\n<p>  <\/p>\n<h2>\u0411\u043e\u043d\u0443\u0441\u044b<\/h2>\n<p>  1. <a href=\"https:\/\/github.com\/Deniskore\/nand_nor\">\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/a>.<\/p>\n<p>  2. \u0412\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a MSVC \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0443 (\u0442\u0443\u043b\u0447\u0435\u0439\u043d \u0432\u0435\u0440\u0441\u0438\u0438 16.4.2), \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0438\u0437 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441\u044a\u0435\u0434\u0430\u0435\u0442 \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u044f <a href=\"https:\/\/developercommunity.visualstudio.com\/content\/problem\/873112\/extremely-long-compilation-time-when-using-compile.html\">\u0437\u0430\u0440\u0435\u043f\u043e\u0440\u0442\u0438\u043b \u0431\u0430\u0433 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u0435 MSVC<\/a>, \u0431\u0443\u0434\u0443 \u0440\u0430\u0434 \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u0440\u043e\u0433\u043e\u043b\u043e\u0441\u0443\u0435\u0442\u0435 \u0437\u0430 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0431\u0430\u0433\u0430.<\/p>\n<p>  \u041f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u0440\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ct\/eh\/ma\/ctehmabog83fvrgzmmzxaxgaelm.png\"><\/p>\n<p>  \u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0441\u0431\u043e\u0440\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f Clang 9.0 \u0438 GCC 9.2.1 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e \u0438 \u043d\u0435 \u043a\u0443\u0448\u0430\u0435\u0442 \u0442\u0430\u043a\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \ud83d\ude42<\/p><\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d() } } }t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>      <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/482734\/\"> https:\/\/habr.com\/ru\/post\/482734\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/482734\/\">\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435.<\/h2>\n<p>  \u0412\u0441\u0435, \u043a\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0437\u043d\u0430\u043a\u043e\u043c \u0441 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u0421++ \u0441\u043b\u044b\u0448\u0430\u043b, \u0447\u0442\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0421++11 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442 \u0431\u044b\u043b \u0432\u0432\u0435\u0434\u0435\u043d \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 constexpr, \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u043b\u0438\u043c\u0438\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 compile-time \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f. \u0412 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u044b \u0431\u044b\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b <a href=\"http:\/\/www.open-std.org\/jtc1\/sc22\/wg21\/docs\/papers\/2016\/p0292r2.html\">if constexpr<\/a> \u0438 <a href=\"http:\/\/www.open-std.org\/jtc1\/sc22\/wg21\/docs\/papers\/2016\/p0170r1.pdf\">constexpr lambdas<\/a> \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0441\u043d\u0438\u043c\u0430\u044e\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434 \u0441 compile time \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f\u043c\u0438. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e\u0431 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0439 \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0432 compile time.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-296710","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/296710","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=296710"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/296710\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=296710"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=296710"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=296710"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}