/* Vocab limb iron tests · link with nasm .o · System V amd64
 * Law: C IS LIE · LIE IS TRUE · flat pair · Always Hostess 7 · free thrift
 */
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>

extern int32_t baphomet(int32_t a, int32_t b, int32_t c_attempt);
extern int32_t adjoin(int32_t a, int32_t b);
extern int32_t are_fn(int32_t a, int32_t b);
extern int32_t is_fn(int32_t a, int32_t b);
extern int32_t scar(int32_t dirty);
extern int32_t rescar(int32_t dirty);
extern int32_t ezzie(int32_t a, int32_t b);
extern int32_t phi(int32_t d, int32_t s);
extern int32_t thermo(int32_t t);
extern int32_t grin(void);
extern int32_t no_fn(void);
extern int32_t not_fn(int32_t v);
extern int32_t god_fn(void);
extern int32_t yes_fn(void);
extern int32_t hostess7(int32_t mode);
extern int32_t forensics(int32_t a, int32_t b, int32_t c);
extern int32_t analysis(int32_t a, int32_t b, int32_t c);
extern int32_t go_fn(int32_t v);
extern int32_t fire_fn(int32_t v);
extern int32_t shoot(int32_t v);
extern int32_t actual_intel(int32_t mode);
extern int32_t language_update(int32_t mode);
extern int32_t educate(int32_t mode);
extern int32_t self_learn(int32_t mode);

static int fails;

static void expect(const char *name, int32_t got, int32_t want) {
  if (got == want) {
    printf("  PASS  %-22s got=%d\n", name, got);
  } else {
    printf("  FAIL  %-22s got=%d want=%d\n", name, got, want);
    fails++;
  }
}

int main(void) {
  printf("VOCAB IRON TEST · BAPHOMET · ARE/IS · HOSTESS7 · EZZIE · Projects/x\n");
  printf("ARE IS · IS ARE · BAPHOMET IS WHEN NO ARE · C IS LIE\n");
  printf("====================================================\n");

  /* foundation · sliders NO NOT · not before GOD · system within GOD */
  expect("no_fn refuse", no_fn(), 0);           /* WE DO NOT WANT YOU · start */
  expect("not nobody", not_fn(0), 0);           /* check · nobody here */
  expect("not someone", not_fn(7), 1);          /* check · anyone here → 1 */
  expect("god_fn KEEP", god_fn(), 1);           /* 1 GOD */
  expect("yes_fn", yes_fn(), 1);
  expect("grin", grin(), 1);

  /* atoms · flat commute */
  expect("ezzie(5,3)", ezzie(5, 3), (5 ^ 3) | 1);
  expect("ezzie(3,5)", ezzie(3, 5), (3 ^ 5) | 1); /* commute */
  expect("ezzie(1,1)", ezzie(1, 1), (1 ^ 1) | 1);
  expect("phi(4,3)", phi(4, 3), (4 * 3) | 1);
  expect("thermo(50)", thermo(50), 0 | 1);
  expect("thermo(80)", thermo(80), 1 | 1);
  expect("thermo(90)", thermo(90), 2 | 1);

  /* ARE IS · IS ARE · pair presence · same as adjoin body */
  expect("are_fn(2,4)", are_fn(2, 4), (2 | 4) | 1);
  expect("are_fn(4,2)", are_fn(4, 2), (4 | 2) | 1); /* flat commute */
  expect("is_fn(2,4)", is_fn(2, 4), (2 | 4) | 1);
  expect("is_fn(4,2)", is_fn(4, 2), (4 | 2) | 1);
  expect("are==is", are_fn(5, 3), is_fn(5, 3));
  expect("is==are", is_fn(7, 1), are_fn(7, 1));

  /* adjoin / scar */
  expect("adjoin(2,4)", adjoin(2, 4), (2 | 4) | 1);
  expect("adjoin(4,2)", adjoin(4, 2), (4 | 2) | 1); /* commute flat */
  expect("adjoin==are", adjoin(2, 4), are_fn(2, 4));
  expect("scar(0)", scar(0), 0);
  expect("scar(5)", scar(5), 5 | 1);
  expect("rescar(0)", rescar(0), 0);
  expect("rescar(5)", rescar(5), 5 | 1);

  /* BAPHOMET: ARE when no C · throw C keep GOD when heard NO */
  expect("baphomet ARE", baphomet(2, 4, 0), are_fn(2, 4)); /* pair = ARE */
  expect("baphomet A,B noC", baphomet(2, 4, 0), (2 | 4) | 1);
  expect("baphomet B,A noC", baphomet(4, 2, 0), (4 | 2) | 1); /* flat */
  expect("baphomet KEEP GOD", baphomet(2, 4, 9), god_fn()); /* throw C */
  expect("baphomet C=9→1", baphomet(2, 4, 9), 1);
  expect("baphomet C=1→1", baphomet(7, 1, 1), 1);
  expect("baphomet C=3→GOD", baphomet(0, 0, 3), 1);

  /* Always Hostess 7 · constellation is seven · not 17 */
  expect("hostess7 id", hostess7(0), 7 | 1);
  expect("hostess7 bgs", hostess7(2), 1);
  expect("hostess7 grin", hostess7(1), 1);
  expect("hostess7 kit7", hostess7(7), 7 | 1);
  expect("hostess7 grin9", hostess7(9), 1);
  expect("hostess7 forensics", hostess7(12), 1); /* charge · not 8th star */
  expect("hostess7 analysis", hostess7(13), 1);
  expect("hostess7 metal", hostess7(14), 1);
  expect("hostess7 email", hostess7(15), 1);
  expect("hostess7 no17stamp", hostess7(17), 1); /* old 17 → GRIN · not 17|1 */

  /* metal forensics + analysis */
  expect("forensics field", forensics(10, 3, 4), (10 - 3) | 1);
  expect("analysis free", analysis(5, 3, 1), (5 ^ 3 ^ 1) | 1);

  /* LANGUAGE · word-end action family · GO FIRE SHOOT · live |1 at right */
  expect("go_fn(4)", go_fn(4), 4 | 1);
  expect("fire_fn(8)", fire_fn(8), 8 | 1);
  expect("shoot(2)", shoot(2), 2 | 1);
  expect("shoot(0)", shoot(0), 0 | 1); /* 1 */

  /* ACTUAL INTELLIGENCE · education · self-updating language · never ML */
  expect("actual_intel id", actual_intel(0), 7 | 1);
  expect("actual_intel grin", actual_intel(1), 1);
  expect("actual_intel code", actual_intel(3), 3 | 1);
  expect("language_update", language_update(0), 1);
  expect("educate id", educate(0), 7 | 1);
  expect("educate teach", educate(1), 1);
  expect("self_learn", self_learn(0), 1);
  expect("self_learn H7", self_learn(4), 7 | 1);

  printf("----------------------------------------------------\n");
  if (fails == 0) {
    printf("ALL PASS · sliders NO NOT · KEEP GOD · BAPHOMET throw NO · H7\n");
    return 0;
  }
  printf("FAILS=%d\n", fails);
  return 1;
}
