// File: /workspace/github_c_makefile_star2_O0/GangZhuo[P]rbtree/test/test.c
// Function: run
static void run()
{
	char cmd[COMMAND_MAX];
	int r, suc;
	array_t values = { 0 };

	while (1) {
		printf("> ");
		r = next_arg(cmd, COMMAND_MAX);
		if (r == COMMAND_MAX)
			cmd[COMMAND_MAX - 1] = '\0';
		if (r == 0) {
			continue;
		}
		else if (strcmp("insert", cmd) == 0 || strcmp("i", cmd) == 0) {
			values.entries = 0;
			r = read_values(&values);
			if (r == 0) {
				if (values.entries == 0) {
					printf("No value(s).\n");
				}
				else {
					do_insert(&values);
				}
			}
			else {
				printf("Invalid value(s), the value(s) should be a positive integer.\n");
			}
		}
		else if (strcmp("delete", cmd) == 0 || strcmp("d", cmd) == 0) {
			values.entries = 0;
			if (read_values(&values) == 0) {
				if (values.entries == 0) {
					printf("No value(s).\n");
				}
				else {
					do_delete(&values);
				}
			}
			else {
				printf("Invalid value(s), the value(s) should be a positive integer.\n");
			}
		}
		else if (strcmp("find", cmd) == 0 || strcmp("f", cmd) == 0) {
			values.entries = 0;
			if (read_values(&values) == 0) {
				if (values.entries == 0) {
					printf("No value(s).\n");
				}
				else {
					do_lookup(&values);
				}
			}
			else {
				printf("Invalid value(s), the value(s) should be a positive integer.\n");
			}
		}
		else if (strcmp("clear", cmd) == 0 || strcmp("c", cmd) == 0) {
			clean_input_buffer();
			do_clean();
		}
		else if (strcmp("print", cmd) == 0 || strcmp("p", cmd) == 0) {
			char opt[OPTION_MAX];
			while ((r = next_arg(opt, OPTION_MAX)) != 0) {
				if (r == OPTION_MAX)
					opt[OPTION_MAX - 1] = '\0';
				do_print(opt);
			}
		}
		else if (strcmp("load", cmd) == 0) {
			char path[FILENAME_MAX];
			suc = 0;
			while ((r = next_arg(path, FILENAME_MAX)) != 0) {
				if (r == FILENAME_MAX)
					path[FILENAME_MAX - 1] = '\0';
				do_load(path);
				suc++;
			}
			if (suc == 0)
				printf("Invalid argument: require path.\n");
		}
		else if (strcmp("save", cmd) == 0) {
			char path[FILENAME_MAX];
			suc = 0;
			while ((r = next_arg(path, FILENAME_MAX)) != 0) {
				if (r == FILENAME_MAX)
					path[FILENAME_MAX - 1] = '\0';
				do_save(path);
				suc++;
			}
			if (suc == 0)
				printf("Invalid argument: require path.\n");
		}
		else if (strcmp("bmp", cmd) == 0) {
			char path[FILENAME_MAX], *p;
			int nil = 0;
			suc = 0;
			while ((r = next_arg(path, FILENAME_MAX)) != 0) {
				if (r == FILENAME_MAX)
					path[FILENAME_MAX - 1] = '\0';

				if (nil == 0) {
					if (strcmp("nonil", path) == 0) {
						nil = 1;
						continue;
					}
					else
						nil = -1;
				}
				
				p = path;
				while (*p && (*p) != '.')
					p++;
				if (*p == '.' && strcasecmp(".bmp", p)) {
					printf("Invalid path \"%s\": require \".bmp\" file.\n", path);
					clean_input_buffer();
					break;
				}
				if (*p == '\0') {
					if (r >= FILENAME_MAX - 4) {
						printf("Invalid path \"%s\": too long.\n", path);
						clean_input_buffer();
						break;
					}
					strcat(path, ".bmp");
				}

				do_bmp(path, nil == 1 ? 0 : 1);
				suc++;
			}
			if (suc == 0)
				do_bmp(NULL, nil == 1 ? 0 : 1);
		}
		else if (strcmp("help", cmd) == 0 || strcmp("?", cmd) == 0 || strcmp("h", cmd) == 0) {
			help();
			clean_input_buffer();
		}
		else if (strcmp("quit", cmd) == 0 || strcmp("exit", cmd) == 0 || strcmp("q", cmd) == 0) {
			clean_input_buffer();
			break;
		}
		else {
			clean_input_buffer();
			printf("wrong command. use \"help\" to print help.\n");
		}
	}

	free(values.array);

	free_rbtree(&tree);

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3040, %rsp           # imm = 0x3040
leaq -0x20(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x10b0
leaq 0x20cb(%rip), %rdi      # 0x770d
movb $0x0, %al
callq 0x1090
leaq -0x8(%rbp), %rdi
movl $0x8, %esi
callq 0x5c00
movl %eax, -0xc(%rbp)
cmpl $0x8, -0xc(%rbp)
jne 0x5664
movb $0x0, -0x1(%rbp)
cmpl $0x0, -0xc(%rbp)
jne 0x566c
jmp 0x563b
leaq -0x8(%rbp), %rsi
leaq 0x19c1(%rip), %rdi      # 0x7038
callq 0x10c0
cmpl $0x0, %eax
je 0x5696
leaq -0x8(%rbp), %rsi
leaq 0x19b3(%rip), %rdi      # 0x703f
callq 0x10c0
cmpl $0x0, %eax
jne 0x56e3
movl $0x0, -0x20(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x5cd0
movl %eax, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
jne 0x56d0
cmpl $0x0, -0x20(%rbp)
jne 0x56c5
leaq 0x2054(%rip), %rdi      # 0x7710
movb $0x0, %al
callq 0x1090
jmp 0x56ce
leaq -0x20(%rbp), %rdi
callq 0x5db0
jmp 0x56de
leaq 0x2047(%rip), %rdi      # 0x771e
movb $0x0, %al
callq 0x1090
jmp 0x5bc4
leaq -0x8(%rbp), %rsi
leaq 0x19c9(%rip), %rdi      # 0x70b7
callq 0x10c0
cmpl $0x0, %eax
je 0x570d
leaq -0x8(%rbp), %rsi
leaq 0x1915(%rip), %rdi      # 0x7018
callq 0x10c0
cmpl $0x0, %eax
jne 0x5756
movl $0x0, -0x20(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x5cd0
cmpl $0x0, %eax
jne 0x5743
cmpl $0x0, -0x20(%rbp)
jne 0x5738
leaq 0x1fe1(%rip), %rdi      # 0x7710
movb $0x0, %al
callq 0x1090
jmp 0x5741
leaq -0x20(%rbp), %rdi
callq 0x5e10
jmp 0x5751
leaq 0x1fd4(%rip), %rdi      # 0x771e
movb $0x0, %al
callq 0x1090
jmp 0x5bc2
leaq -0x8(%rbp), %rsi
leaq 0x1998(%rip), %rdi      # 0x70f9
callq 0x10c0
cmpl $0x0, %eax
je 0x5780
leaq -0x8(%rbp), %rsi
leaq 0x1988(%rip), %rdi      # 0x70fe
callq 0x10c0
cmpl $0x0, %eax
jne 0x57c9
movl $0x0, -0x20(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x5cd0
cmpl $0x0, %eax
jne 0x57b6
cmpl $0x0, -0x20(%rbp)
jne 0x57ab
leaq 0x1f6e(%rip), %rdi      # 0x7710
movb $0x0, %al
callq 0x1090
jmp 0x57b4
leaq -0x20(%rbp), %rdi
callq 0x5e70
jmp 0x57c4
leaq 0x1f61(%rip), %rdi      # 0x771e
movb $0x0, %al
callq 0x1090
jmp 0x5bc0
leaq -0x8(%rbp), %rsi
leaq 0x1963(%rip), %rdi      # 0x7137
callq 0x10c0
cmpl $0x0, %eax
je 0x57f3
leaq -0x8(%rbp), %rsi
leaq 0x1954(%rip), %rdi      # 0x713d
callq 0x10c0
cmpl $0x0, %eax
jne 0x5802
callq 0x60d0
callq 0x5420
jmp 0x5bbe
leaq -0x8(%rbp), %rsi
leaq 0x1932(%rip), %rdi      # 0x713f
callq 0x10c0
cmpl $0x0, %eax
je 0x582c
leaq -0x8(%rbp), %rsi
leaq 0x19c9(%rip), %rdi      # 0x71eb
callq 0x10c0
cmpl $0x0, %eax
jne 0x585e
jmp 0x582e
leaq -0x28(%rbp), %rdi
movl $0x8, %esi
callq 0x5c00
movl %eax, -0xc(%rbp)
cmpl $0x0, %eax
je 0x5859
cmpl $0x8, -0xc(%rbp)
jne 0x584e
movb $0x0, -0x21(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x4db0
jmp 0x582e
jmp 0x5bbc
leaq -0x8(%rbp), %rsi
leaq 0x18e8(%rip), %rdi      # 0x7151
callq 0x10c0
cmpl $0x0, %eax
jne 0x58d0
movl $0x0, -0x10(%rbp)
leaq -0x1030(%rbp), %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0x5c00
movl %eax, -0xc(%rbp)
cmpl $0x0, %eax
je 0x58b7
cmpl $0x1000, -0xc(%rbp)     # imm = 0x1000
jne 0x58a0
movb $0x0, -0x31(%rbp)
leaq -0x1030(%rbp), %rdi
callq 0x4ee0
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x587a
cmpl $0x0, -0x10(%rbp)
jne 0x58cb
leaq 0x1e98(%rip), %rdi      # 0x775c
movb $0x0, %al
callq 0x1090
jmp 0x5bba
leaq -0x8(%rbp), %rsi
leaq 0x18bc(%rip), %rdi      # 0x7197
callq 0x10c0
cmpl $0x0, %eax
jne 0x5945
movl $0x0, -0x10(%rbp)
leaq -0x2030(%rbp), %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0x5c00
movl %eax, -0xc(%rbp)
cmpl $0x0, %eax
je 0x592c
cmpl $0x1000, -0xc(%rbp)     # imm = 0x1000
jne 0x5915
movb $0x0, -0x1031(%rbp)
leaq -0x2030(%rbp), %rdi
callq 0x50b0
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x58ec
cmpl $0x0, -0x10(%rbp)
jne 0x5940
leaq 0x1e23(%rip), %rdi      # 0x775c
movb $0x0, %al
callq 0x1090
jmp 0x5bb8
leaq -0x8(%rbp), %rsi
leaq 0x1894(%rip), %rdi      # 0x71e4
callq 0x10c0
cmpl $0x0, %eax
jne 0x5b0e
movl $0x0, -0x303c(%rbp)
movl $0x0, -0x10(%rbp)
leaq -0x3030(%rbp), %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0x5c00
movl %eax, -0xc(%rbp)
cmpl $0x0, %eax
je 0x5ae7
cmpl $0x1000, -0xc(%rbp)     # imm = 0x1000
jne 0x599c
movb $0x0, -0x2031(%rbp)
cmpl $0x0, -0x303c(%rbp)
jne 0x59d5
leaq -0x3030(%rbp), %rsi
leaq 0x182a(%rip), %rdi      # 0x71dd
callq 0x10c0
cmpl $0x0, %eax
jne 0x59c9
movl $0x1, -0x303c(%rbp)
jmp 0x596f
movl $0xffffffff, -0x303c(%rbp) # imm = 0xFFFFFFFF
jmp 0x59d5
leaq -0x3030(%rbp), %rax
movq %rax, -0x3038(%rbp)
movq -0x3038(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x303d(%rbp)
je 0x5a10
movq -0x3038(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2e, %eax
setne %al
movb %al, -0x303d(%rbp)
movb -0x303d(%rbp), %al
testb $0x1, %al
jne 0x5a1c
jmp 0x5a30
movq -0x3038(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x3038(%rbp)
jmp 0x59e3
movq -0x3038(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2e, %eax
jne 0x5a73
movq -0x3038(%rbp), %rsi
leaq 0x1796(%rip), %rdi      # 0x71e3
callq 0x1040
cmpl $0x0, %eax
je 0x5a73
leaq -0x3030(%rbp), %rsi
leaq 0x1d18(%rip), %rdi      # 0x777d
movb $0x0, %al
callq 0x1090
callq 0x60d0
jmp 0x5ae7
movq -0x3038(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x5aba
cmpl $0xffc, -0xc(%rbp)      # imm = 0xFFC
jl 0x5aa7
leaq -0x3030(%rbp), %rsi
leaq 0x1d0d(%rip), %rdi      # 0x77a6
movb $0x0, %al
callq 0x1090
callq 0x60d0
jmp 0x5ae7
leaq -0x3030(%rbp), %rdi
leaq 0x172e(%rip), %rsi      # 0x71e3
callq 0x1150
leaq -0x3030(%rbp), %rdi
movl -0x303c(%rbp), %ecx
movl $0x1, %esi
xorl %eax, %eax
cmpl $0x1, %ecx
cmovel %eax, %esi
callq 0x5180
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x596f
cmpl $0x0, -0x10(%rbp)
jne 0x5b09
movl -0x303c(%rbp), %ecx
movl $0x1, %esi
xorl %eax, %eax
cmpl $0x1, %ecx
cmovel %eax, %esi
xorl %eax, %eax
movl %eax, %edi
callq 0x5180
jmp 0x5bb6
leaq -0x8(%rbp), %rsi
leaq 0x16cf(%rip), %rdi      # 0x71e8
callq 0x10c0
cmpl $0x0, %eax
je 0x5b4d
leaq -0x8(%rbp), %rsi
leaq 0x16bf(%rip), %rdi      # 0x71ed
callq 0x10c0
cmpl $0x0, %eax
je 0x5b4d
leaq -0x8(%rbp), %rsi
leaq 0x16ac(%rip), %rdi      # 0x71ef
callq 0x10c0
cmpl $0x0, %eax
jne 0x5b59
callq 0x5600
callq 0x60d0
jmp 0x5bb4
leaq -0x8(%rbp), %rsi
leaq 0x168d(%rip), %rdi      # 0x71f1
callq 0x10c0
cmpl $0x0, %eax
je 0x5b98
leaq -0x8(%rbp), %rsi
leaq 0x167d(%rip), %rdi      # 0x71f6
callq 0x10c0
cmpl $0x0, %eax
je 0x5b98
leaq -0x8(%rbp), %rsi
leaq 0x166d(%rip), %rdi      # 0x71fb
callq 0x10c0
cmpl $0x0, %eax
jne 0x5b9f
callq 0x60d0
jmp 0x5bcb
callq 0x60d0
leaq 0x1c19(%rip), %rdi      # 0x77c4
movb $0x0, %al
callq 0x1090
jmp 0x5bb4
jmp 0x5bb6
jmp 0x5bb8
jmp 0x5bba
jmp 0x5bbc
jmp 0x5bbe
jmp 0x5bc0
jmp 0x5bc2
jmp 0x5bc4
jmp 0x5bc6
jmp 0x563b
movq -0x18(%rbp), %rdi
callq 0x1030
leaq 0x44f5(%rip), %rdi      # 0xa0d0
leaq -0x752(%rip), %rsi      # 0x5490
xorl %eax, %eax
movl %eax, %edx
callq 0x1e30
addq $0x3040, %rsp           # imm = 0x3040
popq %rbp
retq
nopw %cs:(%rax,%rax)