// File: /workspace/github_c_makefile_star2_O3/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 $0x38, %rsp
testq %rdi, %rdi
je 0x16a4
movq %rsi, %r14
testq %rsi, %rsi
je 0x16a4
movl %edx, %ebp
movq %rdi, %r15
leaq (,%r14,8), %rdi
callq 0x1110
testq %rax, %rax
je 0x143d
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x1a93
testl %eax, %eax
je 0x1467
callq 0x1060
cmpl $0x0, (%rax)
je 0x1619
movq %rax, %r14
leaq 0xc4e(%rip), %rdi       # 0x2086
jmp 0x165c
callq 0x1060
cmpl $0x0, (%rax)
je 0x1622
movq %rax, %rbx
leaq 0xc23(%rip), %rdi       # 0x2078
xorl %eax, %eax
callq 0x1c68
movl $0x0, (%rbx)
jmp 0x168b
xorl %eax, %eax
movl %ebp, 0xc(%rsp)
movq %rax, 0x10(%rsp)
testl %ebp, %ebp
je 0x1513
movq 0x2c7f(%rip), %r12      # 0x4100
movq 0x2c60(%rip), %rbp      # 0x40e8
xorl %r13d, %r13d
incq %r12
movq %r12, 0x2c6b(%rip)      # 0x4100
testq %rbp, %rbp
je 0x14b6
movq 0x2c57(%rip), %rax      # 0x40f8
leaq -0x1(%rbp), %rcx
movq %rcx, 0x2c3c(%rip)      # 0x40e8
movq -0x8(%rax,%rbp,8), %rax
movq %rcx, %rbp
jmp 0x14f8
incq 0x2c4b(%rip)            # 0x4108
cmpl $0x0, 0x2c4c(%rip)      # 0x4110
je 0x14ca
xorl %ebp, %ebp
jmp 0x14ee
movq 0x2c4f(%rip), %rdi      # 0x4120
callq 0x1eb0
movl $0x1, 0x2c30(%rip)      # 0x4110
movq 0x2c19(%rip), %r12      # 0x4100
movq 0x2bfa(%rip), %rbp      # 0x40e8
movl $0x80, %edi
callq 0x1110
movq %rax, (%rbx,%r13,8)
testq %rax, %rax
je 0x1632
incq %r13
cmpq %r13, %r14
jne 0x148b
jmp 0x1535
xorl %r12d, %r12d
movl $0x80, %edi
callq 0x1110
movq %rax, (%rbx,%r12,8)
testq %rax, %rax
je 0x1648
incq %r12
cmpq %r12, %r14
jne 0x1516
movq (%rbx), %rdi
movl 0xc(%rsp), %ebp
testl %ebp, %ebp
je 0x154d
callq 0x16c3
cmpq $0x2, %r14
jae 0x1558
jmp 0x15b5
callq 0x1030
cmpq $0x1, %r14
jbe 0x15b5
movl $0x1, %eax
movq (%rbx,%rax,8), %rcx
movb $0x0, (%rcx)
cmpb $0x0, (%rcx)
jne 0x1683
incq %rax
cmpq %rax, %r14
jne 0x155d
testl %ebp, %ebp
je 0x1598
cmpq $0x2, %r14
jb 0x15b5
movl $0x1, %r12d
movq (%rbx,%r12,8), %rdi
callq 0x16c3
incq %r12
cmpq %r12, %r14
jne 0x1585
jmp 0x15b5
cmpq $0x2, %r14
jb 0x15b5
movl $0x1, %r12d
movq (%rbx,%r12,8), %rdi
callq 0x1030
incq %r12
cmpq %r12, %r14
jne 0x15a4
movq 0x10(%rsp), %rax
incq %rax
cmpq %r15, %rax
jne 0x146d
leaq 0x18(%rsp), %rdi
callq 0x1a93
testl %eax, %eax
jne 0x1420
movq 0x18(%rsp), %rax
movq 0x20(%rsp), %rcx
subq 0x28(%rsp), %rax
cvtsi2sd %rax, %xmm0
subq 0x30(%rsp), %rcx
cvtsi2sd %rcx, %xmm1
mulsd 0xa0a(%rip), %xmm1      # 0x2008
addsd %xmm0, %xmm1
mulsd 0xa06(%rip), %xmm1      # 0x2010
cvttsd2si %xmm1, %r14
movq %rbx, %rdi
callq 0x1030
jmp 0x1692
leaq 0xa66(%rip), %rdi       # 0x2086
jmp 0x167c
leaq 0xa4f(%rip), %rdi       # 0x2078
xorl %eax, %eax
callq 0x1d87
jmp 0x168b
callq 0x1060
cmpl $0x0, (%rax)
je 0x166c
movq %rax, %r14
leaq 0xa58(%rip), %rdi       # 0x209e
jmp 0x165c
callq 0x1060
cmpl $0x0, (%rax)
je 0x1675
movq %rax, %r14
leaq 0xa4e(%rip), %rdi       # 0x20aa
xorl %eax, %eax
callq 0x1c68
movl $0x0, (%r14)
jmp 0x1683
leaq 0xa2b(%rip), %rdi       # 0x209e
jmp 0x167c
leaq 0xa2e(%rip), %rdi       # 0x20aa
xorl %eax, %eax
callq 0x1d87
movq %rbx, %rdi
callq 0x1030
movq $-0x1, %r14
movq %r14, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x96d(%rip), %rdi       # 0x2018
leaq 0x97f(%rip), %rsi       # 0x2031
leaq 0x97f(%rip), %rcx       # 0x2038
movl $0x36, %edx
callq 0x10b0