Skip to content

Instantly share code, notes, and snippets.

@wrl
Last active October 12, 2018 00:05
Show Gist options
  • Save wrl/a2d0d043dc33bdb96c9c04005acf20ee to your computer and use it in GitHub Desktop.
Save wrl/a2d0d043dc33bdb96c9c04005acf20ee to your computer and use it in GitHub Desktop.
#include <stdio.h>
int
main(int argc, char **argv)
{
int i;
void *jump[] = {
[0] = &&printn,
[1] = &&fizz,
[2] = &&buzz,
[3] = &&fizzbuzz,
[4 ... 7] = &&done
};
#define NEXT do { \
i++; \
\
goto *jump[( \
(!(i % 3)) \
| ((!(i % 5)) << 1) \
| ((i > 100) << 2) \
)]; \
} while (0)
i = 0;
printn:
printf("%d\n", i);
NEXT;
fizz:
puts("fizz");
NEXT;
buzz:
puts("buzz");
NEXT;
fizzbuzz:
puts("fizzbuzz");
NEXT;
done:
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment