// File: /workspace/github_c_makefile_star2_O0/keithnoguchi[P]pearls-in-action/0xd/set1_test.c
// Function: test_set1_alloc
static int test_set1_alloc(int *test_nr)
{
	const struct test {
		const char	*name;
		int		nr;
		int		max;
	} tests[] = {
		{
			.name	= "nr=1, max=1",
			.nr	= 1,
			.max	= 1,
		},
		{
			.name	= "nr=1024, max=1024",
			.nr	= 1024,
			.max	= 1024,
		},
		{
			.name	= "nr=4096, max=4096",
			.nr	= 4096,
			.max	= 4096,
		},
		{
			.name	= "nr=8192, max=8192",
			.nr	= 8192,
			.max	= 8192,
		},
		{
			.name	= "nr=16384, max=16384",
			.nr	= 16384,
			.max	= 16384,
		},
		{
			.name	= "nr=32768, max=32768",
			.nr	= 32768,
			.max	= 32768,
		},
		{
			.name	= "nr=1048575, max=1048575",
			.nr	= 1048575,
			.max	= 1048575,
		},
		{ /* sentinel */ },
	};
	const struct test *t;
	double diff;
	clock_t c;
	int fail = 0;

	for (t = tests; t->name; t++) {
		struct set *s;

		printf("%3d) %-21s: %-35s", ++(*test_nr), __FUNCTION__,
		       t->name);

		c = clock();
		s = alloc_set1(t->nr, t->max);
		c = clock()-c;
		diff = (double)c/CLOCKS_PER_SEC;
		if (!s) {
			printf("FAIL: alloc_set1(m=%d,n=%d): %s: %9.6fsec\n",
			       t->nr, t->max, strerror(errno), diff);
			goto fail;
		}
		if (set_size(s) != 0) {
			printf("FAIL: %ld=set_size()!=0: %9.6fsec\n",
			       set_size(s), diff);
			goto fail;
		}
		set_free(s);
		printf("PASS: %9.6fsec\n", diff);
		continue;
fail:
		if (s)
			set_free(s);
		fail++;
	}
	return fail;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
leaq -0x90(%rbp), %rdi
leaq 0x2363(%rip), %rsi      # 0x38a0
movl $0x80, %edx
callq 0x1080
movl $0x0, -0xac(%rbp)
leaq -0x90(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
cmpq $0x0, (%rax)
je 0x16ec
movq -0x8(%rbp), %rax
movl (%rax), %esi
addl $0x1, %esi
movl %esi, (%rax)
movq -0x98(%rbp), %rax
movq (%rax), %rcx
leaq 0xb66(%rip), %rdi       # 0x20f2
leaq 0xb71(%rip), %rdx       # 0x2104
movb $0x0, %al
callq 0x1060
callq 0x1050
movq %rax, -0xa8(%rbp)
movq -0x98(%rbp), %rax
movl 0x8(%rax), %edi
movq -0x98(%rbp), %rax
movl 0xc(%rax), %esi
callq 0x1220
movq %rax, -0xb8(%rbp)
callq 0x1050
subq -0xa8(%rbp), %rax
movq %rax, -0xa8(%rbp)
cvtsi2sdq -0xa8(%rbp), %xmm0
movsd 0xa7e(%rip), %xmm1      # 0x2068
divsd %xmm1, %xmm0
movsd %xmm0, -0xa0(%rbp)
cmpq $0x0, -0xb8(%rbp)
jne 0x1653
movq -0x98(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0xc0(%rbp)
movq -0x98(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0xbc(%rbp)
callq 0x1040
movl (%rax), %edi
callq 0x10a0
movl -0xc0(%rbp), %esi
movl -0xbc(%rbp), %edx
movq %rax, %rcx
movsd -0xa0(%rbp), %xmm0
leaq 0xaca(%rip), %rdi       # 0x2114
movb $0x1, %al
callq 0x1060
jmp 0x16b0
movq -0xb8(%rbp), %rdi
callq 0x1a60
cmpq $0x0, %rax
je 0x168c
movq -0xb8(%rbp), %rdi
callq 0x1a60
movq %rax, %rsi
movsd -0xa0(%rbp), %xmm0
leaq 0xabc(%rip), %rdi       # 0x213f
movb $0x1, %al
callq 0x1060
jmp 0x16b0
movq -0xb8(%rbp), %rdi
callq 0x1a80
movsd -0xa0(%rbp), %xmm0
leaq 0xabb(%rip), %rdi       # 0x2162
movb $0x1, %al
callq 0x1060
jmp 0x16d5
cmpq $0x0, -0xb8(%rbp)
je 0x16c6
movq -0xb8(%rbp), %rdi
callq 0x1a80
movl -0xac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xac(%rbp)
movq -0x98(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x98(%rbp)
jmp 0x155f
movl -0xac(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax,%rax)