SHARE
TWEET

Untitled

a guest Aug 19th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int main(int argc, char **argv) {
  4.     int x = atoi(argv[1]);
  5.     int y = atoi(argv[2]);
  6.  
  7.     for (int i = (x < y) * 2; i < 4 >> (x < y); ++i) {
  8.         int res;
  9.  
  10.         switch (i) {
  11.             case 0:
  12.                 if (__builtin_sadd_overflow(x, y, &res))
  13.                     res = 0;
  14.                 break;
  15.             case 1:
  16.                 if (__builtin_smul_overflow(x, y, &res))
  17.                     res = 0;
  18.                 break;
  19.             case 2:
  20.                 if (__builtin_ssub_overflow(x, y, &res))
  21.                     res = 0;
  22.                 break;
  23.             case 3:
  24.                 res = !(x
  25. #ifdef UNNECESSARY_CODE
  26.                         < y || x
  27. #endif
  28.                         % y) * (x / y);
  29.                 break;
  30.         }
  31.  
  32.         printf("%dn", res);
  33.     }
  34. }
  35.      
  36. cc -Ofast -DUNNECESSARY_CODE -S -o a1.s a.c
  37. cc -Ofast -S -o a2.s a.c
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top