scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

0156-duff2.c (942B)


      1 /*
      2  *  Disgusting, no?  But it compiles and runs just fine.  I feel a
      3  *  combination of pride and revulsion at this discovery.  If no one's
      4  *  thought of it before, I think I'll name it after myself.  It amazes
      5  *  me that after 10 years of writing C there are still little corners
      6  *  that I haven't explored fully.
      7  *  - Tom Duff
      8  */
      9 send(to, from, count)
     10         register short *to, *from;
     11         register count;
     12 {
     13         register n=(count+7)/8;
     14         switch(count%8){
     15         case 0:      do{*to = *from++;
     16         case 7:           *to = *from++;
     17         case 6:           *to = *from++;
     18         case 5:           *to = *from++;
     19         case 4:           *to = *from++;
     20         case 3:           *to = *from++;
     21         case 2:           *to = *from++;
     22         case 1:           *to = *from++;
     23                             }while(--n>0);
     24         }
     25 }
     26 
     27 int
     28 main()
     29 {
     30 	short a, b[40];
     31 
     32 	send(&a, b, 40);
     33 
     34 	return (a == b[39]) ? 0 : 1;
     35 }