// File: /workspace/github_c_makefile_star2_O1/ebiggers[P]xpack/programs/benchmark.c
// Function: main
int
tmain(int argc, tchar *argv[])
{
	u32 chunk_size = 524288;
	int compression_level = 6;
	void *original_buf = NULL;
	void *compressed_buf = NULL;
	void *decompressed_buf = NULL;
	struct xpack_compressor *compressor = NULL;
	struct xpack_decompressor *decompressor = NULL;
	tchar *default_file_list[] = { NULL };
	int opt_char;
	int i;
	int ret;

	program_invocation_name = get_filename(argv[0]);

	while ((opt_char = tgetopt(argc, argv, optstring)) != -1) {
		switch (opt_char) {
		case '1':
		case '2':
		case '3':
		case '4':
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			compression_level = opt_char - '0';
			break;
		case 'h':
			show_usage(stdout);
			return 0;
		case 'L':
			compression_level = parse_compression_level(toptarg);
			if (compression_level <= 0)
				return 1;
			break;
		case 's':
			chunk_size = parse_chunk_size(toptarg);
			if (chunk_size == 0)
				return 1;
			break;
		case 'V':
			show_version();
			return 0;
		default:
			show_usage(stderr);
			return 1;
		}
	}

	argc -= toptind;
	argv += toptind;

	original_buf = xmalloc(chunk_size);
	compressed_buf = xmalloc(chunk_size - 1);
	decompressed_buf = xmalloc(chunk_size);
	compressor = alloc_compressor(chunk_size, compression_level);
	decompressor = alloc_decompressor();

	ret = -1;
	if (original_buf == NULL || compressed_buf == NULL ||
	    decompressed_buf == NULL ||
	    compressor == NULL || decompressor == NULL)
		goto out;

	if (argc == 0) {
		argv = default_file_list;
		argc = ARRAY_LEN(default_file_list);
	} else {
		for (i = 0; i < argc; i++)
			if (argv[i][0] == '-' && argv[i][1] == '\0')
				argv[i] = NULL;
	}

	printf("Benchmarking XPACK compression:\n");
	printf("\tChunk size: %"PRIu32"\n", chunk_size);
	printf("\tCompression level: %d\n", compression_level);

	for (i = 0; i < argc; i++) {
		struct file_stream in;

		ret = xopen_for_read(argv[i], &in);
		if (ret != 0)
			goto out;

		printf("Processing %"TS"...\n", in.name);

		ret = do_benchmark(&in, original_buf, compressed_buf,
				   decompressed_buf, chunk_size, compressor,
				   decompressor);
		xclose(&in);
		if (ret != 0)
			goto out;
	}
	ret = 0;
out:
	xpack_free_decompressor(decompressor);
	xpack_free_compressor(compressor);
	free(decompressed_buf);
	free(compressed_buf);
	free(original_buf);
	return -ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %r15
movl %edi, %ebp
movq $0x0, 0x90(%rsp)
movq (%rsi), %rdi
callq 0x44ef
leaq 0x6243(%rip), %r14      # 0xa100
movq %rax, (%r14)
movl $0x6, %r13d
movl $0x80000, %eax          # imm = 0x80000
movq %rax, 0x8(%rsp)
leaq 0x312d(%rip), %rbx      # 0x7004
leaq 0x6242(%rip), %r12      # 0xa120
movl %ebp, %edi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x49cc
leal -0x31(%rax), %ecx
cmpl $0x9, %ecx
jae 0x3efb
addl $-0x30, %eax
movl %eax, %r13d
jmp 0x3ede
cmpl $0x55, %eax
jg 0x3f1a
cmpl $0x4c, %eax
jne 0x3f4c
movq (%r12), %rdi
callq 0x492c
movl %eax, %r13d
testl %eax, %eax
jg 0x3ede
jmp 0x43e2
cmpl $0x56, %eax
je 0x4052
cmpl $0x68, %eax
je 0x4065
cmpl $0x73, %eax
jne 0x43dd
movq (%r12), %rdi
callq 0x48e1
movq %rax, 0x8(%rsp)
testl %eax, %eax
jne 0x3ede
jmp 0x43e2
cmpl $-0x1, %eax
jne 0x43dd
leaq 0x6194(%rip), %rax      # 0xa0f0
movslq (%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x8(%rsp), %r12
movl %r12d, %ebx
movq %rbx, %rdi
callq 0x4486
movq %rax, %r14
leal -0x1(%r12), %edi
callq 0x4486
movq %rax, 0x50(%rsp)
movq %rbx, 0x68(%rsp)
movq %rbx, %rdi
callq 0x4486
movq %rax, %rbx
movl %r12d, %edi
movl %r13d, %esi
callq 0x4973
movq %rax, %r12
callq 0x49a6
movq %rbx, %rdx
movq %r14, 0x18(%rsp)
movq %r14, %xmm0
movq 0x50(%rsp), %r14
movq %r14, %xmm1
punpcklqdq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0]
movq %r12, 0x48(%rsp)
movq %r12, %xmm1
movq %rbx, %xmm2
punpcklqdq %xmm1, %xmm2    # xmm2 = xmm2[0],xmm1[0]
pxor %xmm1, %xmm1
movq %rax, 0x40(%rsp)
testq %rax, %rax
sete %al
pcmpeqd %xmm1, %xmm0
pcmpeqd %xmm1, %xmm2
movdqa %xmm0, %xmm1
shufps $0xdd, %xmm2, %xmm1     # xmm1 = xmm1[1,3],xmm2[1,3]
shufps $0x88, %xmm2, %xmm0     # xmm0 = xmm0[0,2],xmm2[0,2]
andps %xmm1, %xmm0
movmskps %xmm0, %ecx
testl %ecx, %ecx
setne %cl
orb %al, %cl
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jne 0x43a8
movq 0x10(%rsp), %rax
subl %eax, %ebp
testl %ebp, %ebp
movq %rdx, 0x20(%rsp)
je 0x4087
leaq (%r15,%rax,8), %rsi
movq %rsi, 0x30(%rsp)
jle 0x4099
movl %ebp, %eax
xorl %ecx, %ecx
movq (%rsi,%rcx,8), %rdx
cmpb $0x2d, (%rdx)
jne 0x4048
cmpb $0x0, 0x1(%rdx)
jne 0x4048
movq $0x0, (%rsi,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x4031
jmp 0x4099
leaq 0x324d(%rip), %rdi      # 0x72a6
callq 0x1060
xorl %ebx, %ebx
jmp 0x43e7
movq 0x5f6c(%rip), %rax      # 0x9fd8
movq (%rax), %rdi
movq (%r14), %rdx
leaq 0x2fd6(%rip), %rsi      # 0x704f
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x1130
jmp 0x43e7
leaq 0x90(%rsp), %rax
movq %rax, 0x30(%rsp)
movl $0x1, %ebp
leaq 0x31e6(%rip), %rdi      # 0x7286
callq 0x1060
leaq 0x2f68(%rip), %rdi      # 0x7014
xorl %ebx, %ebx
movq 0x8(%rsp), %rsi
xorl %eax, %eax
callq 0x10b0
leaq 0x2f64(%rip), %rdi      # 0x7025
movl %r13d, %esi
xorl %eax, %eax
callq 0x10b0
testl %ebp, %ebp
movq 0x20(%rsp), %rdx
jle 0x43a8
movl %ebp, %r15d
xorl %ebp, %ebp
movq 0x18(%rsp), %r13
movq %r15, 0x58(%rsp)
movq 0x30(%rsp), %rax
movq (%rax,%rbp,8), %rdi
leaq 0x78(%rsp), %rsi
callq 0x450d
testl %eax, %eax
je 0x410a
movl %eax, %ebx
movl $0x5, %eax
jmp 0x4374
movq %rbp, 0x60(%rsp)
movq 0x80(%rsp), %rsi
leaq 0x2f1f(%rip), %rdi      # 0x703d
xorl %eax, %eax
callq 0x10b0
xorl %r12d, %r12d
xorl %ebp, %ebp
movq $0x0, 0x38(%rsp)
xorl %r15d, %r15d
leaq 0x78(%rsp), %rdi
movq %r13, %rsi
movq 0x68(%rsp), %rdx
callq 0x46c5
movq %rax, %rbx
testq %rax, %rax
jle 0x426f
movq %r15, 0x8(%rsp)
movl %ebx, %r15d
callq 0x44c5
movq %rax, 0x10(%rsp)
leal -0x1(%rbx), %r8d
movq 0x48(%rsp), %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x2a48
movq %rax, %rbx
callq 0x44c5
movq %rax, %rdx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
andq %rax, %rbx
je 0x41f3
movq %rdx, 0x28(%rsp)
callq 0x44c5
movq %rax, 0x70(%rsp)
movq 0x40(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq 0x20(%rsp), %rcx
movq %r15, %r8
xorl %r9d, %r9d
callq 0x2a6b
movl %eax, %r13d
callq 0x44c5
movq %rax, %r14
subq 0x70(%rsp), %r14
addq %r12, %r14
testl %r13d, %r13d
je 0x4207
movq 0x80(%rsp), %rsi
xorl %ebx, %ebx
leaq 0x2fe3(%rip), %rdi      # 0x71c8
xorl %eax, %eax
callq 0x43fc
movq 0x18(%rsp), %r13
jmp 0x4238
movq %r15, %rbx
movq %r12, %r14
addq %rbx, 0x38(%rsp)
movb $0x1, %bl
movq 0x10(%rsp), %rcx
jmp 0x4242
movq 0x18(%rsp), %r13
movq %r13, %rdi
movq 0x20(%rsp), %rsi
movq %r15, %rdx
callq 0x1160
testl %eax, %eax
je 0x4268
movq 0x80(%rsp), %rsi
xorl %ebx, %ebx
leaq 0x2fb5(%rip), %rdi      # 0x71e6
xorl %eax, %eax
callq 0x43fc
movq 0x10(%rsp), %rcx
movq 0x28(%rsp), %rdx
movq 0x8(%rsp), %rax
addq %r15, %rax
movq %rax, %r15
subq %rcx, %rbp
addq %rdx, %rbp
movq %r14, %r12
testb %bl, %bl
movq 0x50(%rsp), %r14
jne 0x4136
jmp 0x4351
movq 0x28(%rsp), %rdx
jmp 0x41f9
js 0x4356
testq %r15, %r15
je 0x438b
cmpq $0x1, %rbp
adcq $0x0, %rbp
cmpq $0x1, %r12
adcq $0x0, %r12
movq %r12, 0x8(%rsp)
movq 0x38(%rsp), %r9
imulq $0x64, %r9, %rax
xorl %ebx, %ebx
xorl %edx, %edx
divq %r15
movq %rax, %rcx
imulq $0x186a0, %r9, %rax     # imm = 0x186A0
xorl %edx, %edx
divq %r15
movq %rax, %r8
shrq $0x3, %rax
movabsq $0x20c49ba5e353f7cf, %rdx # imm = 0x20C49BA5E353F7CF
mulq %rdx
shrq $0x4, %rdx
imull $0x3e8, %edx, %eax      # imm = 0x3E8
subl %eax, %r8d
leaq 0x2f34(%rip), %rdi      # 0x720e
movq %r15, %rsi
movq %r9, %rdx
xorl %eax, %eax
callq 0x10b0
movq %rbp, %rax
movabsq $0x431bde82d7b634db, %rcx # imm = 0x431BDE82D7B634DB
movq %r15, %rdi
movq %rcx, %r15
mulq %rcx
movq %rdx, %rsi
shrq $0x12, %rsi
imulq $0x3e8, %rdi, %r12      # imm = 0x3E8
movq %r12, %rax
xorl %edx, %edx
divq %rbp
leaq 0x2f1e(%rip), %rdi      # 0x7238
movq %rax, %rdx
xorl %eax, %eax
callq 0x10b0
movq 0x8(%rsp), %rcx
movq %rcx, %rax
mulq %r15
movq %rdx, %rsi
shrq $0x12, %rsi
movq %r12, %rax
xorl %edx, %edx
divq %rcx
leaq 0x2f19(%rip), %rdi      # 0x725e
movq %rax, %rdx
xorl %eax, %eax
callq 0x10b0
jmp 0x4356
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
leaq 0x78(%rsp), %rdi
callq 0x4889
xorl %eax, %eax
testl %ebx, %ebx
setne %al
leal (%rax,%rax,4), %eax
movq 0x58(%rsp), %r15
movq 0x60(%rsp), %rbp
testl %eax, %eax
movq 0x20(%rsp), %rdx
jne 0x439b
incq %rbp
cmpq %r15, %rbp
jne 0x40e7
jmp 0x43a6
leaq 0x3032(%rip), %rdi      # 0x73c4
callq 0x1060
xorl %ebx, %ebx
jmp 0x4356
cmpl $0x5, %eax
jne 0x405e
jmp 0x43a8
xorl %ebx, %ebx
movq 0x40(%rsp), %rdi
movq %rdx, %r15
callq 0x6092
movq 0x48(%rsp), %rdi
callq 0x4c68
movq %r15, %rdi
callq 0x1030
movq %r14, %rdi
callq 0x1030
movq 0x18(%rsp), %rdi
callq 0x1030
negl %ebx
jmp 0x43e7
callq 0x11d0
movl $0x1, %ebx
movl %ebx, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop