// File: /workspace/github_c_makefile_star2_O0/lmcilroy[P]lzm/lzm.c
// Function: benchmark_level
static unsigned int
benchmark_level(struct compress_args * const args, struct chunk *chunks,
    unsigned int nchunks)
{
	struct lzm_state *state = NULL;
	double rate;
	double comp_rate;
	double decomp_rate;
	double comp_perc;
	unsigned long ts_start;
	unsigned long iterations;
	unsigned long time;
	unsigned int t;
	unsigned int c;
	unsigned int ret;
	off_t comp_size;
	off_t decomp_size;
	off_t offset = 0;
	const unsigned char *d1;
	const unsigned char *d2;

	comp_rate = 0;
	ret = lzm_encode_init(&state, args->format, args->level);
	if (ret != 0) {
		fprintf(stderr, "File %s: failed to init lzm: %s\n",
		    args->filename, strerror(ret));
		goto out;
	}

	for (t = 0; t < args->bench_tests; t++) {

		iterations = 0;
		synctime();
		ts_start = gettime();

		do {
			for (c = 0; c < nchunks; c++) {
				chunks[c].size_comp_out = chunks[c].size_comp;
				ret = lzm_encode(state, chunks[c].data_orig,
				    chunks[c].size_orig, chunks[c].data_comp,
				    &chunks[c].size_comp_out);
				if (unlikely(ret != 0)) {
					fprintf(stderr,
					"File %s: failed to encode data: %s\n",
					    args->filename, strerror(ret));
					goto out;
				}
			}

			time = gettime() - ts_start;
			iterations++;

		} while (time < BENCH_TIME);

		rate = (double)(args->st->st_size * iterations * 1000) /
		    (double)time;
		if (rate > comp_rate)
			comp_rate = rate;

		if (args->verbose == true) {
			printf("%10.4f ", rate);
			fflush(stdout);
		}
	}

	if (args->verbose == true)
		printf("\n");

	lzm_encode_finish(state);

	comp_size = 0;
	for (c = 0; c < nchunks; c++)
		comp_size += chunks[c].size_comp_out;

	comp_perc = (double)(comp_size * 100) / (double)args->st->st_size;

	decomp_rate = 0;
	ret = lzm_decode_init(&state, args->format);
	if (ret != 0) {
		fprintf(stderr, "File %s: failed to init lzm: %s\n",
		    args->filename, strerror(ret));
		goto out;
	}

	for (t = 0; t < args->bench_tests; t++) {

		iterations = 0;
		synctime();
		ts_start = gettime();

		do {
			for (c = 0; c < nchunks; c++) {
				chunks[c].size_decomp_out = chunks[c].size_orig;
				ret = lzm_decode(state, chunks[c].data_comp,
				    chunks[c].size_comp_out,
				    chunks[c].data_decomp,
				    &chunks[c].size_decomp_out);
				if (unlikely(ret != 0)) {
					fprintf(stderr,
					"File %s: failed to decode data: %s\n",
					    args->filename, strerror(ret));
					goto out;
				}
			}

			time = gettime() - ts_start;
			iterations++;

		} while (time < BENCH_TIME);

		rate = (double)(args->st->st_size * iterations * 1000) /
		    (double)time;
		if (rate > decomp_rate)
			decomp_rate = rate;

		if (args->verbose == true) {
			printf("%10.4f ", rate);
			fflush(stdout);
		}
	}

	if (args->verbose == true)
		printf("\n");

	lzm_decode_finish(state);

	decomp_size = 0;
	for (c = 0; c < nchunks; c++) {
		decomp_size += chunks[c].size_decomp_out;
		if (chunks[c].size_decomp_out != chunks[c].size_orig) {
			fprintf(stderr,
			"File %s: incorrect chunk size, expect %u, got %u\n",
			    args->filename, chunks[c].size_orig,
			    chunks[c].size_decomp_out);
		}
		d1 = chunks[c].data_orig;
		d2 = chunks[c].data_decomp;
		for (t = 0; t < chunks[c].size_orig; t++) {
			if (*d1 != *d2) {
				fprintf(stderr,
				    "File %s: corruption, offset %lu,"
				    " expect 0x%x, found 0x%x\n",
				    args->filename, offset, *d1, *d2);
				goto out;
			}
			d1++;
			d2++;
			offset++;
		}
	}

	if (decomp_size != args->st->st_size) {
		fprintf(stderr,
		"File %s: incorrect decompressed size, expect %lu, got %lu\n",
		    args->filename, args->st->st_size, decomp_size);
	}

	printf("Level %d: --> %lu, %9.4f%%, %10.4f MB/s, %10.4f MB/s\n",
	    args->level, comp_size, comp_perc, comp_rate, decomp_rate);

 out:
	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x80(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x8(%rbp), %rax
movl 0x1014(%rax), %esi
movq -0x8(%rbp), %rax
movl 0x1018(%rax), %edx
leaq -0x20(%rbp), %rdi
callq 0x4b60
movl %eax, -0x64(%rbp)
cmpl $0x0, -0x64(%rbp)
je 0x3830
movq 0x680d(%rip), %rax      # 0x9ff8
movq (%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x98(%rbp)
movl -0x64(%rbp), %edi
callq 0x1250
movq -0xa0(%rbp), %rdi
movq -0x98(%rbp), %rdx
movq %rax, %rcx
leaq 0x3bba(%rip), %rsi      # 0x73de
movb $0x0, %al
callq 0x1190
jmp 0x3f4d
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x103c(%rcx), %eax
jae 0x3a36
movq $0x0, -0x50(%rbp)
callq 0x3f60
callq 0x3f90
movq %rax, -0x48(%rbp)
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x14(%rbp), %eax
jae 0x3957
movq -0x10(%rbp), %rax
movl -0x60(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x1c(%rax), %ecx
movq -0x10(%rbp), %rax
movl -0x60(%rbp), %edx
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x20(%rax)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movl -0x60(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movq -0x10(%rbp), %rax
movl -0x60(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x18(%rax), %edx
movq -0x10(%rbp), %rax
movl -0x60(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rcx
movq -0x10(%rbp), %r8
movl -0x60(%rbp), %eax
imulq $0x28, %rax, %rax
addq %rax, %r8
addq $0x20, %r8
callq 0x4db0
movl %eax, -0x64(%rbp)
cmpl $0x0, -0x64(%rbp)
setne %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x3947
movq 0x66f6(%rip), %rax      # 0x9ff8
movq (%rax), %rax
movq %rax, -0xb0(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xa8(%rbp)
movl -0x64(%rbp), %edi
callq 0x1250
movq -0xb0(%rbp), %rdi
movq -0xa8(%rbp), %rdx
movq %rax, %rcx
leaq 0x3b09(%rip), %rsi      # 0x7444
movb $0x0, %al
callq 0x1190
jmp 0x3f4d
jmp 0x3949
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x3867
callq 0x3f90
subq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
movl $0xb2d05e00, %eax       # imm = 0xB2D05E00
cmpq %rax, -0x58(%rbp)
jb 0x3860
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %rax
movq -0x50(%rbp), %rcx
imulq %rcx, %rax
imulq $0x3e8, %rax, %rax      # imm = 0x3E8
movq %rax, %xmm0
movaps 0x378b(%rip), %xmm3     # 0x7130
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x378f(%rip), %xmm2     # 0x7140
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0x58(%rbp), %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x28(%rbp), %xmm0
ucomisd -0x30(%rbp), %xmm0
jbe 0x39f7
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x1, 0x1034(%rax)
jne 0x3a26
movsd -0x28(%rbp), %xmm0
leaq 0x3cc2(%rip), %rdi      # 0x76d2
movb $0x1, %al
callq 0x10e0
movq 0x65aa(%rip), %rax      # 0x9fc8
movq (%rax), %rdi
callq 0x11c0
jmp 0x3a28
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x3837
movq -0x8(%rbp), %rax
cmpl $0x1, 0x1034(%rax)
jne 0x3a51
leaq 0x3a44(%rip), %rdi      # 0x748e
movb $0x0, %al
callq 0x10e0
movq -0x20(%rbp), %rdi
callq 0x4d50
movq $0x0, -0x70(%rbp)
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x14(%rbp), %eax
jae 0x3a95
movq -0x10(%rbp), %rax
movl -0x60(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x20(%rax), %eax
addq -0x70(%rbp), %rax
movq %rax, -0x70(%rbp)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x3a69
imulq $0x64, -0x70(%rbp), %rax
cvtsi2sd %rax, %xmm0
movq -0x8(%rbp), %rax
movq (%rax), %rax
cvtsi2sdq 0x30(%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x8(%rbp), %rax
movl 0x1014(%rax), %esi
leaq -0x20(%rbp), %rdi
callq 0x5df0
movl %eax, -0x64(%rbp)
cmpl $0x0, -0x64(%rbp)
je 0x3b25
movq 0x6518(%rip), %rax      # 0x9ff8
movq (%rax), %rax
movq %rax, -0xc0(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xb8(%rbp)
movl -0x64(%rbp), %edi
callq 0x1250
movq -0xc0(%rbp), %rdi
movq -0xb8(%rbp), %rdx
movq %rax, %rcx
leaq 0x38c5(%rip), %rsi      # 0x73de
movb $0x0, %al
callq 0x1190
jmp 0x3f4d
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x103c(%rcx), %eax
jae 0x3d2c
movq $0x0, -0x50(%rbp)
callq 0x3f60
callq 0x3f90
movq %rax, -0x48(%rbp)
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x14(%rbp), %eax
jae 0x3c4d
movq -0x10(%rbp), %rax
movl -0x60(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x18(%rax), %ecx
movq -0x10(%rbp), %rax
movl -0x60(%rbp), %edx
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x24(%rax)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movl -0x60(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
movq -0x10(%rbp), %rax
movl -0x60(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x20(%rax), %edx
movq -0x10(%rbp), %rax
movl -0x60(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rcx
movq -0x10(%rbp), %r8
movl -0x60(%rbp), %eax
imulq $0x28, %rax, %rax
addq %rax, %r8
addq $0x24, %r8
callq 0x5e20
movl %eax, -0x64(%rbp)
cmpl $0x0, -0x64(%rbp)
setne %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x3c3d
movq 0x6400(%rip), %rax      # 0x9ff8
movq (%rax), %rax
movq %rax, -0xd0(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xc8(%rbp)
movl -0x64(%rbp), %edi
callq 0x1250
movq -0xd0(%rbp), %rdi
movq -0xc8(%rbp), %rdx
movq %rax, %rcx
leaq 0x38fc(%rip), %rsi      # 0x752d
movb $0x0, %al
callq 0x1190
jmp 0x3f4d
jmp 0x3c3f
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x3b5c
callq 0x3f90
subq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
movl $0xb2d05e00, %eax       # imm = 0xB2D05E00
cmpq %rax, -0x58(%rbp)
jb 0x3b55
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %rax
movq -0x50(%rbp), %rcx
imulq %rcx, %rax
imulq $0x3e8, %rax, %rax      # imm = 0x3E8
movq %rax, %xmm0
movaps 0x3495(%rip), %xmm3     # 0x7130
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x3499(%rip), %xmm2     # 0x7140
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0x58(%rbp), %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x28(%rbp), %xmm0
ucomisd -0x38(%rbp), %xmm0
jbe 0x3ced
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x1, 0x1034(%rax)
jne 0x3d1c
movsd -0x28(%rbp), %xmm0
leaq 0x39cc(%rip), %rdi      # 0x76d2
movb $0x1, %al
callq 0x10e0
movq 0x62b4(%rip), %rax      # 0x9fc8
movq (%rax), %rdi
callq 0x11c0
jmp 0x3d1e
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x3b2c
movq -0x8(%rbp), %rax
cmpl $0x1, 0x1034(%rax)
jne 0x3d47
leaq 0x374e(%rip), %rdi      # 0x748e
movb $0x0, %al
callq 0x10e0
movq -0x20(%rbp), %rdi
callq 0x5e10
movq $0x0, -0x78(%rbp)
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x14(%rbp), %eax
jae 0x3ee2
movq -0x10(%rbp), %rax
movl -0x60(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x24(%rax), %eax
addq -0x78(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rax
movl -0x60(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x24(%rax), %eax
movq -0x10(%rbp), %rcx
movl -0x60(%rbp), %edx
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x18(%rcx), %eax
je 0x3deb
movq 0x6249(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x10(%rbp), %rax
movl -0x60(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x18(%rax), %ecx
movq -0x10(%rbp), %rax
movl -0x60(%rbp), %esi
imulq $0x28, %rsi, %rsi
addq %rsi, %rax
movl 0x24(%rax), %r8d
leaq 0x38f6(%rip), %rsi      # 0x76da
movb $0x0, %al
callq 0x1190
movq -0x10(%rbp), %rax
movl -0x60(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rax
movl -0x60(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movq %rax, -0x90(%rbp)
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movq -0x10(%rbp), %rcx
movl -0x60(%rbp), %edx
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x18(%rcx), %eax
jae 0x3ed2
movq -0x88(%rbp), %rax
movzbl (%rax), %eax
movq -0x90(%rbp), %rcx
movzbl (%rcx), %ecx
cmpl %ecx, %eax
je 0x3e94
movq 0x619c(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x80(%rbp), %rcx
movq -0x88(%rbp), %rax
movzbl (%rax), %r8d
movq -0x90(%rbp), %rax
movzbl (%rax), %r9d
leaq 0x3884(%rip), %rsi      # 0x770c
movb $0x0, %al
callq 0x1190
jmp 0x3f4d
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
movq -0x90(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x90(%rbp)
movq -0x80(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x80(%rbp)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x3e23
jmp 0x3ed4
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x3d5f
movq -0x78(%rbp), %rax
movq -0x8(%rbp), %rcx
movq (%rcx), %rcx
cmpq 0x30(%rcx), %rax
je 0x3f22
movq 0x60fe(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %rcx
movq -0x78(%rbp), %r8
leaq 0x382b(%rip), %rsi      # 0x7746
movb $0x0, %al
callq 0x1190
movq -0x8(%rbp), %rax
movl 0x1018(%rax), %esi
movq -0x70(%rbp), %rdx
movsd -0x40(%rbp), %xmm0
movsd -0x30(%rbp), %xmm1
movsd -0x38(%rbp), %xmm2
leaq 0x383b(%rip), %rdi      # 0x7781
movb $0x3, %al
callq 0x10e0
movl -0x64(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
nopl (%rax)