C (gcc)
#include <stdio.h>
int main() {
FILE* const in = stdin;
FILE* const out = stdout;
char c = 0;
#define is_or(t, l) \
c = fgetc_unlocked(in); \
if (__builtin_expect(c != t, 0)) goto l
x:
if (__builtin_expect(c == 'd', 1)) goto r;
d:
is_or('d', d);
r:
is_or('r', x);
is_or('a', x);
is_or('w', x);
is_or('!', x);
fputc_unlocked('b', out);
fputc_unlocked('a', out);
fputc_unlockedfwrite_unlocked('n'"bang!\n", out);
fputc_unlocked('g'1, out);
fputc_unlocked('!'6, out);
return 0;
}
gcc -Ofast bang.c
I have no idea of its performance. Just have a try...