// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]libcperciva/tests/mpool/main.c
// Function: time_func
long long
time_func(unsigned long sets, unsigned long reps, unsigned int use_mpool)
{
	struct timeval begin, end;
	long long delta_us;
	unsigned long i, j;
	struct stuff ** arr;

	/* Sanity test. */
	assert((sets > 0) && (reps > 0));

	/* Allocate temporary array. */
	if ((arr = malloc(reps * sizeof(struct stuff *))) == NULL) {
		warnp("Out of memory");
		goto err0;
	}

	/* Get start time. */
	if (monoclock_get_cputime(&begin)) {
		warnp("monoclock_get_cputime()");
		goto err1;
	}

	for (j = 0; j < sets; j++) {
		/* Allocate structures. */
		if (use_mpool) {
			for (i = 0; i < reps; i++) {
				if ((arr[i] = mpool_stuff_malloc()) == NULL) {
					warnp("mpool_stuff_malloc()");
					goto err1;
				}
			}
		} else {
			for (i = 0; i < reps; i++) {
				if ((arr[i] = malloc(sizeof(struct stuff)))
				    == NULL) {
					warnp("malloc()");
					goto err1;
				}
			}
		}

		/*
		 * Free one structure to potentially trigger mpool growth,
		 * then test memory access.
		 */
		if (use_mpool)
			mpool_stuff_free(arr[0]);
		else
			free(arr[0]);
		for (i = 1; i < reps; i++)
			if (check_mem(arr[i]))
				goto err1;

		/* Free remaining structures. */
		if (use_mpool)
			for (i = 1; i < reps; i++)
				mpool_stuff_free(arr[i]);
		else
			for (i = 1; i < reps; i++)
				free(arr[i]);
	}

	/* Get end time and difference. */
	if (monoclock_get_cputime(&end)) {
		warnp("monoclock_get_cputime()");
		goto err1;
	}
	delta_us = (long long)(1e6 * timeval_diff(begin, end));

	/* Clean up. */
	free(arr);

	/* Success! */
	return (delta_us);

err1:
	free(arr);
err0:
	/* Failure! */
	return (-1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
testq %rdi, %rdi
je 0x1531
movq %rsi, %r14
testq %rsi, %rsi
je 0x1531
movl %edx, %ebp
movq %rdi, %r15
leaq (,%r14,8), %rdi
callq 0x1110
testq %rax, %rax
je 0x1328
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x18d4
testl %eax, %eax
je 0x134f
callq 0x1060
cmpl $0x0, (%rax)
je 0x145b
movq %rax, %r14
leaq 0xd6e(%rip), %rdi       # 0x2086
xorl %eax, %eax
callq 0x1a89
andl $0x0, (%r14)
jmp 0x1469
callq 0x1060
cmpl $0x0, (%rax)
je 0x1487
movq %rax, %rbx
leaq 0xd38(%rip), %rdi       # 0x2078
xorl %eax, %eax
callq 0x1a89
andl $0x0, (%rbx)
jmp 0x1471
xorl %r12d, %r12d
cmpq %r15, %r12
je 0x14db
xorl %r13d, %r13d
testl %ebp, %ebp
je 0x13f6
cmpq %r13, %r14
je 0x13fb
incq 0x2d8a(%rip)            # 0x4100
movq 0x2d6b(%rip), %rax      # 0x40e8
testq %rax, %rax
je 0x139b
movq 0x2d6f(%rip), %rcx      # 0x40f8
leaq -0x1(%rax), %rdx
movq %rdx, 0x2d54(%rip)      # 0x40e8
movq -0x8(%rcx,%rax,8), %rax
jmp 0x13cb
incq 0x2d66(%rip)            # 0x4108
cmpl $0x0, 0x2d67(%rip)      # 0x4110
jne 0x13c1
movq 0x2d6e(%rip), %rdi      # 0x4120
callq 0x1da0
movl $0x1, 0x2d4f(%rip)      # 0x4110
movl $0x80, %edi
callq 0x1110
movq %rax, (%rbx,%r13,8)
incq %r13
testq %rax, %rax
jne 0x1366
jmp 0x1497
movl $0x80, %edi
callq 0x1110
movq %rax, (%rbx,%r13,8)
incq %r13
testq %rax, %rax
je 0x14b0
cmpq %r13, %r14
jne 0x13dc
movq (%rbx), %rdi
testl %ebp, %ebp
je 0x1409
callq 0x154e
jmp 0x140e
callq 0x1030
pushq $0x1
popq %rax
cmpq %rax, %r14
je 0x1427
movq (%rbx,%rax,8), %rcx
movb $0x0, (%rcx)
incq %rax
cmpb $0x0, (%rcx)
je 0x1411
jmp 0x1469
pushq $0x1
popq %r13
testl %ebp, %ebp
je 0x144e
cmpq %r13, %r14
je 0x1453
movq (%rbx,%r13,8), %rdi
callq 0x154e
incq %r13
jmp 0x142f
movq (%rbx,%r13,8), %rdi
callq 0x1030
incq %r13
cmpq %r13, %r14
jne 0x1442
incq %r12
jmp 0x1352
leaq 0xc24(%rip), %rdi       # 0x2086
xorl %eax, %eax
callq 0x1c18
movq %rbx, %rdi
callq 0x1030
pushq $-0x1
popq %r14
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xbea(%rip), %rdi       # 0x2078
xorl %eax, %eax
callq 0x1c18
jmp 0x1471
callq 0x1060
cmpl $0x0, (%rax)
je 0x14c9
movq %rax, %r14
leaq 0xbf3(%rip), %rdi       # 0x209e
jmp 0x1318
callq 0x1060
cmpl $0x0, (%rax)
je 0x14d2
movq %rax, %r14
leaq 0xbe6(%rip), %rdi       # 0x20aa
jmp 0x1318
leaq 0xbce(%rip), %rdi       # 0x209e
jmp 0x1462
leaq 0xbd1(%rip), %rdi       # 0x20aa
jmp 0x1462
leaq 0x8(%rsp), %rdi
callq 0x18d4
testl %eax, %eax
jne 0x1300
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
subq 0x18(%rsp), %rax
cvtsi2sd %rax, %xmm0
subq 0x20(%rsp), %rcx
cvtsi2sd %rcx, %xmm1
mulsd 0xaf5(%rip), %xmm1      # 0x2008
addsd %xmm0, %xmm1
mulsd 0xaf1(%rip), %xmm1      # 0x2010
cvttsd2si %xmm1, %r14
movq %rbx, %rdi
callq 0x1030
jmp 0x1475
leaq 0xae0(%rip), %rdi       # 0x2018
leaq 0xaf2(%rip), %rsi       # 0x2031
leaq 0xaf2(%rip), %rcx       # 0x2038
pushq $0x36
popq %rdx
callq 0x10b0