Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Partly deobfuscated Toledo Chess 1.
/**
@file toledo-deobfuscated.c
@brief Toledo Chess 1, deobfuscated
@author Original: Óscar Toledo G. <biyubi@gmail.com>
@author Deobfuscation: Maxthon T. Chan <xcvista@me.com>
This is partly deobfuscated Toledo Chess, winning entry of 18th IOCCC.
*/
#include <setjmp.h>
typedef int G;
char J[78], O[] c, h, e, S, *s, l[149];
jmp_buf z;
G main(G L, G f, G N, G k) {
G u = 99, p, q, r, j, i, x, t, a, b = S, d, M = -1e9;
char *n;
if (*l) {
e = ~e;
while (u > 21) {
q = l[--u] ^ e;
if (!--q) {
if (!l[p = e ? u - 10 : u + 10]) {
{
if (r = l[x = p], !r | (r ^ e) < -1) {
if (j = u[l], -7 == r | 6 == r) {
;
e = ~e;
return 1e5 - 443 * f;
}
u[l] = 0, t = j + 1, i = j - 1;
if (!i & 89 < x)
i = j, t = 6;
if (-1 == t & 30 > x)
t = j, i = -7;
while (++i < t) {
d = 0;
S &= 63;
a = ((j ^ e) != 1 ? 6 != (j ^ e)
? O[32 + x / 10] - O[u / 10 + 32] - q
: (S |= 6 != j ? 8 : 1, 2 == u - x) * 9 + 9 *(x - u == 2)
: (d = 1 == j ? x - u : u - x) / 8 +
!(!((x - u) % 10) | r) * 99 +
(j == 1 ? 90 < x : 29 > x) * (9 * O[28 + i] - 288)) +
O[r + 28] * 9 - 288 + O[x % 10 + 33] - f - O[33 + u % 10];
x[l] = i;
S |= (21 == u | 21 == x) * 2 + (u == 28 | 28 == x) * 4 +
(91 == u | x == 91) * 16 + 32 * (u == 98 | x == 98) +
(20 == d) * 64 * x;
a -= k > f ? main(a, f + 1, M, k) : 0;
if (i == c & u == h & !f & N & a > -1e4 & x == y)
longjmp(z, 1);
S = b;
if (!N | f && (a > M || !f & a == M && 1 & rand())) {
if (!f) {
if (k) {
c = i;
h = u;
y = x;
}
} else if (L - a < N) {
;
e = ~e;
u[l] = j;
x[l] = r;
return a;
}
M = a;
}
}
x[l] = r;
u[l] = j;
;
}
}
if (e ? u > 80 &!l[p -= 10] : u < 39 &!l[p += 10]) {
if (r = l[x = p], !r | (r ^ e) < -1) {
if (j = u[l], -7 == r | 6 == r) {
;
e = ~e;
return 1e5 - 443 * f;
}
u[l] = 0, t = j + 1, i = j - 1;
if (!i & 89 < x)
i = j, t = 6;
if (-1 == t & 30 > x)
t = j, i = -7;
while (++i < t) {
d = 0;
S &= 63;
a = ((j ^ e) != 1 ? 6 != (j ^ e)
? O[32 + x / 10] - O[u / 10 + 32] - q
: (S |= 6 != j ? 8 : 1, 2 == u - x) * 9 + 9 *(x - u == 2)
: (d = 1 == j ? x - u : u - x) / 8 +
!(!((x - u) % 10) | r) * 99 +
(j == 1 ? 90 < x : 29 > x) * (9 * O[28 + i] - 288)) +
O[r + 28] * 9 - 288 + O[x % 10 + 33] - f - O[33 + u % 10];
x[l] = i;
S |= (21 == u | 21 == x) * 2 + (u == 28 | 28 == x) * 4 +
(91 == u | x == 91) * 16 + 32 * (u == 98 | x == 98) +
(20 == d) * 64 * x;
a -= k > f ? main(a, f + 1, M, k) : 0;
if (i == c & u == h & !f & N & a > -1e4 & x == y)
longjmp(z, 1);
S = b;
if (!N | f && (a > M || !f & a == M && 1 & rand())) {
if (!f) {
if (k) {
c = i;
h = u;
y = x;
}
} else if (L - a < N) {
;
e = ~e;
u[l] = j;
x[l] = r;
return a;
}
M = a;
}
}
x[l] = r;
u[l] = j;
;
}
}
}
if (l[p = e ? u - 11 : 9 + u]) {
if (r = l[x = p], !r | (r ^ e) < -1) {
if (j = u[l], -7 == r | 6 == r) {
;
e = ~e;
return 1e5 - 443 * f;
}
u[l] = 0, t = j + 1, i = j - 1;
if (!i & 89 < x)
i = j, t = 6;
if (-1 == t & 30 > x)
t = j, i = -7;
while (++i < t) {
d = 0;
S &= 63;
a = ((j ^ e) != 1 ? 6 != (j ^ e)
? O[32 + x / 10] - O[u / 10 + 32] - q
: (S |= 6 != j ? 8 : 1, 2 == u - x) * 9 + 9 *(x - u == 2)
: (d = 1 == j ? x - u : u - x) / 8 +
!(!((x - u) % 10) | r) * 99 +
(j == 1 ? 90 < x : 29 > x) * (9 * O[28 + i] - 288)) +
O[r + 28] * 9 - 288 + O[x % 10 + 33] - f - O[33 + u % 10];
x[l] = i;
S |= (21 == u | 21 == x) * 2 + (u == 28 | 28 == x) * 4 +
(91 == u | x == 91) * 16 + 32 * (u == 98 | x == 98) +
(20 == d) * 64 * x;
a -= k > f ? main(a, f + 1, M, k) : 0;
if (i == c & u == h & !f & N & a > -1e4 & x == y)
longjmp(z, 1);
S = b;
if (!N | f && (a > M || !f & a == M && 1 & rand())) {
if (!f) {
if (k) {
c = i;
h = u;
y = x;
}
} else if (L - a < N) {
;
e = ~e;
u[l] = j;
x[l] = r;
return a;
}
M = a;
}
}
x[l] = r;
u[l] = j;
;
}
} else if (u - 1 == S >> 6) {
l[u - 1] = 0;
{
if (r = l[x = p], !r | (r ^ e) < -1) {
if (j = u[l], -7 == r | 6 == r) {
l[u - 1] = -2 ^ e;
e = ~e;
return 1e5 - 443 * f;
}
u[l] = 0, t = j + 1, i = j - 1;
if (!i & 89 < x)
i = j, t = 6;
if (-1 == t & 30 > x)
t = j, i = -7;
while (++i < t) {
d = 0;
S &= 63;
a = ((j ^ e) != 1 ? 6 != (j ^ e)
? O[32 + x / 10] - O[u / 10 + 32] - q
: (S |= 6 != j ? 8 : 1, 2 == u - x) * 9 + 9 *(x - u == 2)
: (d = 1 == j ? x - u : u - x) / 8 +
!(!((x - u) % 10) | r) * 99 +
(j == 1 ? 90 < x : 29 > x) * (9 * O[28 + i] - 288)) +
O[r + 28] * 9 - 288 + O[x % 10 + 33] - f - O[33 + u % 10];
x[l] = i;
S |= (21 == u | 21 == x) * 2 + (u == 28 | 28 == x) * 4 +
(91 == u | x == 91) * 16 + 32 * (u == 98 | x == 98) +
(20 == d) * 64 * x;
a -= k > f ? main(a, f + 1, M, k) : 0;
if (i == c & u == h & !f & N & a > -1e4 & x == y)
longjmp(z, 1);
S = b;
if (!N | f && (a > M || !f & a == M && 1 & rand())) {
if (!f) {
if (k) {
c = i;
h = u;
y = x;
}
} else if (L - a < N) {
l[u - 1] = -2 ^ e;
e = ~e;
u[l] = j;
x[l] = r;
return a;
}
M = a;
}
}
x[l] = r;
u[l] = j;
l[u - 1] = -2 ^ e;
}
}
;
}
if (l[p = e ? u - 9 : 11 + u]) {
if (r = l[x = p], !r | (r ^ e) < -1) {
if (j = u[l], -7 == r | 6 == r) {
;
e = ~e;
return 1e5 - 443 * f;
}
u[l] = 0, t = j + 1, i = j - 1;
if (!i & 89 < x)
i = j, t = 6;
if (-1 == t & 30 > x)
t = j, i = -7;
while (++i < t) {
d = 0;
S &= 63;
a = ((j ^ e) != 1 ? 6 != (j ^ e)
? O[32 + x / 10] - O[u / 10 + 32] - q
: (S |= 6 != j ? 8 : 1, 2 == u - x) * 9 + 9 *(x - u == 2)
: (d = 1 == j ? x - u : u - x) / 8 +
!(!((x - u) % 10) | r) * 99 +
(j == 1 ? 90 < x : 29 > x) * (9 * O[28 + i] - 288)) +
O[r + 28] * 9 - 288 + O[x % 10 + 33] - f - O[33 + u % 10];
x[l] = i;
S |= (21 == u | 21 == x) * 2 + (u == 28 | 28 == x) * 4 +
(91 == u | x == 91) * 16 + 32 * (u == 98 | x == 98) +
(20 == d) * 64 * x;
a -= k > f ? main(a, f + 1, M, k) : 0;
if (i == c & u == h & !f & N & a > -1e4 & x == y)
longjmp(z, 1);
S = b;
if (!N | f && (a > M || !f & a == M && 1 & rand())) {
if (!f) {
if (k) {
c = i;
h = u;
y = x;
}
} else if (L - a < N) {
;
e = ~e;
u[l] = j;
x[l] = r;
return a;
}
M = a;
}
}
x[l] = r;
u[l] = j;
;
}
} else if (S >> 6 == 1 + u) {
l[1 + u] = 0;
{
if (r = l[x = p], !r | (r ^ e) < -1) {
if (j = u[l], -7 == r | 6 == r) {
l[1 + u] = e ^ -2;
e = ~e;
return 1e5 - 443 * f;
}
u[l] = 0, t = j + 1, i = j - 1;
if (!i & 89 < x)
i = j, t = 6;
if (-1 == t & 30 > x)
t = j, i = -7;
while (++i < t) {
d = 0;
S &= 63;
a = ((j ^ e) != 1 ? 6 != (j ^ e)
? O[32 + x / 10] - O[u / 10 + 32] - q
: (S |= 6 != j ? 8 : 1, 2 == u - x) * 9 + 9 *(x - u == 2)
: (d = 1 == j ? x - u : u - x) / 8 +
!(!((x - u) % 10) | r) * 99 +
(j == 1 ? 90 < x : 29 > x) * (9 * O[28 + i] - 288)) +
O[r + 28] * 9 - 288 + O[x % 10 + 33] - f - O[33 + u % 10];
x[l] = i;
S |= (21 == u | 21 == x) * 2 + (u == 28 | 28 == x) * 4 +
(91 == u | x == 91) * 16 + 32 * (u == 98 | x == 98) +
(20 == d) * 64 * x;
a -= k > f ? main(a, f + 1, M, k) : 0;
if (i == c & u == h & !f & N & a > -1e4 & x == y)
longjmp(z, 1);
S = b;
if (!N | f && (a > M || !f & a == M && 1 & rand())) {
if (!f) {
if (k) {
c = i;
h = u;
y = x;
}
} else if (L - a < N) {
l[1 + u] = e ^ -2;
e = ~e;
u[l] = j;
x[l] = r;
return a;
}
M = a;
}
}
x[l] = r;
u[l] = j;
l[1 + u] = e ^ -2;
}
}
;
}
}
if (!--q) {
n = O + 41;
while (++n < 50 + O) {
if (r = l[x = u + 80 - *n], !r | (r ^ e) < -1) {
if (j = u[l], -7 == r | 6 == r) {
;
e = ~e;
return 1e5 - 443 * f;
}
u[l] = 0, t = j + 1, i = j - 1;
if (!i & 89 < x)
i = j, t = 6;
if (-1 == t & 30 > x)
t = j, i = -7;
while (++i < t) {
d = 0;
S &= 63;
a = ((j ^ e) != 1 ? 6 != (j ^ e)
? O[32 + x / 10] - O[u / 10 + 32] - q
: (S |= 6 != j ? 8 : 1, 2 == u - x) * 9 + 9 *(x - u == 2)
: (d = 1 == j ? x - u : u - x) / 8 +
!(!((x - u) % 10) | r) * 99 +
(j == 1 ? 90 < x : 29 > x) * (9 * O[28 + i] - 288)) +
O[r + 28] * 9 - 288 + O[x % 10 + 33] - f - O[33 + u % 10];
x[l] = i;
S |= (21 == u | 21 == x) * 2 + (u == 28 | 28 == x) * 4 +
(91 == u | x == 91) * 16 + 32 * (u == 98 | x == 98) +
(20 == d) * 64 * x;
a -= k > f ? main(a, f + 1, M, k) : 0;
if (i == c & u == h & !f & N & a > -1e4 & x == y)
longjmp(z, 1);
S = b;
if (!N | f && (a > M || !f & a == M && 1 & rand())) {
if (!f) {
if (k) {
c = i;
h = u;
y = x;
}
} else if (L - a < N) {
;
e = ~e;
u[l] = j;
x[l] = r;
return a;
}
M = a;
}
}
x[l] = r;
u[l] = j;
;
}
}
}
if (0 < q & 4 > q) {
n = q == 2 ? 53 + O : O + 49;
while (++n < O + (q != 1) * 4 + 54) {
p = u;
do {
if (r = l[x = p -= *n - 80], !r | (r ^ e) < -1) {
if (j = u[l], -7 == r | 6 == r) {
;
e = ~e;
return 1e5 - 443 * f;
}
u[l] = 0, t = j + 1, i = j - 1;
if (!i & 89 < x)
i = j, t = 6;
if (-1 == t & 30 > x)
t = j, i = -7;
while (++i < t) {
d = 0;
S &= 63;
a = ((j ^ e) != 1 ? 6 != (j ^ e)
? O[32 + x / 10] - O[u / 10 + 32] - q
: (S |= 6 != j ? 8 : 1, 2 == u - x) * 9 + 9 *(x - u == 2)
: (d = 1 == j ? x - u : u - x) / 8 +
!(!((x - u) % 10) | r) * 99 +
(j == 1 ? 90 < x : 29 > x) * (9 * O[28 + i] - 288)) +
O[r + 28] * 9 - 288 + O[x % 10 + 33] - f - O[33 + u % 10];
x[l] = i;
S |= (21 == u | 21 == x) * 2 + (u == 28 | 28 == x) * 4 +
(91 == u | x == 91) * 16 + 32 * (u == 98 | x == 98) +
(20 == d) * 64 * x;
a -= k > f ? main(a, f + 1, M, k) : 0;
if (i == c & u == h & !f & N & a > -1e4 & x == y)
longjmp(z, 1);
S = b;
if (!N | f && (a > M || !f & a == M && 1 & rand())) {
if (!f) {
if (k) {
c = i;
h = u;
y = x;
}
} else if (L - a < N) {
;
e = ~e;
u[l] = j;
x[l] = r;
return a;
}
M = a;
}
}
x[l] = r;
u[l] = j;
;
}
} while (!p[l]);
}
}
if (4 == q) {
n = 49 + O;
while (++n < O + 58) {
if (r = l[x = u - *n + 80], !r | (r ^ e) < -1) {
if (j = u[l], -7 == r | 6 == r) {
;
e = ~e;
return 1e5 - 443 * f;
}
u[l] = 0, t = j + 1, i = j - 1;
if (!i & 89 < x)
i = j, t = 6;
if (-1 == t & 30 > x)
t = j, i = -7;
while (++i < t) {
d = 0;
S &= 63;
a = ((j ^ e) != 1 ? 6 != (j ^ e)
? O[32 + x / 10] - O[u / 10 + 32] - q
: (S |= 6 != j ? 8 : 1, 2 == u - x) * 9 + 9 *(x - u == 2)
: (d = 1 == j ? x - u : u - x) / 8 +
!(!((x - u) % 10) | r) * 99 +
(j == 1 ? 90 < x : 29 > x) * (9 * O[28 + i] - 288)) +
O[r + 28] * 9 - 288 + O[x % 10 + 33] - f - O[33 + u % 10];
x[l] = i;
S |= (21 == u | 21 == x) * 2 + (u == 28 | 28 == x) * 4 +
(91 == u | x == 91) * 16 + 32 * (u == 98 | x == 98) +
(20 == d) * 64 * x;
a -= k > f ? main(a, f + 1, M, k) : 0;
if (i == c & u == h & !f & N & a > -1e4 & x == y)
longjmp(z, 1);
S = b;
if (!N | f && (a > M || !f & a == M && 1 & rand())) {
if (!f) {
if (k) {
c = i;
h = u;
y = x;
}
} else if (L - a < N) {
;
e = ~e;
u[l] = j;
x[l] = r;
return a;
}
M = a;
}
}
x[l] = r;
u[l] = j;
;
}
}
if (e &!(S & 24) | !e &!(S & 3) && !l[u - 2] &!l[u - 1] &!l[u - 3] &&
(S = 63, u[l] = 0, l[u] = 6 ^ e, q = 1e4 > main(0, 0, 0, 0),
l[u] = 0, u[l] = e ^ 6, S = b, q) &&
(S = 63, u[l] = 0, l[u - 1] = 6 ^ e, q = 1e4 > main(0, 0, 0, 0),
l[u - 1] = 0, u[l] = e ^ 6, S = b, q)) {
l[u - 1] = 4 ^ e;
l[u - 4] = 0;
{
if (r = l[x = u - 2], !r | (r ^ e) < -1) {
if (j = u[l], -7 == r | 6 == r) {
l[u - 1] = 0;
l[u - 4] = e ^ 4;
e = ~e;
return 1e5 - 443 * f;
}
u[l] = 0, t = j + 1, i = j - 1;
if (!i & 89 < x)
i = j, t = 6;
if (-1 == t & 30 > x)
t = j, i = -7;
while (++i < t) {
d = 0;
S &= 63;
a = ((j ^ e) != 1 ? 6 != (j ^ e)
? O[32 + x / 10] - O[u / 10 + 32] - q
: (S |= 6 != j ? 8 : 1, 2 == u - x) * 9 + 9 *(x - u == 2)
: (d = 1 == j ? x - u : u - x) / 8 +
!(!((x - u) % 10) | r) * 99 +
(j == 1 ? 90 < x : 29 > x) * (9 * O[28 + i] - 288)) +
O[r + 28] * 9 - 288 + O[x % 10 + 33] - f - O[33 + u % 10];
x[l] = i;
S |= (21 == u | 21 == x) * 2 + (u == 28 | 28 == x) * 4 +
(91 == u | x == 91) * 16 + 32 * (u == 98 | x == 98) +
(20 == d) * 64 * x;
a -= k > f ? main(a, f + 1, M, k) : 0;
if (i == c & u == h & !f & N & a > -1e4 & x == y)
longjmp(z, 1);
S = b;
if (!N | f && (a > M || !f & a == M && 1 & rand())) {
if (!f) {
if (k) {
c = i;
h = u;
y = x;
}
} else if (L - a < N) {
l[u - 1] = 0;
l[u - 4] = e ^ 4;
e = ~e;
u[l] = j;
x[l] = r;
return a;
}
M = a;
}
}
x[l] = r;
u[l] = j;
l[u - 1] = 0;
l[u - 4] = e ^ 4;
}
}
;
}
if (e &!(S & 40) | !e &!(S & 5) && !l[u + 1] &!l[2 + u] &&
(S = 63, u[l] = 0, l[u] = 6 ^ e, q = 1e4 > main(0, 0, 0, 0),
l[u] = 0, u[l] = e ^ 6, S = b, q) &&
(S = 63, u[l] = 0, l[1 + u] = 6 ^ e, q = 1e4 > main(0, 0, 0, 0),
l[1 + u] = 0, u[l] = e ^ 6, S = b, q)) {
l[u + 1] = e ^ 4;
l[3 + u] = 0;
{
if (r = l[x = u + 2], !r | (r ^ e) < -1) {
if (j = u[l], -7 == r | 6 == r) {
l[1 + u] = 0;
l[u + 3] = 4 ^ e;
e = ~e;
return 1e5 - 443 * f;
}
u[l] = 0, t = j + 1, i = j - 1;
if (!i & 89 < x)
i = j, t = 6;
if (-1 == t & 30 > x)
t = j, i = -7;
while (++i < t) {
d = 0;
S &= 63;
a = ((j ^ e) != 1 ? 6 != (j ^ e)
? O[32 + x / 10] - O[u / 10 + 32] - q
: (S |= 6 != j ? 8 : 1, 2 == u - x) * 9 + 9 *(x - u == 2)
: (d = 1 == j ? x - u : u - x) / 8 +
!(!((x - u) % 10) | r) * 99 +
(j == 1 ? 90 < x : 29 > x) * (9 * O[28 + i] - 288)) +
O[r + 28] * 9 - 288 + O[x % 10 + 33] - f - O[33 + u % 10];
x[l] = i;
S |= (21 == u | 21 == x) * 2 + (u == 28 | 28 == x) * 4 +
(91 == u | x == 91) * 16 + 32 * (u == 98 | x == 98) +
(20 == d) * 64 * x;
a -= k > f ? main(a, f + 1, M, k) : 0;
if (i == c & u == h & !f & N & a > -1e4 & x == y)
longjmp(z, 1);
S = b;
if (!N | f && (a > M || !f & a == M && 1 & rand())) {
if (!f) {
if (k) {
c = i;
h = u;
y = x;
}
} else if (L - a < N) {
l[1 + u] = 0;
l[u + 3] = 4 ^ e;
e = ~e;
u[l] = j;
x[l] = r;
return a;
}
M = a;
}
}
x[l] = r;
u[l] = j;
l[1 + u] = 0;
l[u + 3] = 4 ^ e;
}
}
;
}
}
}
e = ~e;
return M;
}
while (h < 130) {
l[h] = -(21 > h | 98 < h | 2 > (h + 1) % 10);
O[h++] ^= 3;
}
n = O + 14;
s = 20 + l;
while (++s < 29 + l) {
10 [s] = 1;
70 [s] = ~(*s = *n++ - +84);
60 [s] = -2;
}
while (n = J) {
puts(58 + O);
u = 19;
while (++u < 100) {
*n++ = 32;
if (!(u % 10))
*n++ = 32;
*n++ = O[7 + l[u]];
if ((9 + u) % 10 > 7) {
*n++ = 58 - u / 10;
*n++ = 32;
if (u & 1)
puts(n = J);
}
}
puts(O + 58);
if (-1e4 > main(0, 0, 0, 1)) {
e = ~e;
puts(O + (main(0, 0, 0, 0) > 1e4 ? e ? 90 : 82 : 96));
break;
}
if (1 < L & e) {
d = main(0, 0, 0, 2 + L);
printf(O + 114, h % 10 + 64, 58 - h / 10, y % 10 + 64, 58 - y / 10, d);
} else {
putchar(62 + e);
h = (95 & getchar()) - 44;
c = l[h += (56 - getchar()) * 10];
y = (95 & getchar()) - 44;
y += (56 - getchar()) * 10;
while (10 != (u = (95 & getchar()))) {
c = 5;
while (--c > 1 && u != c[O])
;
c = e ^ c - 7;
}
}
if (!setjmp(z)) {
main(0, 0, 0 + 1, 1);
puts(106 + O);
}
}
while (10 != getchar())
;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.