// File: /workspace/github_cpp_makefile_star2_O2/amadvance[P]tommyds/check.c
// Function: test_list
void test_list(void)
{
	struct object* LIST;
	struct object_vector* VECTOR;
	tommy_node* list;
	unsigned i;
	const unsigned size = TOMMY_SIZE;

	LIST = malloc(size * sizeof(struct object));
	VECTOR = malloc(size * sizeof(struct object_vector));

	for(i=0;i<size;++i) {
		VECTOR[i].value = LIST[i].value = 0;
	}

	tommy_list_init(&list);

	/* sort an empty list */
	tommy_list_sort(&list, compare);

	if (!tommy_list_empty(&list))
		/* LCOV_EXCL_START */
		abort();
		/* LCOV_EXCL_STOP */

	if (tommy_list_tail(&list) != 0)
		/* LCOV_EXCL_START */
		abort();
		/* LCOV_EXCL_STOP */

	if (tommy_list_head(&list) != 0)
		/* LCOV_EXCL_START */
		abort();
		/* LCOV_EXCL_STOP */

	for(i=0;i<size;++i) {
		VECTOR[i].value = LIST[i].value = rnd(size);
		tommy_list_insert_tail(&list, &LIST[i].node, &LIST[i]);
	}

	if (tommy_list_tail(&list) == 0)
		/* LCOV_EXCL_START */
		abort();
		/* LCOV_EXCL_STOP */

	if (tommy_list_head(&list) == 0)
		/* LCOV_EXCL_START */
		abort();
		/* LCOV_EXCL_STOP */

	START("sort random");
	tommy_list_sort(&list, compare);
	STOP();

	START("C qsort random");
	qsort(VECTOR, size, sizeof(VECTOR[0]), compare_vector);
	STOP();

	test_list_order(list);

	/* forward order with some (1%) random values */
	list = 0;
	for(i=0;i<size;++i) {
		VECTOR[i].value = LIST[i].value = i;
		if (rnd(100) == 0)
			VECTOR[i].value = LIST[i].value = rnd(size);
		tommy_list_insert_tail(&list, &LIST[i].node, &LIST[i]);
	}

	START("sort partially ordered");
	tommy_list_sort(&list, compare);
	STOP();

	START("C qsort partially ordered");
	qsort(VECTOR, size, sizeof(VECTOR[0]), compare_vector);
	STOP();

	test_list_order(list);

	/* forward order */
	list = 0;
	for(i=0;i<size;++i) {
		VECTOR[i].value = LIST[i].value = i;
		tommy_list_insert_tail(&list, &LIST[i].node, &LIST[i]);
	}

	START("sort forward");
	tommy_list_sort(&list, compare);
	STOP();

	START("C qsort forward");
	qsort(VECTOR, size, sizeof(VECTOR[0]), compare_vector);
	STOP();

	test_list_order(list);

	/* backward order */
	list = 0;
	for(i=0;i<size;++i) {
		VECTOR[i].value = LIST[i].value = size - 1 - i;
		tommy_list_insert_tail(&list, &LIST[i].node, &LIST[i]);
	}

	START("sort backward");
	tommy_list_sort(&list, compare);
	STOP();

	START("C qsort backward");
	qsort(VECTOR, size, sizeof(VECTOR[0]), compare_vector);
	STOP();

	test_list_order(list);

	/* use a small range of random value to insert a lot of duplicates */
	list = 0;
	for(i=0;i<size;++i) {
		VECTOR[i].value = LIST[i].value = rnd(size / 1000 + 2);
		tommy_list_insert_tail(&list, &LIST[i].node, &LIST[i]);
	}

	START("sort random duplicate");
	tommy_list_sort(&list, compare);
	STOP();

	START("C qsort random duplicate");
	qsort(VECTOR, size, sizeof(VECTOR[0]), compare_vector);
	STOP();

	test_list_order(list);

	free(LIST);
	free(VECTOR);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl $0x3567e00, %edi        # imm = 0x3567E00
callq 0x10b0
movq %rax, %r13
movl $0x1312d00, %edi        # imm = 0x1312D00
callq 0x10b0
movq %rax, %rbx
xorl %eax, %eax
movq %r13, %rcx
cmpq $0x1312d00, %rax        # imm = 0x1312D00
je 0x16f2
andl $0x0, (%rcx)
andl $0x0, (%rbx,%rax)
addq $0x14, %rax
addq $0x38, %rcx
jmp 0x16d9
leaq 0x8(%rsp), %r15
andq $0x0, (%r15)
leaq -0x546(%rip), %rsi      # 0x11bc
movq %r15, %rdi
callq 0x3aac
cmpq $0x0, (%r15)
jne 0x1a56
xorl %r14d, %r14d
leaq 0x8(%rsp), %r15
movq %r13, %r12
cmpq $0x1312d00, %r14        # imm = 0x1312D00
je 0x1754
movl $0xf4240, %edi          # imm = 0xF4240
callq 0x11e8
movl %eax, (%r12)
movl %eax, (%rbx,%r14)
leaq 0x8(%r12), %rsi
movq %r15, %rdi
movq %r12, %rdx
callq 0x1a5b
addq $0x14, %r14
addq $0x38, %r12
jmp 0x171f
movq %r13, 0x10(%rsp)
movq 0x8(%rsp), %rax
testq %rax, %rax
je 0x1a56
cmpq $0x0, 0x8(%rax)
je 0x1a56
leaq 0x4a2b(%rip), %rdi      # 0x61a4
callq 0x127d
leaq -0x5c9(%rip), %rsi      # 0x11bc
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x3aac
callq 0x12cf
leaq 0x4a03(%rip), %rdi      # 0x61a1
callq 0x127d
leaq -0x5d8(%rip), %rcx      # 0x11d2
pushq $0x14
popq %rdx
movl $0xf4240, %esi          # imm = 0xF4240
movq %rbx, %rdi
callq 0x1060
callq 0x12cf
movq (%r15), %rdi
callq 0x1679
andq $0x0, (%r15)
xorl %r13d, %r13d
pushq $0x64
popq %rbp
movq %rbx, %r14
movq 0x10(%rsp), %r12
cmpq $0xf4240, %r13          # imm = 0xF4240
je 0x1822
movl %r13d, (%r12)
movl %r13d, (%r14)
movl %ebp, %edi
callq 0x11e8
testl %eax, %eax
jne 0x1805
movl $0xf4240, %edi          # imm = 0xF4240
callq 0x11e8
movl %eax, (%r12)
movl %eax, (%r14)
leaq 0x8(%r12), %rsi
movq %r15, %rdi
movq %r12, %rdx
callq 0x1a5b
incq %r13
addq $0x38, %r12
addq $0x14, %r14
jmp 0x17d9
leaq 0x498a(%rip), %rdi      # 0x61b3
callq 0x127d
leaq -0x679(%rip), %rsi      # 0x11bc
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x3aac
callq 0x12cf
leaq 0x4962(%rip), %rdi      # 0x61b0
callq 0x127d
leaq -0x688(%rip), %rcx      # 0x11d2
pushq $0x14
popq %rdx
movl $0xf4240, %esi          # imm = 0xF4240
movq %rbx, %rdi
callq 0x1060
callq 0x12cf
movq (%r15), %rdi
callq 0x1679
andq $0x0, (%r15)
xorl %r14d, %r14d
movq %rbx, %r13
movq 0x10(%rsp), %r12
cmpq $0xf4240, %r14          # imm = 0xF4240
je 0x18b4
movl %r14d, (%r12)
movl %r14d, (%r13)
leaq 0x8(%r12), %rsi
movq %r15, %rdi
movq %r12, %rdx
callq 0x1a5b
incq %r14
addq $0x38, %r12
addq $0x14, %r13
jmp 0x1886
leaq 0x4912(%rip), %rdi      # 0x61cd
callq 0x127d
leaq -0x70b(%rip), %rsi      # 0x11bc
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x3aac
callq 0x12cf
leaq 0x48ea(%rip), %rdi      # 0x61ca
callq 0x127d
leaq -0x71a(%rip), %rcx      # 0x11d2
pushq $0x14
popq %rdx
movl $0xf4240, %esi          # imm = 0xF4240
movq %rbx, %rdi
callq 0x1060
callq 0x12cf
movq (%r15), %rdi
callq 0x1679
andq $0x0, (%r15)
movl $0xf423f, %ebp          # imm = 0xF423F
movq $-0x1312d00, %r14       # imm = 0xFECED300
movq 0x10(%rsp), %r13
movq %r13, %r12
testq %r14, %r14
je 0x194e
movl %ebp, (%r12)
movl %ebp, 0x1312d00(%rbx,%r14)
leaq 0x8(%r12), %rsi
movq %r15, %rdi
movq %r12, %rdx
callq 0x1a5b
decl %ebp
addq $0x14, %r14
addq $0x38, %r12
jmp 0x1921
leaq 0x4888(%rip), %rdi      # 0x61dd
callq 0x127d
leaq -0x7a5(%rip), %rsi      # 0x11bc
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x3aac
callq 0x12cf
leaq 0x4860(%rip), %rdi      # 0x61da
callq 0x127d
leaq -0x7b4(%rip), %rcx      # 0x11d2
pushq $0x14
popq %rdx
movl $0xf4240, %esi          # imm = 0xF4240
movq %rbx, %rdi
callq 0x1060
callq 0x12cf
movq (%r15), %rdi
callq 0x1679
andq $0x0, (%r15)
xorl %r14d, %r14d
movq %r13, %r12
cmpq $0x1312d00, %r14        # imm = 0x1312D00
je 0x19e2
movl $0x3ea, %edi            # imm = 0x3EA
callq 0x11e8
movl %eax, (%r12)
movl %eax, (%rbx,%r14)
leaq 0x8(%r12), %rsi
movq %r15, %rdi
movq %r12, %rdx
callq 0x1a5b
addq $0x14, %r14
addq $0x38, %r12
jmp 0x19ad
leaq 0x4805(%rip), %rdi      # 0x61ee
callq 0x127d
leaq -0x839(%rip), %rsi      # 0x11bc
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x3aac
callq 0x12cf
leaq 0x47dd(%rip), %rdi      # 0x61eb
callq 0x127d
leaq -0x848(%rip), %rcx      # 0x11d2
pushq $0x14
popq %rdx
movl $0xf4240, %esi          # imm = 0xF4240
movq %rbx, %rdi
callq 0x1060
callq 0x12cf
movq (%r15), %rdi
callq 0x1679
movq %r13, %rdi
callq 0x1030
movq %rbx, %rdi
callq 0x1030
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1040