// File: /workspace/github_c_makefile_star2_O1/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
movq %r9, %r15
movl %r8d, 0x1c(%rsp)
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbx
xorl %ebp, %ebp
testq %rdx, %rdx
je 0x259b
xorl %eax, %eax
movq (%r13,%rax,8), %rcx
cmpq %rcx, %rbp
cmovbeq %rcx, %rbp
incq %rax
cmpq %rax, %r12
jne 0x2587
testq %rbp, %rbp
je 0x290e
movq %rbp, %rdi
callq 0x1140
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x280b
leaq (,%r12,8), %rdi
callq 0x1140
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x2831
movq %rbx, 0x20(%rsp)
testq %r14, %r14
je 0x264e
movq %r14, %rax
xorl %edx, %edx
divq %rbp
movq %rax, %r14
testq %r15, %r15
je 0x260a
movq 0x90(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %rbp, %rdx
callq *%r15
testl %eax, %eax
jne 0x28e6
movq 0x90(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq *0x80(%rsp)
testl %eax, %eax
jne 0x28cc
cmpq $0x0, 0x88(%rsp)
je 0x264e
movq 0x90(%rsp), %rdi
callq *0x88(%rsp)
testl %eax, %eax
jne 0x28e6
testq %r12, %r12
movq 0x10(%rsp), %rbp
je 0x27f2
xorl %ebx, %ebx
movq (%r13,%rbx,8), %r14
testq %r14, %r14
je 0x292d
movq 0x20(%rsp), %rax
xorl %edx, %edx
divq %r14
movq %rax, %rbp
testq %r15, %r15
je 0x2699
movq 0x90(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %r14, %rdx
callq *%r15
testl %eax, %eax
jne 0x28e6
cmpl $0x0, 0x1c(%rsp)
je 0x26b3
leaq 0x38(%rsp), %rdi
callq 0x2cf7
testl %eax, %eax
je 0x26c5
jmp 0x287b
leaq 0x38(%rsp), %rdi
callq 0x2c10
testl %eax, %eax
jne 0x2891
movq 0x90(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %r14, %rdx
movq %rbp, %rcx
callq *0x80(%rsp)
testl %eax, %eax
jne 0x28cc
cmpl $0x0, 0x1c(%rsp)
je 0x2706
leaq 0x28(%rsp), %rdi
callq 0x2cf7
testl %eax, %eax
movq 0x10(%rsp), %rdx
je 0x271d
jmp 0x287b
leaq 0x28(%rsp), %rdi
callq 0x2c10
testl %eax, %eax
movq 0x10(%rsp), %rdx
jne 0x2891
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 0xd07(%rip), %xmm1      # 0x3450
addsd %xmm0, %xmm1
movsd %xmm1, (%rdx,%rbx,8)
cmpq $0x0, 0x88(%rsp)
je 0x2774
movq 0x90(%rsp), %rdi
callq *0x88(%rsp)
testl %eax, %eax
jne 0x28e6
incq %rbx
cmpq %rbx, %r12
jne 0x265e
xorl %ebx, %ebx
leaq 0xdf3(%rip), %r14       # 0x357c
movq 0x10(%rsp), %rbp
movq 0x20(%rsp), %r15
movq (%r13,%rbx,8), %rcx
movq %r15, %rax
xorl %edx, %edx
divq %rcx
movq %rax, %rdx
imulq %rcx, %rdx
movq %rdx, %xmm0
punpckldq 0xcac(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xcb4(%rip), %xmm0      # 0x3470
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd 0xc88(%rip), %xmm1      # 0x3458
movsd (%rbp,%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 0x2793
movq %rbp, %rdi
callq 0x1030
movq 0x8(%rsp), %rdi
callq 0x1030
xorl %eax, %eax
jmp 0x28ff
callq 0x1080
cmpl $0x0, (%rax)
je 0x2858
movq %rax, %rbx
leaq 0xd2e(%rip), %rdi       # 0x354d
xorl %eax, %eax
callq 0x29cc
movl $0x0, (%rbx)
jmp 0x28fa
callq 0x1080
cmpl $0x0, (%rax)
je 0x286b
movq %rax, %r14
leaq 0xd08(%rip), %rdi       # 0x354d
xorl %eax, %eax
callq 0x29cc
movl $0x0, (%r14)
jmp 0x28f0
leaq 0xcee(%rip), %rdi       # 0x354d
xorl %eax, %eax
callq 0x2aeb
jmp 0x28fa
leaq 0xcdb(%rip), %rdi       # 0x354d
xorl %eax, %eax
callq 0x2aeb
jmp 0x28f0
callq 0x1080
cmpl $0x0, (%rax)
je 0x28b5
movq %rax, %r14
leaq 0xcc5(%rip), %rdi       # 0x3554
jmp 0x28a5
callq 0x1080
cmpl $0x0, (%rax)
je 0x28be
movq %rax, %r14
leaq 0xcc7(%rip), %rdi       # 0x356c
xorl %eax, %eax
callq 0x29cc
movl $0x0, (%r14)
jmp 0x28cc
leaq 0xc98(%rip), %rdi       # 0x3554
jmp 0x28c5
leaq 0xca7(%rip), %rdi       # 0x356c
xorl %eax, %eax
callq 0x2aeb
cmpq $0x0, 0x88(%rsp)
je 0x28e6
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 0xb6b(%rip), %rdi       # 0x3480
leaq 0xb73(%rip), %rsi       # 0x348f
leaq 0xb7f(%rip), %rcx       # 0x34a2
movl $0x35, %edx
callq 0x10e0
leaq 0xb50(%rip), %rdi       # 0x3484
leaq 0xb54(%rip), %rsi       # 0x348f
leaq 0xb60(%rip), %rcx       # 0x34a2
movl $0x50, %edx
callq 0x10e0