// SDB-CGEN V2.6.2
#include <ctype.h>
#include <stdio.h>
#include <string.h>

struct kv { const char *name; const char *value; };
static const struct kv kvs[] = {
// gcc -DMAIN=1 snes.c ; ./a.out > snes.h
	{"adc", "add with carry"},
	{"and", "bitwise AND"},
	{"asl", "arithmetic shift left"},
	{"bcc", "branch on carry clear"},
	{"bcs", "branch on carry set"},
	{"beq", "branch if equal (zero)"},
	{"bit", "test bits"},
	{"bmi", "branch if minus (negative)"},
	{"bne", "branch if not equal"},
	{"bpl", "branch if plus (not negative)"},
	{"brk", "break / software interrupt"},
	{"bvc", "branch if overflow clear"},
	{"bvs", "branch if overflow set"},
	{"clc", "clear carry"},
	{"cld", "clear decimal"},
	{"cli", "clear interrupt disable"},
	{"clv", "clear overflow"},
	{"cmp", "compare"},
	{"cpa", "compare accumulator"},
	{"cpx", "compare X register"},
	{"cpy", "compare Y register"},
	{"dec", "decrement memory"},
	{"dex", "decrement X register"},
	{"dey", "decrement Y register"},
	{"eor", "exclusive OR"},
	{"inc", "increment memory"},
	{"invalid", "invalid instruction"},
	{"inx", "increment X register"},
	{"iny", "increment Y register"},
	{"jmp", "jump"},
	{"jsr", "jump to subroutine"},
	{"lda", "load accumulator"},
	{"ldx", "load X register"},
	{"ldy", "load Y register"},
	{"lsr", "logical shift right"},
	{"mvn", "move negative (block transfer)"},
	{"mvp", "move positive (block transfer)"},
	{"nop", "no operation"},
	{"ora", "bitwise OR (accumulator)"},
	{"pha", "push accumulator"},
	{"phb", "push B register"},
	{"phk", "push program bank"},
	{"php", "push processor status"},
	{"phx", "push X register"},
	{"phy", "push Y register"},
	{"pla", "pull accumulator (pop)"},
	{"plb", "pull B register (pop)"},
	{"plp", "pull processor status (pop)"},
	{"plx", "pull X register"},
	{"ply", "pull Y register"},
	{"rep", "reset processor status bits (clear flags)"},
	{"rol", "rotate left"},
	{"ror", "rotate right"},
	{"rti", "return from interrupt"},
	{"rts", "return from subroutine"},
	{"sbc", "subtract with carry"},
	{"sei", "set interrupt disable"},
	{"sep", "set processor status bits"},
	{"sta", "store accumulator"},
	{"stx", "store X register"},
	{"sty", "store Y register"},
	{"stz", "store zero"},
	{"tax", "transfer A to X"},
	{"tay", "transfer A to Y"},
	{"txa", "transfer X to A"},
	{"txs", "transfer X to S"},
	{"tya", "transfer Y to A"},
	{"xba", "swap B and A (byte swap)"},
  {NULL, NULL}
};
typedef int (*GperfForeachCallback)(void *user, const char *k, const char *v);
int gperf_snes_foreach(GperfForeachCallback cb, void *user) {
  int i = 0; while (kvs[i].name) {
  cb (user, kvs[i].name, kvs[i].value);
  i++;}
  return 0;
}
const char *gperf_snes_get(const char *s) {
  int i = 0; while (kvs[i].name) {
  if (!strcmp (s, kvs[i].name)) return kvs[i].value;
  i++;}
  return NULL;
}
#define sdb_hash_c_snes(x,y) gperf_snes_hash(x)
const unsigned int gperf_snes_hash(const char *s) {
  int sum = strlen (s);
  while (*s) { sum += *s; s++; }
  return sum;
}
struct {const char *name;void *get;void *hash;void *foreach;} gperf_snes = {
  .name = "snes",
  .get = &gperf_snes_get,
  .hash = &gperf_snes_hash,
  .foreach = &gperf_snes_foreach
};

#if MAIN
int main () {
	const char *s = ((char*(*)(char*))gperf_snes.get)("foo");
	printf ("%s\n", s);
}
#endif
