5 ms·
Ask HN: Robinson.c: What is this C code?
This code showed up in my $HOME recently, under the name robinson.c. Any idea where it's from?
typedef struct A*B,*(*C)();struct A{C(*d)();B e;}*v(),*b;C n[256];
# include <stdio.h>
#define a (d->e)
#define o (B)printf
#define X(_){return _;}
#define Y(_,A)B _(d,e)B d,e;X(A)
#define Z(P)C P(f,g,h,i)C f,g,h,i;X(P)
#define c(_)(b=(B)malloc(sizeof(*b)),b->d=_,b->e=d,b)
#define _(D,E,F,G,H)B D();Y(D/**/f,E)Y(D/**/g,F)Y(D/**/h,G)Y(D/**/i,H)Y(D,(*(*d->d)(D/**/f,D/**/g,D/**/h,D/**/i))(d,e))
Z(f)
Z(g)
Z(h)
Z(i)
_(j,d,d,j a,j a)
_(k,d,c(h),c(h),c(h))
_(l,c(i),d,c(i),c(i))
_(m,c(g),c(f),l(m a),k(m a))
_(p,d,l(m(d)),k(p a),l(m a))
_(q,l(p(d)),m(d),l a,k(q a))
_(r,m(d),k(mf a),l(r a),k a)
_(s,d,e,o("0",s a),o("1",s a))
_(t,d,p(e),k(t(a,e)),v(k(t(a,e)),e))
_(u,k(e),l(r(e)),k(v(a,e)),l(v(a,e)))
_(v,e,r(e),u(e,a),u(q(e),a))
_(w,o("0"),d,s(d),s(d))
_(x,(*n[getchar()])(d),o("-1"),w(p(d,o("-"))),xh(d))
_(y,xf(mg()),v(d,p(yf())),v(d,yf()),t(d,yf()))
_(z,xf(yf()),(*(*j(d)->d)(w,x))(d),xf(k(d)),xf(l(d)))
main(){
n['(']=zf;n['x']=yi;n['-']=yg;
n['+']=yh;n['0']=zh;n['1']=zi;
n[' ']=xf;n[')']=n['\n']=kf;
o("\n",zg(yf()));}
- Cheyana 4y agoGoogle comes up with nothing but this HN post. It looks like it could be an entry in the Obfuscated C code contest.
- Someone 4y ago“robinson.c” indeed isn’t a good search term because there are many people with that name, but a search for typedef struct A*B,*(*C)();struct A{C(*d)();B e;}*v(),*b;C n[256]; for me, gave https://www.ioccc.org/1989/robison.c https://www.ioccc.org/1989/robison.c as the second hit, directly after the HN hit.
- Cheyana 4y agoYeah. The obfuscated code thing immediately came to mind simply because if you've seen other examples on that site, they tend to look a lot like that, though stupidly I didn't think to search on a line of code.
- tmaly 4y ago[flagged]
- version_five 4y agoThat adds nothing to the discussion and reduces the SNR. You might as well have wikipedia'd something and posted what wikipedia says. Nobody cares about gpt output.
- version_five 4y agoI'm on my phone and it doesnt work on mobile or I'd look, but try the advice here: https://stackoverflow.com/questions/3019609/any-utility-to-test-expand-c-c-define-macros https://stackoverflow.com/questions/3019609/any-utility-to-t... It probably won't help but you can at least expand the preprocessor stuff. Edit: I ran it though the preprocessor and it doesn't make anything clearer. It also doesn't compile with gcc and default options.
- yellow_lead 4y agoThis doesn't seem to compile...
- deleted 4y ago[deleted]
- ksherlock 4y agoit's "robison.c" from the 1989 IOCCC https://github.com/c00kiemon5ter/ioccc-obfuscated-c-contest/blob/04a21846149c768e1d856f947ac2527c00cafd96/1989/robison.c https://github.com/c00kiemon5ter/ioccc-obfuscated-c-contest/... https://github.com/c00kiemon5ter/ioccc-obfuscated-c-contest/blob/04a21846149c768e1d856f947ac2527c00cafd96/1989/robison.hint https://github.com/c00kiemon5ter/ioccc-obfuscated-c-contest/... --- This program is a handy picoAPL interpreter written in C--. It outputs the evaluation of an APL expression from standard input. Functions are limited to dyadic +,-,x, and unary -; numerals must be binary. Parentheses may be used for grouping. For example: 101x111-100 prints: 1111
- willmeyers 4y agoWe found a winner! Nice researching skills.
- deleted 4y ago[deleted]
- deleted 4y ago[deleted]