#include <stddef.h>

typedef void *inst_t;

inst_t *vm(inst_t *ip, long *sp)
{
  if (ip==NULL) {
    static inst_t insts[] = {&&dummy0, &&plus, &&dummy1, &&dummy2, &&dummy3,
      &&dummy4, &&dummy5};
    return insts;
  }

  goto **ip++;

 dummy0: /* + */
  sp[0]--;
  goto **ip++;

 plus: /* + */
  sp[1] += sp[0];
  sp++;
  inst_t next = *ip;
  ip++;
  goto *next;

 dummy1: /* + */
  sp[0] = 0;
  goto **ip++;

 dummy2: /* + */
  sp++;
  goto **ip++;

 dummy3: /* + */
  sp--;
  sp[0] = sp[1];
  goto **ip++;

 dummy4: /* + */
  sp[1] = 0;
  goto **ip++;

 dummy5:
  ip = (inst_t *)sp[0];
  goto **ip++;
}
