# IOCCC (1984) Part 2

in C on IOCCC

## Work in Progress

This page is a work in progress, that is, I will try to explain stuff, but I have not (yet) understood everything myself.

`laman.c`

```
a[900]; b;c;d=1 ;e=1;f; g;h;O; main(k,
l)char* *l;{g= atoi(* ++l); for(k=
0;k*k< g;b=k ++>>1) ;for(h= 0;h*h<=
g;++h); --h;c=( (h+=g>h *(h+1)) -1)>>1;
while(d <=g){ ++O;for (f=0;f< O&&d<=g
;++f)a[ b<<5|c] =d++,b+= e;for( f=0;f<O
&&d<=g; ++f)a[b <<5|c]= d++,c+= e;e= -e
;}for(c =0;c<h; ++c){ for(b=0 ;b<k;++
b){if(b <k/2)a[ b<<5|c] ^=a[(k -(b+1))
<<5|c]^= a[b<<5 |c]^=a[ (k-(b+1 ))<<5|c]
;printf( a[b<<5|c ]?"%-4d" :" " ,a[b<<5
|c]);} putchar( '\n');}} /*Mike Laman*/
```

Would ya look at this beauty. It is absolutely awesome! Okay, enough talking. Let’s get to work.

After going through some beautification, this is what it looks like:

```
a[900];
b;
c;
d = 1;
e = 1;
f;
g;
h;
O;
main(k, l) char * * l; {
g = atoi( * ++l);
for (k = 0; k * k < g; b = k++ >> 1);
for (h = 0; h * h <= g; ++h);
--h;
c = ((h += g > h * (h + 1)) - 1) >> 1;
while (d <= g) {
++O;
for (f = 0; f < O && d <= g; ++f) a[b << 5 | c] = d++, b += e;
for (f = 0; f < O && d <= g; ++f) a[b << 5 | c] = d++, c += e;
e = -e;
}
for (c = 0; c < h; ++c) {
for (b = 0; b < k; ++
b) {
if (b < k / 2) a[b << 5 | c] ^= a[(k - (b + 1)) << 5 | c] ^= a[b << 5 | c] ^= a[(k - (b + 1)) << 5 | c];
printf(a[b << 5 | c] ? "%-4d" : " ", a[b << 5 | c]);
}
putchar('\n');
}
} /*Mike Laman*/
```

Okay, still not very comprehensible.

A few points:

- This style of writing
`main (int k, char* *l)`

as`main(k , l) char* * l;`

came around because of this book.

Yes, this book and C, for that matter, is that old.

Anyways, we need to modernize it.

```
int a[900],b,c,d = 1,e = 1,f,g,h,O;
int main(int k, char* *l){
g = atoi( * ++l);
for (k = 0; k * k < g; b = k++ >> 1);
for (h = 0; h * h <= g; ++h);
--h;
c = ((h += g > h * (h + 1)) - 1) >> 1;
while (d <= g) {
++O;
for (f = 0; f < O && d <= g; ++f) a[b << 5 | c] = d++, b += e;
for (f = 0; f < O && d <= g; ++f) a[b << 5 | c] = d++, c += e;
e = -e;
}
for (c = 0; c < h; ++c) {
for (b = 0; b < k; ++
b) {
if (b < k / 2) a[b << 5 | c] ^= a[(k - (b + 1)) << 5 | c] ^= a[b << 5 | c] ^= a[(k - (b + 1)) << 5 | c];
printf(a[b << 5 | c] ? "%-4d" : " ", a[b << 5 | c]);
}
putchar('\n');
}
return 0;
} /*Mike Laman*/
```

I do not know what else to do. Discuss about it in the comments! Hopefully, I’ll gain some insight (I very well understand this code, but I don’t think there is anything else that I can do to simplify it).

This might be one of those *very interesting* tricks you can do with code.

Anyways, the comment section is open for discussion.

## The copyright

Copyright © 1984, Landon Curt Noll. All Rights Reserved. Permission for personal, educational or non-profit use is granted provided this this copyright and notice are included in its entirety and remains unaltered. All other uses must receive prior permission in writing from both Landon Curt Noll and Larry Bassel.