// File: /workspace/github_c_makefile_star2_O3/dalnefre[P]kernel_abe/reduce.c
// Function: test_reduce
void
test_reduce()
{
	DBUG_ENTER("test_reduce");
	init_reduce();
	TRACE(printf("--test_reduce--\n"));

	assert_reduce("0", "0");
	assert_reduce("1", "1");
	assert_reduce("TRUE", "TRUE");
	assert_reduce("FALSE", "FALSE");
	assert_reduce("()", "()");
	assert_reduce("()", "NIL");
	
	assert_reduce("(literal 0)", "0");
	assert_reduce("(literal TRUE)", "TRUE");
	assert_reduce("(literal ())", "()");
	assert_reduce("(literal (x))", "(x)");

	assert_reduce("(list? TRUE)", "FALSE");
	assert_reduce("(list? ())", "TRUE");
	assert_reduce("(list? (literal (x)))", "TRUE");

	assert_reduce("(empty? TRUE)", "FALSE");
	assert_reduce("(empty? ())", "TRUE");
	assert_reduce("(empty? (literal (x)))", "FALSE");

	assert_reduce("(first (literal (x)))", "x");
	assert_reduce("(rest (literal (x)))", "()");
	assert_reduce("(first (literal (x y)))", "x");
	assert_reduce("(rest (literal (x y)))", "(y)");
	assert_reduce("(prepend 0 ())", "(0)");
	assert_reduce("(prepend 0 (prepend 1 ()))", "(0 1)");
	assert_reduce("(prepend 0 (literal (1)))", "(0 1)");
	assert_reduce("(prepend (literal x) (literal (y)))", "(x y)");
	assert_reduce("(first (prepend 0 (literal (1))))", "0");
	assert_reduce("(rest (prepend 0 (literal (1))))", "(1)");
	assert_reduce("(first ())", "()");
	assert_reduce("(rest ())", "()");
	assert_reduce("(list)", "()");
	assert_reduce("(list 0)", "(0)");
	assert_reduce("(list 0 1)", "(0 1)");
	assert_reduce("(list (literal x) (literal (y)))", "(x (y))");

	assert_reduce("(seq)", "NIL");
	assert_reduce("(seq 1)", "(1)");
	assert_reduce("(seq 1 2)", "(1 2)");
	assert_reduce("(seq (literal x) (literal (y)))", "(x (y))");

	assert_reduce("(equal? 0 0)", "TRUE");
	assert_reduce("(equal? 0 1)", "FALSE");
	assert_reduce("(equal? NIL ())", "TRUE");
	assert_reduce("(equal? 0 ())", "FALSE");

	assert_reduce("(if TRUE (literal Yes) (?))", "Yes");
	assert_reduce("(if FALSE (?) (literal No))", "No");

	assert_reduce("(number? 0)", "TRUE");
	assert_reduce("(number? 1)", "TRUE");
	assert_reduce("(number? -1)", "TRUE");
	assert_reduce("(number? TRUE)", "FALSE");
	assert_reduce("(number? ())", "FALSE");

	assert_reduce("(zero? 0)", "TRUE");
	assert_reduce("(zero? 1)", "FALSE");
	assert_reduce("(zero? -1)", "FALSE");
	assert_reduce("(zero? TRUE)", "FALSE");
	assert_reduce("(zero? ())", "FALSE");

	assert_reduce("(sum 1 1)", "2");
	assert_reduce("(sum 1 2 3)", "6");
	assert_reduce("(sum 1 0 -1)", "0");
	assert_reduce("(sum 41)", "41");
	assert_reduce("(zero? (sum 0 -1))", "FALSE");
	assert_reduce("(zero? (sum 1 -1))", "TRUE");

	assert_reduce("(product 1 1)", "1");
	assert_reduce("(product -1 2 3)", "-6");
	assert_reduce("(product 1 0)", "0");
	assert_reduce("(product 41)", "41");
	assert_reduce("(zero? (product 0 -1))", "TRUE");
	assert_reduce("(zero? (product 1 -1))", "FALSE");
	
	assert_reduce("((template (x) (literal x)) 0)", "0");
	assert_reduce("((template (x y) (literal (y x))) TRUE FALSE)", "(FALSE TRUE)");
	assert_reduce("((template (x y) (literal (y x))) foo bar)", "(bar foo)");
	reduce_line(reduce_cfg, "(define 2tuple (template (x y) (prepend x (prepend y ()))))", a_sink);
	assert_reduce("(2tuple () (sum 1 2))", "(() 3)");
	
	assert_reduce("((function (x) (prepend x ())) 0)", "(0)");
	assert_reduce("((function (x) (if x FALSE TRUE)) TRUE)", "FALSE");
	assert_reduce("((function (x) (if x FALSE TRUE)) FALSE)", "TRUE");	
	assert_reduce("((function (x) (list (literal Hello) x)) (literal World))", "(Hello World)");
	assert_reduce("(((function (x) (function (y) (sum x y))) 3) 4)", "7");
	reduce_line(reduce_cfg, "(define fact (function (n) (if (zero? n) 1 (product n (fact (sum n -1))))))", a_sink);
	assert_reduce("(fact 3)", "6");

	assert_reduce("(reduce 0)", "0");
	assert_reduce("(reduce (literal (equal? 0 0)))", "TRUE");

	reduce_line(reduce_cfg, "(define not (function (x) (if x FALSE TRUE)))", a_sink);
	assert_reduce("(not TRUE)", "FALSE");
	assert_reduce("(not FALSE)", "TRUE");
#if 0
	assert_reduce("(not 0)", "_");		/* error expected */
#endif
	reduce_line(reduce_cfg, "(define symbol? (function (x) (not (list? x))))", a_sink);
	assert_reduce("(symbol? 0)", "TRUE");
	assert_reduce("(symbol? ())", "FALSE");
	assert_reduce("(symbol? (literal x))", "TRUE");
	reduce_line(reduce_cfg, "(define swap2 (function (x y) (prepend y (prepend x NIL))))", a_sink);
	assert_reduce("(swap2 0 1 2)", "(1 0)");
	
#if 0
	assert_reduce("(?)", "_");	/* this case produces error messages, but should pass */
#endif
	report_actor_usage(reduce_cfg);
	DBUG_RETURN;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
leaq 0xc53c(%rip), %rax      # 0x1467b
movq %rsp, %rdi
movq %rax, (%rdi)
leaq 0x1323c(%rip), %rax     # 0x1b388
movq (%rax), %rax
movq 0x50(%rax), %rax
movl 0x8(%rax), %ecx
movl %ecx, 0x8(%rdi)
movl $0x68b, 0xc(%rdi)       # imm = 0x68B
leaq 0xe99d(%rip), %rcx      # 0x16b04
movq %rcx, 0x10(%rdi)
leaq 0x12fbe(%rip), %rcx     # 0x1b130
movq %rcx, 0x18(%rdi)
movq %rax, 0x20(%rdi)
callq 0x1339a
callq 0x8cb7
leaq 0xcdcd(%rip), %rdi      # 0x14f58
callq 0x20a0
leaq 0xdd79(%rip), %rbx      # 0x15f10
movq %rbx, %rdi
movq %rbx, %rsi
callq 0x8795
leaq 0xe04d(%rip), %rdi      # 0x161f6
movq %rdi, %rsi
callq 0x8795
leaq 0xe0ad(%rip), %r14      # 0x16265
movq %r14, %rdi
movq %r14, %rsi
callq 0x8795
leaq 0xe0d1(%rip), %r15      # 0x1629b
movq %r15, %rdi
movq %r15, %rsi
callq 0x8795
leaq 0xdf0a(%rip), %rbp      # 0x160e6
movq %rbp, %rdi
movq %rbp, %rsi
callq 0x8795
leaq 0xe63a(%rip), %rsi      # 0x16828
movq %rbp, %rdi
callq 0x8795
leaq 0xc48a(%rip), %rdi      # 0x14687
movq %rbx, %rsi
callq 0x8795
leaq 0xc487(%rip), %rdi      # 0x14693
movq %r14, %rsi
callq 0x8795
leaq 0xc487(%rip), %rdi      # 0x146a2
movq %rbp, %rsi
callq 0x8795
leaq 0xc485(%rip), %rdi      # 0x146af
leaq 0xe3fe(%rip), %rsi      # 0x1662f
callq 0x8795
leaq 0xc480(%rip), %rdi      # 0x146bd
movq %r15, %rsi
callq 0x8795
leaq 0xc47e(%rip), %rdi      # 0x146ca
movq %r14, %rsi
callq 0x8795
leaq 0xc47a(%rip), %rdi      # 0x146d5
movq %r14, %rsi
callq 0x8795
leaq 0xc481(%rip), %rdi      # 0x146eb
movq %r15, %rsi
callq 0x8795
leaq 0xc480(%rip), %rdi      # 0x146f9
movq %r14, %rsi
callq 0x8795
leaq 0xc47d(%rip), %rdi      # 0x14705
movq %r15, %rsi
callq 0x8795
leaq 0xc485(%rip), %rdi      # 0x1471c
leaq 0xde1f(%rip), %rbx      # 0x160bd
movq %rbx, %rsi
callq 0x8795
leaq 0xc485(%rip), %rdi      # 0x14732
movq %rbp, %rsi
callq 0x8795
leaq 0xc48b(%rip), %rdi      # 0x14747
movq %rbx, %rsi
callq 0x8795
leaq 0xc494(%rip), %rdi      # 0x1475f
leaq 0xe383(%rip), %rsi      # 0x16655
callq 0x8795
leaq 0xc498(%rip), %rdi      # 0x14776
leaq 0xe6d9(%rip), %r12      # 0x169be
movq %r12, %rsi
callq 0x8795
leaq 0xc491(%rip), %rdi      # 0x14785
leaq 0xc4a5(%rip), %r13      # 0x147a0
movq %r13, %rsi
callq 0x8795
leaq 0xc49c(%rip), %rdi      # 0x147a6
movq %r13, %rsi
callq 0x8795
leaq 0xc4a7(%rip), %rdi      # 0x147c0
leaq 0xc4c4(%rip), %rsi      # 0x147e4
callq 0x8795
leaq 0xc4be(%rip), %rdi      # 0x147ea
leaq 0xdbdd(%rip), %rsi      # 0x15f10
callq 0x8795
leaq 0xc4cd(%rip), %rdi      # 0x1480c
leaq 0xe5b5(%rip), %rbx      # 0x168fb
movq %rbx, %rsi
callq 0x8795
leaq 0xc4d8(%rip), %rdi      # 0x1482d
movq %rbp, %rsi
callq 0x8795
leaq 0xc4d4(%rip), %rdi      # 0x14838
movq %rbp, %rsi
callq 0x8795
leaq 0xdbf7(%rip), %rdi      # 0x15f6a
movq %rbp, %rsi
callq 0x8795
leaq 0xc4c0(%rip), %rdi      # 0x14842
movq %r12, %rsi
movq %r12, %rbp
callq 0x8795
leaq 0xc4b7(%rip), %rdi      # 0x1484b
movq %r13, %rsi
callq 0x8795
leaq 0xc4b3(%rip), %rdi      # 0x14856
leaq 0xc4cd(%rip), %r13      # 0x14877
movq %r13, %rsi
callq 0x8795
leaq 0xc4c6(%rip), %rdi      # 0x1487f
leaq 0xe468(%rip), %rsi      # 0x16828
callq 0x8795
leaq 0xc4b9(%rip), %rdi      # 0x14885
movq %rbx, %rsi
callq 0x8795
leaq 0xc4b2(%rip), %rdi      # 0x1488d
leaq 0xc4b5(%rip), %rsi      # 0x14897
callq 0x8795
leaq 0xc4af(%rip), %rdi      # 0x1489d
movq %r13, %rsi
callq 0x8795
leaq 0xc4c0(%rip), %rdi      # 0x148bd
movq %r14, %rsi
callq 0x8795
leaq 0xc4be(%rip), %rdi      # 0x148ca
movq %r15, %rsi
callq 0x8795
leaq 0xc4bc(%rip), %rdi      # 0x148d7
movq %r14, %rsi
callq 0x8795
leaq 0xc4bd(%rip), %rdi      # 0x148e7
movq %r15, %rsi
callq 0x8795
leaq 0xc4bc(%rip), %rdi      # 0x148f5
leaq 0xc4d1(%rip), %rsi      # 0x14911
callq 0x8795
leaq 0xc4c9(%rip), %rdi      # 0x14915
leaq 0xc4de(%rip), %rsi      # 0x14931
callq 0x8795
leaq 0xc4d5(%rip), %rdi      # 0x14934
movq %r14, %rsi
callq 0x8795
leaq 0xc4d2(%rip), %rdi      # 0x14940
movq %r14, %rsi
callq 0x8795
leaq 0xc4cf(%rip), %rdi      # 0x1494c
movq %r14, %rsi
callq 0x8795
leaq 0xc4cd(%rip), %rdi      # 0x14959
movq %r15, %rsi
callq 0x8795
leaq 0xc4cd(%rip), %rdi      # 0x14968
movq %r15, %rsi
callq 0x8795
leaq 0xc4cb(%rip), %rdi      # 0x14975
movq %r14, %rsi
callq 0x8795
leaq 0xc4c6(%rip), %rdi      # 0x1497f
movq %r15, %rsi
callq 0x8795
leaq 0xc4c1(%rip), %rdi      # 0x14989
movq %r15, %rsi
callq 0x8795
leaq 0xc4bd(%rip), %rdi      # 0x14994
movq %r15, %rsi
callq 0x8795
leaq 0xc4bb(%rip), %rdi      # 0x149a1
movq %r15, %rsi
callq 0x8795
leaq 0xc4b7(%rip), %rdi      # 0x149ac
leaq 0xdcba(%rip), %rsi      # 0x161b6
callq 0x8795
leaq 0xc4ae(%rip), %rdi      # 0x149b6
leaq 0xc512(%rip), %r13      # 0x14a21
movq %r13, %rsi
callq 0x8795
leaq 0xc4a4(%rip), %rdi      # 0x149c2
leaq 0xd9eb(%rip), %r12      # 0x15f10
movq %r12, %rsi
callq 0x8795
leaq 0xc49b(%rip), %rdi      # 0x149cf
leaq 0xc49d(%rip), %rbx      # 0x149d8
movq %rbx, %rsi
callq 0x8795
leaq 0xc491(%rip), %rdi      # 0x149db
movq %r15, %rsi
callq 0x8795
leaq 0xc495(%rip), %rdi      # 0x149ee
movq %r14, %rsi
callq 0x8795
leaq 0xc499(%rip), %rdi      # 0x14a01
leaq 0xdc87(%rip), %rsi      # 0x161f6
callq 0x8795
leaq 0xc494(%rip), %rdi      # 0x14a0f
leaq 0xc49e(%rip), %rsi      # 0x14a20
callq 0x8795
leaq 0xc495(%rip), %rdi      # 0x14a23
movq %r12, %rsi
callq 0x8795
leaq 0xc494(%rip), %rdi      # 0x14a31
movq %rbx, %rsi
callq 0x8795
leaq 0xc492(%rip), %rdi      # 0x14a3e
movq %r14, %rsi
callq 0x8795
leaq 0xc49a(%rip), %rdi      # 0x14a55
movq %r15, %rsi
callq 0x8795
leaq 0xc4a2(%rip), %rdi      # 0x14a6c
movq %r12, %rsi
callq 0x8795
leaq 0xc4b2(%rip), %rdi      # 0x14a8b
leaq 0xc4d9(%rip), %rsi      # 0x14ab9
callq 0x8795
leaq 0xc4da(%rip), %rdi      # 0x14ac6
leaq 0xc4fe(%rip), %rsi      # 0x14af1
callq 0x8795
movq 0x12dd9(%rip), %rdi     # 0x1b3d8
movq 0x12b92(%rip), %rdx     # 0x1b198
leaq 0xc4ee(%rip), %rsi      # 0x14afb
callq 0x7f15
leaq 0xc51e(%rip), %rdi      # 0x14b37
leaq 0xc52d(%rip), %rsi      # 0x14b4d
callq 0x8795
leaq 0xc528(%rip), %rdi      # 0x14b54
movq %rbp, %rsi
callq 0x8795
leaq 0xc53b(%rip), %rdi      # 0x14b76
movq %r15, %rsi
callq 0x8795
leaq 0xc554(%rip), %rdi      # 0x14b9e
movq %r14, %rsi
callq 0x8795
leaq 0xc56e(%rip), %rdi      # 0x14bc7
leaq 0xc5a1(%rip), %rsi      # 0x14c01
callq 0x8795
leaq 0xc5a3(%rip), %rdi      # 0x14c0f
leaq 0xc5cc(%rip), %rsi      # 0x14c3f
callq 0x8795
movq 0x12d59(%rip), %rdi     # 0x1b3d8
movq 0x12b12(%rip), %rdx     # 0x1b198
leaq 0xc5b4(%rip), %rsi      # 0x14c41
callq 0x7f15
leaq 0xc5f4(%rip), %rdi      # 0x14c8d
movq %r13, %rsi
callq 0x8795
leaq 0xc5ee(%rip), %rdi      # 0x14c96
movq %r12, %rsi
callq 0x8795
leaq 0xc5ea(%rip), %rdi      # 0x14ca1
movq %r14, %rsi
callq 0x8795
movq 0x12d12(%rip), %rdi     # 0x1b3d8
movq 0x12acb(%rip), %rdx     # 0x1b198
leaq 0xc5ed(%rip), %rsi      # 0x14cc1
callq 0x7f15
leaq 0xc60f(%rip), %rdi      # 0x14cef
movq %r15, %rsi
callq 0x8795
leaq 0xc60b(%rip), %rdi      # 0x14cfa
movq %r14, %rsi
callq 0x8795
movq 0x12cda(%rip), %rdi     # 0x1b3d8
movq 0x12a93(%rip), %rdx     # 0x1b198
leaq 0xc5fa(%rip), %rsi      # 0x14d06
callq 0x7f15
leaq 0xc61e(%rip), %rdi      # 0x14d36
movq %r14, %rsi
callq 0x8795
leaq 0xc61b(%rip), %rdi      # 0x14d42
movq %r15, %rsi
callq 0x8795
leaq 0xc619(%rip), %rdi      # 0x14d4f
movq %r14, %rsi
callq 0x8795
movq 0x12c93(%rip), %rdi     # 0x1b3d8
movq 0x12a4c(%rip), %rdx     # 0x1b198
leaq 0xc612(%rip), %rsi      # 0x14d65
callq 0x7f15
leaq 0xc642(%rip), %rdi      # 0x14da1
leaq 0xc649(%rip), %rsi      # 0x14daf
callq 0x8795
movq 0x12c66(%rip), %rdi     # 0x1b3d8
callq 0xb4f4
movq %rsp, %rdi
movl $0x6fd, 0xc(%rdi)       # imm = 0x6FD
callq 0x1351f
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq