// File: /workspace/github_c_makefile_star2_O1/dalnefre[P]kernel_abe/kernel.c
// Function: test_kernel
void
test_kernel()
{
	SOURCE* src;
	CONS* expr;
	CONS* expect;

	DBUG_ENTER("test_kernel");
	TRACE(printf("--test_kernel--\n"));

	/*
	 * test character source
	 */
	src = string_source(NULL);
	assert((src->empty)(src) == a_true);
	assert((src->next)(src) == NUMBER(EOF));

	src = string_source("");
	assert((src->empty)(src) == a_true);
	assert((src->next)(src) == NUMBER(EOF));

	src = string_source(" ");
	assert((src->empty)(src) == a_false);
	expr = (src->next)(src);
	assert(expr == NUMBER(32));
	assert(expr == NUMBER(' '));
	assert((src->empty)(src) == a_true);
	assert((src->next)(src) == NUMBER(EOF));

	src = string_source("()");
	assert((src->empty)(src) == a_false);
	expr = (src->next)(src);
	assert(expr == NUMBER('('));
	assert((src->empty)(src) == a_false);
	expr = (src->next)(src);
	assert(expr == NUMBER(')'));
	assert((src->empty)(src) == a_true);
	assert((src->next)(src) == NUMBER(EOF));

	src = string_source("\r\n");
	expr = read_sexpr(src);
	expect = NUMBER(EOF);
	assert(equal(expect, expr));

	src = string_source("()");
	expr = read_sexpr(src);
	expect = a_nil;
	assert(equal(expect, expr));
/*
	src = string_source("(x)");
	expr = read_sexpr(src);
	expect = pr(ATOM("x"), NIL);
	assert(equal(expect, expr));

	src = string_source("(x y)");
	expr = read_sexpr(src);
	expect = pr(ATOM("x"), pr(ATOM("y"), NIL));
	assert(equal(expect, expr));
*/
	src = string_source("(x (y");
	expr = read_sexpr(src);
	expect = NUMBER(EOF);
	assert(equal(expect, expr));

	/*
	 * #inert
	 * ==> #inert
	 */
	expr = a_inert;
	expect = a_inert;
	assert_eval(expr, expect);

	/*
	 * (boolean? #t #f)
	 * ==> #t
	 */
	expr = ACTOR(pair_type, pr(
		get_symbol(ATOM("boolean?")),
		ACTOR(pair_type, pr(
			a_true,
			ACTOR(pair_type, pr(
				a_false,
				a_nil))))));
	expect = a_true;
	assert_eval(expr, expect);

	/*
	 * (ignore? #ignore #inert)
	 * ==> #f
	 */
	expr = ACTOR(pair_type, pr(
		get_symbol(ATOM("ignore?")),
		ACTOR(pair_type, pr(
			a_ignore,
			ACTOR(pair_type, pr(
				a_inert,
				a_nil))))));
	expect = a_false;
	assert_eval(expr, expect);

	/*
	 * (($vau (x) #ignore x) y)
	 * ==> y
	 */
	expr = read_sexpr(string_source(
		"(($vau (x) #ignore x) y)"));
/*	expr = ACTOR(pair_type, pr(
		ACTOR(pair_type, pr(
			get_symbol(ATOM("$vau")),
			ACTOR(pair_type, pr(
				ACTOR(pair_type, pr(
					get_symbol(ATOM("x")),
					a_nil)),
				ACTOR(pair_type, pr(
					a_ignore,
					ACTOR(pair_type, pr(
						get_symbol(ATOM("x")),
						a_nil)))))))),
		ACTOR(pair_type, pr(
			get_symbol(ATOM("y")),
			a_nil)))); */
	expect = get_symbol(ATOM("y"));
	assert_eval(expr, expect);

	/*
	 * (list #t #f)
	 */
/*	expr = ACTOR(pair_type, pr(
		get_symbol(ATOM("list")),
		ACTOR(pair_type, pr(
			a_true,
			ACTOR(pair_type, pr(
				a_false,
				a_nil))))));
	expect = a_true;
	assert_eval(expr, expect);
*/
	/*
	 * ($sequence
	 *		($define! y #t)
	 *		(($lambda (x) x) y))
	 * ==> #t
	 */
	expr = read_sexpr(string_source(
"($sequence \n\
	($define! y #t) \n\
	(($lambda (x) x) y))\n\
"));
/*	expr = ACTOR(pair_type, pr(
		get_symbol(ATOM("$sequence")),
		ACTOR(pair_type, pr(
			ACTOR(pair_type, pr(
				get_symbol(ATOM("$define!")),
				ACTOR(pair_type, pr(
					get_symbol(ATOM("y")),
					ACTOR(pair_type, pr(
						a_true,
						a_nil)))))),
			ACTOR(pair_type, pr(
				ACTOR(pair_type, pr(
					ACTOR(pair_type, pr(
						get_symbol(ATOM("$lambda")),
						ACTOR(pair_type, pr(
							ACTOR(pair_type, pr(
								get_symbol(ATOM("x")),
								a_nil)),
							ACTOR(pair_type, pr(
								get_symbol(ATOM("x")),
								a_nil)))))),
					ACTOR(pair_type, pr(
						get_symbol(ATOM("y")),
						a_nil)))),
				a_nil)))))); */
	expect = a_true;
	assert_eval(expr, expect);

	/*
	 * (eq? #f (boolean? #t #f))
	 * ==> #f
	 */
	expr = read_sexpr(string_source(
		"(eq? #f (boolean? #t #f))"));
	expect = a_false;
	assert_eval(expr, expect);

	/*
	 * ($if #t
	 *		($if #f
	 *			0
	 *			42)
	 *		314)
	 * ==> 42
	 */
	expr = read_sexpr(string_source(
"($if #t \n\
	($if #f \n\
		0 \n\
		42) \n\
	314)\n\
"));
	expect = get_const(NUMBER(42));
	assert_eval(expr, expect);

	/*
	 * (eq? (cons 0 (cons 1 ())) (list 0 1))
	 * ==> #f  ; equal?, but not eq?
	 */
	expr = read_sexpr(string_source(
		"(eq? (cons 0 (cons 1 ())) (list 0 1))"));
	expect = a_false;
	assert_eval(expr, expect);

	/*
	 * ($sequence
	 *		(write (cons (list #t #f #inert #ignore) (cons 0 1)))
	 *		(newline))
	 * ==> #t
	 */
	expr = read_sexpr(string_source(
"($sequence \n\
	(write (cons (list #t #f #inert #ignore) (cons 0 1))) \n\
	(newline))"
));
	expect = a_true;
	assert_eval(expr, expect);
	
	/*
	 * (($lambda ((#ignore . x)) x) (cons 0 1))
	 * ==> 1
	 */
	expr = read_sexpr(string_source(
		"(($lambda ((#ignore . x)) x) (cons 0 1))"));
	expect = get_const(NUMBER(1));
	assert_eval(expr, expect);

/* ...ADD TESTS HERE... */

#if 1
	cfg_force_gc(CFG);			/* clean up garbage created by tests */
#endif

	DBUG_RETURN;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x30, %rsp
leaq 0x17d6f(%rip), %rax     # 0x1c295
leaq 0x8(%rsp), %rdi
movq %rax, (%rdi)
leaq 0x1edfb(%rip), %rax     # 0x23330
movq (%rax), %rax
movq 0x50(%rax), %rax
movl 0x8(%rax), %ecx
movl %ecx, 0x8(%rdi)
movl $0xbd3, 0xc(%rdi)       # imm = 0xBD3
leaq 0x17dfa(%rip), %rcx     # 0x1c34a
movq %rcx, 0x10(%rdi)
leaq 0x1ebf5(%rip), %rcx     # 0x23150
movq %rcx, 0x18(%rdi)
movq %rax, 0x20(%rdi)
callq 0x1b912
leaq 0x1864c(%rip), %rdi     # 0x1cbbb
callq 0x20a0
xorl %edi, %edi
callq 0x2ed6
movq %rax, %rbx
movq %rax, %rdi
callq *0x8(%rax)
cmpq 0x1edfd(%rip), %rax     # 0x23388
jne 0x49a1
movq %rbx, %rdi
callq *0x18(%rbx)
cmpq $-0x1, %rax
jne 0x49c0
leaq 0x17da2(%rip), %rdi     # 0x1c34a
callq 0x2ed6
movq %rax, %rbx
movq %rax, %rdi
callq *0x8(%rax)
cmpq 0x1edcb(%rip), %rax     # 0x23388
jne 0x49df
movq %rbx, %rdi
callq *0x18(%rbx)
cmpq $-0x1, %rax
jne 0x49fe
leaq 0x1a20e(%rip), %rdi     # 0x1e7e8
callq 0x2ed6
movq %rax, %rbx
movq %rax, %rdi
callq *0x8(%rax)
cmpq 0x1ed91(%rip), %rax     # 0x23380
jne 0x4a1d
movq %rbx, %rdi
callq *0x18(%rbx)
cmpq $0x83, %rax
jne 0x4a3c
movq %rbx, %rdi
callq *0x8(%rbx)
cmpq 0x1ed74(%rip), %rax     # 0x23388
jne 0x4a5b
movq %rbx, %rdi
callq *0x18(%rbx)
cmpq $-0x1, %rax
jne 0x4a7a
leaq 0x17b2c(%rip), %rdi     # 0x1c15d
callq 0x2ed6
movq %rax, %rbx
movq %rax, %rdi
callq *0x8(%rax)
cmpq 0x1ed3a(%rip), %rax     # 0x23380
jne 0x4a99
movq %rbx, %rdi
callq *0x18(%rbx)
cmpq $0xa3, %rax
jne 0x4ab8
movq %rbx, %rdi
callq *0x8(%rbx)
cmpq 0x1ed15(%rip), %rax     # 0x23380
jne 0x4ad7
movq %rbx, %rdi
callq *0x18(%rbx)
cmpq $0xa7, %rax
jne 0x4af6
movq %rbx, %rdi
callq *0x8(%rbx)
cmpq 0x1ecf8(%rip), %rax     # 0x23388
jne 0x4b15
movq %rbx, %rdi
callq *0x18(%rbx)
cmpq $-0x1, %rax
jne 0x4b34
leaq 0x17c9b(%rip), %rdi     # 0x1c348
callq 0x2ed6
movq %rax, %rdi
callq 0x3431
movq $-0x1, %rdi
movq %rax, %rsi
callq 0x19d00
testq %rax, %rax
je 0x4b53
leaq 0x17a84(%rip), %rdi     # 0x1c15d
callq 0x2ed6
movq %rax, %rdi
callq 0x3431
movq 0x1ecab(%rip), %rdi     # 0x23398
movq %rax, %rsi
callq 0x19d00
testq %rax, %rax
je 0x4b72
leaq 0x17c5a(%rip), %rdi     # 0x1c35f
callq 0x2ed6
movq %rax, %rdi
callq 0x3431
movq $-0x1, %rdi
movq %rax, %rsi
callq 0x19d00
testq %rax, %rax
je 0x4b91
movq 0x1ec77(%rip), %rdi     # 0x233a8
movq %rdi, %rsi
callq 0x4bb0
movq 0x1ec60(%rip), %r14     # 0x233a0
leaq 0x17c1e(%rip), %rdi     # 0x1c365
callq 0x1707c
movq %rax, %rdi
callq 0x3fcf
movq %rax, %r15
movq 0x1ec42(%rip), %r12     # 0x233a0
movq 0x1ec23(%rip), %r13     # 0x23388
movq 0x1ec14(%rip), %rdi     # 0x23380
movq 0x1ec25(%rip), %rsi     # 0x23398
callq 0x19b84
leaq -0xc2d(%rip), %rbx      # 0x3b52
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x1283a
movq %r13, %rdi
movq %rax, %rsi
callq 0x19b84
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x1283a
movq %r15, %rdi
movq %rax, %rsi
callq 0x19b84
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x1283a
movq 0x1ebc2(%rip), %rsi     # 0x23388
movq %rax, %rdi
callq 0x4bb0
movq 0x1ebcb(%rip), %r14     # 0x233a0
leaq 0x17b92(%rip), %rdi     # 0x1c36e
callq 0x1707c
movq %rax, %rdi
callq 0x3fcf
movq %rax, %r15
movq 0x1ebad(%rip), %r12     # 0x233a0
movq 0x1ebb6(%rip), %r13     # 0x233b0
movq 0x1eba7(%rip), %rdi     # 0x233a8
movq 0x1eb90(%rip), %rsi     # 0x23398
callq 0x19b84
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x1283a
movq %r13, %rdi
movq %rax, %rsi
callq 0x19b84
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x1283a
movq %r15, %rdi
movq %rax, %rsi
callq 0x19b84
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x1283a
movq 0x1eb2c(%rip), %rsi     # 0x23380
movq %rax, %rdi
callq 0x4bb0
leaq 0x17b13(%rip), %rdi     # 0x1c376
callq 0x2ed6
movq %rax, %rdi
callq 0x3431
movq %rax, %rbx
leaq 0x17ae9(%rip), %rdi     # 0x1c363
callq 0x1707c
movq %rax, %rdi
callq 0x3fcf
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4bb0
leaq 0x17af6(%rip), %rdi     # 0x1c38f
callq 0x2ed6
movq %rax, %rdi
callq 0x3431
movq 0x1eadb(%rip), %rsi     # 0x23388
movq %rax, %rdi
callq 0x4bb0
leaq 0x17b08(%rip), %rdi     # 0x1c3c4
callq 0x2ed6
movq %rax, %rdi
callq 0x3431
movq 0x1eab0(%rip), %rsi     # 0x23380
movq %rax, %rdi
callq 0x4bb0
leaq 0x17aff(%rip), %rdi     # 0x1c3de
callq 0x2ed6
movq %rax, %rdi
callq 0x3431
movq %rax, %rbx
movl $0xab, %edi
callq 0x3e58
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4bb0
leaq 0x17af9(%rip), %rdi     # 0x1c404
callq 0x2ed6
movq %rax, %rdi
callq 0x3431
movq 0x1ea61(%rip), %rsi     # 0x23380
movq %rax, %rdi
callq 0x4bb0
leaq 0x17afc(%rip), %rdi     # 0x1c42a
callq 0x2ed6
movq %rax, %rdi
callq 0x3431
movq 0x1ea46(%rip), %rsi     # 0x23388
movq %rax, %rdi
callq 0x4bb0
leaq 0x17b29(%rip), %rdi     # 0x1c47a
callq 0x2ed6
movq %rax, %rdi
callq 0x3431
movq %rax, %rbx
movl $0x7, %edi
callq 0x3e58
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4bb0
movq 0x1ea23(%rip), %rdi     # 0x233a0
callq 0x12417
leaq 0x8(%rsp), %rdi
movl $0xcbd, 0xc(%rdi)       # imm = 0xCBD
callq 0x1ba97
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x178f9(%rip), %rdi     # 0x1c2a1
leaq 0x1766d(%rip), %rsi     # 0x1c01c
leaq 0x17907(%rip), %rcx     # 0x1c2bd
movl $0xbda, %edx            # imm = 0xBDA
callq 0x2100
leaq 0x17909(%rip), %rdi     # 0x1c2d0
leaq 0x1764e(%rip), %rsi     # 0x1c01c
leaq 0x178e8(%rip), %rcx     # 0x1c2bd
movl $0xbdb, %edx            # imm = 0xBDB
callq 0x2100
leaq 0x178bb(%rip), %rdi     # 0x1c2a1
leaq 0x1762f(%rip), %rsi     # 0x1c01c
leaq 0x178c9(%rip), %rcx     # 0x1c2bd
movl $0xbde, %edx            # imm = 0xBDE
callq 0x2100
leaq 0x178cb(%rip), %rdi     # 0x1c2d0
leaq 0x17610(%rip), %rsi     # 0x1c01c
leaq 0x178aa(%rip), %rcx     # 0x1c2bd
movl $0xbdf, %edx            # imm = 0xBDF
callq 0x2100
leaq 0x178cc(%rip), %rdi     # 0x1c2f0
leaq 0x175f1(%rip), %rsi     # 0x1c01c
leaq 0x1788b(%rip), %rcx     # 0x1c2bd
movl $0xbe2, %edx            # imm = 0xBE2
callq 0x2100
leaq 0x178ca(%rip), %rdi     # 0x1c30d
leaq 0x175d2(%rip), %rsi     # 0x1c01c
leaq 0x1786c(%rip), %rcx     # 0x1c2bd
movl $0xbe4, %edx            # imm = 0xBE4
callq 0x2100
leaq 0x1783f(%rip), %rdi     # 0x1c2a1
leaq 0x175b3(%rip), %rsi     # 0x1c01c
leaq 0x1784d(%rip), %rcx     # 0x1c2bd
movl $0xbe6, %edx            # imm = 0xBE6
callq 0x2100
leaq 0x1784f(%rip), %rdi     # 0x1c2d0
leaq 0x17594(%rip), %rsi     # 0x1c01c
leaq 0x1782e(%rip), %rcx     # 0x1c2bd
movl $0xbe7, %edx            # imm = 0xBE7
callq 0x2100
leaq 0x17850(%rip), %rdi     # 0x1c2f0
leaq 0x17575(%rip), %rsi     # 0x1c01c
leaq 0x1780f(%rip), %rcx     # 0x1c2bd
movl $0xbea, %edx            # imm = 0xBEA
callq 0x2100
leaq 0x17861(%rip), %rdi     # 0x1c320
leaq 0x17556(%rip), %rsi     # 0x1c01c
leaq 0x177f0(%rip), %rcx     # 0x1c2bd
movl $0xbec, %edx            # imm = 0xBEC
callq 0x2100
leaq 0x17812(%rip), %rdi     # 0x1c2f0
leaq 0x17537(%rip), %rsi     # 0x1c01c
leaq 0x177d1(%rip), %rcx     # 0x1c2bd
movl $0xbed, %edx            # imm = 0xBED
callq 0x2100
leaq 0x17837(%rip), %rdi     # 0x1c334
leaq 0x17518(%rip), %rsi     # 0x1c01c
leaq 0x177b2(%rip), %rcx     # 0x1c2bd
movl $0xbef, %edx            # imm = 0xBEF
callq 0x2100
leaq 0x17785(%rip), %rdi     # 0x1c2a1
leaq 0x174f9(%rip), %rsi     # 0x1c01c
leaq 0x17793(%rip), %rcx     # 0x1c2bd
movl $0xbf0, %edx            # imm = 0xBF0
callq 0x2100
leaq 0x17795(%rip), %rdi     # 0x1c2d0
leaq 0x174da(%rip), %rsi     # 0x1c01c
leaq 0x17774(%rip), %rcx     # 0x1c2bd
movl $0xbf1, %edx            # imm = 0xBF1
callq 0x2100
leaq 0x177f1(%rip), %rdi     # 0x1c34b
leaq 0x174bb(%rip), %rsi     # 0x1c01c
leaq 0x17755(%rip), %rcx     # 0x1c2bd
movl $0xbf6, %edx            # imm = 0xBF6
callq 0x2100
leaq 0x177d2(%rip), %rdi     # 0x1c34b
leaq 0x1749c(%rip), %rsi     # 0x1c01c
leaq 0x17736(%rip), %rcx     # 0x1c2bd
movl $0xbfb, %edx            # imm = 0xBFB
callq 0x2100
leaq 0x177b3(%rip), %rdi     # 0x1c34b
leaq 0x1747d(%rip), %rsi     # 0x1c01c
leaq 0x17717(%rip), %rcx     # 0x1c2bd
movl $0xc0a, %edx            # imm = 0xC0A
callq 0x2100