// File: /workspace/github_c_makefile_star2_O0/lmcilroy[P]lzm/lzm.c
// Function: benchmark
static unsigned int
benchmark(const int fd_in, struct compress_args * const args)
{
	struct chunk *chunks;
	cpu_set_t cpuset;
	off_t bytes_left;
	unsigned int chunk_size;
	unsigned int c;
	unsigned int nchunks;
	unsigned int ret;
	int cpu;

	nchunks = howmany(args->st->st_size, args->chunk_size);
	chunks = calloc(nchunks, sizeof(*chunks));
	if (chunks == NULL) {
		ret = errno;
		fprintf(stderr, "File %s: failed to allocate %ld bytes: %s\n",
		    args->filename, nchunks * sizeof(*chunks), strerror(ret));
		goto out;
	}

	cpu = sched_getcpu();
	if (cpu == -1) {
		ret = errno;
		fprintf(stderr, "Failed to get cpu: %s\n", strerror(ret));
		goto out;
	}

	CPU_ZERO(&cpuset);
	CPU_SET(cpu, &cpuset);
	ret = sched_setaffinity(0, sizeof(cpuset), &cpuset);
	if (ret != 0) {
		ret = errno;
		fprintf(stderr, "Failed to set cpu affinity: %s\n",
		    strerror(ret));
		goto out;
	}

	setpriority(PRIO_PROCESS, 0, -20);

	bytes_left = args->st->st_size;
	for (c = 0; c < nchunks; c++) {
		chunk_size = MIN(bytes_left, args->chunk_size);
		bytes_left -= chunk_size;
		ret = benchmark_init_chunk(fd_in, &chunks[c], chunk_size, args);
		if (ret != 0)
			goto out;
	}

	printf("File %s: size %lu bytes\n", args->filename, args->st->st_size);

	if (args->level != LZM_LEVEL_DEF)
		benchmark_level(args, chunks, nchunks);
	else {
		for (args->level = LZM_LEVEL_NONE;
		    args->level < LZM_LEVEL_COUNT;
		    args->level++) {
			benchmark_level(args, chunks, nchunks);
		}
	}

 out:
	if (chunks != NULL) {
		for (c = 0; c < nchunks; c++) {
			if (chunks[c].data_orig != NULL)
				free(chunks[c].data_orig);
			if (chunks[c].data_comp != NULL)
				free(chunks[c].data_comp);
			if (chunks[c].data_decomp != NULL)
				free(chunks[c].data_decomp);
		}
		free(chunks);
	}

	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %rax
movq -0x10(%rbp), %rcx
movl 0x101c(%rcx), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
addq %rcx, %rax
movq -0x10(%rbp), %rcx
movl 0x101c(%rcx), %ecx
cqto
idivq %rcx
movl %eax, -0xac(%rbp)
movl -0xac(%rbp), %eax
movl %eax, %edi
movl $0x28, %esi
callq 0x1160
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x3045
callq 0x1040
movl (%rax), %eax
movl %eax, -0xb0(%rbp)
movq 0x7013(%rip), %rax      # 0x9ff8
movq (%rax), %rax
movq %rax, -0xe0(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xd8(%rbp)
movl -0xac(%rbp), %eax
imulq $0x28, %rax, %rax
movq %rax, -0xd0(%rbp)
movl -0xb0(%rbp), %edi
callq 0x1250
movq -0xe0(%rbp), %rdi
movq -0xd8(%rbp), %rdx
movq -0xd0(%rbp), %rcx
movq %rax, %r8
leaq 0x45ff(%rip), %rsi      # 0x7638
movb $0x0, %al
callq 0x1190
jmp 0x32fd
callq 0x1210
movl %eax, -0xb4(%rbp)
cmpl $-0x1, -0xb4(%rbp)
jne 0x309f
callq 0x1040
movl (%rax), %eax
movl %eax, -0xb0(%rbp)
movq 0x6f8b(%rip), %rax      # 0x9ff8
movq (%rax), %rax
movq %rax, -0xe8(%rbp)
movl -0xb0(%rbp), %edi
callq 0x1250
movq -0xe8(%rbp), %rdi
movq %rax, %rdx
leaq 0x45d0(%rip), %rsi      # 0x7663
movb $0x0, %al
callq 0x1190
jmp 0x32fd
jmp 0x30a1
leaq -0x98(%rbp), %rdi
xorl %esi, %esi
movl $0x80, %edx
callq 0x1110
movslq -0xb4(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
shrq $0x3, %rax
cmpq $0x80, %rax
jae 0x310c
movq -0xc0(%rbp), %rcx
andq $0x3f, %rcx
movl $0x1, %eax
shlq %cl, %rax
movq -0xc0(%rbp), %rcx
shrq $0x6, %rcx
orq -0x98(%rbp,%rcx,8), %rax
movq %rax, -0x98(%rbp,%rcx,8)
movq %rax, -0xf0(%rbp)
jmp 0x3117
xorl %eax, %eax
movq %rax, -0xf0(%rbp)
jmp 0x3117
movq -0xf0(%rbp), %rax
movq %rax, -0xc8(%rbp)
xorl %edi, %edi
movl $0x80, %esi
leaq -0x98(%rbp), %rdx
callq 0x1130
movl %eax, -0xb0(%rbp)
cmpl $0x0, -0xb0(%rbp)
je 0x318d
callq 0x1040
movl (%rax), %eax
movl %eax, -0xb0(%rbp)
movq 0x6e9d(%rip), %rax      # 0x9ff8
movq (%rax), %rax
movq %rax, -0xf8(%rbp)
movl -0xb0(%rbp), %edi
callq 0x1250
movq -0xf8(%rbp), %rdi
movq %rax, %rdx
leaq 0x44f9(%rip), %rsi      # 0x767a
movb $0x0, %al
callq 0x1190
jmp 0x32fd
xorl %esi, %esi
movl $0xffffffec, %edx       # imm = 0xFFFFFFEC
movl %esi, %edi
callq 0x1100
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %rax
movq %rax, -0xa0(%rbp)
movl $0x0, -0xa8(%rbp)
movl -0xa8(%rbp), %eax
cmpl -0xac(%rbp), %eax
jae 0x3273
movq -0xa0(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0x101c(%rcx), %ecx
cmpq %rcx, %rax
jge 0x31ef
movq -0xa0(%rbp), %rax
movq %rax, -0x100(%rbp)
jmp 0x3200
movq -0x10(%rbp), %rax
movl 0x101c(%rax), %eax
movq %rax, -0x100(%rbp)
movq -0x100(%rbp), %rax
movl %eax, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
movl %eax, %ecx
movq -0xa0(%rbp), %rax
subq %rcx, %rax
movq %rax, -0xa0(%rbp)
movl -0x4(%rbp), %edi
movq -0x18(%rbp), %rsi
movl -0xa8(%rbp), %eax
imulq $0x28, %rax, %rax
addq %rax, %rsi
movl -0xa4(%rbp), %edx
movq -0x10(%rbp), %rcx
callq 0x3540
movl %eax, -0xb0(%rbp)
cmpl $0x0, -0xb0(%rbp)
je 0x325d
jmp 0x32fd
jmp 0x325f
movl -0xa8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa8(%rbp)
jmp 0x31b7
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %rdx
leaq 0x440d(%rip), %rdi      # 0x769a
movb $0x0, %al
callq 0x10e0
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x1018(%rax)
je 0x32b6
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0xac(%rbp), %edx
callq 0x3790
jmp 0x32fb
movq -0x10(%rbp), %rax
movl $0x0, 0x1018(%rax)
movq -0x10(%rbp), %rax
cmpl $0x8, 0x1018(%rax)
jae 0x32f9
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0xac(%rbp), %edx
callq 0x3790
movq -0x10(%rbp), %rax
movl 0x1018(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x1018(%rax)
jmp 0x32c4
jmp 0x32fb
jmp 0x32fd
cmpq $0x0, -0x18(%rbp)
je 0x33d7
movl $0x0, -0xa8(%rbp)
movl -0xa8(%rbp), %eax
cmpl -0xac(%rbp), %eax
jae 0x33ce
movq -0x18(%rbp), %rax
movl -0xa8(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
je 0x3354
movq -0x18(%rbp), %rax
movl -0xa8(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdi
callq 0x1030
movq -0x18(%rbp), %rax
movl -0xa8(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x8(%rax)
je 0x3386
movq -0x18(%rbp), %rax
movl -0xa8(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
callq 0x1030
movq -0x18(%rbp), %rax
movl -0xa8(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x10(%rax)
je 0x33b8
movq -0x18(%rbp), %rax
movl -0xa8(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdi
callq 0x1030
jmp 0x33ba
movl -0xa8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa8(%rbp)
jmp 0x3312
movq -0x18(%rbp), %rdi
callq 0x1030
movl -0xb0(%rbp), %eax
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopw %cs:(%rax,%rax)