// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
leaq 0x107ca(%rip), %rax     # 0x1a679
movq %rax, -0x28(%rbp)
leaq 0x164ce(%rip), %rax     # 0x20388
movq (%rax), %rax
movq 0x50(%rax), %rax
movl 0x8(%rax), %eax
movl %eax, -0x20(%rbp)
movl $0x68b, -0x1c(%rbp)     # imm = 0x68B
leaq 0x12ddb(%rip), %rax     # 0x1ccb0
movq %rax, -0x18(%rbp)
leaq 0x16250(%rip), %rax     # 0x20130
movq %rax, -0x10(%rbp)
leaq 0x1649d(%rip), %rax     # 0x20388
movq (%rax), %rax
movq 0x50(%rax), %rax
movq %rax, -0x8(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x19910
callq 0xac40
leaq 0x1077a(%rip), %rdi     # 0x1a685
movb $0x0, %al
callq 0x20d0
leaq 0x11fe3(%rip), %rsi     # 0x1befc
movq %rsi, %rdi
callq 0xa5c0
leaq 0x122c7(%rip), %rsi     # 0x1c1ef
movq %rsi, %rdi
callq 0xa5c0
leaq 0x12327(%rip), %rsi     # 0x1c25e
movq %rsi, %rdi
callq 0xa5c0
leaq 0x1234e(%rip), %rsi     # 0x1c294
movq %rsi, %rdi
callq 0xa5c0
leaq 0x1218a(%rip), %rsi     # 0x1c0df
movq %rsi, %rdi
callq 0xa5c0
leaq 0x1217b(%rip), %rdi     # 0x1c0df
leaq 0x128f4(%rip), %rsi     # 0x1c85f
callq 0xa5c0
leaq 0x1071f(%rip), %rdi     # 0x1a696
leaq 0x11f7e(%rip), %rsi     # 0x1befc
callq 0xa5c0
leaq 0x10718(%rip), %rdi     # 0x1a6a2
leaq 0x122cd(%rip), %rsi     # 0x1c25e
callq 0xa5c0
leaq 0x10714(%rip), %rdi     # 0x1a6b1
leaq 0x1213b(%rip), %rsi     # 0x1c0df
callq 0xa5c0
leaq 0x1070e(%rip), %rdi     # 0x1a6be
leaq 0x12665(%rip), %rsi     # 0x1c61c
callq 0xa5c0
leaq 0x10709(%rip), %rdi     # 0x1a6cc
leaq 0x122ca(%rip), %rsi     # 0x1c294
callq 0xa5c0
leaq 0x10703(%rip), %rdi     # 0x1a6d9
leaq 0x12281(%rip), %rsi     # 0x1c25e
callq 0xa5c0
leaq 0x106fb(%rip), %rdi     # 0x1a6e4
leaq 0x1226e(%rip), %rsi     # 0x1c25e
callq 0xa5c0
leaq 0x106fe(%rip), %rdi     # 0x1a6fa
leaq 0x12291(%rip), %rsi     # 0x1c294
callq 0xa5c0
leaq 0x106f9(%rip), %rdi     # 0x1a708
leaq 0x12248(%rip), %rsi     # 0x1c25e
callq 0xa5c0
leaq 0x106f2(%rip), %rdi     # 0x1a714
leaq 0x1226b(%rip), %rsi     # 0x1c294
callq 0xa5c0
leaq 0x106f6(%rip), %rdi     # 0x1a72b
leaq 0x1207a(%rip), %rsi     # 0x1c0b6
callq 0xa5c0
leaq 0x106f9(%rip), %rdi     # 0x1a741
leaq 0x12090(%rip), %rsi     # 0x1c0df
callq 0xa5c0
leaq 0x106fb(%rip), %rdi     # 0x1a756
leaq 0x12054(%rip), %rsi     # 0x1c0b6
callq 0xa5c0
leaq 0x10700(%rip), %rdi     # 0x1a76e
leaq 0x125cd(%rip), %rsi     # 0x1c642
callq 0xa5c0
leaq 0x10704(%rip), %rdi     # 0x1a785
leaq 0x129ac(%rip), %rsi     # 0x1ca34
callq 0xa5c0
leaq 0x10700(%rip), %rdi     # 0x1a794
leaq 0x10714(%rip), %rsi     # 0x1a7af
callq 0xa5c0
leaq 0x1070e(%rip), %rdi     # 0x1a7b5
leaq 0x10701(%rip), %rsi     # 0x1a7af
callq 0xa5c0
leaq 0x10715(%rip), %rdi     # 0x1a7cf
leaq 0x10732(%rip), %rsi     # 0x1a7f3
callq 0xa5c0
leaq 0x1072c(%rip), %rdi     # 0x1a7f9
leaq 0x11e28(%rip), %rsi     # 0x1befc
callq 0xa5c0
leaq 0x1073b(%rip), %rdi     # 0x1a81b
leaq 0x1288a(%rip), %rsi     # 0x1c971
callq 0xa5c0
leaq 0x10749(%rip), %rdi     # 0x1a83c
leaq 0x11fe5(%rip), %rsi     # 0x1c0df
callq 0xa5c0
leaq 0x10741(%rip), %rdi     # 0x1a847
leaq 0x11fd2(%rip), %rsi     # 0x1c0df
callq 0xa5c0
leaq 0x11e3d(%rip), %rdi     # 0x1bf56
leaq 0x11fbf(%rip), %rsi     # 0x1c0df
callq 0xa5c0
leaq 0x10725(%rip), %rdi     # 0x1a851
leaq 0x12901(%rip), %rsi     # 0x1ca34
callq 0xa5c0
leaq 0x1071b(%rip), %rdi     # 0x1a85a
leaq 0x10669(%rip), %rsi     # 0x1a7af
callq 0xa5c0
leaq 0x10713(%rip), %rdi     # 0x1a865
leaq 0x1072d(%rip), %rsi     # 0x1a886
callq 0xa5c0
leaq 0x10729(%rip), %rdi     # 0x1a88e
leaq 0x126f3(%rip), %rsi     # 0x1c85f
callq 0xa5c0
leaq 0x1071c(%rip), %rdi     # 0x1a894
leaq 0x127f2(%rip), %rsi     # 0x1c971
callq 0xa5c0
leaq 0x10711(%rip), %rdi     # 0x1a89c
leaq 0x10714(%rip), %rsi     # 0x1a8a6
callq 0xa5c0
leaq 0x1070e(%rip), %rdi     # 0x1a8ac
leaq 0x106e1(%rip), %rsi     # 0x1a886
callq 0xa5c0
leaq 0x1071b(%rip), %rdi     # 0x1a8cc
leaq 0x120a6(%rip), %rsi     # 0x1c25e
callq 0xa5c0
leaq 0x10715(%rip), %rdi     # 0x1a8d9
leaq 0x120c9(%rip), %rsi     # 0x1c294
callq 0xa5c0
leaq 0x1070f(%rip), %rdi     # 0x1a8e6
leaq 0x12080(%rip), %rsi     # 0x1c25e
callq 0xa5c0
leaq 0x1070c(%rip), %rdi     # 0x1a8f6
leaq 0x120a3(%rip), %rsi     # 0x1c294
callq 0xa5c0
leaq 0x10707(%rip), %rdi     # 0x1a904
leaq 0x1071c(%rip), %rsi     # 0x1a920
callq 0xa5c0
leaq 0x10714(%rip), %rdi     # 0x1a924
leaq 0x10729(%rip), %rsi     # 0x1a940
callq 0xa5c0
leaq 0x10720(%rip), %rdi     # 0x1a943
leaq 0x12034(%rip), %rsi     # 0x1c25e
callq 0xa5c0
leaq 0x10719(%rip), %rdi     # 0x1a94f
leaq 0x12021(%rip), %rsi     # 0x1c25e
callq 0xa5c0
leaq 0x10712(%rip), %rdi     # 0x1a95b
leaq 0x1200e(%rip), %rsi     # 0x1c25e
callq 0xa5c0
leaq 0x1070c(%rip), %rdi     # 0x1a968
leaq 0x12031(%rip), %rsi     # 0x1c294
callq 0xa5c0
leaq 0x10708(%rip), %rdi     # 0x1a977
leaq 0x1201e(%rip), %rsi     # 0x1c294
callq 0xa5c0
leaq 0x10702(%rip), %rdi     # 0x1a984
leaq 0x11fd5(%rip), %rsi     # 0x1c25e
callq 0xa5c0
leaq 0x106f9(%rip), %rdi     # 0x1a98e
leaq 0x11ff8(%rip), %rsi     # 0x1c294
callq 0xa5c0
leaq 0x106f0(%rip), %rdi     # 0x1a998
leaq 0x11fe5(%rip), %rsi     # 0x1c294
callq 0xa5c0
leaq 0x106e8(%rip), %rdi     # 0x1a9a3
leaq 0x11fd2(%rip), %rsi     # 0x1c294
callq 0xa5c0
leaq 0x106e2(%rip), %rdi     # 0x1a9b0
leaq 0x11fbf(%rip), %rsi     # 0x1c294
callq 0xa5c0
leaq 0x106da(%rip), %rdi     # 0x1a9bb
leaq 0x11ec7(%rip), %rsi     # 0x1c1af
callq 0xa5c0
leaq 0x106d1(%rip), %rdi     # 0x1a9c5
leaq 0x10735(%rip), %rsi     # 0x1aa30
callq 0xa5c0
leaq 0x106ca(%rip), %rdi     # 0x1a9d1
leaq 0x11bee(%rip), %rsi     # 0x1befc
callq 0xa5c0
leaq 0x106c4(%rip), %rdi     # 0x1a9de
leaq 0x106c6(%rip), %rsi     # 0x1a9e7
callq 0xa5c0
leaq 0x106bd(%rip), %rdi     # 0x1a9ea
leaq 0x11f60(%rip), %rsi     # 0x1c294
callq 0xa5c0
leaq 0x106bd(%rip), %rdi     # 0x1a9fd
leaq 0x11f17(%rip), %rsi     # 0x1c25e
callq 0xa5c0
leaq 0x106bd(%rip), %rdi     # 0x1aa10
leaq 0x11e95(%rip), %rsi     # 0x1c1ef
callq 0xa5c0
leaq 0x106b8(%rip), %rdi     # 0x1aa1e
leaq 0x106c2(%rip), %rsi     # 0x1aa2f
callq 0xa5c0
leaq 0x106b9(%rip), %rdi     # 0x1aa32
leaq 0x11b7c(%rip), %rsi     # 0x1befc
callq 0xa5c0
leaq 0x106b4(%rip), %rdi     # 0x1aa40
leaq 0x10654(%rip), %rsi     # 0x1a9e7
callq 0xa5c0
leaq 0x106ae(%rip), %rdi     # 0x1aa4d
leaq 0x11eb8(%rip), %rsi     # 0x1c25e
callq 0xa5c0
leaq 0x106b2(%rip), %rdi     # 0x1aa64
leaq 0x11edb(%rip), %rsi     # 0x1c294
callq 0xa5c0
leaq 0x106b6(%rip), %rdi     # 0x1aa7b
leaq 0x11b30(%rip), %rsi     # 0x1befc
callq 0xa5c0
leaq 0x106c2(%rip), %rdi     # 0x1aa9a
leaq 0x106e9(%rip), %rsi     # 0x1aac8
callq 0xa5c0
leaq 0x106ea(%rip), %rdi     # 0x1aad5
leaq 0x1070e(%rip), %rsi     # 0x1ab00
callq 0xa5c0
movq 0x15fda(%rip), %rdi     # 0x203d8
movq 0x15d93(%rip), %rdx     # 0x20198
leaq 0x106fe(%rip), %rsi     # 0x1ab0a
callq 0x9be0
leaq 0x1072e(%rip), %rdi     # 0x1ab46
leaq 0x1073d(%rip), %rsi     # 0x1ab5c
callq 0xa5c0
leaq 0x10738(%rip), %rdi     # 0x1ab63
leaq 0x12602(%rip), %rsi     # 0x1ca34
callq 0xa5c0
leaq 0x10747(%rip), %rdi     # 0x1ab85
leaq 0x11e4f(%rip), %rsi     # 0x1c294
callq 0xa5c0
leaq 0x1075c(%rip), %rdi     # 0x1abad
leaq 0x11e06(%rip), %rsi     # 0x1c25e
callq 0xa5c0
leaq 0x10772(%rip), %rdi     # 0x1abd6
leaq 0x107a5(%rip), %rsi     # 0x1ac10
callq 0xa5c0
leaq 0x107a7(%rip), %rdi     # 0x1ac1e
leaq 0x107d0(%rip), %rsi     # 0x1ac4e
callq 0xa5c0
movq 0x15f4e(%rip), %rdi     # 0x203d8
movq 0x15d07(%rip), %rdx     # 0x20198
leaq 0x107b8(%rip), %rsi     # 0x1ac50
callq 0x9be0
leaq 0x107f8(%rip), %rdi     # 0x1ac9c
leaq 0x10585(%rip), %rsi     # 0x1aa30
callq 0xa5c0
leaq 0x107ee(%rip), %rdi     # 0x1aca5
leaq 0x11a3e(%rip), %rsi     # 0x1befc
callq 0xa5c0
leaq 0x107e6(%rip), %rdi     # 0x1acb0
leaq 0x11d8d(%rip), %rsi     # 0x1c25e
callq 0xa5c0
movq 0x15efb(%rip), %rdi     # 0x203d8
movq 0x15cb4(%rip), %rdx     # 0x20198
leaq 0x107e5(%rip), %rsi     # 0x1acd0
callq 0x9be0
leaq 0x10807(%rip), %rdi     # 0x1acfe
leaq 0x11d96(%rip), %rsi     # 0x1c294
callq 0xa5c0
leaq 0x107ff(%rip), %rdi     # 0x1ad09
leaq 0x11d4d(%rip), %rsi     # 0x1c25e
callq 0xa5c0
movq 0x15ebb(%rip), %rdi     # 0x203d8
movq 0x15c74(%rip), %rdx     # 0x20198
leaq 0x107ea(%rip), %rsi     # 0x1ad15
callq 0x9be0
leaq 0x1080e(%rip), %rdi     # 0x1ad45
leaq 0x11d20(%rip), %rsi     # 0x1c25e
callq 0xa5c0
leaq 0x10807(%rip), %rdi     # 0x1ad51
leaq 0x11d43(%rip), %rsi     # 0x1c294
callq 0xa5c0
leaq 0x10801(%rip), %rdi     # 0x1ad5e
leaq 0x11cfa(%rip), %rsi     # 0x1c25e
callq 0xa5c0
movq 0x15e68(%rip), %rdi     # 0x203d8
movq 0x15c21(%rip), %rdx     # 0x20198
leaq 0x107f6(%rip), %rsi     # 0x1ad74
callq 0x9be0
leaq 0x10826(%rip), %rdi     # 0x1adb0
leaq 0x1082d(%rip), %rsi     # 0x1adbe
callq 0xa5c0
movq 0x15e3b(%rip), %rdi     # 0x203d8
callq 0xe590
movl $0x6fd, -0x1c(%rbp)     # imm = 0x6FD
leaq -0x28(%rbp), %rdi
callq 0x19ae0
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)