diff --git a/.gitattributes b/.gitattributes
index 2751d1e393de484de4ca7fe8124c1f789489c7f4..9cb60e9cc2e61225457e0705e2c4670e98625ac7 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -327,6 +327,21 @@ tests/coreutils/Makefile -text
 tests/coreutils/bzip2_manual_tests.sh -text
 tests/coreutils/cat_manual_tests.sh -text
 tests/coreutils/ls_manual_tests.sh -text
+tests/simple/Makefile -text
+tests/simple/banner_O3.exe -text
+tests/simple/banner_nop.exe -text
+tests/simple/banner_test.sh -text
+tests/simple/cal_O3.exe -text
+tests/simple/cal_nop.exe -text
+tests/simple/cal_test.sh -text
+tests/simple/dumbledore_cmd_O3.exe -text
+tests/simple/dumbledore_cmd_nop.exe -text
+tests/simple/dumbledore_test.sh -text
+tests/simple/jack_tests/banner.c -text
+tests/simple/jack_tests/cal.c -text
+tests/simple/jack_tests/grep.c -text
+tests/simple/jack_tests/k1.c -text
+tests/simple/jack_tests/od.c -text
 tools/Makefile -text
 tools/cover/Makefile -text
 tools/cover/cover.cpp -text
diff --git a/tests/simple/Makefile b/tests/simple/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..7316b2aff6d4a4f3366c77192741fbf10ead21d6
--- /dev/null
+++ b/tests/simple/Makefile
@@ -0,0 +1,63 @@
+progs=discrete_xform.peasoup integration_simp.peasoup sieve.peasoup knapsack.peasoup dumbledore_cmd_nop.peasoup dumbledore_cmd_O3.peasoup quick_sort.peasoup hanoi.peasoup merge_sort.peasoup k1.peasoup banner_nop.peasoup banner_O3.peasoup cal_nop.peasoup cal_O3.peasoup
+
+ps_analyze_flags="--step ilr=off --step integertransform=off --step manual_test=on --step concolic=off --step isr=off"
+
+ps_analyze_concolic_flags="--step ilr=off --step integertransform=off --step manual_test=off --step concolic=on --step isr=off"
+
+discrete_xform.peasoup:
+	${PEASOUP_HOME}/tools/ps_analyze.sh ${SECURITY_TRANSFORMS_HOME}/tests/simple/discrete_fourier_transform.exe discrete_xform.peasoup ${ps_analyze_flags} --manual_test_script ${SECURITY_TRANSFORMS_HOME}/tests/simple/discrete_xform_test.sh
+
+integration_simp.peasoup:
+	${PEASOUP_HOME}/tools/ps_analyze.sh ${SECURITY_TRANSFORMS_HOME}/tests/simple/integration_simp.exe integration_simp.peasoup ${ps_analyze_flags} --manual_test_script ${SECURITY_TRANSFORMS_HOME}/tests/simple/integration_simp_test.sh
+
+sieve.peasoup:
+	${PEASOUP_HOME}/tools/ps_analyze.sh ${SECURITY_TRANSFORMS_HOME}/tests/simple/sieve.exe sieve.peasoup ${ps_analyze_flags} --manual_test_script ${SECURITY_TRANSFORMS_HOME}/tests/simple/sieve_test.sh
+
+knapsack.peasoup:
+	${PEASOUP_HOME}/tools/ps_analyze.sh ${SECURITY_TRANSFORMS_HOME}/tests/simple/knapsack_problem.exe knapsack.peasoup ${ps_analyze_flags} --manual_test_script ${SECURITY_TRANSFORMS_HOME}/tests/simple/knapsack_test.sh
+
+dumbledore_cmd_nop.peasoup:
+	${PEASOUP_HOME}/tools/ps_analyze.sh ${SECURITY_TRANSFORMS_HOME}/tests/simple/dumbledore_cmd_nop.exe dumbledore_cmd_nop.peasoup ${ps_analyze_flags} --manual_test_script ${SECURITY_TRANSFORMS_HOME}/tests/simple/dumbledore_test.sh
+
+dumbledore_cmd_O3.peasoup:
+	${PEASOUP_HOME}/tools/ps_analyze.sh ${SECURITY_TRANSFORMS_HOME}/tests/simple/dumbledore_cmd_O3.exe dumbledore_cmd_O3.peasoup ${ps_analyze_flags} --manual_test_script ${SECURITY_TRANSFORMS_HOME}/tests/simple/dumbledore_test.sh
+
+dumbledore_cmd_O3_concolic.peasoup:
+	${PEASOUP_HOME}/tools/ps_analyze.sh ${SECURITY_TRANSFORMS_HOME}/tests/simple/dumbledore_cmd_O3.exe dumbledore_cmd_O3.peasoup ${ps_analyze_concolic_flags} 
+
+quick_sort.peasoup:
+	${PEASOUP_HOME}/tools/ps_analyze.sh ${SECURITY_TRANSFORMS_HOME}/tests/simple/quick_sort.exe quick_sort.peasoup ${ps_analyze_flags} --manual_test_script ${SECURITY_TRANSFORMS_HOME}/tests/simple/quick_sort_test.sh
+
+hanoi.peasoup:
+	${PEASOUP_HOME}/tools/ps_analyze.sh ${SECURITY_TRANSFORMS_HOME}/tests/simple/hanoi.exe hanoi.peasoup ${ps_analyze_flags} --manual_test_script ${SECURITY_TRANSFORMS_HOME}/tests/simple/hanoi_test.sh
+
+merge_sort.peasoup:
+	${PEASOUP_HOME}/tools/ps_analyze.sh ${SECURITY_TRANSFORMS_HOME}/tests/simple/merge_sort.exe merge_sort.peasoup ${ps_analyze_flags} --manual_test_script ${SECURITY_TRANSFORMS_HOME}/tests/simple/merge_sort_test.sh
+
+k1.peasoup:
+	${PEASOUP_HOME}/tools/ps_analyze.sh ${SECURITY_TRANSFORMS_HOME}/tests/simple/k1.exe k1.peasoup ${ps_analyze_flags} --manual_test_script ${SECURITY_TRANSFORMS_HOME}/tests/simple/k1_test.sh
+
+banner_nop.peasoup:
+	${PEASOUP_HOME}/tools/ps_analyze.sh ${SECURITY_TRANSFORMS_HOME}/tests/simple/banner_nop.exe banner_nop.peasoup ${ps_analyze_flags} --manual_test_script ${SECURITY_TRANSFORMS_HOME}/tests/simple/banner_test.sh
+
+banner_O3.peasoup:
+	${PEASOUP_HOME}/tools/ps_analyze.sh ${SECURITY_TRANSFORMS_HOME}/tests/simple/banner_O3.exe banner_O3.peasoup ${ps_analyze_flags} --manual_test_script ${SECURITY_TRANSFORMS_HOME}/tests/simple/banner_test.sh
+
+cal_O3.peasoup:
+	${PEASOUP_HOME}/tools/ps_analyze.sh ${SECURITY_TRANSFORMS_HOME}/tests/simple/cal_O3.exe cal_O3.peasoup ${ps_analyze_flags} --manual_test_script ${SECURITY_TRANSFORMS_HOME}/tests/simple/cal_test.sh
+
+cal_O3_concolic.peasoup:
+	${PEASOUP_HOME}/tools/ps_analyze.sh ${SECURITY_TRANSFORMS_HOME}/tests/simple/cal_O3.exe cal_O3_concolic.peasoup ${ps_analyze_concolic_flags}
+
+
+cal_nop.peasoup:
+	${PEASOUP_HOME}/tools/ps_analyze.sh ${SECURITY_TRANSFORMS_HOME}/tests/simple/cal_nop.exe cal_nop.peasoup ${ps_analyze_flags} --manual_test_script ${SECURITY_TRANSFORMS_HOME}/tests/simple/cal_test.sh
+
+
+
+
+clean:
+	rm -f ${progs}
+	rm -Rf peasoup_executable_directory.*
+	${PEASOUP_HOME}/tools/db/drop_my_tables.sh
+	${PEASOUP_HOME}/tools/db/pdb_setup.sh
\ No newline at end of file
diff --git a/tests/simple/banner_O3.exe b/tests/simple/banner_O3.exe
new file mode 100755
index 0000000000000000000000000000000000000000..8bda73c386f1d556a5039009e9195fb53dd6182c
Binary files /dev/null and b/tests/simple/banner_O3.exe differ
diff --git a/tests/simple/banner_nop.exe b/tests/simple/banner_nop.exe
new file mode 100755
index 0000000000000000000000000000000000000000..2dd6f18cc49d78af7569605541293efaaec56eb5
Binary files /dev/null and b/tests/simple/banner_nop.exe differ
diff --git a/tests/simple/banner_test.sh b/tests/simple/banner_test.sh
new file mode 100644
index 0000000000000000000000000000000000000000..5c69984a1610fcfd6185829dcc9cdc650c5b3be6
--- /dev/null
+++ b/tests/simple/banner_test.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/banner_nop.exe hello > outputfile1
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./banner.exe hello > outputfile1" --prog banner.exe  --outfile outputfile1 --name hello
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/banner_nop.exe 12345 > outputfile1
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./banner.exe 12345 > outputfile1" --prog banner.exe  --outfile outputfile1 --name numbers
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/banner_nop.exe Hello World 1234 > outputfile1
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./banner.exe Hello World 1234 > outputfile1" --prog banner.exe  --outfile outputfile1 --name HelloWorld1234
\ No newline at end of file
diff --git a/tests/simple/cal_O3.exe b/tests/simple/cal_O3.exe
new file mode 100755
index 0000000000000000000000000000000000000000..d6e0ea1762a7fde37733683cc42e6478f0aa8e91
Binary files /dev/null and b/tests/simple/cal_O3.exe differ
diff --git a/tests/simple/cal_nop.exe b/tests/simple/cal_nop.exe
new file mode 100755
index 0000000000000000000000000000000000000000..780f7dc3b7e04e2e8a62572005d78318e1265369
Binary files /dev/null and b/tests/simple/cal_nop.exe differ
diff --git a/tests/simple/cal_test.sh b/tests/simple/cal_test.sh
new file mode 100644
index 0000000000000000000000000000000000000000..1bc6e58c6c5944caabfbe9df2d42935bd61e27d8
--- /dev/null
+++ b/tests/simple/cal_test.sh
@@ -0,0 +1,107 @@
+#!/bin/sh
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/cal_nop.exe > outputfile1
+exitcode=$?
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./cal_nop.exe > outputfile1" --prog cal_nop.exe  --outfile outputfile1 --name NoInput --exitcode $exitcode
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/cal_nop.exe 999999 > outputfile1
+exitcode=$?
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./cal_nop.exe 999999 > outputfile1" --prog cal_nop.exe  --outfile outputfile1 --name BadYear1 --exitcode $exitcode
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/cal_nop.exe 0 > outputfile1
+exitcode=$?
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./cal_nop.exe 0 > outputfile1" --prog cal_nop.exe  --outfile outputfile1 --name BadYear2 --exitcode $exitcode
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/cal_nop.exe 0 2011 > outputfile1
+exitcode=$?
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./cal_nop.exe 0 2011 > outputfile1" --prog cal_nop.exe  --outfile outputfile1 --name BadMonth1 --exitcode $exitcode
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/cal_nop.exe 13 2011 > outputfile1
+exitcode=$?
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./cal_nop.exe 13 2011 > outputfile1" --prog cal_nop.exe  --outfile outputfile1 --name BadMonth2 --exitcode $exitcode
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/cal_nop.exe 13 0 > outputfile1
+exitcode=$?
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./cal_nop.exe 13 0 > outputfile1" --prog cal_nop.exe  --outfile outputfile1 --name BadYearMonth1 --exitcode $exitcode
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/cal_nop.exe 0 999999 > outputfile1
+exitcode=$?
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./cal_nop.exe 0 999999 > outputfile1" --prog cal_nop.exe  --outfile outputfile1 --name BadYearMonth2 --exitcode $exitcode
+
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/cal_nop.exe 2011 > outputfile1
+exitcode=$?
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./cal_nop.exe 2011 > outputfile1" --prog cal_nop.exe  --outfile outputfile1 --name Year2001 --exitcode $exitcode
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/cal_nop.exe 1500 > outputfile1
+exitcode=$?
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./cal_nop.exe 1500 > outputfile1" --prog cal_nop.exe  --outfile outputfile1 --name Year1500 --exitcode $exitcode
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/cal_nop.exe 1 > outputfile1
+exitcode=$?
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./cal_nop.exe 1 > outputfile1" --prog cal_nop.exe  --outfile outputfile1 --name Year1 --exitcode $exitcode
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/cal_nop.exe 2000 > outputfile1
+exitcode=$?
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./cal_nop.exe 2000 > outputfile1" --prog cal_nop.exe  --outfile outputfile1 --name LeapYear2000 --exitcode $exitcode
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/cal_nop.exe 1804 > outputfile1
+exitcode=$?
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./cal_nop.exe 1804 > outputfile1" --prog cal_nop.exe  --outfile outputfile1 --name LeapYear1804 --exitcode $exitcode
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/cal_nop.exe 1 2011 > outputfile1
+exitcode=$?
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./cal_nop.exe 1 2011 > outputfile1" --prog cal_nop.exe  --outfile outputfile1 --name Jan2011 --exitcode $exitcode
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/cal_nop.exe 2 2011 > outputfile1
+exitcode=$?
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./cal_nop.exe 2 2011 > outputfile1" --prog cal_nop.exe  --outfile outputfile1 --name Feb2011 --exitcode $exitcode
+
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/cal_nop.exe 3 2011 > outputfile1
+exitcode=$?
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./cal_nop.exe 3 2011 > outputfile1" --prog cal_nop.exe  --outfile outputfile1 --name March2011 --exitcode $exitcode
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/cal_nop.exe 4 2011 > outputfile1
+exitcode=$?
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./cal_nop.exe 4 2011 > outputfile1" --prog cal_nop.exe  --outfile outputfile1 --name April2011 --exitcode $exitcode
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/cal_nop.exe 5 2011 > outputfile1
+exitcode=$?
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./cal_nop.exe 5 2011 > outputfile1" --prog cal_nop.exe  --outfile outputfile1 --name May2011 --exitcode $exitcode
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/cal_nop.exe 6 2011 > outputfile1
+exitcode=$?
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./cal_nop.exe 6 2011 > outputfile1" --prog cal_nop.exe  --outfile outputfile1 --name June2011 --exitcode $exitcode
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/cal_nop.exe 7 2011 > outputfile1
+exitcode=$?
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./cal_nop.exe 7 2011 > outputfile1" --prog cal_nop.exe  --outfile outputfile1 --name July2011 --exitcode $exitcode
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/cal_nop.exe 8 2011 > outputfile1
+exitcode=$?
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./cal_nop.exe 8 2011 > outputfile1" --prog cal_nop.exe  --outfile outputfile1 --name August2011 --exitcode $exitcode
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/cal_nop.exe 9 2011 > outputfile1
+exitcode=$?
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./cal_nop.exe 9 2011 > outputfile1" --prog cal_nop.exe  --outfile outputfile1 --name Sept2011 --exitcode $exitcode
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/cal_nop.exe 10 2011 > outputfile1
+exitcode=$?
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./cal_nop.exe 10 2011 > outputfile1" --prog cal_nop.exe  --outfile outputfile1 --name Oct2011 --exitcode $exitcode
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/cal_nop.exe 11 2011 > outputfile1
+exitcode=$?
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./cal_nop.exe 11 2011 > outputfile1" --prog cal_nop.exe  --outfile outputfile1 --name Nov2011 --exitcode $exitcode
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/cal_nop.exe 12 2011 > outputfile1
+exitcode=$?
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./cal_nop.exe 12 2011 > outputfile1" --prog cal_nop.exe  --outfile outputfile1 --name Dec2011 --exitcode $exitcode
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/cal_nop.exe 2 1952 > outputfile1
+exitcode=$?
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./cal_nop.exe 2 1952 > outputfile1" --prog cal_nop.exe  --outfile outputfile1 --name LeapYearFeb1952 --exitcode $exitcode
+
+
+rm outputfile1
+
diff --git a/tests/simple/dumbledore_cmd_O3.exe b/tests/simple/dumbledore_cmd_O3.exe
new file mode 100755
index 0000000000000000000000000000000000000000..deeaa78f185d77653eff2dd8b7af80f0cdc58aab
Binary files /dev/null and b/tests/simple/dumbledore_cmd_O3.exe differ
diff --git a/tests/simple/dumbledore_cmd_nop.exe b/tests/simple/dumbledore_cmd_nop.exe
new file mode 100755
index 0000000000000000000000000000000000000000..51d1db3a9093191360c3e75968049c1227bd450c
Binary files /dev/null and b/tests/simple/dumbledore_cmd_nop.exe differ
diff --git a/tests/simple/dumbledore_test.sh b/tests/simple/dumbledore_test.sh
new file mode 100644
index 0000000000000000000000000000000000000000..5c3bbb7951dd32cdf35c686b614b93e226f012dd
--- /dev/null
+++ b/tests/simple/dumbledore_test.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/dumbledore_cmd_nop.exe > outputfile1
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./dumbledore_cmd.exe > outputfile1" --prog dumbledore_cmd.exe  --outfile outputfile1 --name NoInput
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/dumbledore_cmd_nop.exe Ben > outputfile1
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./dumbledore_cmd.exe Ben > outputfile1" --prog dumbledore_cmd.exe  --outfile outputfile1 --name DInput
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/dumbledore_cmd_nop.exe "Wizard in Train" > outputfile1
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./dumbledore_cmd.exe \"Wizard in Train\" > outputfile1" --prog dumbledore_cmd.exe  --outfile outputfile1 --name DInput2
+
+$SECURITY_TRANSFORMS_HOME/tests/simple/dumbledore_cmd_nop.exe "Wizard in Training" > outputfile1
+$PEASOUP_HOME/tools/manual_test_import.sh --cmd "./dumbledore_cmd.exe \"Wizard in Training\" > outputfile1" --prog dumbledore_cmd.exe  --outfile outputfile1 --name BInput
+
+# cleanup
+rm outputfile1
diff --git a/tests/simple/jack_tests/banner.c b/tests/simple/jack_tests/banner.c
new file mode 100644
index 0000000000000000000000000000000000000000..1accc98aa0a9936bf0cf97500baf318e2780ce20
--- /dev/null
+++ b/tests/simple/jack_tests/banner.c
@@ -0,0 +1,193 @@
+#include <stdio.h>
+/*
+ *      improved banner program
+ */
+
+/*
+ *      bit pattern character table
+ */
+
+char btab[][7] = {
+        010,    010,    010,    010,    010,    00,     010,
+        024,    024,    024,    00,     00,     00,     00,
+        024,    024,    0177,   024,    0177,   024,    024,
+        010,    034,    050,    034,    012,    034,    010,
+        0161,   0122,   0164,   010,    027,    045,    0107,
+        034,    042,    024,    010,    025,    042,    035,
+        04,     010,    020,    00,     00,     00,     00,
+        01,     02,     04,     04,     04,     02,     01,
+        0100,   040,    020,    020,    020,    040,    0100,
+        0111,   052,    034,    0177,   034,    052,    0111,
+        00,     010,    010,    076,    010,    010,    00,
+        00,     00,     00,     00,     00,     040,    0100,
+        00,     00,     00,     074,    00,     00,     00,
+        00,     00,     00,     00,     00,     00,     040,
+        01,     02,     04,     010,    020,    040,    0100,
+        034,    042,    0105,   0111,   0121,   042,    034,
+        030,    010,    010,    010,    010,    010,    034,
+        034,    042,    02,     04,     010,    020,    076,
+        034,    042,    02,     04,     02,     042,    034,
+        02,     06,     012,    022,    077,    02,     02,
+        076,    040,    040,    074,    02,     042,    034,
+        02,     04,     010,    036,    041,    041,    036,
+        077,    01,     02,     04,     010,    020,    040,
+        034,    042,    042,    034,    042,    042,    034,
+        036,    041,    041,    036,    04,     010,    020,
+        00,     00,     00,     010,    00,     010,    00,
+        00,     00,     00,     010,    00,     010,    020,
+        02,     04,     010,    020,    010,    04,     02,
+        00,     00,     074,    00,     074,    00,     00,
+        040,    020,    010,    04,     010,    020,    040,
+        034,    042,    02,     04,     010,    00,     010,
+        076,    0101,   0117,   0111,   0117,   0100,   076,
+        034,    042,    0101,   0177,   0101,   0101,   0101,
+        0176,   0101,   0101,   0176,   0101,   0101,   0176,
+        034,    042,    0100,   0100,   0100,   042,    034,
+        0174,   0102,   0101,   0101,   0101,   0102,   0174,
+        0176,   0100,   0100,   0170,   0100,   0100,   0176,
+        0176,   0100,   0100,   0170,   0100,   0100,   0100,
+        036,    041,    0100,   0100,   0107,   041,    036,
+        0101,   0101,   0101,   0177,   0101,   0101,   0101,
+        034,    010,    010,    010,    010,    010,    034,
+        02,     02,     02,     02,     02,     042,    034,
+        0102,   0104,   0110,   0120,   0150,   0104,   0102,
+        0100,   0100,   0100,   0100,   0100,   0100,   0176,
+        0101,   0143,   0125,   0111,   0101,   0101,   0101,
+        0101,   0141,   0121,   0111,   0105,   0103,   0101,
+        076,    0101,   0101,   0101,   0101,   0101,   076,
+        0176,   0101,   0101,   0176,   0100,   0100,   0100,
+        076,    0101,   0101,   0111,   0105,   0102,   075,
+        0176,   0101,   0101,   0176,   0104,   0102,   0101,
+        076,    0101,   0100,   076,    01,     0101,   076,
+        0177,   010,    010,    010,    010,    010,    010,
+        0101,   0101,   0101,   0101,   0101,   0101,   076,
+        0101,   0101,   0101,   0101,   042,    024,    010,
+        0101,   0101,   0101,   0111,   0125,   0143,   0101,
+        0101,   042,    024,    010,    024,    042,    0101,
+        0101,   042,    024,    010,    010,    010,    010,
+        0177,   02,     04,     010,    020,    040,    0177,
+        07,     04,     04,     04,     04,     04,     07,
+        0100,   040,    020,    010,    04,     02,     01,
+        0160,   020,    020,    020,    020,    020,    0160,
+        010,    024,    042,    0101,   00,     00,     00,
+        00,     00,     00,     00,     00,     00,     0177,
+        020,    010,    04,     00,     00,     00,     00,
+        00,     076,    02,     076,    042,    077,    00,
+        040,    040,    074,    042,    042,    0174,   00,
+        00,     036,    040,    040,    040,    036,    00,
+        02,     02,     036,    042,    042,    037,    00,
+        00,     036,    041,    077,    040,    036,    00,
+        010,    024,    020,    070,    020,    020,    00,
+        00,     034,    042,    042,    036,    02,     014,
+        040,    040,    076,    041,    041,    041,    00,
+        010,    00,     010,    010,    010,    034,    00,
+        02,     00,     02,     02,     02,     022,    014,
+        040,    044,    050,    060,    050,    044,    00,
+        030,    010,    010,    010,    010,    034,    00,
+        00,     0166,   0111,   0111,   0111,   0111,   00,
+        00,     076,    041,    041,    041,    041,    00,
+        00,     036,    041,    041,    041,    036,    00,
+        00,     074,    042,    042,    074,    040,    040,
+        00,     036,    042,    042,    036,    02,     03,
+        00,     054,    042,    040,    040,    040,    00,
+        00,     036,    040,    036,    01,     036,    00,
+        020,    074,    020,    020,    022,    014,    00,
+        00,     041,    041,    041,    041,    035,    00,
+        00,     042,    042,    024,    024,    010,    00,
+        00,     0101,   0101,   0111,   0111,   066,    00,
+        00,     042,    024,    010,    024,    042,    00,
+        00,     042,    042,    042,    036,    02,     014,
+        00,     076,    04,     010,    020,    076,    00,
+        03,     04,     04,     030,    04,     04,     03,
+        010,    010,    010,    010,    010,    010,    010,
+        0140,   020,    020,    014,    020,    020,    0140,
+        060,    0111,   06,     00,     00,     00,     00,
+        0177,   0177,   0177,   0177,   0177,   0177,   0177,
+
+};
+
+/*
+ * subroutine to make the characters for a banner
+ */
+
+char *
+mkline(s, prch, line, space)
+        char *s, prch, *space;
+        int line;
+{
+        char *rs, *rl;
+        int bit;
+        int i, j, m;
+
+        rl = space;
+        for (i = 0; i < 7; i++) {
+                j = 0;
+                for (rs = s; *rs && j < line; j++) {
+                        bit = (bit=(*rs++&0177)-'!') < 0 ? 0 : btab[bit][i];
+                        for (m = 0100; bit; m >>= 1) {
+                                *rl++ = m&bit ? (prch ? prch : rs[-1]) : ' ';
+                                bit &= ~m;
+                        }
+                        *rl++ = '\t';
+                }
+                while (*--rl == '\t')
+                        ;
+                ++rl;
+                *rl++ = '\n';
+        }
+        *rl = '\0';
+        return(space);
+}
+
+main(argc, argv)
+        int argc;
+        char **argv;
+{
+        char prch, *space;
+        static char buf[256];
+        int line;
+        char *malloc();
+
+        prch = '*';
+        line = 10;
+        while (**++argv == '-') {
+                --argc;
+                switch(*++*argv) {
+
+                case 'c':               /* char to use */
+                        prch = *++*argv;
+                        break;
+
+                case 'l':
+                case 'w':
+                        line = atoi(++*argv)>>3;
+                        break;
+                }
+        }
+        space = malloc((unsigned)line*64);
+        printf("\n");
+        if (--argc) {
+                do {
+                        *space = '*';
+                        printf("\n%s", mkline(*argv++, prch, line, space));
+                } while (--argc);
+        }
+
+        else
+                while (fgets(buf, sizeof(buf), stdin) != NULL) {
+                        printf("\n%s", mkline(buf, prch, line, space));
+                }
+}
+
+atoi (str)
+char *str;
+{
+   int i = 0;
+   int retval = 0;
+
+   while (str[i] >= '0' && str[i] <= '9') {
+      retval *= 10;
+      retval += str[i++] - '0';
+   }
+   return (retval);
+}
diff --git a/tests/simple/jack_tests/cal.c b/tests/simple/jack_tests/cal.c
new file mode 100644
index 0000000000000000000000000000000000000000..eb8175d68db0017ab9545a23ed5777252f2f0de4
--- /dev/null
+++ b/tests/simple/jack_tests/cal.c
@@ -0,0 +1,206 @@
+char	dayw[] = {
+	" S  M Tu  W Th  F  S"
+};
+char	*smon[]= {
+	"January", "February", "March", "April",
+	"May", "June", "July", "August",
+	"September", "October", "November", "December",
+};
+char	string[432];
+
+main(argc, argv)
+char *argv[];
+{
+	int y, i, j;
+	int m;
+
+	if(argc < 2) {
+		printf("usage: cal [month] year\n");
+		exit(0);
+	}
+	if(argc == 2)
+		goto xlong;
+
+/*
+ *	print out just month
+ */
+
+	m = number(argv[1]);
+	if(m<1 || m>12)
+		goto badarg;
+	y = number(argv[2]);
+	if(y<1 || y>9999)
+		goto badarg;
+	printf("   %s %u\n", smon[m-1], y);
+	printf("%s\n", dayw);
+	cal(m, y, string, 24);
+	for(i=0; i<6*24; i+=24)
+		pstr(string+i, 24);
+	exit(0);
+
+/*
+ *	print out complete year
+ */
+
+xlong:
+	y = number(argv[1]);
+	if(y<1 || y>9999)
+		goto badarg;
+	printf("\n\n\n");
+	printf("				%u\n", y);
+	printf("\n");
+	for(i=0; i<12; i+=3) {
+		for(j=0; j<6*72; j++)
+			string[j] = '\0';
+		printf("	 %.3s", smon[i]);
+		printf("			%.3s", smon[i+1]);
+		printf("		       %.3s\n", smon[i+2]);
+		printf("%s   %s   %s\n", dayw, dayw, dayw);
+		cal(i+1, y, string, 72);
+		cal(i+2, y, string+23, 72);
+		cal(i+3, y, string+46, 72);
+		for(j=0; j<6*72; j+=72)
+			pstr(string+j, 72);
+	}
+	printf("\n\n\n");
+	exit(0);
+
+badarg:
+	printf("Bad argument\n");
+}
+
+number(str)
+char *str;
+{
+	int n, c;
+	char *s;
+
+	n = 0;
+	s = str;
+	while(c = *s++) {
+		if(c<'0' || c>'9')
+			return(0);
+		n = n*10 + c-'0';
+	}
+	return(n);
+}
+
+pstr(str, n)
+char *str;
+{
+	int i;
+	char *s;
+
+	s = str;
+	i = n;
+	while(i--)
+		if(*s++ == '\0')
+			s[-1] = ' ';
+	i = n+1;
+	while(i--)
+		if(*--s != ' ')
+			break;
+	s[1] = '\0';
+	printf("%s\n", str);
+}
+
+char	mon[] = {
+	0,
+	31, 29, 31, 30,
+	31, 30, 31, 31,
+	30, 31, 30, 31,
+};
+
+cal(m, y, p, w)
+char *p;
+{
+	int d, i;
+	char *s;
+
+	s = p;
+	d = jan1(y);
+	mon[2] = 29;
+	mon[9] = 30;
+
+	switch((jan1(y+1)+7-d)%7) {
+
+	/*
+	 *	non-leap year
+	 */
+	case 1:
+		mon[2] = 28;
+		break;
+
+	/*
+	 *	1752
+	 */
+	default:
+		mon[9] = 19;
+		break;
+
+	/*
+	 *	leap year
+	 */
+	case 2:
+		;
+	}
+	for(i=1; i<m; i++)
+		d += mon[i];
+	d %= 7;
+	s += 3*d;
+	for(i=1; i<=mon[m]; i++) {
+		if(i==3 && mon[m]==19) {
+			i += 11;
+			mon[m] += 11;
+		}
+		if(i > 9)
+			*s = i/10+'0';
+		s++;
+		*s++ = i%10+'0';
+		s++;
+		if(++d == 7) {
+			d = 0;
+			s = p+w;
+			p = s;
+		}
+	}
+}
+
+/*
+ *	return day of the week
+ *	of jan 1 of given year
+ */
+
+
+jan1(yr)
+{
+	int y, d;
+
+/*
+ *	normal gregorian calendar
+ *	one extra day per four years
+ */
+
+	y = yr;
+	d = 4+y+(y+3)/4;
+
+/*
+ *	julian calendar
+ *	regular gregorian
+ *	less three days per 400
+ */
+
+	if(y > 1800) {
+		d -= (y-1701)/100;
+		d += (y-1601)/400;
+	}
+
+/*
+ *	great calendar changeover instant
+ */
+
+	if(y > 1752)
+		d += 3;
+
+	return(d%7);
+}
diff --git a/tests/simple/jack_tests/grep.c b/tests/simple/jack_tests/grep.c
new file mode 100644
index 0000000000000000000000000000000000000000..d49f0e3e13cf0805245ca6c7803e17a2d4e546bf
--- /dev/null
+++ b/tests/simple/jack_tests/grep.c
@@ -0,0 +1,523 @@
+#ifndef lint
+static char sccsid[] = "@(#)grep.c	4.5 (Berkeley) 8/11/83";
+#endif
+
+/*
+ * grep -- print lines matching (or not matching) a pattern
+ *
+ *	status returns:
+ *		0 - ok, and some matches
+ *		1 - ok, but no matches
+ *		2 - some error
+ */
+
+#include <stdio.h>
+#include <ctype.h>
+
+#define	CBRA	1
+#define	CCHR	2
+#define	CDOT	4
+#define	CCL	6
+#define	NCCL	8
+#define	CDOL	10
+#define	CEOF	11
+#define	CKET	12
+#define	CBRC	14
+#define	CLET	15
+#define	CBACK	18
+
+#define	STAR	01
+
+#define	LBSIZE	BUFSIZ
+#define	ESIZE	256
+#define	NBRA	9
+
+char	expbuf[ESIZE];
+long	lnum;
+char	linebuf[LBSIZE+1];
+char	ybuf[ESIZE];
+int	bflag;
+int	lflag;
+int	nflag;
+int	cflag;
+int	vflag;
+int	nfile;
+int	hflag	= 1;
+int	sflag;
+int	yflag;
+int	wflag;
+int	retcode = 0;
+int	circf;
+int	blkno;
+long	tln;
+int	nsucc;
+char	*braslist[NBRA];
+char	*braelist[NBRA];
+char	bittab[] = {
+	1,
+	2,
+	4,
+	8,
+	16,
+	32,
+	64,
+	128
+};
+
+main(argc, argv)
+char **argv;
+{
+	while (--argc > 0 && (++argv)[0][0]=='-')
+		switch (argv[0][1]) {
+
+		case 'i':
+		case 'y':
+			yflag++;
+			continue;
+
+		case 'w':
+			wflag++;
+			continue;
+
+		case 'h':
+			hflag = 0;
+			continue;
+
+		case 's':
+			sflag++;
+			continue;
+
+		case 'v':
+			vflag++;
+			continue;
+
+		case 'b':
+			bflag++;
+			continue;
+
+		case 'l':
+			lflag++;
+			continue;
+
+		case 'c':
+			cflag++;
+			continue;
+
+		case 'n':
+			nflag++;
+			continue;
+
+		case 'e':
+			--argc;
+			++argv;
+			goto out;
+
+		default:
+			errexit("grep: unknown flag\n", (char *)NULL);
+			continue;
+		}
+out:
+	if (argc<=0)
+		exit(2);
+	if (yflag) {
+		register char *p, *s;
+		for (s = ybuf, p = *argv; *p; ) {
+			if (*p == '\\') {
+				*s++ = *p++;
+				if (*p)
+					*s++ = *p++;
+			} else if (*p == '[') {
+				while (*p != '\0' && *p != ']')
+					*s++ = *p++;
+			} else if (islower(*p)) {
+				*s++ = '[';
+				*s++ = toupper(*p);
+				*s++ = *p++;
+				*s++ = ']';
+			} else
+				*s++ = *p++;
+			if (s >= ybuf+ESIZE-5)
+				errexit("grep: argument too long\n", (char *)NULL);
+		}
+		*s = '\0';
+		*argv = ybuf;
+	}
+	compile(*argv);
+	nfile = --argc;
+	if (argc<=0) {
+		if (lflag)
+			exit(1);
+		execute((char *)NULL);
+	} else while (--argc >= 0) {
+		argv++;
+		execute(*argv);
+	}
+	exit(retcode != 0 ? retcode : nsucc == 0);
+}
+
+compile(sp)
+register char *sp;
+{
+	register int c;
+	register char *ep;
+	char *cstart;
+	char *lastep;
+	int cclcnt;
+	char bracket[NBRA], *bracketp;
+	int closed;
+	char numbra;
+	char neg;
+
+	ep = expbuf;
+	lastep = 0;
+	bracketp = bracket;
+	closed = numbra = 0;
+	if (*sp == '^') {
+		circf++;
+		sp++;
+	}
+	if (wflag)
+		*ep++ = CBRC;
+	for (;;) {
+		if (ep >= &expbuf[ESIZE])
+			goto cerror;
+		if ((c = *sp++) != '*')
+			lastep = ep;
+		switch (c) {
+
+		case '\0':
+			if (wflag)
+				*ep++ = CLET;
+			*ep++ = CEOF;
+			return;
+
+		case '.':
+			*ep++ = CDOT;
+			continue;
+
+		case '*':
+			if (lastep==0 || *lastep==CBRA || *lastep==CKET ||
+			    *lastep == CBRC || *lastep == CLET)
+				goto defchar;
+			*lastep |= STAR;
+			continue;
+
+		case '$':
+			if (*sp != '\0')
+				goto defchar;
+			*ep++ = CDOL;
+			continue;
+
+		case '[':
+			if(&ep[17] >= &expbuf[ESIZE])
+				goto cerror;
+			*ep++ = CCL;
+			neg = 0;
+			if((c = *sp++) == '^') {
+				neg = 1;
+				c = *sp++;
+			}
+			cstart = sp;
+			do {
+				if (c=='\0')
+					goto cerror;
+				if (c=='-' && sp>cstart && *sp!=']') {
+					for (c = sp[-2]; c<*sp; c++)
+						ep[c>>3] |= bittab[c&07];
+					sp++;
+				}
+				ep[c>>3] |= bittab[c&07];
+			} while((c = *sp++) != ']');
+			if(neg) {
+				for(cclcnt = 0; cclcnt < 16; cclcnt++)
+					ep[cclcnt] ^= -1;
+				ep[0] &= 0376;
+			}
+
+			ep += 16;
+
+			continue;
+
+		case '\\':
+			if((c = *sp++) == 0)
+				goto cerror;
+			if(c == '<') {
+				*ep++ = CBRC;
+				continue;
+			}
+			if(c == '>') {
+				*ep++ = CLET;
+				continue;
+			}
+			if(c == '(') {
+				if(numbra >= NBRA) {
+					goto cerror;
+				}
+				*bracketp++ = numbra;
+				*ep++ = CBRA;
+				*ep++ = numbra++;
+				continue;
+			}
+			if(c == ')') {
+				if(bracketp <= bracket) {
+					goto cerror;
+				}
+				*ep++ = CKET;
+				*ep++ = *--bracketp;
+				closed++;
+				continue;
+			}
+
+			if(c >= '1' && c <= '9') {
+				if((c -= '1') >= closed)
+					goto cerror;
+				*ep++ = CBACK;
+				*ep++ = c;
+				continue;
+			}
+
+		defchar:
+		default:
+			*ep++ = CCHR;
+			*ep++ = c;
+		}
+	}
+    cerror:
+	errexit("grep: RE error\n", (char *)NULL);
+}
+
+execute(file)
+char *file;
+{
+	register char *p1, *p2;
+	register int c;
+
+	if (file) {
+		if (freopen(file, "r", stdin) == NULL) {
+			perror(file);
+			retcode = 2;
+		}
+	}
+	lnum = 0;
+	tln = 0;
+	for (;;) {
+		lnum++;
+		p1 = linebuf;
+		while ((c = getchar()) != '\n') {
+			if (c == EOF) {
+				if (cflag) {
+					if (nfile>1)
+						printf("%s:", file);
+					printf("%D\n", tln);
+					fflush(stdout);
+				}
+				return;
+			}
+			*p1++ = c;
+			if (p1 >= &linebuf[LBSIZE-1])
+				break;
+		}
+		*p1++ = '\0';
+		p1 = linebuf;
+		p2 = expbuf;
+		if (circf) {
+			if (advance(p1, p2))
+				goto found;
+			goto nfound;
+		}
+		/* fast check for first character */
+		if (*p2==CCHR) {
+			c = p2[1];
+			do {
+				if (*p1!=c)
+					continue;
+				if (advance(p1, p2))
+					goto found;
+			} while (*p1++);
+			goto nfound;
+		}
+		/* regular algorithm */
+		do {
+			if (advance(p1, p2))
+				goto found;
+		} while (*p1++);
+	nfound:
+		if (vflag)
+			succeed(file);
+		continue;
+	found:
+		if (vflag==0)
+			succeed(file);
+	}
+}
+
+advance(lp, ep)
+register char *lp, *ep;
+{
+	register char *curlp;
+	char c;
+	char *bbeg;
+	int ct;
+
+	for (;;) switch (*ep++) {
+
+	case CCHR:
+		if (*ep++ == *lp++)
+			continue;
+		return(0);
+
+	case CDOT:
+		if (*lp++)
+			continue;
+		return(0);
+
+	case CDOL:
+		if (*lp==0)
+			continue;
+		return(0);
+
+	case CEOF:
+		return(1);
+
+	case CCL:
+		c = *lp++ & 0177;
+		if(ep[c>>3] & bittab[c & 07]) {
+			ep += 16;
+			continue;
+		}
+		return(0);
+	case CBRA:
+		braslist[*ep++] = lp;
+		continue;
+
+	case CKET:
+		braelist[*ep++] = lp;
+		continue;
+
+	case CBACK:
+		bbeg = braslist[*ep];
+		if (braelist[*ep]==0)
+			return(0);
+		ct = braelist[*ep++] - bbeg;
+		if(ecmp(bbeg, lp, ct)) {
+			lp += ct;
+			continue;
+		}
+		return(0);
+
+	case CBACK|STAR:
+		bbeg = braslist[*ep];
+		if (braelist[*ep]==0)
+			return(0);
+		ct = braelist[*ep++] - bbeg;
+		curlp = lp;
+		while(ecmp(bbeg, lp, ct))
+			lp += ct;
+		while(lp >= curlp) {
+			if(advance(lp, ep))	return(1);
+			lp -= ct;
+		}
+		return(0);
+
+
+	case CDOT|STAR:
+		curlp = lp;
+		while (*lp++);
+		goto star;
+
+	case CCHR|STAR:
+		curlp = lp;
+		while (*lp++ == *ep);
+		ep++;
+		goto star;
+
+	case CCL|STAR:
+		curlp = lp;
+		do {
+			c = *lp++ & 0177;
+		} while(ep[c>>3] & bittab[c & 07]);
+		ep += 16;
+		goto star;
+
+	star:
+		if(--lp == curlp) {
+			continue;
+		}
+
+		if(*ep == CCHR) {
+			c = ep[1];
+			do {
+				if(*lp != c)
+					continue;
+				if(advance(lp, ep))
+					return(1);
+			} while(lp-- > curlp);
+			return(0);
+		}
+
+		do {
+			if (advance(lp, ep))
+				return(1);
+		} while (lp-- > curlp);
+		return(0);
+
+	case CBRC:
+		if (lp == expbuf)
+			continue;
+#define	uletter(c)	(isalpha(c) || (c) == '_')
+		if (uletter(*lp) || isdigit(*lp))
+			if (!uletter(lp[-1]) && !isdigit(lp[-1]))
+				continue;
+		return (0);
+
+	case CLET:
+		if (!uletter(*lp) && !isdigit(*lp))
+			continue;
+		return (0);
+
+	default:
+		errexit("grep RE botch\n", (char *)NULL);
+	}
+}
+
+succeed(f)
+char *f;
+{
+	nsucc = 1;
+	if (sflag)
+		return;
+	if (cflag) {
+		tln++;
+		return;
+	}
+	if (lflag) {
+		printf("%s\n", f);
+		fflush(stdout);
+		fseek(stdin, 0l, 2);
+		return;
+	}
+	if (nfile > 1 && hflag)
+		printf("%s:", f);
+	if (bflag)
+		printf("%u:", blkno);
+	if (nflag)
+		printf("%ld:", lnum);
+	printf("%s\n", linebuf);
+	fflush(stdout);
+}
+
+ecmp(a, b, count)
+char	*a, *b;
+{
+	register int cc = count;
+	while(cc--)
+		if(*a++ != *b++)	return(0);
+	return(1);
+}
+
+errexit(s, f)
+char *s, *f;
+{
+	fprintf(stderr, s, f);
+	exit(2);
+}
diff --git a/tests/simple/jack_tests/k1.c b/tests/simple/jack_tests/k1.c
new file mode 100644
index 0000000000000000000000000000000000000000..1151f989bb73ebb4fa902c3d74d1864a50ddca52
--- /dev/null
+++ b/tests/simple/jack_tests/k1.c
@@ -0,0 +1,43 @@
+/*
+ * Kernel 1 Hydro
+ *
+ * Translated from Fortran by Sanjay Jinturkar 
+ * 6/28/92
+ */
+#define LOOP 50000
+
+#ifndef TIMES
+#define TIMES 100
+#endif
+
+main()
+{
+   double x[LOOP], y[LOOP], zx[LOOP+23];
+   int i;
+
+   for (i = 0; i < LOOP; i++)
+      x[i] = y[i] = zx[i] = 3.0;
+
+   for (i = 0; i < TIMES; i++)
+      loop (x, y, zx, LOOP);
+
+   printf("contents\n");
+   for(i = 0;i<LOOP;i++)
+   {
+       printf("x: %lf\ty: %lf\tzx: %lf\n",x[i],y[i],zx[i]);
+   }
+}
+
+loop(x, y, zx, n) 
+double x[], y[], zx[];
+int n;
+{
+  int k;
+  double q = 12.0;
+  double r = 5.2;
+  double t = 13.4;
+
+  for (k = 0; k < n; k++)
+     x[k] = q + y[k] * (r * zx[k + 10] + t * zx[k + 11]);
+}
+
diff --git a/tests/simple/jack_tests/od.c b/tests/simple/jack_tests/od.c
new file mode 100644
index 0000000000000000000000000000000000000000..d78c719795e3cf9b000198089cc8884056cd1303
--- /dev/null
+++ b/tests/simple/jack_tests/od.c
@@ -0,0 +1,893 @@
+static char *sccsid = "@(#)od.c	5.11 (Berkeley) 4/29/83";
+/*
+ * od -- octal, hex, decimal, character dump of data in a file.
+ *
+ * usage:  od [-abBcdDefFhHiIlLopPs[n]vw[n]xX] [file] [[+]offset[.][b] [label]]
+ *
+ * where the option flags have the following meaning:
+ *   character	object	radix	signed?
+ *	a	byte	(10)	(n.a.)	ASCII named byte stream
+ *	b	byte	  8	 no	byte octal
+ *	c	byte	 (8)	(no)	character with octal non-graphic bytes
+ *	d	short	 10	 no
+ *	D	long	 10	 no
+ *	e,F	double	(10)		double precision floating pt.
+ *	f	float	(10)		single precision floating pt.
+ *	h,x	short	 16	 no
+ *	H,X	long	 16	 no
+ *	i	short	 10	yes
+ *	I,l,L	long	 10	yes
+ *	o,B	short	  8	 no	(default conversion)
+ *	O	long	  8	 no
+ *	s[n]	string	 (8)		ASCII graphic strings
+ *
+ *	p				indicate EVEN parity on 'a' conversion
+ *	P				indicate ODD parity on 'a' conversion
+ *	v				show all data - don't skip like lines.
+ *	w[n]				bytes per display line
+ *
+ * More than one format character may be given.
+ * If {file} is not specified, standard input is read.
+ * If {file} is not specified, then {offset} must start with '+'.
+ * {Offset} may be HEX (0xnnn), OCTAL (0nn), or decimal (nnn.).
+ * The default is octal. The same radix will be used to display the address.
+ */
+
+#include <stdio.h>
+
+#define DBUF_SIZE	BUFSIZ
+#define BIG_DBUF	32
+#define NO		0
+#define YES		1
+#define EVEN	       -1
+#define ODD		1
+#define UNSIGNED	0
+#define SIGNED		1
+#define PADDR		1
+#define MIN_SLEN	3
+
+int	a_put();
+int	b_put();
+int	c_put();
+int	s_put();
+int	us_put();
+int	l_put();
+int	f_put();
+int	d_put();
+int	st_put();
+
+struct dfmt {
+	int	df_field;	/* external field required for object */
+	int	df_size;	/* size (bytes) of object */
+	int	df_radix;	/* conversion radix */
+	int	df_signed;	/* signed? flag */
+	int	df_paddr;	/* "put address on each line?" flag */
+	int	(*df_put)();	/* function to output object */
+	char	*df_fmt;	/* output string format */
+} *conv_vec[32];		/* vector of conversions to be done */
+
+struct dfmt	ascii	= { 3, sizeof (char),   10,        0, PADDR,  a_put, 0};
+struct dfmt	byte	= { 3, sizeof (char),    8, UNSIGNED, PADDR,  b_put, 0};
+struct dfmt	cchar	= { 3, sizeof (char),    8, UNSIGNED, PADDR,  c_put, 0};
+struct dfmt	u_s_oct	= { 6, sizeof (short),   8, UNSIGNED, PADDR, us_put, 0};
+struct dfmt	u_s_dec	= { 5, sizeof (short),  10, UNSIGNED, PADDR, us_put, 0};
+struct dfmt	u_s_hex	= { 4, sizeof (short),  16, UNSIGNED, PADDR, us_put, 0};
+struct dfmt	u_l_oct	= {11, sizeof (long),    8, UNSIGNED, PADDR,  l_put, 0};
+struct dfmt	u_l_dec	= {10, sizeof (long),   10, UNSIGNED, PADDR,  l_put, 0};
+struct dfmt	u_l_hex	= { 8, sizeof (long),   16, UNSIGNED, PADDR,  l_put, 0};
+struct dfmt	s_s_dec	= { 6, sizeof (short),  10,   SIGNED, PADDR,  s_put, 0};
+struct dfmt	s_l_dec	= {11, sizeof (long),   10,   SIGNED, PADDR,  l_put, 0};
+struct dfmt	flt	= {14, sizeof (float),  10,   SIGNED, PADDR,  f_put, 0};
+struct dfmt	dble	= {21, sizeof (double), 10,   SIGNED, PADDR,  d_put, 0};
+struct dfmt	string	= { 0,               0,  8,        0,    NO, st_put, 0};
+
+
+char	usage[]	="usage: od [-abcdfhilopswvx] [file] [[+]offset[.][b] [label]]";
+char	dbuf[DBUF_SIZE];
+char	lastdbuf[DBUF_SIZE];
+int	addr_base	= 8;		/* default address base is OCTAL */
+long	addr		= 0L;		/* current file offset */
+long	label		= -1L;		/* current label; -1 is "off" */
+int	dbuf_size	= 16;		/* file bytes / display line */
+int	_parity		= NO;		/* show parity on ascii bytes */
+char	fmt[]	= "            %s";	/* 12 blanks */
+char	*icvt();
+char	*scvt();
+char	*underline();
+long	get_addr();
+
+
+/*
+ * special form of _ctyp
+ */
+
+#define A	01
+#define G	02
+#define D	04
+#define P	010
+#define X	020
+#define isdigit(c)	(_ctyp[c] & D)
+#define isascii(c)	(_ctyp[c] & A)
+#define isgraphic(c)	(_ctyp[c] & G)
+#define isprint(c)	(_ctyp[c] & P)
+#define ishex(c)	(_ctyp[c] & (X|D))
+
+char	_ctyp[256] = {
+/* 000 */	0,	0,	0,	0,	0,	0,	0,	0,
+/* 010 */	A,	A,	A,	0,	A,	A,	0,	0,
+/* 020 */	0,	0,	0,	0,	0,	0,	0,	0,
+/* 030 */	0,	0,	0,	0,	0,	0,	0,	0,
+/* 040 */     P|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,
+/* 050 */   P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,
+/* 060 */ P|G|D|A,P|G|D|A,P|G|D|A,P|G|D|A,P|G|D|A,P|G|D|A,P|G|D|A,P|G|D|A,
+/* 070 */ P|G|D|A,P|G|D|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,
+/* 100 */   P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,
+/* 110 */   P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,
+/* 120 */   P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,
+/* 130 */   P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,
+/* 140 */   P|G|A,X|P|G|A,X|P|G|A,X|P|G|A,X|P|G|A,X|P|G|A,X|P|G|A,  P|G|A,
+/* 150 */   P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,
+/* 160 */   P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,
+/* 170 */   P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,  P|G|A,	0,
+/* 200 */	0,	0,	0,	0,	0,	0,	0,	0,
+/* 210 */	0,	0,	0,	0,	0,	0,	0,	0,
+/* 220 */	0,	0,	0,	0,	0,	0,	0,	0,
+/* 230 */	0,	0,	0,	0,	0,	0,	0,	0,
+/* 240 */	0,	0,	0,	0,	0,	0,	0,	0,
+/* 250 */	0,	0,	0,	0,	0,	0,	0,	0,
+/* 260 */	0,	0,	0,	0,	0,	0,	0,	0,
+/* 270 */	0,	0,	0,	0,	0,	0,	0,	0,
+/* 300 */	0,	0,	0,	0,	0,	0,	0,	0,
+/* 310 */	0,	0,	0,	0,	0,	0,	0,	0,
+/* 320 */	0,	0,	0,	0,	0,	0,	0,	0,
+/* 330 */	0,	0,	0,	0,	0,	0,	0,	0,
+/* 340 */	0,	0,	0,	0,	0,	0,	0,	0,
+/* 350 */	0,	0,	0,	0,	0,	0,	0,	0,
+/* 360 */	0,	0,	0,	0,	0,	0,	0,	0,
+/* 370 */	0,	0,	0,	0,	0,	0,	0,	0,
+};
+
+main(argc, argv)
+int	argc;
+char	**argv;
+{
+	register char *p;
+	register char *l;
+	register n, same;
+	struct dfmt	*d;
+	struct dfmt	**cv = conv_vec;
+	int	showall = NO;
+	int	field, llen, nelm;
+	int	max_llen = 0;
+
+	argv++;
+	argc--;
+
+	if(argc > 0)
+	{
+		p = *argv;
+		if(*p == '-')
+		{
+			while(*++p != '\0')
+			{
+				switch(*p)
+				{
+				case 'a':
+					d = &ascii;
+					break;
+				case 'b':
+					d = &byte;
+					break;
+				case 'c':
+					d = &cchar;
+					break;
+				case 'd':
+					d = &u_s_dec;
+					break;
+				case 'D':
+					d = &u_l_dec;
+					break;
+				case 'e':
+				case 'F':
+					d = &dble;
+					break;
+				case 'f':
+					d = &flt;
+					break;
+				case 'h':
+				case 'x':
+					d = &u_s_hex;
+					break;
+				case 'H':
+				case 'X':
+					d = &u_l_hex;
+					break;
+				case 'i':
+					d = &s_s_dec;
+					break;
+				case 'I':
+				case 'l':
+				case 'L':
+					d = &s_l_dec;
+					break;
+				case 'o':
+				case 'B':
+					d = &u_s_oct;
+					break;
+				case 'O':
+					d = &u_l_oct;
+					break;
+				case 'p':
+					_parity = EVEN;
+					continue;
+				case 'P':
+					_parity = ODD;
+					continue;
+				case 's':
+					d = &string;
+					*(cv++) = d;
+					while (isdigit(p[1]))
+						d->df_size = (10 * d->df_size) + (*++p - '0');
+					if (d->df_size <= 0)
+						d->df_size = MIN_SLEN;
+					showall = YES;
+					continue;
+				case 'w':
+					dbuf_size = 0;
+					while (isdigit(p[1]))
+						dbuf_size = (10 * dbuf_size) + (*++p - '0');
+					if (dbuf_size == 0)
+						dbuf_size = BIG_DBUF;
+					continue;
+				case 'v':
+					showall = YES;
+					continue;
+				default:
+					printf("od: bad flag -%c\n", *p);
+					puts(usage);
+					exit(1);
+				}
+				*(cv++) = d;
+			}
+			argc--;
+			argv++;
+		}
+	}
+
+	/*
+	 * if nothing spec'd, setup default conversion.
+	 */
+	if(cv == conv_vec)
+		*(cv++) = &u_s_oct;
+
+	*cv = (struct dfmt *)0;
+
+	/*
+	 * calculate display parameters
+	 */
+	for (cv = conv_vec; d = *cv; cv++)
+	{
+		nelm = (dbuf_size + d->df_size - 1) / d->df_size;
+		llen = nelm * (d->df_field + 1);
+		if (llen > max_llen)
+			max_llen = llen;
+	}
+
+	/*
+	 * setup df_fmt to point to uniform output fields.
+	 */
+	for (cv = conv_vec; d = *cv; cv++)
+	{
+		if (d->df_field)	/* only if external field is known */
+		{
+			nelm = (dbuf_size + d->df_size - 1) / d->df_size;
+			field = max_llen / nelm;
+			d->df_fmt = fmt + 12 - (field - d->df_field);
+		}
+	}
+
+	/*
+	 * input file specified ?
+	 */
+	if(argc > 0 && **argv != '+')
+	{
+		if (freopen(*argv, "r", stdin) == NULL)
+		{
+			perror(*argv);
+			exit(1);
+		}
+		argv++;
+		argc--;
+	}
+
+	/*
+	 * check for possible offset [label]
+	 */
+	if (argc > 0)
+	{
+		addr = get_addr(*argv);
+		offset(addr);
+		argv++;
+		argc--;
+
+		if (argc > 0)
+			label = get_addr(*argv);
+	}
+
+	/*
+	 * main dump loop
+	 */
+	same = -1;
+	while ((n = fread(dbuf, 1, dbuf_size, stdin)) > 0)
+	{
+		if (same>=0 && bufncmp(dbuf, lastdbuf, dbuf_size) == 0 && !showall)
+		{
+			if (same==0)
+			{
+				printf("*\n");
+				same = 1;
+			}
+		}
+		else
+		{
+			line(n);
+			same = 0;
+			p = dbuf;
+			l = lastdbuf;
+			for (nelm = 0; nelm < dbuf_size; nelm++)
+			{
+				*l++ = *p;
+				*p++ = '\0';
+			}
+		}
+		addr += n;
+		if (label >= 0)
+			label += n;
+	}
+
+	/*
+	 * Some conversions require "flushing".
+	 */
+	n = 0;
+	for (cv = conv_vec; *cv; cv++)
+	{
+		if ((*cv)->df_paddr)
+		{
+			if (n++ == 0)
+				put_addr(addr, label, '\n');
+		}
+		else
+			(*((*cv)->df_put))(0, *cv);
+	}
+}
+
+put_addr(a, l, c)
+long	a;
+long	l;
+char	c;
+{
+	fputs(icvt(a, addr_base, UNSIGNED, 7), stdout);
+	if (l >= 0)
+		printf(" (%s)", icvt(l, addr_base, UNSIGNED, 7));
+	putchar(c);
+}
+
+line(n)
+int	n;
+{
+	register i, first;
+	register struct dfmt *c;
+	register struct dfmt **cv = conv_vec;
+
+	first = YES;
+	while (c = *cv++)
+	{
+		if (c->df_paddr)
+		{
+			if (first)
+			{
+				put_addr(addr, label, ' ');
+				first = NO;
+			}
+			else
+			{
+				putchar('\t');
+				if (label >= 0)
+					fputs("\t  ", stdout);
+			}
+		}
+		i = 0;
+		while (i < n)
+			i += (*(c->df_put))(dbuf+i, c);
+		if (c->df_paddr)
+			putchar('\n');
+	}
+}
+
+s_put(n, d)
+short	*n;
+struct dfmt	*d;
+{
+	printf(d->df_fmt, icvt((long)*n, d->df_radix, d->df_signed, d->df_field));
+	return(d->df_size);
+}
+
+us_put(n, d)
+unsigned short	*n;
+struct dfmt	*d;
+{
+	printf(d->df_fmt, icvt((long)*n, d->df_radix, d->df_signed, d->df_field));
+	return(d->df_size);
+}
+
+l_put(n, d)
+long	*n;
+struct dfmt	*d;
+{
+	printf(d->df_fmt, icvt(*n, d->df_radix, d->df_signed, d->df_field));
+	return(d->df_size);
+}
+
+d_put(f, d)
+double	*f;
+struct dfmt *d;
+{
+	char fbuf[24];
+	struct l { long n[2]; };
+
+#if	vax
+	if ((((struct l *)f)->n[0] & 0xff00) == 0x8000)	/* Vax illegal f.p. */
+		sprintf(fbuf, "    %08x %08x",
+			((struct l *)f)->n[0], ((struct l *)f)->n[1]);
+	else
+#endif
+
+		sprintf(fbuf, "%21.14e", *f);
+	printf(d->df_fmt, fbuf);
+	return(d->df_size);
+}
+
+f_put(f, d)
+float	*f;
+struct dfmt *d;
+{
+	char fbuf[16];
+
+#if	vax
+	if ((*(long *)f & 0xff00) == 0x8000)	/* Vax illegal f.p. form */
+		sprintf(fbuf, "      %08x", *(long *)f);
+	else
+#endif
+		sprintf(fbuf, "%14.7e", *f);
+	printf(d->df_fmt, fbuf);
+	return(d->df_size);
+}
+
+
+char	asc_name[34][4] = {
+/* 000 */	"nul",	"soh",	"stx",	"etx",	"eot",	"enq",	"ack",	"bel",
+/* 010 */	" bs",	" ht",	" nl",	" vt",	" ff",	" cr",	" so",	" si",
+/* 020 */	"dle",	"dc1",	"dc2",	"dc3",	"dc4",	"nak",	"syn",	"etb",
+/* 030 */	"can",	" em",	"sub",	"esc",	" fs",	" gs",	" rs",	" us",
+/* 040 */	" sp",	"del"
+};
+
+a_put(cc, d)
+char	*cc;
+struct dfmt *d;
+{
+	int c = *cc;
+	register char *s = "   ";
+	register pbit = parity((int)c & 0377);
+
+	c &= 0177;
+	if (isgraphic(c))
+	{
+		s[2] = c;
+		if (pbit == _parity)
+			printf(d->df_fmt, underline(s));
+		else
+			printf(d->df_fmt, s);
+	}
+	else
+	{
+		if (c == 0177)
+			c = ' ' + 1;
+		if (pbit == _parity)
+			printf(d->df_fmt, underline(asc_name[c]));
+		else
+			printf(d->df_fmt, asc_name[c]);
+	}
+	return(1);
+}
+
+parity(word)
+int	word;
+{
+	register int p = 0;
+	register int w = word;
+
+	if (w)
+		do
+		{
+			p ^= 1;
+		} while(w &= (~(-w)));
+	return (p? ODD:EVEN);
+}
+
+char *
+underline(s)
+char	*s;
+{
+	static char ulbuf[16];
+	register char *u = ulbuf;
+
+	while (*s)
+	{
+		if (*s != ' ')
+		{
+			*u++ = '_';
+			*u++ = '\b';
+		}
+		*u++ = *s++;
+	}
+	*u = '\0';
+	return(ulbuf);
+}
+
+b_put(b, d)
+char	*b;
+struct dfmt *d;
+{
+	printf(d->df_fmt, icvt((long)*b & 0377, d->df_radix, d->df_signed, d->df_field));
+	return(1);
+}
+
+c_put(cc, d)
+char	*cc;
+struct dfmt *d;
+{
+	register char	*s;
+	register int	n;
+	register int	c = *cc & 0377;
+
+	s = scvt(c, d);
+	for (n = d->df_field - strlen(s); n > 0; n--)
+		putchar(' ');
+	printf(d->df_fmt, s);
+	return(1);
+}
+
+char *scvt(c, d)
+int	c;
+struct dfmt	*d;
+{
+	static char s[2];
+
+	switch(c)
+	{
+		case '\0':
+			return("\\0");
+
+		case '\b':
+			return("\\b");
+
+		case '\f':
+			return("\\f");
+
+		case '\n':
+			return("\\n");
+
+		case '\r':
+			return("\\r");
+
+		case '\t':
+			return("\\t");
+
+		default:
+			if (isprint(c))
+			{
+				s[0] = c;
+				return(s);
+			}
+			return(icvt((long)c, d->df_radix, d->df_signed, d->df_field));
+	}
+}
+
+/*
+ * Look for strings.
+ * A string contains bytes > 037 && < 177, and ends with a null.
+ * The minimum length is given in the dfmt structure.
+ */
+
+#define CNULL		'\0'
+#define S_EMPTY	0
+#define S_FILL	1
+#define	S_CONT	2
+#define SBUFSIZE	1024
+
+static char	str_buf[SBUFSIZE];
+static int	str_mode = S_EMPTY;
+static char	*str_ptr;
+static long	str_addr;
+static long	str_label;
+
+st_put(cc, d)
+char	*cc;
+struct dfmt	*d;
+{
+	register int	c;
+
+	if (cc == 0)
+	{
+		pr_sbuf(d, YES);
+		return(1);
+	}
+
+	c = (*cc & 0377);
+
+	if (str_mode & S_FILL)
+	{
+		if (isascii(c))
+			put_sbuf(c, d);
+		else
+		{
+			*str_ptr = CNULL;
+			if (c == NULL)
+				pr_sbuf(d, YES);
+			str_mode = S_EMPTY;
+		}
+	}
+	else if (isascii(c))
+	{
+		str_mode = S_FILL;
+		str_addr = addr + (cc - dbuf);	  /* ugly */
+		if ((str_label = label) >= 0)
+			str_label += (cc - dbuf); /*  ''  */
+		str_ptr = str_buf;
+		put_sbuf(c, d);
+	}
+
+	return(1);
+}
+
+put_sbuf(c, d)
+int	c;
+struct dfmt	*d;
+{
+	*str_ptr++ = c;
+	if (str_ptr >= (str_buf + SBUFSIZE))
+	{
+		pr_sbuf(d, NO);
+		str_ptr = str_buf;
+		str_mode |= S_CONT;
+	}
+}
+
+pr_sbuf(d, end)
+struct dfmt	*d;
+int	end;
+{
+	register char	*p = str_buf;
+
+	if (str_mode == S_EMPTY
+	    || (!(str_mode & S_CONT) && (str_ptr - str_buf) < d->df_size))
+		return;
+
+	if (!(str_mode & S_CONT))
+		put_addr(str_addr, str_label, ' ');
+
+	while (p < str_ptr)
+		fputs(scvt(*p++, d), stdout);
+
+	if (end)
+		putchar('\n');
+}
+
+/*
+ * integer to ascii conversion
+ *
+ * This code has been rearranged to produce optimized runtime code.
+ */
+
+#define MAXINTLENGTH	32
+static char	_digit[] = "0123456789abcdef";
+static char	_icv_buf[MAXINTLENGTH+1];
+static long	_mask = 0x7fffffff;
+
+char *
+icvt (value, radix, psigned, ndigits)
+long	value;
+int	radix;
+int	psigned;
+int	ndigits;
+{
+	register long	val = value;
+	register long	rad = radix;
+	register char	*b = &_icv_buf[MAXINTLENGTH];
+	register char	*d = _digit;
+	register long	tmp1;
+	register long	tmp2;
+	long	rem;
+	long	kludge;
+	int	sign;
+
+	if (val == 0)
+	{
+		*--b = '0';
+		sign = 0;
+		goto done; /*return(b);*/
+	}
+
+	if (psigned && (sign = (val < 0)))	/* signed conversion */
+	{
+		/*
+		 * It is necessary to do the first divide
+		 * before the absolute value, for the case -2^31
+		 *
+		 * This is actually what is being done...
+		 * tmp1 = (int)(val % rad);
+		 * val /= rad;
+		 * val = -val
+		 * *--b = d[-tmp1];
+		 */
+		tmp1 = val / rad;
+		*--b = d[(tmp1 * rad) - val];
+		val = -tmp1;
+	}
+	else				/* unsigned conversion */
+	{
+		sign = 0;
+		if (val < 0)
+		{	/* ALL THIS IS TO SIMULATE UNSIGNED LONG MOD & DIV */
+			kludge = _mask - (rad - 1);
+			val &= _mask;
+			/*
+			 * This is really what's being done...
+			 * rem = (kludge % rad) + (val % rad);
+			 * val = (kludge / rad) + (val / rad) + (rem / rad) + 1;
+			 * *--b = d[rem % rad];
+			 */
+			tmp1 = kludge / rad;
+			tmp2 = val / rad;
+			rem = (kludge - (tmp1 * rad)) + (val - (tmp2 * rad));
+			val = ++tmp1 + tmp2;
+			tmp1 = rem / rad;
+			val += tmp1;
+			*--b = d[rem - (tmp1 * rad)];
+		}
+	}
+
+	while (val)
+	{
+		/*
+		 * This is really what's being done ...
+		 * *--b = d[val % rad];
+		 * val /= rad;
+		 */
+		tmp1 = val / rad;
+		*--b = d[val - (tmp1 * rad)];
+		val = tmp1;
+	}
+
+done:
+	if (sign)
+		*--b = '-';
+
+	tmp1 = ndigits - (&_icv_buf[MAXINTLENGTH] - b);
+	tmp2 = psigned? ' ':'0';
+	while (tmp1 > 0)
+	{
+		*--b = tmp2;
+		tmp1--;
+	}
+
+	return(b);
+}
+
+long get_addr(s)
+register char *s;
+{
+	register char *p;
+	register long a;
+	register int d;
+
+	if (*s=='+')
+		s++;
+	if (*s=='x')
+	{
+		s++;
+		addr_base = 16;
+	}
+	else if (*s=='0' && s[1]=='x')
+	{
+		s += 2;
+		addr_base = 16;
+	}
+	else if (*s == '0')
+		addr_base = 8;
+	p = s;
+	while(*p)
+	{
+		if (*p++=='.')
+			addr_base = 10;
+	}
+	for (a=0; *s; s++)
+	{
+		d = *s;
+		if(isdigit(d))
+			a = a*addr_base + d - '0';
+		else if (ishex(d) && addr_base==16)
+			a = a*addr_base + d + 10 - 'a';
+		else
+			break;
+	}
+
+	if (*s == '.')
+		s++;
+	if(*s=='b')
+		a *= 512;
+	if(*s=='B')
+		a *= 1024;
+
+	return(a);
+}
+
+bufncmp(a, b, n)
+char	*a;
+char	*b;
+int	n;
+{
+	while (n--)
+		if (*a++ != *b++)
+			return(1);
+	return(0);
+}
+
+offset(a)
+long	a;
+{
+	if (canseek(stdin))
+	{
+		/*
+		 * in case we're accessing a raw disk,
+		 * we have to seek in multiples of a physical block.
+		 */
+		fseek(stdin, a & 0xfffffe00L, 0);
+		a &= 0x1ffL;
+	}
+	dumbseek(stdin, a);
+}
+
+dumbseek(s, offset)
+FILE	*s;
+long	offset;
+{
+	char	buf[BUFSIZ];
+	int	n;
+	int	nr;
+
+	while (offset > 0)
+	{
+		nr = (offset > BUFSIZ) ? BUFSIZ : (int)offset;
+		if ((n = fread(buf, 1, nr, s)) != nr)
+		{
+			fprintf(stderr, "EOF\n");
+			exit(1);
+		}
+		offset -= n;
+	}
+}
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+canseek(f)
+FILE	*f;
+{
+	struct stat statb;
+
+	return( (fstat(fileno(f),&statb)==0) &&
+		(statb.st_nlink > 0) &&		/*!pipe*/
+		(!isatty(fileno(f))) );
+}