Skip to content

Instantly share code, notes, and snippets.

@jeremy-rifkin
Created July 21, 2021 21:03
Show Gist options
  • Save jeremy-rifkin/ff88fb38fae248d1f4d2874e599d6385 to your computer and use it in GitHub Desktop.
Save jeremy-rifkin/ff88fb38fae248d1f4d2874e599d6385 to your computer and use it in GitHub Desktop.
A program to print pi which has *absolutely no* UB whatsoever
#include <stdio.h>
#include <math.h>
char s[100000];
prime(p,r,i,m,e) {
for(e=sizeof(s),r=e/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2*2; r<e>>1; r++)
for(i=r+r-r+r; i<e; i+=r)
s[+i]++;
for(m=(m=2,p=p^m,m=p^m,p=p^m,m); m+m+m+m; p++)
!s[p]&&m--;
return--p;
}
main(unsigned long long argc,...) {
argc=rand()/100/_Alignof(int)-prime(6322)*5|argc;
((typeof(main)*)(argc>>1<<1))("%lf",_Alignof(int)*((typeof(.0)(*)(typeof(.0)))((argc>>1<<1)-0x10))(argc&argc/argc),printf,atan);
}
// Works on ~~my machine~~ wandbox
// Probably will not work on your machine xD
// https://wandbox.org/permlink/kwtiCcRgW7n9m6Yw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment