Here’s a 64-bit JIT compiler for the RPN calculator. Each expression entered in a REPL is compiled by cc() in-memory and then called with a single instruction in exe().

You can see 64-bit overflow:

$ gcc r.c -o r $ ./r >9223372036854775807 1 + -9223372036854775808

64-bit JIT compiler for RPN calculator //RPN compiler: E:EEf|n f:[+-*/] n:[0-9]+ #include<stdio.h> #include<stdlib.h> #include<sys/mman.h> typedef long long I;typedef char C,*S; #define O(x...) printf(x),fflush(stdout) #define R return #define Z static #define CASE(x,y...) case x:{y;}break; #define PE(x) if((x)<0)perror("pe"),exit(2) S m,m0; I exe(){m=m0;asm("call *%0;"::"g"(m0):);} S repl() {I c=' ';I d(){R c==EOF?exit(1),0:(c=getchar());} I sp(){while(c==' ')d();} I no(){I i=0,k=0;while(c>='0'&&c<='9')k=1,i=i*10+c-'0',d();R k?i:-1;} I wi(I x){*(I*)m=x;m+=8;} I ws(S x){while(*x)*m++=*x++;} I cc() {ws("\x48\x89\xe5"); while(c!='

') {I i;sp(); if((i=no())>=0)ws("\x48\xb8"),wi(i);else {ws("\x58\x5b"); switch(c){CASE('+',ws("\x48\x01\xd8")) CASE('-',ws("\x48\x29\xd8")) CASE('*',ws("\x48\x0f\xaf\xc3")) CASE('/',ws("\x48\x99\x48\x89\xec")) default:O("'lex

"),exit(1); }d(); }ws("\x50");sp(); }ws("\x48\x89\xec");ws("\xc3"); } while(O(">"),d(),c!=EOF){cc();O("%lld

",exe());} } I main(I c,S*v) {I n=1<<20;PE(m0=m=mmap(NULL,n,7,0x22,0,0));repl();} 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 //RPN compiler: E:EEf|n f:[+-*/] n:[0-9]+ #include<stdio.h> #include<stdlib.h> #include<sys/mman.h> typedef long long I ; typedef char C , * S ; #define O(x...) printf(x),fflush(stdout) #define R return #define Z static #define CASE(x,y...) case x:{y;}break; #define PE(x) if((x)<0)perror("pe"),exit(2) S m , m0 ; I exe ( ) { m = m0 ; asm ( "call *%0;" :: "g" ( m0 ) : ) ; } S repl ( ) { I c = ' ' ; I d ( ) { R c == EOF ? exit ( 1 ) , 0 : ( c = getchar ( ) ) ; } I sp ( ) { while ( c == ' ' ) d ( ) ; } I no ( ) { I i = 0 , k = 0 ; while ( c >= '0' && c <= '9' ) k = 1 , i = i* 10 + c - '0' , d ( ) ; R k ? i : - 1 ; } I wi ( I x ) { * ( I* ) m = x ; m += 8 ; } I ws ( S x ) { while ( * x ) * m ++ = * x ++ ; } I cc ( ) { ws ( "\x48\x89\xe5" ) ; while ( c != '

' ) { I i ; sp ( ) ; if ( ( i = no ( ) ) >= 0 ) ws ( "\x48\xb8" ) , wi ( i ) ; else { ws ( "\x58\x5b" ) ; switch ( c ) { CASE ( '+' , ws ( "\x48\x01\xd8" ) ) CASE ( '-' , ws ( "\x48\x29\xd8" ) ) CASE ( '*' , ws ( "\x48\x0f\xaf\xc3" ) ) CASE ( '/' , ws ( "\x48\x99\x48\x89\xec" ) ) default : O ( "'lex

" ) , exit ( 1 ) ; } d ( ) ; } ws ( "\x50" ) ; sp ( ) ; } ws ( "\x48\x89\xec" ) ; ws ( "\xc3" ) ; } while ( O ( ">" ) , d ( ) , c != EOF ) { cc ( ) ; O ( "%lld

" , exe ( ) ) ; } } I main ( I c , S* v ) { I n = 1 << 20 ; PE ( m0 = m = mmap ( NULL , n , 7 , 0x22 , 0 , 0 ) ) ; repl ( ) ; }