Advertisement
F_x

Loader.c

F_x
Apr 8th, 2019
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.15 KB | None | 0 0
  1. //Ref: https://gist.github.com/aycabta/9088471
  2. int r, a;
  3.  
  4. P(y, x) { // referential transparent
  5.     return (y * 2 + 1) << x;
  6. }
  7.  
  8. // position of lowest 1-bit
  9. // Z(0b1) = 0, Z(0b10) = 1
  10. Z(x) { // referential transparent
  11.     int pos = 0;
  12.     while((x & 1) == 0) {
  13.         x >>= 1;
  14.         pos++;
  15.     }
  16.     return pos;
  17. }
  18.  
  19. // cut last 100... (bin) off
  20. // L(0b101011000000) = 0b10101
  21. L(x) { // referential transparent
  22.     return x >> (Z(x) + 1);
  23. }
  24.  
  25. S(v, y, c, t)
  26. {
  27.     int f = L(t);
  28.     int x = r;
  29.  
  30.     if (f != 2) {
  31.         if (f > 2) {
  32.             if(f == v) return y;
  33.             if(f > v) return t - c;
  34.             /*(f < v)*/ return t;
  35.         } else {
  36.             t = S(4, 13, -4, y);
  37.             return P(f, P(S(v, y, c, L(x)), S(v + 2, t, c, Z(x))));
  38.         }
  39.     } else {
  40.         A(S(v, y, c, L(x)), S(v, y, c, Z(x)));
  41.     }
  42. }
  43.  
  44. A(y, x) {
  45.     if (L(y) != 1) {
  46.         return 5 << P(y, x);
  47.     } else {
  48.         return S(4, x, 4, Z(r));
  49.     }
  50. }
  51.  
  52. D(x) {
  53.     int c = 0;
  54.     int t = 7;
  55.     int u = 14;
  56.     while (1) {
  57.         if (x) D(x - 1);
  58.         x >>= 1;
  59.         if (x & 1) break;
  60.         int d = L(L(D(x)));
  61.         int f = L(r);
  62.         x = L(r);
  63.         if (c == r && L(u) == 0 && L(r) == f) {
  64.             x >>= 1;
  65.             if (x & 1) {
  66.                 u = S(4, d, 4, r);
  67.                 t = A(t, d);
  68.                 x >>= 1;
  69.                 if ((f >> 1) & x & 1) {
  70.                     c = P(d, c);
  71.                     t = S(4, 13, -4, t);
  72.                     u = S(4, 13, -4, u);
  73.                 }
  74.             }
  75.         };
  76.         if (c) {
  77.             x >>= 1;
  78.             if (x & 1) {
  79.                 x >>= 1;
  80.                 if(~u & 2 | x & 1) {
  81.                     u = 1 << P(L(c), u);
  82.                     t = P(u, P(L(c), t));
  83.                 } else {
  84.                     t = P(0, P(L(c), t));
  85.                 }
  86.  
  87.                 c = r;
  88.             }
  89.         }
  90.         x >>= 1;
  91.         if (u >> 1 & x & 1) {
  92.             c = P(t, c);
  93.             u = S(4, 13, -4, t);
  94.             t = 9;
  95.         }
  96.     }
  97.     return a = P(P(t, P(u, P(x, c))), a);
  98. }
  99.  
  100. main() {
  101.     return D(D(D(D(D(99)))));
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement