// File: /workspace/github_c_makefile_star2_O0/cyb70289[P]tt/tests/sort.c
// Function: main
int main(void)
{
	int *data = malloc(sizeof(int) * LEN);
	int *data_save = malloc(sizeof(int) * LEN);

	printf("Generating %d integers...\n", LEN);
	struct timeval tv;
	for (int i = 0; i < LEN; i++) {
		gettimeofday(&tv, NULL);
		srand(tv.tv_usec);
		data[i] = rand();
		data[i] /= (RAND_MAX / LEN);
		data[i] -= (LEN / 2);
	}
	memcpy(data_save, data, sizeof(int) * LEN);
	printf("Done\n\n");

	struct tt_sort_input input = {
		.num	= {
			.size	= sizeof(int),
			.cmp	= cmp_int,
			.swap	= NULL,
		},
		.data	= data,
		.count	= LEN,
		.alg	= TT_SORT_MERGE,
	};

	memcpy(data, data_save, sizeof(int) * LEN);
	printf("Testing merge sort...\n");
	clock_t st = clock();
	tt_sort(&input);
	if (verify(data))
		printf("Done in %u ms\n", (uint)(clock() - st) / 1000);
	else
		printf("FAIL\n");
	printf("\n");

	memcpy(data, data_save, sizeof(int) * LEN);
	printf("Testing heap sort...\n");
	input.alg = TT_SORT_HEAP;
	st = clock();
	tt_sort(&input);
	if (verify(data))
		printf("Done in %u ms\n", (uint)(clock() - st) / 1000);
	else
		printf("FAIL\n");
	printf("\n");

	memcpy(data, data_save, sizeof(int) * LEN);
	printf("Testing quick sort(random)...\n");
	input.alg = TT_SORT_QUICK;
	st = clock();
	tt_sort(&input);
	if (verify(data))
		printf("Done in %u ms\n", (uint)(clock() - st) / 1000);
	else
		printf("FAIL\n");
	printf("\n");

	printf("Testing quick sort(sorted)...\n");
	input.alg = TT_SORT_QUICK;
	st = clock();
	tt_sort(&input);
	if (verify(data))
		printf("Done in %u ms\n", (uint)(clock() - st) / 1000);
	else
		printf("FAIL\n");
	printf("\n");

	printf("Testing quick sort(two value)...\n");
	for (int i = 0; i < LEN; i++)
		data[i] = (data[i] >= 0 ? 1 : -1);
	input.alg = TT_SORT_QUICK;
	st = clock();
	tt_sort(&input);
	if (verify(data))
		printf("Done in %u ms\n", (uint)(clock() - st) / 1000);
	else
		printf("FAIL\n");
	printf("\n");

	printf("Testing quick sort(equal)...\n");
	for (int i = 0; i < LEN; i++)
		data[i] = 1;
	input.alg = TT_SORT_QUICK;
	st = clock();
	tt_sort(&input);
	if (verify(data))
		printf("Done in %u ms\n", (uint)(clock() - st) / 1000);
	else
		printf("FAIL\n");
	printf("\n");

	memcpy(data, data_save, sizeof(int) * LEN);
	printf("Testing insert sort...\n");
	input.alg = TT_SORT_INSERT;
	st = clock();
	tt_sort(&input);
	if (verify(data))
		printf("Done in %u ms\n", (uint)(clock() - st) / 1000);
	else
		printf("FAIL\n");
	printf("\n");

	free(data);
	free(data_save);

	return 0;
}

