// File: /workspace/github_c_makefile_star2_O3/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, %r13d
movq $0x0, 0x90(%rsp)
movq (%rsi), %rdi
callq 0x45bb
leaq 0x6192(%rip), %rcx      # 0xa100
movq %rax, (%rcx)
movl $0x6, %r12d
movl $0x80000, %ebp          # imm = 0x80000
leaq 0x3081(%rip), %rbx      # 0x7004
leaq 0x6196(%rip), %r14      # 0xa120
movl %r13d, %edi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x4a68
leal -0x31(%rax), %ecx
cmpl $0x9, %ecx
jae 0x3fa8
addl $-0x30, %eax
movl %eax, %r12d
jmp 0x3f8a
cmpl $0x55, %eax
jg 0x3fc6
cmpl $0x4c, %eax
jne 0x3ff4
movq (%r14), %rdi
callq 0x49ca
movl %eax, %r12d
testl %eax, %eax
jg 0x3f8a
jmp 0x44a7
cmpl $0x56, %eax
je 0x40f0
cmpl $0x68, %eax
je 0x4104
cmpl $0x73, %eax
jne 0x44a2
movq (%r14), %rdi
callq 0x497f
movl %eax, %ebp
testl %eax, %eax
jne 0x3f8a
jmp 0x44a7
cmpl $-0x1, %eax
jne 0x44a2
leaq 0x60ec(%rip), %rax      # 0xa0f0
movslq (%rax), %rax
movq %rax, 0x28(%rsp)
movl %ebp, %r14d
movq %r14, %rdi
callq 0x4552
movq %rax, 0x8(%rsp)
leal -0x1(%rbp), %edi
callq 0x4552
movq %rax, %rbx
movq %r14, 0x48(%rsp)
movq %r14, %rdi
callq 0x4552
movq %rax, %r14
movq %rbp, (%rsp)
movl %ebp, %edi
movl %r12d, %esi
callq 0x4a11
movq %rax, %rbp
callq 0x4a44
movq 0x8(%rsp), %xmm0
movq %rbx, 0x18(%rsp)
movq %rbx, %xmm1
movq %r14, %rbx
punpcklqdq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0]
movq %rbp, 0x50(%rsp)
movq %rbp, %xmm1
movq %r14, %xmm2
punpcklqdq %xmm1, %xmm2    # xmm2 = xmm2[0],xmm1[0]
pxor %xmm1, %xmm1
movq %rax, 0x38(%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, %r14d      # imm = 0xFFFFFFFF
jne 0x446d
movq 0x28(%rsp), %rax
subl %eax, %r13d
testl %r13d, %r13d
je 0x412e
leaq (%r15,%rax,8), %r15
movq (%rsp), %rbp
jle 0x4140
movl %r13d, %eax
xorl %ecx, %ecx
movq (%r15,%rcx,8), %rdx
cmpb $0x2d, (%rdx)
jne 0x40e6
cmpb $0x0, 0x1(%rdx)
jne 0x40e6
movq $0x0, (%r15,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x40cf
jmp 0x4140
leaq 0x31af(%rip), %rdi      # 0x72a6
callq 0x1060
xorl %r14d, %r14d
jmp 0x44ad
movq 0x5ecd(%rip), %rax      # 0x9fd8
movq (%rax), %rdi
leaq 0x5feb(%rip), %rax      # 0xa100
movq (%rax), %rdx
leaq 0x2f30(%rip), %rsi      # 0x704f
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x1130
jmp 0x44ad
leaq 0x90(%rsp), %r15
movl $0x1, %r13d
movq (%rsp), %rbp
leaq 0x313f(%rip), %rdi      # 0x7286
callq 0x1060
leaq 0x2ec1(%rip), %rdi      # 0x7014
xorl %r14d, %r14d
movl %ebp, %esi
xorl %eax, %eax
callq 0x10b0
leaq 0x2ebf(%rip), %rdi      # 0x7025
movl %r12d, %esi
xorl %eax, %eax
callq 0x10b0
testl %r13d, %r13d
jle 0x446d
movl %r13d, %eax
movq %rax, 0x78(%rsp)
leaq 0x58(%rsp), %r13
leaq 0x2eb0(%rip), %rbp      # 0x703d
xorl %eax, %eax
movq %rbx, 0x10(%rsp)
movq %r15, 0x70(%rsp)
movq %rax, 0x80(%rsp)
movq (%r15,%rax,8), %rdi
movq %r13, %rsi
callq 0x45d9
testl %eax, %eax
jne 0x44c2
movq 0x60(%rsp), %rsi
movq %rbp, %rdi
xorl %eax, %eax
callq 0x10b0
movq %r13, %rdi
movq 0x8(%rsp), %rsi
movq %rsi, %r12
movq 0x48(%rsp), %rdx
callq 0x478e
movq %rax, %r14
testq %rax, %rax
jle 0x43f1
movq $0x0, 0x20(%rsp)
movq $0x0, 0x40(%rsp)
xorl %r13d, %r13d
movq $0x0, (%rsp)
movq 0x18(%rsp), %rbp
leaq 0x58(%rsp), %r15
movq %r12, %rbx
movl %r14d, %r12d
callq 0x4591
movq %rax, 0x28(%rsp)
decl %r14d
movq 0x50(%rsp), %rdi
movq %rbx, %rsi
movq %r12, %rdx
movq %rbp, %rcx
movq %r14, %r8
callq 0x2a64
movq %rax, %rbx
callq 0x4591
movq %rax, %rcx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
andq %rax, %rbx
je 0x42c9
movq %rcx, 0x88(%rsp)
callq 0x4591
movq %rax, %r14
movq 0x38(%rsp), %rdi
movq %rbp, %rsi
movq %rbx, %rdx
movq 0x10(%rsp), %r15
movq %r15, %rcx
movq %r12, %r8
xorl %r9d, %r9d
callq 0x2a87
movl %eax, 0x34(%rsp)
callq 0x4591
cmpl $0x0, 0x34(%rsp)
jne 0x443a
movq %rax, %rbp
movq %r12, %rdx
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x1160
testl %eax, %eax
jne 0x4443
movq (%rsp), %rax
subq %r14, %rax
addq %rbp, %rax
movq %rax, (%rsp)
movq 0x18(%rsp), %rbp
leaq 0x58(%rsp), %r15
movq 0x88(%rsp), %rcx
jmp 0x42cc
movq %r12, %rbx
addq %rbx, 0x40(%rsp)
addq %r12, 0x20(%rsp)
subq 0x28(%rsp), %r13
addq %rcx, %r13
movq %r15, %rdi
movq 0x8(%rsp), %rbx
movq %rbx, %rsi
movq 0x48(%rsp), %rdx
callq 0x478e
movq %rax, %r14
testq %rax, %rax
jg 0x420f
movq 0x10(%rsp), %rbx
movq 0x70(%rsp), %r15
leaq 0x2d2d(%rip), %rbp      # 0x703d
js 0x440b
cmpq $0x0, 0x20(%rsp)
je 0x43f3
cmpq $0x1, %r13
adcq $0x0, %r13
movq (%rsp), %r14
cmpq $0x1, %r14
adcq $0x0, %r14
movq 0x40(%rsp), %r9
imulq $0x64, %r9, %rax
xorl %edx, %edx
movq 0x20(%rsp), %rbx
divq %rbx
movq %rax, %rcx
imulq $0x186a0, %r9, %rax     # imm = 0x186A0
xorl %edx, %edx
divq %rbx
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 0x2e8e(%rip), %rdi      # 0x720e
movq %rbx, %rsi
movq %r9, %rdx
xorl %eax, %eax
callq 0x10b0
movq %r13, %rax
movabsq $0x431bde82d7b634db, %r12 # imm = 0x431BDE82D7B634DB
mulq %r12
movq %rdx, %rsi
shrq $0x12, %rsi
imulq $0x3e8, %rbx, %rbx      # imm = 0x3E8
movq %rbx, %rax
xorl %edx, %edx
divq %r13
leaq 0x2e7e(%rip), %rdi      # 0x7238
movq %rax, %rdx
xorl %eax, %eax
callq 0x10b0
movq %r14, %rax
mulq %r12
movq %rdx, %rsi
shrq $0x12, %rsi
movq %rbx, %rax
movq 0x10(%rsp), %rbx
xorl %edx, %edx
divq %r14
leaq 0x2e79(%rip), %rdi      # 0x725e
movq %rax, %rdx
xorl %eax, %eax
callq 0x10b0
jmp 0x43ff
js 0x440b
leaq 0x2fca(%rip), %rdi      # 0x73c4
callq 0x1060
leaq 0x58(%rsp), %rdi
callq 0x4927
jmp 0x441a
leaq 0x58(%rsp), %rdi
callq 0x4927
testl %r14d, %r14d
jne 0x446d
movq 0x80(%rsp), %rax
incq %rax
xorl %r14d, %r14d
cmpq 0x78(%rsp), %rax
leaq 0x58(%rsp), %r13
jne 0x4199
jmp 0x446d
leaq 0x2d87(%rip), %rdi      # 0x71c8
jmp 0x444a
leaq 0x2d9c(%rip), %rdi      # 0x71e6
leaq 0x58(%rsp), %rbx
movq 0x8(%rbx), %rsi
xorl %eax, %eax
callq 0x44c8
movq %rbx, %rdi
callq 0x4927
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movq 0x10(%rsp), %rbx
movq 0x38(%rsp), %rdi
callq 0x6202
movq 0x50(%rsp), %rdi
callq 0x4dc7
movq %rbx, %rdi
callq 0x1030
movq 0x18(%rsp), %rdi
callq 0x1030
movq 0x8(%rsp), %rdi
callq 0x1030
negl %r14d
jmp 0x44ad
callq 0x11d0
movl $0x1, %r14d
movl %r14d, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %r14d
jmp 0x446d
nop