// File: /workspace/github_c_makefile_star2_O1/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:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl $0x40000, %edi          # imm = 0x40000
callq 0x1140
movq %rax, %rbx
movl $0x40000, %edi          # imm = 0x40000
callq 0x1140
movq %rax, %r14
leaq 0x2bc8(%rip), %rdi      # 0x4020
xorl %r12d, %r12d
movl $0x10000, %esi          # imm = 0x10000
xorl %eax, %eax
callq 0x10b0
leaq 0x38(%rsp), %r15
movq %r15, %rdi
xorl %esi, %esi
callq 0x10d0
movl 0x40(%rsp), %edi
callq 0x10f0
callq 0x1180
cltq
imulq $-0x7ffefffd, %rax, %rcx # imm = 0x80010003
shrq $0x20, %rcx
addl %ecx, %eax
movl %eax, %ecx
sarl $0xe, %ecx
shrl $0x1f, %eax
addl %ecx, %eax
addl $0xffff8000, %eax       # imm = 0xFFFF8000
movl %eax, (%rbx,%r12,4)
incq %r12
cmpq $0x10000, %r12          # imm = 0x10000
jne 0x146c
movl $0x40000, %edx          # imm = 0x40000
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1120
leaq 0x2b81(%rip), %rdi      # 0x404a
callq 0x1060
leaq 0x8(%rsp), %r12
movl $0x4, (%r12)
leaq 0x4b7(%rip), %rax       # 0x1999
movq %rax, 0x8(%r12)
pxor %xmm0, %xmm0
movdqu %xmm0, 0x10(%r12)
movq %rbx, 0x20(%r12)
movabsq $0x100010000, %rax      # imm = 0x100010000
movq %rax, 0x28(%r12)
movl $0x40000, %edx          # imm = 0x40000
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1120
leaq 0x2b33(%rip), %rdi      # 0x4050
callq 0x1060
callq 0x1090
movq %rax, %r15
movq %r12, %rdi
callq 0x20b0
movq $-0x1, %rax
cmpq $0xfffe, %rax           # imm = 0xFFFE
je 0x1554
movl 0x4(%rbx,%rax,4), %edx
leaq 0x1(%rax), %rcx
cmpl 0x8(%rbx,%rax,4), %edx
movq %rcx, %rax
jle 0x1539
jmp 0x1559
movl $0xffff, %ecx           # imm = 0xFFFF
cmpq $0xfffe, %rcx           # imm = 0xFFFE
jbe 0x1585
callq 0x1090
subl %r15d, %eax
imulq $0x10624dd3, %rax, %rsi # imm = 0x10624DD3
shrq $0x26, %rsi
leaq 0x2abf(%rip), %rdi      # 0x403b
xorl %eax, %eax
callq 0x10b0
jmp 0x1591
leaq 0x2b80(%rip), %rdi      # 0x410c
callq 0x1060
movl $0xa, %edi
callq 0x1040
movl $0x40000, %edx          # imm = 0x40000
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1120
leaq 0x2ab4(%rip), %rdi      # 0x4066
callq 0x1060
leaq 0x8(%rsp), %r12
movl $0x2, 0x2c(%r12)
callq 0x1090
movq %rax, %r15
movq %r12, %rdi
callq 0x20b0
movq $-0x1, %rax
cmpq $0xfffe, %rax           # imm = 0xFFFE
je 0x15f7
movl 0x4(%rbx,%rax,4), %edx
leaq 0x1(%rax), %rcx
cmpl 0x8(%rbx,%rax,4), %edx
movq %rcx, %rax
jle 0x15dc
jmp 0x15fc
movl $0xffff, %ecx           # imm = 0xFFFF
cmpq $0xffff, %rcx           # imm = 0xFFFF
jb 0x1628
callq 0x1090
subl %r15d, %eax
imulq $0x10624dd3, %rax, %rsi # imm = 0x10624DD3
shrq $0x26, %rsi
leaq 0x2a1c(%rip), %rdi      # 0x403b
xorl %eax, %eax
callq 0x10b0
jmp 0x1634
leaq 0x2add(%rip), %rdi      # 0x410c
callq 0x1060
movl $0xa, %edi
callq 0x1040
movl $0x40000, %edx          # imm = 0x40000
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1120
leaq 0x2a26(%rip), %rdi      # 0x407b
callq 0x1060
leaq 0x8(%rsp), %r12
movl $0x3, 0x2c(%r12)
callq 0x1090
movq %rax, %r15
movq %r12, %rdi
callq 0x20b0
movq $-0x1, %rax
cmpq $0xfffe, %rax           # imm = 0xFFFE
je 0x169a
movl 0x4(%rbx,%rax,4), %edx
leaq 0x1(%rax), %rcx
cmpl 0x8(%rbx,%rax,4), %edx
movq %rcx, %rax
jle 0x167f
jmp 0x169f
movl $0xffff, %ecx           # imm = 0xFFFF
cmpq $0xffff, %rcx           # imm = 0xFFFF
jb 0x16cb
callq 0x1090
subl %r15d, %eax
imulq $0x10624dd3, %rax, %rsi # imm = 0x10624DD3
shrq $0x26, %rsi
leaq 0x2979(%rip), %rdi      # 0x403b
xorl %eax, %eax
callq 0x10b0
jmp 0x16d7
leaq 0x2a3a(%rip), %rdi      # 0x410c
callq 0x1060
movl $0xa, %edi
callq 0x1040
leaq 0x29b1(%rip), %rdi      # 0x4099
callq 0x1060
leaq 0x8(%rsp), %r12
movl $0x3, 0x2c(%r12)
callq 0x1090
movq %rax, %r15
movq %r12, %rdi
callq 0x20b0
movq $-0x1, %rax
cmpq $0xfffe, %rax           # imm = 0xFFFE
je 0x172d
movl 0x4(%rbx,%rax,4), %edx
leaq 0x1(%rax), %rcx
cmpl 0x8(%rbx,%rax,4), %edx
movq %rcx, %rax
jle 0x1712
jmp 0x1732
movl $0xffff, %ecx           # imm = 0xFFFF
cmpq $0xffff, %rcx           # imm = 0xFFFF
jb 0x175e
callq 0x1090
subl %r15d, %eax
imulq $0x10624dd3, %rax, %rsi # imm = 0x10624DD3
shrq $0x26, %rsi
leaq 0x28e6(%rip), %rdi      # 0x403b
xorl %eax, %eax
callq 0x10b0
jmp 0x176a
leaq 0x29a7(%rip), %rdi      # 0x410c
callq 0x1060
movl $0xa, %edi
callq 0x1040
leaq 0x293c(%rip), %rdi      # 0x40b7
callq 0x1060
xorl %eax, %eax
movdqu (%rbx,%rax,4), %xmm0
psrad $0x1f, %xmm0
por 0x287c(%rip), %xmm0     # 0x4010
movdqu %xmm0, (%rbx,%rax,4)
addq $0x4, %rax
cmpq $0x10000, %rax          # imm = 0x10000
jne 0x1782
leaq 0x8(%rsp), %r12
movl $0x3, 0x2c(%r12)
callq 0x1090
movq %rax, %r15
movq %r12, %rdi
callq 0x20b0
movq $-0x1, %rax
cmpq $0xfffe, %rax           # imm = 0xFFFE
je 0x17e5
movl 0x4(%rbx,%rax,4), %edx
leaq 0x1(%rax), %rcx
cmpl 0x8(%rbx,%rax,4), %edx
movq %rcx, %rax
jle 0x17ca
jmp 0x17ea
movl $0xffff, %ecx           # imm = 0xFFFF
cmpq $0xffff, %rcx           # imm = 0xFFFF
jb 0x1816
callq 0x1090
subl %r15d, %eax
imulq $0x10624dd3, %rax, %rsi # imm = 0x10624DD3
shrq $0x26, %rsi
leaq 0x282e(%rip), %rdi      # 0x403b
xorl %eax, %eax
callq 0x10b0
jmp 0x1822
leaq 0x28ef(%rip), %rdi      # 0x410c
callq 0x1060
movl $0xa, %edi
callq 0x1040
leaq 0x28a5(%rip), %rdi      # 0x40d8
callq 0x1060
xorl %eax, %eax
movaps 0x27cf(%rip), %xmm0     # 0x4010
movups %xmm0, (%rbx,%rax,4)
addq $0x4, %rax
cmpq $0x10000, %rax          # imm = 0x10000
jne 0x1841
leaq 0x8(%rsp), %r12
movl $0x3, 0x2c(%r12)
callq 0x1090
movq %rax, %r15
movq %r12, %rdi
callq 0x20b0
movq $-0x1, %rax
cmpq $0xfffe, %rax           # imm = 0xFFFE
je 0x1891
movl 0x4(%rbx,%rax,4), %edx
leaq 0x1(%rax), %rcx
cmpl 0x8(%rbx,%rax,4), %edx
movq %rcx, %rax
jle 0x1876
jmp 0x1896
movl $0xffff, %ecx           # imm = 0xFFFF
cmpq $0xffff, %rcx           # imm = 0xFFFF
jb 0x18c2
callq 0x1090
subl %r15d, %eax
imulq $0x10624dd3, %rax, %rsi # imm = 0x10624DD3
shrq $0x26, %rsi
leaq 0x2782(%rip), %rdi      # 0x403b
xorl %eax, %eax
callq 0x10b0
jmp 0x18ce
leaq 0x2843(%rip), %rdi      # 0x410c
callq 0x1060
movl $0xa, %edi
callq 0x1040
movl $0x40000, %edx          # imm = 0x40000
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1120
leaq 0x2806(%rip), %rdi      # 0x40f5
callq 0x1060
leaq 0x8(%rsp), %r12
movl $0x0, 0x2c(%r12)
callq 0x1090
movq %rax, %r15
movq %r12, %rdi
callq 0x20b0
movq $-0x1, %rax
cmpq $0xfffe, %rax           # imm = 0xFFFE
je 0x1934
movl 0x4(%rbx,%rax,4), %edx
leaq 0x1(%rax), %rcx
cmpl 0x8(%rbx,%rax,4), %edx
movq %rcx, %rax
jle 0x1919
jmp 0x1939
movl $0xffff, %ecx           # imm = 0xFFFF
cmpq $0xffff, %rcx           # imm = 0xFFFF
jb 0x1965
callq 0x1090
subl %r15d, %eax
imulq $0x10624dd3, %rax, %rsi # imm = 0x10624DD3
shrq $0x26, %rsi
leaq 0x26df(%rip), %rdi      # 0x403b
xorl %eax, %eax
callq 0x10b0
jmp 0x1971
leaq 0x27a0(%rip), %rdi      # 0x410c
callq 0x1060
movl $0xa, %edi
callq 0x1040
movq %rbx, %rdi
callq 0x1030
movq %r14, %rdi
callq 0x1030
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq