Skip to content

Instantly share code, notes, and snippets.

@Danct12
Created March 20, 2024 10:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Danct12/5ab889aa353de51013e0d00ae43d363f to your computer and use it in GitHub Desktop.
Save Danct12/5ab889aa353de51013e0d00ae43d363f to your computer and use it in GitHub Desktop.
/* This is the deobfuscated version of the optimized donut.c code by
* Andy Sloane (@a1k0n).
*
* Taken from:
* https://www.a1k0n.net/2021/01/13/optimizing-donut.html
*
* Additionally, I have fixed warnings raised by the compiler.
*/
#include <string.h>
#include <stdio.h>
#include <unistd.h>
int x,y,o,N;
#define R(t, x, y) \
f = x; \
x -= t * y; \
y += t * f; \
f = (3 - x * x - y * y) / 2; \
x *= f; \
y *= f;
int main()
{
float z[1760], a = 0, e = 1, c = 1, d = 0, f, g, h, G, H, A, t, D;
char b[1760];
for(;;) {
memset(b, 32, 1760);
memset(z, 0, 7040);
g = 0, h = 1;
for(int j = 0; j < 90; j++){
G = 0, H = 1;
for (int i = 0; i < 314; i++) {
A = h + 2;
D = 1 / (G * A * a + g * e+5);
t = G * A * e - g * a;
x = 40 + 30 * D * (H * A * d - t * c);
y = 12 + 15 * D * (H * A * c + t * d);
o = x + 80 * y;
N = 8 * ((g * a - G * h * e) * d - G * h * a - g * e - H * h * c);
if (22 > y && y > 0 && x > 0 && 80 > x && D > z[o]) {
z[o] = D;
b[o] = (N>0?N:0)[".,-~:;=!*#$@"];
}
R(.02, H, G);
}
R(.07, h, g);
}
for(int k = 0; 1761 > k; k++)
putchar( k % 80 ? b[k] : 10);
R(.04, e, a);
R(.02, d, c);
usleep(15000);
printf('\n' + (" donut.c! \x1b[23A"));
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment