#include <stdlib.h>
#include <string.h>
struct cell {
int c, d;
void *label;
};
size_t width(const char *s) {
register const char *p;
for (p = s; *p && *p == *s; p++) {}
return p - s;
}
size_t nop_width(const char *s) {
const char *p;
for (p = s; *p; p++) {
if (*p == '>' || *p == '<' || *p == '+' || *p == '-') break;
if (*p == '.' || *p == ',' || *p == '[' || *p == ']') break;
}
return p - s;
}
struct cell *find_square_bracket_right(struct cell *p) {
int depth = 0;
for (; p->c; p++) {
if (p->c == '[') depth++;
else if (p->c == ']') {
if (depth == 0) break;
else depth--;
}
}
return p;
}
struct cell *init_square_brackets(struct cell *b) {
struct cell *p, *q;
for (p = b; p->c; p++) {
if (p->c == '[') {
q = find_square_bracket_right(p + 1);
p->d = q - p + 1;
q->d = - (q - p) + 1;
}
}
return b;
}
struct cell *reject_d0(struct cell *cells) {
register struct cell *p, *q;
for (p = cells; p->c && p->d; p++) {}
for (q = p; p->c; p++) {
if (p->d == 0) continue;
for (; q->c; q++) {
if (q->d != 0) continue;
*q++ = *p;
p->d = 0;
break;
}
}
q->c = '\0';
q->d = 0;
return cells;
}
struct cell *optimize_flat_loop(struct cell *cells) {
register struct cell *p, *a, *b, *c, *d, *e, *f, *g;
for (p = cells; p->c; p++) {
if (p->c != '[') continue;
a = p + 1, b = p + 2;
if (a->c == '>' && b->c == ']') {
p->c = 'G';
p->d = a->d;
a->d = b->d = 0;
p += 3;
continue;
}
if (!(a->c == '+' && a->d == -1)) continue;
c = p + 3, d = p + 4, e = p + 5, f = p + 6, g = p + 7;
if (b->c == ']') {
p->c = 'H';
p->d = 1;
a->d = b->d = 0;
p += 2;
} else if (b->c == '>' && c->c == '+' && d->c == '>' && e->c == ']'
&& abs(c
->d
) == 1 && b
->d
+ d
->d
== 0) { p->c = 0 < c->d ? 'I' : 'J';
p->d = b->d;
a->c = 'H';
a->d = 1;
b->d = c->d = d->d = e->d = 0;
p += 5;
} else if (b->c == '>' && c->c == '+' && d->c == '>' && e->c == '+' && f->c == '>' && g->c == ']'
&& abs(c
->d
) == 1 && abs(e
->d
) == 1 && b
->d
+ d
->d
+ f
->d
== 0) { p->c = 0 < c->d ? 'I' : 'J';
p->d = b->d;
a->c = 0 < e->d ? 'I' : 'J';
a->d = b->d + d->d;
b->c = 'H';
b->d = 1;
c->d = d->d = e->d = f->d = g->d = 0;
p += 7;
}
}
return reject_d0(cells);
}
struct cell *scan(const char *s) {
struct cell
*cells
= malloc(sizeof (struct cell
) * (strlen(s
) + 1)), *p
; for (p = cells; *s; ) {
switch (p->c = *s) {
case '>': case '+': p->d = width(s), s += p->d, p++; break;
case '<': p->c = '>', p->d = -width(s), s -= p->d, p++; break;
case '-': p->c = '+', p->d = -width(s), s -= p->d, p++; break;
case '.': case ',': case '[': case ']': p->d = 1; s++, p++; break;
default: s += nop_width(s); break;
}
}
p->c = '\0';
p->d = 0;
return init_square_brackets(optimize_flat_loop(cells));
}
struct cell *f(struct cell *ip0, register char *dp) {
register struct cell *ip;
for (ip = ip0; ip->c; ip++) {
switch (ip->c) {
case '>': ip->label = &&A; break;
case '+': ip->label = &&B; break;
case '.': ip->label = &&C; break;
case ',': ip->label = &&D; break;
case '[': ip->label = &&E; break;
case ']': ip->label = &&F; break;
case 'G': ip->label = &&G; break;
case 'H': ip->label = &&H; break;
case 'I': ip->label = &&I; break;
case 'J': ip->label = &&J; break;
default: ip->label = &&Z; break;
}
}
ip->label = &&RETURN;
ip = ip0;
TOP: goto *ip->label;
A: dp += ip->d; ip++; goto TOP;
B: *dp += ip->d; ip++; goto TOP;
D
: *dp
= getchar(); ip
++; goto TOP
; E: *dp ? ip++ : (ip += ip->d); goto TOP;
F: *dp ? (ip += ip->d) : ip++; goto TOP;
G: while (*dp) dp += ip->d; ip++; goto TOP;
H: *dp = 0; ip++; goto TOP;
I: *(dp + ip->d) += *dp; ip++; goto TOP;
J: *(dp + ip->d) -= *dp; ip++; goto TOP;
Z: ip++; goto TOP;
RETURN: return ip0;
}
void g(const char *s) {
char data[30000] = {0};
}
int main() {
char *s =
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