kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

05_wide.c (542B)


      1 /* Wide arithmetic: 64-bit multiply/divide/shift mixes that lower to
      2  * compiler-rt helpers on some targets. Returns a value in [0,127]. */
      3 int bounce_main(void) {
      4   unsigned long long a = 0x0123456789ABCDEFull;
      5   unsigned long long b = 0xFEDCBA9876543210ull;
      6   unsigned long long m = a * b;          /* low 64 of the product */
      7   unsigned long long d = b / (a | 1ull); /* 64-bit divide */
      8   long long s = (long long)(a >> 17) - (long long)(b >> 29);
      9   s += (long long)(m ^ d);
     10   s ^= (long long)(a % 1000003ull);
     11   return (int)(s & 0x7f);
     12 }