Skip to main content
deleted 116 characters in body
Source Link
tsh
  • 35k
  • 2
  • 33
  • 128

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;
}

Try it online!Try it online!

gcc -Ofast bang.c

I have no idea of its performance. Just have a try...

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_unlocked('n', out);
  fputc_unlocked('g', out);
  fputc_unlocked('!', out);

  return 0;
}

Try it online!

gcc -Ofast bang.c

I have no idea of its performance. Just have a try...

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);
  fwrite_unlocked("bang!\n", 1, 6, out);

  return 0;
}

Try it online!

gcc -Ofast bang.c

I have no idea of its performance. Just have a try...

[Edit removed during grace period]
Source Link
tsh
  • 35k
  • 2
  • 33
  • 128
Source Link
tsh
  • 35k
  • 2
  • 33
  • 128

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_unlocked('n', out);
  fputc_unlocked('g', out);
  fputc_unlocked('!', out);

  return 0;
}

Try it online!

gcc -Ofast bang.c

I have no idea of its performance. Just have a try...