// File: /workspace/github_c_makefile_star2_O3/Tarsnap[P]libcperciva/liball/../util/perftest.c
// Function: perftest_buffers
int
perftest_buffers(size_t nbytes, const size_t * sizes, size_t nsizes,
    size_t nbytes_warmup, int cputime,
    int init_func(void *, uint8_t *, size_t),
    int func(void *, uint8_t *, size_t, size_t),
    int clean_func(void *), void * cookie)
{
	uint8_t * buf;
	struct timeval begin, end;
	double * delta_s;
	double speed;
	size_t i;
	size_t buflen;
	size_t num_buffers;
	size_t nbuffers_warmup;
	size_t nbytes_in_buffer;
	size_t max_buflen = 0;

	/* Find the maximum buffer size. */
	for (i = 0; i < nsizes; i++) {
		if (max_buflen < sizes[i])
			max_buflen = sizes[i];
	}
	assert(max_buflen > 0);

	/* Allocate buffers. */
	if ((buf = malloc(max_buflen)) == NULL) {
		warnp("malloc");
		goto err0;
	}
	if ((delta_s = malloc(nsizes * sizeof(double))) == NULL) {
		warnp("malloc");
		goto err1;
	}

	/* Warm up. */
	if (nbytes_warmup > 0) {
		nbuffers_warmup = nbytes_warmup / max_buflen;
		if (init_func && init_func(cookie, buf, max_buflen))
			goto err2;
		if (func(cookie, buf, max_buflen, nbuffers_warmup))
			goto err3;
		if (clean_func && clean_func(cookie))
			goto err2;
	}

	/* Run operations. */
	for (i = 0; i < nsizes; i++) {
		/* Configure and sanity checks. */
		buflen = sizes[i];
		assert(buflen > 0);
		num_buffers = nbytes / buflen;

		/* Set up. */
		if (init_func && init_func(cookie, buf, buflen))
			goto err2;

		/* Get beginning time. */
		if (cputime) {
			if (monoclock_get_cputime(&begin)) {
				warnp("monoclock_get_cputime()");
				goto err3;
			}
		} else {
			if (monoclock_get(&begin)) {
				warnp("monoclock_get()");
				goto err3;
			}
		}

		/* Time actual code. */
		if (func(cookie, buf, buflen, num_buffers))
			goto err3;

		/* Get ending time. */
		if (cputime) {
			if (monoclock_get_cputime(&end)) {
				warnp("monoclock_get_cputime()");
				goto err3;
			}
		} else {
			if (monoclock_get(&end)) {
				warnp("monoclock_get()");
				goto err3;
			}
		}

		/* Store time. */
		delta_s[i] = timeval_diff(begin, end);

		/* Clean up. */
		if (clean_func && clean_func(cookie))
			goto err2;
	}

	/* Print output. */
	for (i = 0; i < nsizes; i++) {
		buflen = sizes[i];
		num_buffers = nbytes / buflen;

		/* We might not be processing an integer number of buffers. */
		nbytes_in_buffer = buflen * num_buffers;
		speed = (double)nbytes_in_buffer / 1e6 / delta_s[i];

		/* Print output. */
		printf("%zu blocks of size %zu\t%.06f s\t%.06f MB/s\n",
		    num_buffers, buflen, delta_s[i], speed);
	}

	/* Clean up. */
	free(delta_s);
	free(buf);

	/* Success! */
	return (0);

err3:
	if (clean_func)
		clean_func(cookie);
err2:
	free(delta_s);
err1:
	free(buf);
err0:
	/* Failure! */
	return (-1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %r8d, 0x1c(%rsp)
movq %rdi, 0x20(%rsp)
testq %rdx, %rdx
je 0x2a5a
movq %r9, %r15
movq %rcx, %rbp
movq %rdx, %r12
movq %rsi, %r13
xorl %r14d, %r14d
xorl %eax, %eax
movq %r14, %rcx
movq (%r13,%rax,8), %r14
cmpq %r14, %rcx
cmovaq %rcx, %r14
incq %rax
cmpq %rax, %r12
jne 0x26ce
testq %r14, %r14
je 0x2a5a
movq %r14, %rdi
callq 0x1140
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x2957
leaq (,%r12,8), %rdi
callq 0x1140
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x297d
testq %rbp, %rbp
je 0x2793
movq %rbp, %rax
xorl %edx, %edx
divq %r14
movq %rax, %rbp
testq %r15, %r15
je 0x274f
movq 0x90(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %r14, %rdx
callq *%r15
testl %eax, %eax
jne 0x2a32
movq 0x90(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %r14, %rdx
movq %rbp, %rcx
callq *0x80(%rsp)
testl %eax, %eax
jne 0x2a18
cmpq $0x0, 0x88(%rsp)
je 0x2793
movq 0x90(%rsp), %rdi
callq *0x88(%rsp)
testl %eax, %eax
jne 0x2a32
xorl %ebx, %ebx
movq (%r13,%rbx,8), %r14
testq %r14, %r14
movq 0x20(%rsp), %rax
je 0x2a79
xorl %edx, %edx
divq %r14
movq %rax, %rbp
testq %r15, %r15
je 0x27d0
movq 0x90(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %r14, %rdx
callq *%r15
testl %eax, %eax
jne 0x2a32
cmpl $0x0, 0x1c(%rsp)
je 0x281e
leaq 0x38(%rsp), %rdi
callq 0x2e43
testl %eax, %eax
jne 0x29c7
movq 0x90(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %r14, %rdx
movq %rbp, %rcx
callq *0x80(%rsp)
testl %eax, %eax
jne 0x2a18
leaq 0x28(%rsp), %rdi
callq 0x2e43
testl %eax, %eax
je 0x2864
jmp 0x29c7
leaq 0x38(%rsp), %rdi
callq 0x2d5c
testl %eax, %eax
jne 0x29dd
movq 0x90(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %r14, %rdx
movq %rbp, %rcx
callq *0x80(%rsp)
testl %eax, %eax
jne 0x2a18
leaq 0x28(%rsp), %rdi
callq 0x2d5c
testl %eax, %eax
jne 0x29dd
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %rcx
subq 0x38(%rsp), %rax
subq 0x40(%rsp), %rcx
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %rcx, %xmm1
mulsd 0xbf0(%rip), %xmm1      # 0x3480
addsd %xmm0, %xmm1
movq 0x10(%rsp), %rax
movsd %xmm1, (%rax,%rbx,8)
cmpq $0x0, 0x88(%rsp)
je 0x28c0
movq 0x90(%rsp), %rdi
callq *0x88(%rsp)
testl %eax, %eax
jne 0x2a32
incq %rbx
cmpq %rbx, %r12
jne 0x2795
xorl %ebx, %ebx
leaq 0xcd7(%rip), %r14       # 0x35ac
movq 0x10(%rsp), %r15
movq 0x20(%rsp), %rbp
movq (%r13,%rbx,8), %rcx
movq %rbp, %rax
xorl %edx, %edx
divq %rcx
movq %rax, %rdx
imulq %rcx, %rdx
movq %rdx, %xmm0
punpckldq 0xb90(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xb98(%rip), %xmm0      # 0x34a0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd 0xb6c(%rip), %xmm1      # 0x3488
movsd (%r15,%rbx,8), %xmm0
divsd %xmm0, %xmm1
movq %r14, %rdi
movq %rax, %rsi
movq %rcx, %rdx
movb $0x2, %al
callq 0x10d0
incq %rbx
cmpq %rbx, %r12
jne 0x28df
movq %r15, %rdi
callq 0x1030
movq 0x8(%rsp), %rdi
callq 0x1030
xorl %eax, %eax
jmp 0x2a4b
callq 0x1080
cmpl $0x0, (%rax)
je 0x29a4
movq %rax, %rbx
leaq 0xc12(%rip), %rdi       # 0x357d
xorl %eax, %eax
callq 0x2b18
movl $0x0, (%rbx)
jmp 0x2a46
callq 0x1080
cmpl $0x0, (%rax)
je 0x29b7
movq %rax, %r14
leaq 0xbec(%rip), %rdi       # 0x357d
xorl %eax, %eax
callq 0x2b18
movl $0x0, (%r14)
jmp 0x2a3c
leaq 0xbd2(%rip), %rdi       # 0x357d
xorl %eax, %eax
callq 0x2c37
jmp 0x2a46
leaq 0xbbf(%rip), %rdi       # 0x357d
xorl %eax, %eax
callq 0x2c37
jmp 0x2a3c
callq 0x1080
cmpl $0x0, (%rax)
je 0x2a01
movq %rax, %r14
leaq 0xba9(%rip), %rdi       # 0x3584
jmp 0x29f1
callq 0x1080
cmpl $0x0, (%rax)
je 0x2a0a
movq %rax, %r14
leaq 0xbab(%rip), %rdi       # 0x359c
xorl %eax, %eax
callq 0x2b18
movl $0x0, (%r14)
jmp 0x2a18
leaq 0xb7c(%rip), %rdi       # 0x3584
jmp 0x2a11
leaq 0xb8b(%rip), %rdi       # 0x359c
xorl %eax, %eax
callq 0x2c37
cmpq $0x0, 0x88(%rsp)
je 0x2a32
movq 0x90(%rsp), %rdi
callq *0x88(%rsp)
movq 0x10(%rsp), %rdi
callq 0x1030
movq 0x8(%rsp), %rdi
callq 0x1030
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xa4f(%rip), %rdi       # 0x34b0
leaq 0xa57(%rip), %rsi       # 0x34bf
leaq 0xa63(%rip), %rcx       # 0x34d2
movl $0x35, %edx
callq 0x10e0
leaq 0xa34(%rip), %rdi       # 0x34b4
leaq 0xa38(%rip), %rsi       # 0x34bf
leaq 0xa44(%rip), %rcx       # 0x34d2
movl $0x50, %edx
callq 0x10e0