#include <stddef.h>

typedef void *inst_t;

inst_t *vm(inst_t *ip, long *sp, inst_t **rp)
{
  inst_t next;
  if (ip==NULL) {
    static inst_t insts[] = {&&plus, &&plus_end, &&semis, &&call, };
    return insts;
  }

  goto **ip++;

 plus: /* + */
  ip++;
  sp[1] += sp[0];
  sp++;
 plus_end:
  asm("# plus_end");
  asm("# plus_end");
  asm("# plus_end");
  asm("# plus_end");
  asm("# plus_end");
  asm("# plus_end");
  asm("# plus_end");
  asm("# plus_end");
  asm("# plus_end");
  next = ip[-1];
  goto *next;

 semis: /* ;s */
  ip = *rp;
  rp++;
  next = *ip;
  ip++;
  goto *next;

 call:
  *--rp = ip+2;
  ip = (inst_t *)ip[1];
  next = *ip;
  goto *next;

}
