// File: /workspace/github_c_makefile_star2_O2/GangZhuo[P]rbtree/test/test.c
// Function: main
int main(int argc, char **argv)
{
	if (asc16_load(&asc16, "ASC16")) {
		printf("Failed to read \"ASC16\"\n");
		return EXIT_FAILURE;
	}

	if (argc > 1) {
		int i;
		char *cmd;
		for (i = 1; i < argc; i++) {
			cmd = argv[i];
			if (strcmp("insert", cmd) == 0 || strcmp("i", cmd) == 0) {
				i++;
				if (i < argc) {
					int v = atoi(argv[i]);
					if (v < 1) {
						printf("Invalid value, the value(s) should be a positive integer.\n");
						return EXIT_FAILURE;
					}
					else {
						insert(v);
					}
				}
				else {
					printf("Invalid arguments, usage: rbtree [insert 1] [insert 2]...\n");
					return EXIT_FAILURE;
				}
			}
			else if (strcmp("delete", cmd) == 0 || strcmp("d", cmd) == 0) {
				i++;
				if (i < argc) {
					int v = atoi(argv[i]);
					if (v < 1) {
						printf("Invalid value, the value(s) should be a positive integer.\n");
						return EXIT_FAILURE;
					}
					else {
						delete(v);
					}
				}
				else {
					printf("Invalid arguments, usage: rbtree [delete 1] [delete 2]...\n");
					return EXIT_FAILURE;
				}
			}
			else if (strcmp("find", cmd) == 0 || strcmp("f", cmd) == 0) {
				i++;
				if (i < argc) {
					int v = atoi(argv[i]);
					if (v < 1) {
						printf("Invalid value, the value(s) should be a positive integer.\n");
						return EXIT_FAILURE;
					}
					else {
						lookup(v);
					}
				}
				else {
					printf("Invalid arguments, usage: rbtree [find 1] [find 2]...\n");
					return EXIT_FAILURE;
				}
			}
			else if (strcmp("clear", cmd) == 0 || strcmp("c", cmd) == 0) {
				do_clean();
			}
			else if (strcmp("print", cmd) == 0 || strcmp("p", cmd) == 0) {
				const char *opt = "";
				if ((i + 1) < argc) {
					if (strcmp("pre", argv[i + 1]) == 0 ||
						strcmp("in", argv[i + 1]) == 0 ||
						strcmp("post", argv[i + 1]) == 0) {
						opt = argv[++i];
					}
				}
				do_print(opt);
			}
			else if (strcmp("load", cmd) == 0) {
				i++;
				if (i < argc) {
					do_load(argv[i]);
				}
				else {
					printf("Invalid arguments, usage: rbtree [load <path>] [load <path>]...\n");
					return EXIT_FAILURE;
				}
			}
			else if (strcmp("save", cmd) == 0) {
				i++;
				if (i < argc) {
					do_save(argv[i]);
				}
				else {
					printf("Invalid arguments, usage: rbtree [save <path>] [save <path>]...\n");
					return EXIT_FAILURE;
				}
			}
			else if (strcmp("bmp", cmd) == 0) {
				const char *path = NULL, *p;
				int nil = 1;

				if ((i + 1) < argc) {
					if (nil == 0) {
						if (strcmp("nonil", argv[i + 1]) == 0) {
							nil = 0;
							i++;
						}
					}
					if ((i + 1) < argc) {
						path = argv[i + 1];
						p = path;
						while (*p && (*p) != '.')
							p++;
						if (*p == '.' && strcasecmp(".bmp", p) == 0)
							i++;
						else
							path = NULL;
					}
					do_bmp(path, nil);
				}
			}
			else if (strcmp("help", cmd) == 0 || strcmp("?", cmd) == 0 || strcmp("h", cmd) == 0) {
				help();
			}
			else if (strcmp("quit", cmd) == 0 || strcmp("exit", cmd) == 0 || strcmp("q", cmd) == 0) {
				return EXIT_SUCCESS;
			}
			else {
				printf("wrong command \"%s\". use \"help\" to print help.\n", cmd);
				return EXIT_FAILURE;
			}
		}
		printf("\n");
	}

	help();
	printf("\n");

	run();

	asc16_free(&asc16);

	return EXIT_SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1028, %rsp           # imm = 0x1028
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x46ef(%rip), %rdi      # 0x7180
leaq 0x157e(%rip), %rsi      # 0x4016
callq 0x19ae
testl %eax, %eax
je 0x2ab5
pushq $0x1
popq %rbx
leaq 0x1947(%rip), %rdi      # 0x43f2
callq 0x1070
jmp 0x32e3
cmpl $0x2, %ebp
jl 0x2ddd
pushq $0x1
popq %rax
leaq 0x1554(%rip), %r15      # 0x401c
movl %eax, %r13d
cmpl %ebp, %r13d
jge 0x2dd5
movslq %r13d, %rax
movq (%rbx,%rax,8), %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x10e0
testl %eax, %eax
je 0x2c37
movzbl (%r14), %r12d
movl %r12d, %eax
subl $0x69, %eax
jne 0x2aff
movzbl 0x1(%r14), %eax
negl %eax
testl %eax, %eax
je 0x2c37
leaq 0x1515(%rip), %rdi      # 0x4025
movq %r14, %rsi
callq 0x10e0
testl %eax, %eax
je 0x2c63
movl %r12d, %eax
subl $0x64, %eax
jne 0x2b2d
movzbl 0x1(%r14), %eax
negl %eax
testl %eax, %eax
je 0x2c63
leaq 0x14ee(%rip), %rdi      # 0x402c
movq %r14, %rsi
callq 0x10e0
testl %eax, %eax
je 0x2c8f
movl %r12d, %eax
subl $0x66, %eax
jne 0x2b5b
movzbl 0x1(%r14), %eax
negl %eax
testl %eax, %eax
je 0x2c8f
leaq 0x14c7(%rip), %rdi      # 0x4033
movq %r14, %rsi
callq 0x10e0
testl %eax, %eax
je 0x2cb8
movl %r12d, %eax
subl $0x63, %eax
jne 0x2b89
movzbl 0x1(%r14), %eax
negl %eax
testl %eax, %eax
je 0x2cb8
leaq 0x14a1(%rip), %rdi      # 0x403b
movq %r14, %rsi
callq 0x10e0
testl %eax, %eax
je 0x2cbf
movl %r12d, %eax
subl $0x70, %eax
jne 0x2bb7
movzbl 0x1(%r14), %eax
negl %eax
testl %eax, %eax
je 0x2cbf
leaq 0x1482(%rip), %rdi      # 0x404a
movq %r14, %rsi
callq 0x10e0
testl %eax, %eax
je 0x2d36
leaq 0x1470(%rip), %rdi      # 0x404f
movq %r14, %rsi
callq 0x10e0
testl %eax, %eax
je 0x2d50
leaq 0x1465(%rip), %rdi      # 0x405b
movq %r14, %rsi
callq 0x10e0
testl %eax, %eax
je 0x2d6a
leaq 0x1452(%rip), %rdi      # 0x405f
movq %r14, %rsi
callq 0x10e0
testl %eax, %eax
je 0x2da5
cmpl $0x3f, %r12d
jne 0x2d8e
cmpb $0x0, 0x1(%r14)
je 0x2da5
jmp 0x3309
incl %r13d
cmpl %ebp, %r13d
jge 0x32c2
movslq %r13d, %rax
movq (%rbx,%rax,8), %rdi
callq 0x1170
testl %eax, %eax
jle 0x32b9
movl %eax, %edi
callq 0x3357
jmp 0x2d2e
incl %r13d
cmpl %ebp, %r13d
jge 0x32cb
movslq %r13d, %rax
movq (%rbx,%rax,8), %rdi
callq 0x1170
testl %eax, %eax
jle 0x32b9
movl %eax, %edi
callq 0x33c1
jmp 0x2d2e
incl %r13d
cmpl %ebp, %r13d
jge 0x32d4
movslq %r13d, %rax
movq (%rbx,%rax,8), %rdi
callq 0x1170
testl %eax, %eax
jle 0x32b9
movl %eax, %edi
callq 0x3426
jmp 0x2d2e
callq 0x3894
jmp 0x2d2e
leal 0x1(%r13), %r12d
cmpl %ebp, %r12d
jge 0x2d22
movslq %r12d, %rax
movq (%rbx,%rax,8), %r14
leaq 0x136b(%rip), %rdi      # 0x4041
movq %r14, %rsi
callq 0x10e0
testl %eax, %eax
je 0x2d1a
movzbl (%r14), %eax
subl $0x69, %eax
jne 0x2cfa
movzbl 0x1(%r14), %eax
subl $0x6e, %eax
jne 0x2cfa
movzbl 0x2(%r14), %eax
negl %eax
testl %eax, %eax
je 0x2d1a
leaq 0x133e(%rip), %rdi      # 0x4045
movq %r14, %rsi
callq 0x10e0
leaq 0x14f7(%rip), %rdi      # 0x420d
testl %eax, %eax
jne 0x2d29
movl %r12d, %r13d
movq %r14, %rdi
jmp 0x2d29
leaq 0x14e4(%rip), %rdi      # 0x420d
callq 0x3456
incl %r13d
jmp 0x2acb
incl %r13d
cmpl %ebp, %r13d
jge 0x32f7
movslq %r13d, %rax
movq (%rbx,%rax,8), %rdi
callq 0x353a
jmp 0x2d2e
incl %r13d
cmpl %ebp, %r13d
jge 0x3300
movslq %r13d, %rax
movq (%rbx,%rax,8), %rdi
callq 0x3693
jmp 0x2d2e
leal 0x1(%r13), %r12d
cmpl %ebp, %r12d
jge 0x2d2e
movslq %r12d, %rax
movq (%rbx,%rax,8), %r14
movq %r14, %rsi
movzbl (%rsi), %eax
testl %eax, %eax
je 0x2dbc
cmpl $0x2e, %eax
je 0x2dac
incq %rsi
jmp 0x2d7d
movl %r12d, %eax
subl $0x68, %eax
jne 0x2d9b
movzbl 0x1(%r14), %eax
negl %eax
testl %eax, %eax
jne 0x3309
callq 0x3986
jmp 0x2d2e
leaq 0x12a7(%rip), %rdi      # 0x405a
callq 0x1050
testl %eax, %eax
je 0x2dc2
movl %r13d, %r12d
xorl %r14d, %r14d
movq %r14, %rdi
pushq $0x1
popq %rsi
callq 0x373b
movl %r12d, %r13d
jmp 0x2d2e
pushq $0xa
popq %rdi
callq 0x1040
callq 0x3986
pushq $0xa
popq %rdi
callq 0x1040
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rax
movaps %xmm0, (%rax)
leaq 0x4(%rsp), %r15
pushq $0x8
popq %rbp
leaq 0x20(%rsp), %rbx
leaq 0x143b(%rip), %rdi      # 0x4244
xorl %eax, %eax
callq 0x10b0
movq %r15, %rdi
movl %ebp, %esi
callq 0x3992
testl %eax, %eax
je 0x2e02
leaq 0x11f7(%rip), %rdi      # 0x401c
movq %r15, %rsi
pushq $0x7
popq %rdx
callq 0x1130
testl %eax, %eax
je 0x2faa
cmpw $0x69, 0x4(%rsp)
je 0x2faa
leaq 0x11da(%rip), %rdi      # 0x4025
movq %r15, %rsi
pushq $0x7
popq %rdx
callq 0x1130
testl %eax, %eax
je 0x3019
cmpw $0x64, 0x4(%rsp)
je 0x3019
leaq 0x11bb(%rip), %rdi      # 0x402c
movq %r15, %rsi
pushq $0x5
popq %r14
movq %r14, %rdx
callq 0x1130
testl %eax, %eax
je 0x3078
cmpw $0x66, 0x4(%rsp)
je 0x3078
leaq 0x1198(%rip), %rdi      # 0x4033
movq %r15, %rsi
pushq $0x6
popq %rdx
callq 0x1130
testl %eax, %eax
je 0x309c
cmpw $0x63, 0x4(%rsp)
je 0x309c
leaq 0x117a(%rip), %rdi      # 0x403b
movq %r15, %rsi
pushq $0x6
popq %rdx
callq 0x1130
testl %eax, %eax
je 0x3001
cmpw $0x70, 0x4(%rsp)
je 0x3001
leaq 0x1163(%rip), %rdi      # 0x404a
movq %r15, %rsi
movq %r14, %rdx
callq 0x1130
testl %eax, %eax
je 0x30fe
leaq 0x114e(%rip), %rdi      # 0x404f
movq %r15, %rsi
movq %r14, %rdx
callq 0x1130
testl %eax, %eax
je 0x3130
cmpl $0x706d62, 0x4(%rsp)    # imm = 0x706D62
je 0x318b
leaq 0x1136(%rip), %rdi      # 0x405f
movq %r15, %rsi
movq %r14, %rdx
callq 0x1130
testl %eax, %eax
je 0x317c
cmpw $0x3f, 0x4(%rsp)
je 0x317c
cmpw $0x68, 0x4(%rsp)
je 0x317c
leaq 0x110d(%rip), %rdi      # 0x4068
movq %r15, %rsi
movq %r14, %rdx
callq 0x1130
testl %eax, %eax
je 0x3285
leaq 0x10f8(%rip), %rdi      # 0x406d
movq %r15, %rsi
movq %r14, %rdx
callq 0x1130
testl %eax, %eax
je 0x3285
cmpw $0x71, 0x4(%rsp)
je 0x3285
callq 0x3ba9
leaq 0x1781(%rip), %rdi      # 0x4721
callq 0x1070
jmp 0x2e02
andl $0x0, 0x10(%rsp)
leaq 0x10(%rsp), %rdi
callq 0x3a67
testl %eax, %eax
jne 0x308b
movl 0x10(%rsp), %r12d
testl %r12d, %r12d
je 0x30ed
movq 0x18(%rsp), %r13
movl $0x0, %eax
cmovlel %eax, %r12d
xorl %r14d, %r14d
cmpq %r14, %r12
je 0x305f
movl (%r13,%r14,4), %edi
callq 0x3357
incq %r14
jmp 0x2fe0
movb $0x0, 0x27(%rsp)
movq %rbx, %rdi
callq 0x3456
movq %rbx, %rdi
movl %ebp, %esi
callq 0x3992
cmpl $0x8, %eax
je 0x2ff4
testl %eax, %eax
jne 0x2ff9
jmp 0x2e02
andl $0x0, 0x10(%rsp)
leaq 0x10(%rsp), %rdi
callq 0x3a67
testl %eax, %eax
jne 0x308b
movl 0x10(%rsp), %r12d
testl %r12d, %r12d
je 0x30ed
movq 0x18(%rsp), %r13
movl $0x0, %eax
cmovlel %eax, %r12d
xorl %r14d, %r14d
cmpq %r14, %r12
je 0x305f
movl (%r13,%r14,4), %edi
callq 0x33c1
incq %r14
jmp 0x304b
movl 0x412b(%rip), %esi      # 0x7190
leaq 0x11cb(%rip), %rdi      # 0x4237
xorl %eax, %eax
callq 0x10b0
jmp 0x2e02
andl $0x0, 0x10(%rsp)
leaq 0x10(%rsp), %rdi
callq 0x3a67
testl %eax, %eax
je 0x30ab
leaq 0x16d8(%rip), %rdi      # 0x476a
callq 0x1070
jmp 0x2e02
callq 0x3ba9
callq 0x3894
jmp 0x2e02
movl 0x10(%rsp), %r12d
testl %r12d, %r12d
je 0x30ed
leaq 0x16f8(%rip), %rdi      # 0x47b4
callq 0x1070
movq 0x18(%rsp), %r13
testl %r12d, %r12d
movl $0x0, %eax
cmovlel %eax, %r12d
xorl %r14d, %r14d
cmpq %r14, %r12
je 0x2e02
movl (%r13,%r14,4), %edi
callq 0x3426
incq %r14
jmp 0x30d5
leaq 0x16b3(%rip), %rdi      # 0x47a7
callq 0x1070
jmp 0x2e02
xorl %r12d, %r12d
movq %rbx, %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0x3992
cmpl $0x1000, %eax           # imm = 0x1000
je 0x311b
testl %eax, %eax
jne 0x3123
jmp 0x3162
movb $0x0, 0x101f(%rsp)
movq %rbx, %rdi
callq 0x353a
decl %r12d
jmp 0x3101
xorl %r12d, %r12d
movq %rbx, %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0x3992
cmpl $0x1000, %eax           # imm = 0x1000
je 0x314d
testl %eax, %eax
jne 0x3155
jmp 0x3162
movb $0x0, 0x101f(%rsp)
movq %rbx, %rdi
callq 0x3693
decl %r12d
jmp 0x3133
testl %r12d, %r12d
jne 0x2e02
leaq 0x15d8(%rip), %rdi      # 0x474a
callq 0x1070
jmp 0x2e02
callq 0x3986
callq 0x3ba9
jmp 0x2e02
movl $0x0, 0xc(%rsp)
xorl %r13d, %r13d
leaq 0xeb7(%rip), %r14       # 0x4054
movq %rbx, %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0x3992
movl %eax, %r12d
cmpl $0x1000, %eax           # imm = 0x1000
je 0x31be
testl %r12d, %r12d
jne 0x31c6
jmp 0x3263
movb $0x0, 0x101f(%rsp)
testl %r13d, %r13d
jne 0x31e5
movq %r14, %rdi
movq %rbx, %rsi
pushq $0x6
popq %rdx
callq 0x1130
pushq $0x1
popq %r13
testl %eax, %eax
je 0x319d
pushq $-0x1
popq %r13
movq %rbx, %rsi
movzbl (%rsi), %eax
testl %eax, %eax
je 0x320b
cmpl $0x2e, %eax
je 0x31f9
incq %rsi
jmp 0x31e8
leaq 0xe5a(%rip), %rdi       # 0x405a
callq 0x1050
testl %eax, %eax
je 0x3229
jmp 0x3244
cmpl $0xffb, %r12d           # imm = 0xFFB
jg 0x324d
movq %rbx, %rdi
callq 0x10a0
movl $0x706d622e, 0x20(%rsp,%rax) # imm = 0x706D622E
movb $0x0, 0x24(%rsp,%rax)
xorl %esi, %esi
cmpl $0x1, %r13d
setne %sil
movq %rbx, %rdi
callq 0x373b
incl 0xc(%rsp)
jmp 0x319d
leaq 0xffc(%rip), %rdi       # 0x4247
jmp 0x3254
leaq 0x101c(%rip), %rdi      # 0x4270
movq %rbx, %rsi
xorl %eax, %eax
callq 0x10b0
callq 0x3ba9
movl 0xc(%rsp), %eax
testl %eax, %eax
jne 0x2e02
xorl %esi, %esi
cmpl $0x1, %r13d
setne %sil
xorl %edi, %edi
callq 0x373b
jmp 0x2e02
callq 0x3ba9
movq 0x18(%rsp), %rdi
callq 0x1030
leaq 0x3e45(%rip), %rdi      # 0x70e0
leaq 0x642(%rip), %rsi       # 0x38e4
xorl %ebx, %ebx
xorl %edx, %edx
callq 0x1789
leaq 0x3ece(%rip), %rdi      # 0x7180
callq 0x19a0
jmp 0x32e3
leaq 0x10f8(%rip), %rdi      # 0x43b8
jmp 0x32db
leaq 0x10b5(%rip), %rdi      # 0x437e
jmp 0x32db
leaq 0x1072(%rip), %rdi      # 0x4344
jmp 0x32db
leaq 0x1033(%rip), %rdi      # 0x430e
callq 0x1070
pushq $0x1
popq %rbx
movl %ebx, %eax
addq $0x1028, %rsp           # imm = 0x1028
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xfd0(%rip), %rdi       # 0x42ce
jmp 0x32db
leaq 0xf87(%rip), %rdi       # 0x428e
jmp 0x32db
leaq 0xd58(%rip), %rdi       # 0x4068
movq %r14, %rsi
callq 0x10e0
xorl %ebx, %ebx
testl %eax, %eax
je 0x32e3
leaq 0xd48(%rip), %rdi       # 0x406d
movq %r14, %rsi
callq 0x10e0
testl %eax, %eax
je 0x32e3
subl $0x71, %r12d
jne 0x333c
movzbl 0x1(%r14), %r12d
negl %r12d
testl %r12d, %r12d
je 0x32e3
leaq 0xd29(%rip), %rdi       # 0x4074
movq %r14, %rsi
xorl %eax, %eax
callq 0x10b0
jmp 0x32e0