// deobfuscated version of "FIRST and THIRD" // deobfuscated by typeswitch // original by Sean Barrett (@nothings) // // original design document: ftp.funet.fi/pub/doc/IOCCC/1992/buzzard.2.design // original obfuscated code: ftp.funet.fi/pub/doc/IOCCC/1992/buzzard.2.c #define comma m[m[0]++] = char s[5000]; int m[20000]={32},L=1,IP,T[500],*S=T,t=64,w,f; void create(x) { comma L; L= *m-1; comma t; comma x; scanf("%s",s+t); t+=strlen(s+t)+1; } void run(x) { switch (m[x++]){ case 0: // lit *++S=f; f=m[IP++]; break; case 1: // default compile action, which is to comma the xt comma x; break; case 2: // docolon op, which pushes IP on RS and gives a new IP m[++m[1]]=IP; IP=x; break; case 3: // : -- makes an activation which just pushes create(1); comma 2; break; case 4: // immediate -- overwrites the compile op with docol, // and moves HERE back to compensate *m-=2; comma 2; break; case 5: // read_ ? if (scanf("%s",s) < 1) exit(0); for(w=L; strcmp(s, &s[m[w+1]]) != 0; w=m[w]); // last link L is 1 (see that L=1 initially) // m[2] has to be zero for this loop to finish // basically w=1 here means we didn't find a word // in the dictionary, but m[2] being zero means we're // comparing s against itself, which is a convenient way to stop if (w != 1) { // no string run(w+2); // run compile xt } else { comma 2 // m[2]=0 means the corresponding operator is lit comma atoi(s) // push integer value } break; case 6: // load @ f=m[f]; break; case 7: // store ! m[f]= *S--; f= *S--; break; case 8: // subtraction - f= *S-- - f; break; case 9: // multiplication * f *= *S--; break; case 10: // division / f= *S-- / f; break; case 11: // is-negative <0 f=0>f; break; case 12: // exit, i.e. return from function IP=m[m[1]--]; break; case 13: // echo, i.e. emit character to stdout putchar(f); f= *S--; break; case 14: // key, i.e. get character from stdin *++S=f; f=getchar(); case 15: // _pick, not really used f=S[-f]; break; } } main() { create(3); create(4); create(1); w= *m; comma 5; comma 2; IP= *m; comma w; comma IP-1; for(w=6;w<16;) create(1),comma w++; m[1]= *m; *m += 512; while(1) run(m[IP++]); }