// File: /workspace/github_c_makefile_star2_O0/lmcilroy[P]lzm/lzmencode.c
// Function: lzm_encode_fast
static unsigned int
lzm_encode_fast(
    const struct lzm_state * const state,
    const unsigned char * const buffer_in,
    const unsigned int size_in,
    unsigned char * const buffer_out,
    unsigned int * const size_out)
{
	const unsigned char * const end = buffer_in + size_in;
	const unsigned char * const match_end = end - 7;
	const unsigned char * const scan_end = match_end - 7;
	const unsigned char * const out_limit = buffer_out + *size_out;
	const unsigned char *lit_start = buffer_in;
	const unsigned char *curr_in = buffer_in;
	const unsigned char *next_curr;
	const unsigned char *last;
	unsigned char *curr_out = buffer_out;
	struct ht_entry *last_htp;
	unsigned long int token;
	unsigned long int next_token;
	unsigned int last_token;
	unsigned int len;
	unsigned int off;
	unsigned int misses = (1 << MISS_ORDER) + 1;
	unsigned int hashval;
	unsigned int next_hashval;

	lzm_reset(state, buffer_in);

	token = readmem64(curr_in);
	hashval = hash_fast(token);
	next_token = readmem64(curr_in + 1);
	next_hashval = hash_fast(next_token);
	last_htp = &state->last_ht[hashval];
	last_htp->index = curr_in - buffer_in;
	last_htp->token = token;
	curr_in++;

	while (likely(curr_in < scan_end)) {
		token = next_token;
		hashval = next_hashval;
		next_curr = curr_in + (misses >> MISS_ORDER);
		next_token = readmem64(next_curr);
		next_hashval = hash_fast(next_token);
		last_htp = &state->last_ht[hashval];
		last = last_htp->index + buffer_in;
		last_token = last_htp->token;
		last_htp->index = curr_in - buffer_in;
		last_htp->token = token;

		if ((unsigned int)token != last_token ||
		    (curr_in - last) & ~MAX_OFFSET_MASK) {
			misses++;
			curr_in = next_curr;
			continue;
		}
		misses = (1 << MISS_ORDER) + 1;

		len = MIN_MATCH;
		len += matchlen(curr_in + len, last + len, match_end);
		off = matchlen_rev(curr_in, last, lit_start, buffer_in);
		curr_in -= off;
		last -= off;
		len += off;

		curr_out = output_match(curr_out, lit_start,
		    curr_in - lit_start, curr_in - last, len, out_limit);
		if (unlikely(curr_out == NULL))
			return EOVERFLOW;

		curr_in += len;
		lit_start = curr_in;

		token = readmem64(curr_in - 2);
		hashval = hash_fast(token);
		next_token = readmem64(curr_in);
		next_hashval = hash_fast(next_token);
		last_htp = &state->last_ht[hashval];
		last_htp->index = curr_in - 2 - buffer_in;
		last_htp->token = token;
	}

	curr_out = output_literals(curr_out, lit_start, end - lit_start,
	    out_limit);
	if (curr_out == NULL)
		return EOVERFLOW;

	*size_out = curr_out - buffer_out;
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
addq $-0x7, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
addq $-0x7, %rax
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rax
movq -0x30(%rbp), %rcx
movl (%rcx), %ecx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x78(%rbp)
movl $0x41, -0xa0(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x5270
movq -0x60(%rbp), %rdi
callq 0x52d0
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdi
callq 0x52f0
movl %eax, -0xa4(%rbp)
movq -0x60(%rbp), %rdi
addq $0x1, %rdi
callq 0x52d0
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rdi
callq 0x52f0
movl %eax, -0xa8(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0xa4(%rbp), %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x60(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
movl %eax, %ecx
movq -0x80(%rbp), %rax
movl %ecx, (%rax)
movq -0x88(%rbp), %rax
movl %eax, %ecx
movq -0x80(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
cmpq -0x48(%rbp), %rax
setb %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x4450
movq -0x90(%rbp), %rax
movq %rax, -0x88(%rbp)
movl -0xa8(%rbp), %eax
movl %eax, -0xa4(%rbp)
movq -0x60(%rbp), %rax
movl -0xa0(%rbp), %ecx
shrl $0x6, %ecx
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
callq 0x52d0
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rdi
callq 0x52f0
movl %eax, -0xa8(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0xa4(%rbp), %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movl (%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x80(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x94(%rbp)
movq -0x60(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
movl %eax, %ecx
movq -0x80(%rbp), %rax
movl %ecx, (%rax)
movq -0x88(%rbp), %rax
movl %eax, %ecx
movq -0x80(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x88(%rbp), %rax
cmpl -0x94(%rbp), %eax
jne 0x4292
movq -0x60(%rbp), %rax
movq -0x70(%rbp), %rcx
subq %rcx, %rax
andq $-0x10000000, %rax      # imm = 0xF0000000
cmpq $0x0, %rax
je 0x42ae
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0x41a3
movl $0x41, -0xa0(%rbp)
movl $0x4, -0x98(%rbp)
movq -0x60(%rbp), %rdi
movl -0x98(%rbp), %eax
addq %rax, %rdi
movq -0x70(%rbp), %rsi
movl -0x98(%rbp), %eax
addq %rax, %rsi
movq -0x40(%rbp), %rdx
callq 0x5310
addl -0x98(%rbp), %eax
movl %eax, -0x98(%rbp)
movq -0x60(%rbp), %rdi
movq -0x70(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq -0x18(%rbp), %rcx
callq 0x5580
movl %eax, -0x9c(%rbp)
movl -0x9c(%rbp), %ecx
movq -0x60(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movl -0x9c(%rbp), %ecx
movq -0x70(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movl -0x9c(%rbp), %eax
addl -0x98(%rbp), %eax
movl %eax, -0x98(%rbp)
movq -0x78(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x60(%rbp), %rax
movq -0x58(%rbp), %rcx
subq %rcx, %rax
movl %eax, %edx
movq -0x60(%rbp), %rax
movq -0x70(%rbp), %rcx
subq %rcx, %rax
movl %eax, %ecx
movl -0x98(%rbp), %r8d
movq -0x50(%rbp), %r9
callq 0x58b0
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x43a9
movl $0x4b, -0x4(%rbp)
jmp 0x449c
movl -0x98(%rbp), %ecx
movq -0x60(%rbp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x60(%rbp), %rdi
addq $-0x2, %rdi
callq 0x52d0
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdi
callq 0x52f0
movl %eax, -0xa4(%rbp)
movq -0x60(%rbp), %rdi
callq 0x52d0
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rdi
callq 0x52f0
movl %eax, -0xa8(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0xa4(%rbp), %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x60(%rbp), %rax
addq $-0x2, %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
movl %eax, %ecx
movq -0x80(%rbp), %rax
movl %ecx, (%rax)
movq -0x88(%rbp), %rax
movl %eax, %ecx
movq -0x80(%rbp), %rax
movl %ecx, 0x4(%rax)
jmp 0x41a3
movq -0x78(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x38(%rbp), %rax
movq -0x58(%rbp), %rcx
subq %rcx, %rax
movl %eax, %edx
movq -0x50(%rbp), %rcx
callq 0x4e80
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
jne 0x4482
movl $0x4b, -0x4(%rbp)
jmp 0x449c
movq -0x78(%rbp), %rax
movq -0x28(%rbp), %rcx
subq %rcx, %rax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax,%rax)