// File: /workspace/github_c_makefile_star2_O1/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 0x1663
movq %rsi, %r14
testq %rsi, %rsi
je 0x1663
movl %edx, %ebp
movq %rdi, %r15
leaq (,%r14,8), %rdi
callq 0x1110
testq %rax, %rax
je 0x143d
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x1a57
testl %eax, %eax
je 0x1467
callq 0x1060
cmpl $0x0, (%rax)
je 0x15d8
movq %rax, %r14
leaq 0xc4e(%rip), %rdi       # 0x2086
jmp 0x161b
callq 0x1060
cmpl $0x0, (%rax)
je 0x15e1
movq %rax, %rbx
leaq 0xc23(%rip), %rdi       # 0x2078
xorl %eax, %eax
callq 0x1c2c
movl $0x0, (%rbx)
jmp 0x164a
xorl %r12d, %r12d
xorl %r13d, %r13d
testl %ebp, %ebp
je 0x14e4
incq 0x2c88(%rip)            # 0x4100
movq 0x2c69(%rip), %rax      # 0x40e8
testq %rax, %rax
je 0x149d
movq 0x2c6d(%rip), %rcx      # 0x40f8
leaq -0x1(%rax), %rdx
movq %rdx, 0x2c52(%rip)      # 0x40e8
movq -0x8(%rcx,%rax,8), %rax
jmp 0x14cd
incq 0x2c64(%rip)            # 0x4108
cmpl $0x0, 0x2c65(%rip)      # 0x4110
jne 0x14c3
movq 0x2c6c(%rip), %rdi      # 0x4120
callq 0x1e70
movl $0x1, 0x2c4d(%rip)      # 0x4110
movl $0x80, %edi
callq 0x1110
movq %rax, (%rbx,%r13,8)
testq %rax, %rax
je 0x15f1
incq %r13
cmpq %r13, %r14
jne 0x1471
jmp 0x1503
movl $0x80, %edi
callq 0x1110
movq %rax, (%rbx,%r13,8)
testq %rax, %rax
je 0x1607
incq %r13
cmpq %r13, %r14
jne 0x14e4
movq (%rbx), %rdi
testl %ebp, %ebp
je 0x1511
callq 0x1682
jmp 0x1516
callq 0x1030
cmpq $0x2, %r14
jb 0x1539
movl $0x1, %eax
movq (%rbx,%rax,8), %rcx
movb $0x0, (%rcx)
cmpb $0x0, (%rcx)
jne 0x1642
incq %rax
cmpq %rax, %r14
jne 0x1521
testl %ebp, %ebp
je 0x155c
cmpq $0x2, %r14
jb 0x1579
movl $0x1, %r13d
movq (%rbx,%r13,8), %rdi
callq 0x1682
incq %r13
cmpq %r13, %r14
jne 0x1549
jmp 0x1579
cmpq $0x2, %r14
jb 0x1579
movl $0x1, %r13d
movq (%rbx,%r13,8), %rdi
callq 0x1030
incq %r13
cmpq %r13, %r14
jne 0x1568
incq %r12
cmpq %r15, %r12
jne 0x146a
leaq 0x8(%rsp), %rdi
callq 0x1a57
testl %eax, %eax
jne 0x1420
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
subq 0x18(%rsp), %rax
cvtsi2sd %rax, %xmm0
subq 0x20(%rsp), %rcx
cvtsi2sd %rcx, %xmm1
mulsd 0xa4b(%rip), %xmm1      # 0x2008
addsd %xmm0, %xmm1
mulsd 0xa47(%rip), %xmm1      # 0x2010
cvttsd2si %xmm1, %r14
movq %rbx, %rdi
callq 0x1030
jmp 0x1651
leaq 0xaa7(%rip), %rdi       # 0x2086
jmp 0x163b
leaq 0xa90(%rip), %rdi       # 0x2078
xorl %eax, %eax
callq 0x1d4b
jmp 0x164a
callq 0x1060
cmpl $0x0, (%rax)
je 0x162b
movq %rax, %r14
leaq 0xa99(%rip), %rdi       # 0x209e
jmp 0x161b
callq 0x1060
cmpl $0x0, (%rax)
je 0x1634
movq %rax, %r14
leaq 0xa8f(%rip), %rdi       # 0x20aa
xorl %eax, %eax
callq 0x1c2c
movl $0x0, (%r14)
jmp 0x1642
leaq 0xa6c(%rip), %rdi       # 0x209e
jmp 0x163b
leaq 0xa6f(%rip), %rdi       # 0x20aa
xorl %eax, %eax
callq 0x1d4b
movq %rbx, %rdi
callq 0x1030
movq $-0x1, %r14
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9ae(%rip), %rdi       # 0x2018
leaq 0x9c0(%rip), %rsi       # 0x2031
leaq 0x9c0(%rip), %rcx       # 0x2038
movl $0x36, %edx
callq 0x10b0