// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
cmpq $0x0, -0x10(%rbp)
jbe 0x12f3
cmpq $0x0, -0x18(%rbp)
jbe 0x12f3
jmp 0x1312
leaq 0x1d36(%rip), %rdi      # 0x3030
leaq 0x1d48(%rip), %rsi      # 0x3049
movl $0x36, %edx
leaq 0x1d43(%rip), %rcx      # 0x3050
callq 0x10c0
movq -0x18(%rbp), %rdi
shlq $0x3, %rdi
callq 0x1100
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
jne 0x1365
jmp 0x132b
callq 0x1070
cmpl $0x0, (%rax)
je 0x1350
leaq 0x1d54(%rip), %rdi      # 0x3090
movb $0x0, %al
callq 0x21c0
callq 0x1070
movl $0x0, (%rax)
jmp 0x135e
leaq 0x1d39(%rip), %rdi      # 0x3090
movb $0x0, %al
callq 0x2410
jmp 0x1360
jmp 0x163c
leaq -0x30(%rbp), %rdi
callq 0x1f10
cmpl $0x0, %eax
je 0x13af
jmp 0x1375
callq 0x1070
cmpl $0x0, (%rax)
je 0x139a
leaq 0x1d18(%rip), %rdi      # 0x309e
movb $0x0, %al
callq 0x21c0
callq 0x1070
movl $0x0, (%rax)
jmp 0x13a8
leaq 0x1cfd(%rip), %rdi      # 0x309e
movb $0x0, %al
callq 0x2410
jmp 0x13aa
jmp 0x1633
movq $0x0, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x10(%rbp), %rax
jae 0x159a
cmpl $0x0, -0x1c(%rbp)
je 0x1442
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x1440
callq 0x1650
movq -0x60(%rbp), %rcx
movq -0x50(%rbp), %rdx
movq %rax, (%rcx,%rdx,8)
cmpq $0x0, %rax
jne 0x1430
jmp 0x13f6
callq 0x1070
cmpl $0x0, (%rax)
je 0x141b
leaq 0x1caf(%rip), %rdi      # 0x30b6
movb $0x0, %al
callq 0x21c0
callq 0x1070
movl $0x0, (%rax)
jmp 0x1429
leaq 0x1c94(%rip), %rdi      # 0x30b6
movb $0x0, %al
callq 0x2410
jmp 0x142b
jmp 0x1633
jmp 0x1432
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x13d3
jmp 0x14be
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x14bc
movl $0x80, %edi
callq 0x1100
movq -0x60(%rbp), %rcx
movq -0x50(%rbp), %rdx
movq %rax, (%rcx,%rdx,8)
cmpq $0x0, %rax
jne 0x14ac
jmp 0x1472
callq 0x1070
cmpl $0x0, (%rax)
je 0x1497
leaq 0x1c3f(%rip), %rdi      # 0x30c2
movb $0x0, %al
callq 0x21c0
callq 0x1070
movl $0x0, (%rax)
jmp 0x14a5
leaq 0x1c24(%rip), %rdi      # 0x30c2
movb $0x0, %al
callq 0x2410
jmp 0x14a7
jmp 0x1633
jmp 0x14ae
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x144a
jmp 0x14be
cmpl $0x0, -0x1c(%rbp)
je 0x14d2
movq -0x60(%rbp), %rax
movq (%rax), %rdi
callq 0x1670
jmp 0x14de
movq -0x60(%rbp), %rax
movq (%rax), %rdi
callq 0x1030
movq $0x1, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x151b
movq -0x60(%rbp), %rax
movq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x1290
cmpl $0x0, %eax
je 0x150b
jmp 0x1633
jmp 0x150d
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x14e6
cmpl $0x0, -0x1c(%rbp)
je 0x1554
movq $0x1, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x1552
movq -0x60(%rbp), %rax
movq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x1670
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x1529
jmp 0x1587
movq $0x1, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x1585
movq -0x60(%rbp), %rax
movq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x1030
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x155c
jmp 0x1587
jmp 0x1589
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x13b7
leaq -0x40(%rbp), %rdi
callq 0x1f10
cmpl $0x0, %eax
je 0x15e1
jmp 0x15aa
callq 0x1070
cmpl $0x0, (%rax)
je 0x15cf
leaq 0x1ae3(%rip), %rdi      # 0x309e
movb $0x0, %al
callq 0x21c0
callq 0x1070
movl $0x0, (%rax)
jmp 0x15dd
leaq 0x1ac8(%rip), %rdi      # 0x309e
movb $0x0, %al
callq 0x2410
jmp 0x15df
jmp 0x1633
movq -0x40(%rbp), %rax
subq -0x30(%rbp), %rax
cvtsi2sd %rax, %xmm0
movq -0x38(%rbp), %rax
subq -0x28(%rbp), %rax
cvtsi2sd %rax, %xmm1
movsd 0x1a0d(%rip), %xmm2     # 0x3010
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd 0x19f5(%rip), %xmm0     # 0x3008
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, -0x48(%rbp)
movq -0x60(%rbp), %rdi
callq 0x1030
movq -0x48(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x1644
movq -0x60(%rbp), %rdi
callq 0x1030
movq $-0x1, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nop