/* imp_runtime.c */
#include <stdio.h>
#include <stdlib.h>

extern void NDIAG(int PC, int LNB, int p3, int p4);
extern void STOP(void);
extern int  IOCP(int ep, int n);

extern void s_ndiag(int PC, int LNB, int p3, int p4) asm("_s_ndiag");
extern void s_stop(void) asm("_s_stop");
extern int  s_iocp(int ep, int n) asm("_s_iocp");

static int debug = 0;

void s_ndiag(int PC, int LNB, int p3, int p4) {
  if (debug)
    fprintf(
      stderr,
      "s_ndiag called: PC=%d LNB=%d p3=%d p4=%d\n",
      PC, LNB, p3, p4);
  NDIAG(PC, LNB, p3, p4);
  abort();
  exit(1);
}

void s_stop(void) {
  STOP();
  exit(0);
}

int s_iocp(int ep, int n) {
  if (debug) fprintf(stderr, "s_iocp called: ep=%d n=%d\n", ep, n);
  return IOCP(ep, n);
}