// Assembly:
subq $0x78, %rsp
movl $0x0, 0x74(%rsp)
movl $0x40000, %edi          # imm = 0x40000
callq 0x1130
movq %rax, 0x68(%rsp)
movl $0x40000, %edi          # imm = 0x40000
callq 0x1130
movq %rax, 0x60(%rsp)
leaq 0x4d63(%rip), %rdi      # 0x6004
movl $0x10000, %esi          # imm = 0x10000
movb $0x0, %al
callq 0x1090
movl $0x0, 0x4c(%rsp)
cmpl $0x10000, 0x4c(%rsp)    # imm = 0x10000
jge 0x1332
leaq 0x50(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x10b0
movq 0x58(%rsp), %rax
movl %eax, %edi
callq 0x10e0
callq 0x1160
movl %eax, %edx
movq 0x68(%rsp), %rax
movslq 0x4c(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movq 0x68(%rsp), %rax
movq %rax, (%rsp)
movslq 0x4c(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl $0x7fff, %esi           # imm = 0x7FFF
cltd
idivl %esi
movl %eax, %edx
movq (%rsp), %rax
movl %edx, (%rax,%rcx,4)
movq 0x68(%rsp), %rax
movslq 0x4c(%rsp), %rcx
movl (%rax,%rcx,4), %edx
subl $0x8000, %edx           # imm = 0x8000
movl %edx, (%rax,%rcx,4)
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x12b5
movq 0x60(%rsp), %rdi
movq 0x68(%rsp), %rsi
movl $0x40000, %edx          # imm = 0x40000
callq 0x1110
leaq 0x4cd2(%rip), %rdi      # 0x601f
movb $0x0, %al
callq 0x1090
movl $0x4, 0x18(%rsp)
leaq 0x46d(%rip), %rax       # 0x17d0
movq %rax, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x30(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x38(%rsp)
movl $0x10000, 0x40(%rsp)    # imm = 0x10000
movl $0x1, 0x44(%rsp)
movq 0x68(%rsp), %rdi
movq 0x60(%rsp), %rsi
movl $0x40000, %edx          # imm = 0x40000
callq 0x1110
leaq 0x4c77(%rip), %rdi      # 0x6026
movb $0x0, %al
callq 0x1090
callq 0x1070
movq %rax, 0x10(%rsp)
leaq 0x18(%rsp), %rdi
callq 0x2820
movq 0x68(%rsp), %rdi
callq 0x17f0
testb $0x1, %al
jne 0x13da
jmp 0x13ff
callq 0x1070
subq 0x10(%rsp), %rax
movl $0x3e8, %ecx            # imm = 0x3E8
xorl %edx, %edx
divl %ecx
movl %eax, %esi
leaq 0x4c47(%rip), %rdi      # 0x603d
movb $0x0, %al
callq 0x1090
jmp 0x140d
leaq 0x4c46(%rip), %rdi      # 0x604c
movb $0x0, %al
callq 0x1090
leaq 0x4c10(%rip), %rdi      # 0x6024
movb $0x0, %al
callq 0x1090
movq 0x68(%rsp), %rdi
movq 0x60(%rsp), %rsi
movl $0x40000, %edx          # imm = 0x40000
callq 0x1110
leaq 0x4c1c(%rip), %rdi      # 0x6052
movb $0x0, %al
callq 0x1090
movl $0x2, 0x44(%rsp)
callq 0x1070
movq %rax, 0x10(%rsp)
leaq 0x18(%rsp), %rdi
callq 0x2820
movq 0x68(%rsp), %rdi
callq 0x17f0
testb $0x1, %al
jne 0x1469
jmp 0x148e
callq 0x1070
subq 0x10(%rsp), %rax
movl $0x3e8, %ecx            # imm = 0x3E8
xorl %edx, %edx
divl %ecx
movl %eax, %esi
leaq 0x4bb8(%rip), %rdi      # 0x603d
movb $0x0, %al
callq 0x1090
jmp 0x149c
leaq 0x4bb7(%rip), %rdi      # 0x604c
movb $0x0, %al
callq 0x1090
leaq 0x4b81(%rip), %rdi      # 0x6024
movb $0x0, %al
callq 0x1090
movq 0x68(%rsp), %rdi
movq 0x60(%rsp), %rsi
movl $0x40000, %edx          # imm = 0x40000
callq 0x1110
leaq 0x4ba3(%rip), %rdi      # 0x6068
movb $0x0, %al
callq 0x1090
movl $0x3, 0x44(%rsp)
callq 0x1070
movq %rax, 0x10(%rsp)
leaq 0x18(%rsp), %rdi
callq 0x2820
movq 0x68(%rsp), %rdi
callq 0x17f0
testb $0x1, %al
jne 0x14f8
jmp 0x151d
callq 0x1070
subq 0x10(%rsp), %rax
movl $0x3e8, %ecx            # imm = 0x3E8
xorl %edx, %edx
divl %ecx
movl %eax, %esi
leaq 0x4b29(%rip), %rdi      # 0x603d
movb $0x0, %al
callq 0x1090
jmp 0x152b
leaq 0x4b28(%rip), %rdi      # 0x604c
movb $0x0, %al
callq 0x1090
leaq 0x4af2(%rip), %rdi      # 0x6024
movb $0x0, %al
callq 0x1090
leaq 0x4b47(%rip), %rdi      # 0x6087
movb $0x0, %al
callq 0x1090
movl $0x3, 0x44(%rsp)
callq 0x1070
movq %rax, 0x10(%rsp)
leaq 0x18(%rsp), %rdi
callq 0x2820
movq 0x68(%rsp), %rdi
callq 0x17f0
testb $0x1, %al
jne 0x1573
jmp 0x1598
callq 0x1070
subq 0x10(%rsp), %rax
movl $0x3e8, %ecx            # imm = 0x3E8
xorl %edx, %edx
divl %ecx
movl %eax, %esi
leaq 0x4aae(%rip), %rdi      # 0x603d
movb $0x0, %al
callq 0x1090
jmp 0x15a6
leaq 0x4aad(%rip), %rdi      # 0x604c
movb $0x0, %al
callq 0x1090
leaq 0x4a77(%rip), %rdi      # 0x6024
movb $0x0, %al
callq 0x1090
leaq 0x4aeb(%rip), %rdi      # 0x60a6
movb $0x0, %al
callq 0x1090
movl $0x0, 0xc(%rsp)
cmpl $0x10000, 0xc(%rsp)     # imm = 0x10000
jge 0x160b
movq 0x68(%rsp), %rax
movslq 0xc(%rsp), %rcx
movl (%rax,%rcx,4), %ecx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0x1, %eax
cmpl $0x0, %ecx
cmovgel %eax, %edx
movq 0x68(%rsp), %rax
movslq 0xc(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x15ca
movl $0x3, 0x44(%rsp)
callq 0x1070
movq %rax, 0x10(%rsp)
leaq 0x18(%rsp), %rdi
callq 0x2820
movq 0x68(%rsp), %rdi
callq 0x17f0
testb $0x1, %al
jne 0x1637
jmp 0x165c
callq 0x1070
subq 0x10(%rsp), %rax
movl $0x3e8, %ecx            # imm = 0x3E8
xorl %edx, %edx
divl %ecx
movl %eax, %esi
leaq 0x49ea(%rip), %rdi      # 0x603d
movb $0x0, %al
callq 0x1090
jmp 0x166a
leaq 0x49e9(%rip), %rdi      # 0x604c
movb $0x0, %al
callq 0x1090
leaq 0x49b3(%rip), %rdi      # 0x6024
movb $0x0, %al
callq 0x1090
leaq 0x4a49(%rip), %rdi      # 0x60c8
movb $0x0, %al
callq 0x1090
movl $0x0, 0x8(%rsp)
cmpl $0x10000, 0x8(%rsp)     # imm = 0x10000
jge 0x16b6
movq 0x68(%rsp), %rax
movslq 0x8(%rsp), %rcx
movl $0x1, (%rax,%rcx,4)
movl 0x8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8(%rsp)
jmp 0x168e
movl $0x3, 0x44(%rsp)
callq 0x1070
movq %rax, 0x10(%rsp)
leaq 0x18(%rsp), %rdi
callq 0x2820
movq 0x68(%rsp), %rdi
callq 0x17f0
testb $0x1, %al
jne 0x16e2
jmp 0x1707
callq 0x1070
subq 0x10(%rsp), %rax
movl $0x3e8, %ecx            # imm = 0x3E8
xorl %edx, %edx
divl %ecx
movl %eax, %esi
leaq 0x493f(%rip), %rdi      # 0x603d
movb $0x0, %al
callq 0x1090
jmp 0x1715
leaq 0x493e(%rip), %rdi      # 0x604c
movb $0x0, %al
callq 0x1090
leaq 0x4908(%rip), %rdi      # 0x6024
movb $0x0, %al
callq 0x1090
movq 0x68(%rsp), %rdi
movq 0x60(%rsp), %rsi
movl $0x40000, %edx          # imm = 0x40000
callq 0x1110
leaq 0x49a8(%rip), %rdi      # 0x60e6
movb $0x0, %al
callq 0x1090
movl $0x0, 0x44(%rsp)
callq 0x1070
movq %rax, 0x10(%rsp)
leaq 0x18(%rsp), %rdi
callq 0x2820
movq 0x68(%rsp), %rdi
callq 0x17f0
testb $0x1, %al
jne 0x1771
jmp 0x1796
callq 0x1070
subq 0x10(%rsp), %rax
movl $0x3e8, %ecx            # imm = 0x3E8
xorl %edx, %edx
divl %ecx
movl %eax, %esi
leaq 0x48b0(%rip), %rdi      # 0x603d
movb $0x0, %al
callq 0x1090
jmp 0x17a4
leaq 0x48af(%rip), %rdi      # 0x604c
movb $0x0, %al
callq 0x1090
leaq 0x4879(%rip), %rdi      # 0x6024
movb $0x0, %al
callq 0x1090
movq 0x68(%rsp), %rdi
callq 0x1030
movq 0x60(%rsp), %rdi
callq 0x1030
xorl %eax, %eax
addq $0x78, %rsp
retq
nopl (%rax)