// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xa0, %rsp
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movq %r9, -0x38(%rbp)
movq $0x0, -0xa0(%rbp)
movq $0x0, -0x78(%rbp)
movq -0x78(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0x36c4
movq -0xa0(%rbp), %rax
movq -0x18(%rbp), %rcx
movq -0x78(%rbp), %rdx
cmpq (%rcx,%rdx,8), %rax
jae 0x36b4
movq -0x18(%rbp), %rax
movq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xa0(%rbp)
jmp 0x36b6
movq -0x78(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x78(%rbp)
jmp 0x3682
cmpq $0x0, -0xa0(%rbp)
jbe 0x36d0
jmp 0x36ef
leaq 0x1da9(%rip), %rdi      # 0x5480
leaq 0x1db1(%rip), %rsi      # 0x548f
movl $0x35, %edx
leaq 0x1db8(%rip), %rcx      # 0x54a2
callq 0x10d0
movq -0xa0(%rbp), %rdi
callq 0x1110
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
jne 0x3741
jmp 0x3707
callq 0x1070
cmpl $0x0, (%rax)
je 0x372c
leaq 0x1e35(%rip), %rdi      # 0x554d
movb $0x0, %al
callq 0x3c50
callq 0x1070
movl $0x0, (%rax)
jmp 0x373a
leaq 0x1e1a(%rip), %rdi      # 0x554d
movb $0x0, %al
callq 0x3ea0
jmp 0x373c
jmp 0x3b76
movq -0x20(%rbp), %rdi
shlq $0x3, %rdi
callq 0x1110
movq %rax, -0x68(%rbp)
cmpq $0x0, %rax
jne 0x3794
jmp 0x375a
callq 0x1070
cmpl $0x0, (%rax)
je 0x377f
leaq 0x1de2(%rip), %rdi      # 0x554d
movb $0x0, %al
callq 0x3c50
callq 0x1070
movl $0x0, (%rax)
jmp 0x378d
leaq 0x1dc7(%rip), %rdi      # 0x554d
movb $0x0, %al
callq 0x3ea0
jmp 0x378f
jmp 0x3b6d
cmpq $0x0, -0x28(%rbp)
jbe 0x381a
movq -0x28(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %edx
divq -0xa0(%rbp)
movq %rax, -0x90(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x37d7
movq -0x38(%rbp), %rax
movq 0x20(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0xa0(%rbp), %rdx
callq *%rax
cmpl $0x0, %eax
je 0x37d7
jmp 0x3b64
movq 0x10(%rbp), %rax
movq 0x20(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0xa0(%rbp), %rdx
movq -0x90(%rbp), %rcx
callq *%rax
cmpl $0x0, %eax
je 0x37fd
jmp 0x3b51
cmpq $0x0, 0x18(%rbp)
je 0x3818
movq 0x18(%rbp), %rax
movq 0x20(%rbp), %rdi
callq *%rax
cmpl $0x0, %eax
je 0x3818
jmp 0x3b64
jmp 0x381a
movq $0x0, -0x78(%rbp)
movq -0x78(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0x3a62
movq -0x18(%rbp), %rax
movq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x80(%rbp)
cmpq $0x0, -0x80(%rbp)
jbe 0x3849
jmp 0x3868
leaq 0x1c34(%rip), %rdi      # 0x5484
leaq 0x1c38(%rip), %rsi      # 0x548f
movl $0x50, %edx
leaq 0x1c3f(%rip), %rcx      # 0x54a2
callq 0x10d0
movq -0x10(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %edx
divq -0x80(%rbp)
movq %rax, -0x88(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x389e
movq -0x38(%rbp), %rax
movq 0x20(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x80(%rbp), %rdx
callq *%rax
cmpl $0x0, %eax
je 0x389e
jmp 0x3b64
cmpl $0x0, -0x2c(%rbp)
je 0x38f0
leaq -0x50(%rbp), %rdi
callq 0x4210
cmpl $0x0, %eax
je 0x38ee
jmp 0x38b4
callq 0x1070
cmpl $0x0, (%rax)
je 0x38d9
leaq 0x1c8f(%rip), %rdi      # 0x5554
movb $0x0, %al
callq 0x3c50
callq 0x1070
movl $0x0, (%rax)
jmp 0x38e7
leaq 0x1c74(%rip), %rdi      # 0x5554
movb $0x0, %al
callq 0x3ea0
jmp 0x38e9
jmp 0x3b51
jmp 0x393c
leaq -0x50(%rbp), %rdi
callq 0x40e0
cmpl $0x0, %eax
je 0x393a
jmp 0x3900
callq 0x1070
cmpl $0x0, (%rax)
je 0x3925
leaq 0x1c5b(%rip), %rdi      # 0x556c
movb $0x0, %al
callq 0x3c50
callq 0x1070
movl $0x0, (%rax)
jmp 0x3933
leaq 0x1c40(%rip), %rdi      # 0x556c
movb $0x0, %al
callq 0x3ea0
jmp 0x3935
jmp 0x3b51
jmp 0x393c
movq 0x10(%rbp), %rax
movq 0x20(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x80(%rbp), %rdx
movq -0x88(%rbp), %rcx
callq *%rax
cmpl $0x0, %eax
je 0x395f
jmp 0x3b51
cmpl $0x0, -0x2c(%rbp)
je 0x39b1
leaq -0x60(%rbp), %rdi
callq 0x4210
cmpl $0x0, %eax
je 0x39af
jmp 0x3975
callq 0x1070
cmpl $0x0, (%rax)
je 0x399a
leaq 0x1bce(%rip), %rdi      # 0x5554
movb $0x0, %al
callq 0x3c50
callq 0x1070
movl $0x0, (%rax)
jmp 0x39a8
leaq 0x1bb3(%rip), %rdi      # 0x5554
movb $0x0, %al
callq 0x3ea0
jmp 0x39aa
jmp 0x3b51
jmp 0x39fd
leaq -0x60(%rbp), %rdi
callq 0x40e0
cmpl $0x0, %eax
je 0x39fb
jmp 0x39c1
callq 0x1070
cmpl $0x0, (%rax)
je 0x39e6
leaq 0x1b9a(%rip), %rdi      # 0x556c
movb $0x0, %al
callq 0x3c50
callq 0x1070
movl $0x0, (%rax)
jmp 0x39f4
leaq 0x1b7f(%rip), %rdi      # 0x556c
movb $0x0, %al
callq 0x3ea0
jmp 0x39f6
jmp 0x3b51
jmp 0x39fd
movq -0x60(%rbp), %rax
subq -0x50(%rbp), %rax
cvtsi2sd %rax, %xmm1
movq -0x58(%rbp), %rax
subq -0x48(%rbp), %rax
cvtsi2sd %rax, %xmm0
movsd 0x1a39(%rip), %xmm2     # 0x5458
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x68(%rbp), %rax
movq -0x78(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
cmpq $0x0, 0x18(%rbp)
je 0x3a4f
movq 0x18(%rbp), %rax
movq 0x20(%rbp), %rdi
callq *%rax
cmpl $0x0, %eax
je 0x3a4f
jmp 0x3b64
jmp 0x3a51
movq -0x78(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x78(%rbp)
jmp 0x3822
movq $0x0, -0x78(%rbp)
movq -0x78(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0x3b36
movq -0x18(%rbp), %rax
movq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rax
movq -0x80(%rbp), %rcx
xorl %edx, %edx
divq %rcx
movq %rax, -0x88(%rbp)
movq -0x80(%rbp), %rax
movq -0x88(%rbp), %rcx
imulq %rcx, %rax
movq %rax, -0x98(%rbp)
movaps 0x19a7(%rip), %xmm1     # 0x5460
movq -0x98(%rbp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x19a3(%rip), %xmm1     # 0x5470
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x196c(%rip), %xmm1     # 0x5450
divsd %xmm1, %xmm0
movq -0x68(%rbp), %rax
movq -0x78(%rbp), %rcx
divsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x70(%rbp)
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %rdx
movq -0x68(%rbp), %rax
movq -0x78(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd -0x70(%rbp), %xmm1
leaq 0x1a5e(%rip), %rdi      # 0x557c
movb $0x2, %al
callq 0x10c0
movq -0x78(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x78(%rbp)
jmp 0x3a6a
movq -0x68(%rbp), %rdi
callq 0x1030
movq -0x40(%rbp), %rdi
callq 0x1030
movl $0x0, -0x4(%rbp)
jmp 0x3b7d
cmpq $0x0, 0x18(%rbp)
je 0x3b62
movq 0x18(%rbp), %rax
movq 0x20(%rbp), %rdi
callq *%rax
jmp 0x3b64
movq -0x68(%rbp), %rdi
callq 0x1030
movq -0x40(%rbp), %rdi
callq 0x1030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax)