// File: /workspace/github_c_makefile_star2_O3/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 0x17dbc(%rip), %rax     # 0x1c295
leaq 0x8(%rsp), %rdi
movq %rax, (%rdi)
leaq 0x1ee48(%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 0x17e47(%rip), %rcx     # 0x1c34a
movq %rcx, 0x10(%rdi)
leaq 0x1ec42(%rip), %rcx     # 0x23150
movq %rcx, 0x18(%rdi)
movq %rax, 0x20(%rdi)
callq 0x1ba26
leaq 0x18699(%rip), %rdi     # 0x1cbbb
callq 0x20a0
xorl %edi, %edi
callq 0x2eb6
movq %rax, %rbx
movq %rax, %rdi
callq *0x8(%rax)
cmpq 0x1ee4a(%rip), %rax     # 0x23388
jne 0x4954
movq %rbx, %rdi
callq *0x18(%rbx)
cmpq $-0x1, %rax
jne 0x4973
leaq 0x17def(%rip), %rdi     # 0x1c34a
callq 0x2eb6
movq %rax, %rbx
movq %rax, %rdi
callq *0x8(%rax)
cmpq 0x1ee18(%rip), %rax     # 0x23388
jne 0x4992
movq %rbx, %rdi
callq *0x18(%rbx)
cmpq $-0x1, %rax
jne 0x49b1
leaq 0x1a25b(%rip), %rdi     # 0x1e7e8
callq 0x2eb6
movq %rax, %rbx
movq %rax, %rdi
callq *0x8(%rax)
cmpq 0x1edde(%rip), %rax     # 0x23380
jne 0x49d0
movq %rbx, %rdi
callq *0x18(%rbx)
cmpq $0x83, %rax
jne 0x49ef
movq %rbx, %rdi
callq *0x8(%rbx)
cmpq 0x1edc1(%rip), %rax     # 0x23388
jne 0x4a0e
movq %rbx, %rdi
callq *0x18(%rbx)
cmpq $-0x1, %rax
jne 0x4a2d
leaq 0x17b79(%rip), %rdi     # 0x1c15d
callq 0x2eb6
movq %rax, %rbx
movq %rax, %rdi
callq *0x8(%rax)
cmpq 0x1ed87(%rip), %rax     # 0x23380
jne 0x4a4c
movq %rbx, %rdi
callq *0x18(%rbx)
cmpq $0xa3, %rax
jne 0x4a6b
movq %rbx, %rdi
callq *0x8(%rbx)
cmpq 0x1ed62(%rip), %rax     # 0x23380
jne 0x4a8a
movq %rbx, %rdi
callq *0x18(%rbx)
cmpq $0xa7, %rax
jne 0x4aa9
movq %rbx, %rdi
callq *0x8(%rbx)
cmpq 0x1ed45(%rip), %rax     # 0x23388
jne 0x4ac8
movq %rbx, %rdi
callq *0x18(%rbx)
cmpq $-0x1, %rax
jne 0x4ae7
leaq 0x17ce8(%rip), %rdi     # 0x1c348
callq 0x2eb6
movq %rax, %rdi
callq 0x3438
movq $-0x1, %rdi
movq %rax, %rsi
callq 0x19dcc
testq %rax, %rax
je 0x4b06
leaq 0x17ad1(%rip), %rdi     # 0x1c15d
callq 0x2eb6
movq %rax, %rdi
callq 0x3438
movq 0x1ecf8(%rip), %rdi     # 0x23398
movq %rax, %rsi
callq 0x19dcc
testq %rax, %rax
je 0x4b25
leaq 0x17ca7(%rip), %rdi     # 0x1c35f
callq 0x2eb6
movq %rax, %rdi
callq 0x3438
movq $-0x1, %rdi
movq %rax, %rsi
callq 0x19dcc
testq %rax, %rax
je 0x4b44
movq 0x1ecc4(%rip), %rdi     # 0x233a8
movq %rdi, %rsi
callq 0x4b63
movq 0x1ecad(%rip), %r14     # 0x233a0
leaq 0x17c6b(%rip), %rdi     # 0x1c365
callq 0x170ff
movq %rax, %rdi
callq 0x3fe8
movq %rax, %r15
movq 0x1ec8f(%rip), %r12     # 0x233a0
movq 0x1ec70(%rip), %r13     # 0x23388
movq 0x1ec61(%rip), %rdi     # 0x23380
movq 0x1ec72(%rip), %rsi     # 0x23398
callq 0x19c50
leaq -0xbbe(%rip), %rbx      # 0x3b74
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x128be
movq %r13, %rdi
movq %rax, %rsi
callq 0x19c50
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x128be
movq %r15, %rdi
movq %rax, %rsi
callq 0x19c50
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x128be
movq 0x1ec0f(%rip), %rsi     # 0x23388
movq %rax, %rdi
callq 0x4b63
movq 0x1ec18(%rip), %r14     # 0x233a0
leaq 0x17bdf(%rip), %rdi     # 0x1c36e
callq 0x170ff
movq %rax, %rdi
callq 0x3fe8
movq %rax, %r15
movq 0x1ebfa(%rip), %r12     # 0x233a0
movq 0x1ec03(%rip), %r13     # 0x233b0
movq 0x1ebf4(%rip), %rdi     # 0x233a8
movq 0x1ebdd(%rip), %rsi     # 0x23398
callq 0x19c50
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x128be
movq %r13, %rdi
movq %rax, %rsi
callq 0x19c50
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x128be
movq %r15, %rdi
movq %rax, %rsi
callq 0x19c50
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x128be
movq 0x1eb79(%rip), %rsi     # 0x23380
movq %rax, %rdi
callq 0x4b63
leaq 0x17b60(%rip), %rdi     # 0x1c376
callq 0x2eb6
movq %rax, %rdi
callq 0x3438
movq %rax, %rbx
leaq 0x17b36(%rip), %rdi     # 0x1c363
callq 0x170ff
movq %rax, %rdi
callq 0x3fe8
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4b63
leaq 0x17b43(%rip), %rdi     # 0x1c38f
callq 0x2eb6
movq %rax, %rdi
callq 0x3438
movq 0x1eb28(%rip), %rsi     # 0x23388
movq %rax, %rdi
callq 0x4b63
leaq 0x17b55(%rip), %rdi     # 0x1c3c4
callq 0x2eb6
movq %rax, %rdi
callq 0x3438
movq 0x1eafd(%rip), %rsi     # 0x23380
movq %rax, %rdi
callq 0x4b63
leaq 0x17b4c(%rip), %rdi     # 0x1c3de
callq 0x2eb6
movq %rax, %rdi
callq 0x3438
movq %rax, %rbx
movl $0xab, %edi
callq 0x3e71
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4b63
leaq 0x17b46(%rip), %rdi     # 0x1c404
callq 0x2eb6
movq %rax, %rdi
callq 0x3438
movq 0x1eaae(%rip), %rsi     # 0x23380
movq %rax, %rdi
callq 0x4b63
leaq 0x17b49(%rip), %rdi     # 0x1c42a
callq 0x2eb6
movq %rax, %rdi
callq 0x3438
movq 0x1ea93(%rip), %rsi     # 0x23388
movq %rax, %rdi
callq 0x4b63
leaq 0x17b76(%rip), %rdi     # 0x1c47a
callq 0x2eb6
movq %rax, %rdi
callq 0x3438
movq %rax, %rbx
movl $0x7, %edi
callq 0x3e71
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4b63
movq 0x1ea70(%rip), %rdi     # 0x233a0
callq 0x1249b
leaq 0x8(%rsp), %rdi
movl $0xcbd, 0xc(%rdi)       # imm = 0xCBD
callq 0x1bbab
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x17946(%rip), %rdi     # 0x1c2a1
leaq 0x176ba(%rip), %rsi     # 0x1c01c
leaq 0x17954(%rip), %rcx     # 0x1c2bd
movl $0xbda, %edx            # imm = 0xBDA
callq 0x2100
leaq 0x17956(%rip), %rdi     # 0x1c2d0
leaq 0x1769b(%rip), %rsi     # 0x1c01c
leaq 0x17935(%rip), %rcx     # 0x1c2bd
movl $0xbdb, %edx            # imm = 0xBDB
callq 0x2100
leaq 0x17908(%rip), %rdi     # 0x1c2a1
leaq 0x1767c(%rip), %rsi     # 0x1c01c
leaq 0x17916(%rip), %rcx     # 0x1c2bd
movl $0xbde, %edx            # imm = 0xBDE
callq 0x2100
leaq 0x17918(%rip), %rdi     # 0x1c2d0
leaq 0x1765d(%rip), %rsi     # 0x1c01c
leaq 0x178f7(%rip), %rcx     # 0x1c2bd
movl $0xbdf, %edx            # imm = 0xBDF
callq 0x2100
leaq 0x17919(%rip), %rdi     # 0x1c2f0
leaq 0x1763e(%rip), %rsi     # 0x1c01c
leaq 0x178d8(%rip), %rcx     # 0x1c2bd
movl $0xbe2, %edx            # imm = 0xBE2
callq 0x2100
leaq 0x17917(%rip), %rdi     # 0x1c30d
leaq 0x1761f(%rip), %rsi     # 0x1c01c
leaq 0x178b9(%rip), %rcx     # 0x1c2bd
movl $0xbe4, %edx            # imm = 0xBE4
callq 0x2100
leaq 0x1788c(%rip), %rdi     # 0x1c2a1
leaq 0x17600(%rip), %rsi     # 0x1c01c
leaq 0x1789a(%rip), %rcx     # 0x1c2bd
movl $0xbe6, %edx            # imm = 0xBE6
callq 0x2100
leaq 0x1789c(%rip), %rdi     # 0x1c2d0
leaq 0x175e1(%rip), %rsi     # 0x1c01c
leaq 0x1787b(%rip), %rcx     # 0x1c2bd
movl $0xbe7, %edx            # imm = 0xBE7
callq 0x2100
leaq 0x1789d(%rip), %rdi     # 0x1c2f0
leaq 0x175c2(%rip), %rsi     # 0x1c01c
leaq 0x1785c(%rip), %rcx     # 0x1c2bd
movl $0xbea, %edx            # imm = 0xBEA
callq 0x2100
leaq 0x178ae(%rip), %rdi     # 0x1c320
leaq 0x175a3(%rip), %rsi     # 0x1c01c
leaq 0x1783d(%rip), %rcx     # 0x1c2bd
movl $0xbec, %edx            # imm = 0xBEC
callq 0x2100
leaq 0x1785f(%rip), %rdi     # 0x1c2f0
leaq 0x17584(%rip), %rsi     # 0x1c01c
leaq 0x1781e(%rip), %rcx     # 0x1c2bd
movl $0xbed, %edx            # imm = 0xBED
callq 0x2100
leaq 0x17884(%rip), %rdi     # 0x1c334
leaq 0x17565(%rip), %rsi     # 0x1c01c
leaq 0x177ff(%rip), %rcx     # 0x1c2bd
movl $0xbef, %edx            # imm = 0xBEF
callq 0x2100
leaq 0x177d2(%rip), %rdi     # 0x1c2a1
leaq 0x17546(%rip), %rsi     # 0x1c01c
leaq 0x177e0(%rip), %rcx     # 0x1c2bd
movl $0xbf0, %edx            # imm = 0xBF0
callq 0x2100
leaq 0x177e2(%rip), %rdi     # 0x1c2d0
leaq 0x17527(%rip), %rsi     # 0x1c01c
leaq 0x177c1(%rip), %rcx     # 0x1c2bd
movl $0xbf1, %edx            # imm = 0xBF1
callq 0x2100
leaq 0x1783e(%rip), %rdi     # 0x1c34b
leaq 0x17508(%rip), %rsi     # 0x1c01c
leaq 0x177a2(%rip), %rcx     # 0x1c2bd
movl $0xbf6, %edx            # imm = 0xBF6
callq 0x2100
leaq 0x1781f(%rip), %rdi     # 0x1c34b
leaq 0x174e9(%rip), %rsi     # 0x1c01c
leaq 0x17783(%rip), %rcx     # 0x1c2bd
movl $0xbfb, %edx            # imm = 0xBFB
callq 0x2100
leaq 0x17800(%rip), %rdi     # 0x1c34b
leaq 0x174ca(%rip), %rsi     # 0x1c01c
leaq 0x17764(%rip), %rcx     # 0x1c2bd
movl $0xc0a, %edx            # imm = 0xC0A
callq 0x2100