// File: /workspace/github_c_makefile_star2_O0/lmcilroy[P]lzm/lzmencode.c
// Function: lzm_encode_high
static unsigned int
lzm_encode_high(
    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 - 3;
	const unsigned char * const out_limit = buffer_out + *size_out;
	const unsigned char *curr_in = buffer_in;
	const unsigned char *next_curr;
	const unsigned char *curr_o;
	const unsigned char *last;
	const unsigned char *last_o;
	const unsigned char *match_last;
	const unsigned char *match_curr;
	const unsigned char *next_last;
	unsigned char *curr_out = buffer_out;
	struct ht_entry *last_htp;
	unsigned int token;
	unsigned int next_token;
	unsigned int last_token;
	unsigned int len;
	unsigned int off;
	unsigned int val;
	unsigned int match_len;
	unsigned int match_val;
	unsigned int curr_chain;
	unsigned int index;
	unsigned int misses = (1 << MISS_ORDER) + 1;
	unsigned int hashval;
	unsigned int next_hashval;

	struct prev_match prev;

	lzm_reset(state, buffer_in);

	prev.lit_start = buffer_in;
	prev.start = 0;
	prev.last = 0;
	prev.length = 0;

	token = readmem32(curr_in);
	hashval = hash_high(token, state->hash_order);
	next_token = readmem32(curr_in + 1);
	next_hashval = hash_high(next_token, state->hash_order);
	last_htp = &state->last_ht[hashval];
	index = curr_in - buffer_in;
	state->chains[index & state->chain_mask] = *last_htp;
	last_htp->index = index;
	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 = readmem32(next_curr);
		next_hashval = hash_high(next_token, state->hash_order);
		last_htp = &state->last_ht[hashval];
		last = last_htp->index + buffer_in;
		last_token = last_htp->token;
		index = curr_in - buffer_in;
		state->chains[index & state->chain_mask] = *last_htp;
		last_htp->index = index;
		last_htp->token = token;

		match_val = 0;
		match_len = 0;
		match_last = NULL;
		curr_chain = 1;

		for (;;) {
			if ((curr_in - last) & ~MAX_OFFSET_MASK)
				break;

			if ((token == last_token) && (match_len == 0 ||
			    curr_in[match_len] == last[match_len])) {

				len = MIN_MATCH;
				len += matchlen(curr_in + len, last + len,
				    match_end);
				off = matchlen_rev(curr_in, last,
				    prev.lit_start, buffer_in);
				curr_o = curr_in - off;
				last_o = last - off;
				len += off;
				val = len - lzm_offset_cost(curr_o - last_o);

				if (val > match_val) {
					match_val = val;
					match_len = len;
					match_last = last_o;
					match_curr = curr_o;
					if ((curr_o + len) >= scan_end)
						break;
				}
			}

			if (curr_chain++ == MAX_CHAIN_LENGTH)
				break;

			index = last - buffer_in;
			last_htp = &state->chains[index & state->chain_mask];
			next_last = last_htp->index + buffer_in;
			last_token = last_htp->token;

			if (next_last >= last)
				break;

			last = next_last;
		}

		if (match_len == 0) {
			misses++;
			curr_in = next_curr;
			continue;
		}
		misses = (1 << MISS_ORDER) + 1;

		curr_out = output_match_merge(&prev, curr_out, match_curr,
		    match_last, match_len, out_limit);
		if (unlikely(curr_out == NULL))
			return EOVERFLOW;

		match_curr += match_len;
		if (match_curr >= scan_end)
			break;

		curr_in = next_curr;
		while (curr_in < match_curr) {
			token = next_token;
			hashval = next_hashval;
			next_curr = curr_in + (misses >> MISS_ORDER);
			next_token = readmem32(next_curr);
			next_hashval = hash_high(next_token,
			    state->hash_order);
			last_htp = &state->last_ht[hashval];
			index = curr_in - buffer_in;
			state->chains[index & state->chain_mask] = *last_htp;
			last_htp->index = index;
			last_htp->token = token;
			curr_in = next_curr;
		}
	}

	curr_out = output_match_final(&prev, curr_out, end, out_limit);
	if (curr_out == NULL)
		return EOVERFLOW;

	*size_out = curr_out - buffer_out;
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
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 $-0x3, %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 -0x28(%rbp), %rax
movq %rax, -0x98(%rbp)
movl $0x41, -0xcc(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x5270
movq -0x18(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq $0x0, -0xf0(%rbp)
movq $0x0, -0xe8(%rbp)
movl $0x0, -0xe0(%rbp)
movq -0x58(%rbp), %rdi
callq 0x5920
movl %eax, -0xa4(%rbp)
movl -0xa4(%rbp), %edi
movq -0x10(%rbp), %rax
movl 0x10(%rax), %esi
callq 0x5ba0
movl %eax, -0xd0(%rbp)
movq -0x58(%rbp), %rdi
addq $0x1, %rdi
callq 0x5920
movl %eax, -0xa8(%rbp)
movl -0xa8(%rbp), %edi
movq -0x10(%rbp), %rax
movl 0x10(%rax), %esi
callq 0x5ba0
movl %eax, -0xd4(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0xd0(%rbp), %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0xa0(%rbp)
movq -0x58(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0xc8(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl -0xc8(%rbp), %ecx
movq -0x10(%rbp), %rdx
andl 0x1c(%rdx), %ecx
movl %ecx, %ecx
movq -0xa0(%rbp), %rdx
movq (%rdx), %rdx
movq %rdx, (%rax,%rcx,8)
movl -0xc8(%rbp), %ecx
movq -0xa0(%rbp), %rax
movl %ecx, (%rax)
movl -0xa4(%rbp), %ecx
movq -0xa0(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x48(%rbp), %rax
setb %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x4b02
movl -0xa8(%rbp), %eax
movl %eax, -0xa4(%rbp)
movl -0xd4(%rbp), %eax
movl %eax, -0xd0(%rbp)
movq -0x58(%rbp), %rax
movl -0xcc(%rbp), %ecx
shrl $0x6, %ecx
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
callq 0x5920
movl %eax, -0xa8(%rbp)
movl -0xa8(%rbp), %edi
movq -0x10(%rbp), %rax
movl 0x10(%rax), %esi
callq 0x5ba0
movl %eax, -0xd4(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0xd0(%rbp), %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movl (%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0xa0(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0xac(%rbp)
movq -0x58(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0xc8(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl -0xc8(%rbp), %ecx
movq -0x10(%rbp), %rdx
andl 0x1c(%rdx), %ecx
movl %ecx, %ecx
movq -0xa0(%rbp), %rdx
movq (%rdx), %rdx
movq %rdx, (%rax,%rcx,8)
movl -0xc8(%rbp), %ecx
movq -0xa0(%rbp), %rax
movl %ecx, (%rax)
movl -0xa4(%rbp), %ecx
movq -0xa0(%rbp), %rax
movl %ecx, 0x4(%rax)
movl $0x0, -0xc0(%rbp)
movl $0x0, -0xbc(%rbp)
movq $0x0, -0x80(%rbp)
movl $0x1, -0xc4(%rbp)
movq -0x58(%rbp), %rax
movq -0x70(%rbp), %rcx
subq %rcx, %rax
andq $-0x10000000, %rax      # imm = 0xF0000000
cmpq $0x0, %rax
je 0x4771
jmp 0x4964
movl -0xa4(%rbp), %eax
cmpl -0xac(%rbp), %eax
jne 0x48cc
cmpl $0x0, -0xbc(%rbp)
je 0x47b0
movq -0x58(%rbp), %rax
movl -0xbc(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movq -0x70(%rbp), %rcx
movl -0xbc(%rbp), %edx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jne 0x48cc
movl $0x4, -0xb0(%rbp)
movq -0x58(%rbp), %rdi
movl -0xb0(%rbp), %eax
addq %rax, %rdi
movq -0x70(%rbp), %rsi
movl -0xb0(%rbp), %eax
addq %rax, %rsi
movq -0x40(%rbp), %rdx
callq 0x5310
addl -0xb0(%rbp), %eax
movl %eax, -0xb0(%rbp)
movq -0x58(%rbp), %rdi
movq -0x70(%rbp), %rsi
movq -0xf8(%rbp), %rdx
movq -0x18(%rbp), %rcx
callq 0x5580
movl %eax, -0xb4(%rbp)
movq -0x58(%rbp), %rax
movl -0xb4(%rbp), %ecx
movl %ecx, %edx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x70(%rbp), %rax
movl -0xb4(%rbp), %ecx
movl %ecx, %edx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movl -0xb4(%rbp), %eax
addl -0xb0(%rbp), %eax
movl %eax, -0xb0(%rbp)
movl -0xb0(%rbp), %eax
movl %eax, -0xfc(%rbp)
movq -0x68(%rbp), %rax
movq -0x78(%rbp), %rcx
subq %rcx, %rax
movl %eax, %edi
callq 0x5bc0
movl %eax, %ecx
movl -0xfc(%rbp), %eax
subl %ecx, %eax
movl %eax, -0xb8(%rbp)
movl -0xb8(%rbp), %eax
cmpl -0xc0(%rbp), %eax
jbe 0x48ca
movl -0xb8(%rbp), %eax
movl %eax, -0xc0(%rbp)
movl -0xb0(%rbp), %eax
movl %eax, -0xbc(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x68(%rbp), %rax
movl -0xb0(%rbp), %ecx
addq %rcx, %rax
cmpq -0x48(%rbp), %rax
jb 0x48c8
jmp 0x4964
jmp 0x48ca
jmp 0x48cc
movl -0xc4(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0xc4(%rbp)
cmpl $0x80, %eax
jne 0x48e6
jmp 0x4964
movq -0x70(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0xc8(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl -0xc8(%rbp), %ecx
movq -0x10(%rbp), %rdx
andl 0x1c(%rdx), %ecx
movl %ecx, %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movl (%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x90(%rbp)
movq -0xa0(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0xac(%rbp)
movq -0x90(%rbp), %rax
cmpq -0x70(%rbp), %rax
jb 0x4954
jmp 0x4964
movq -0x90(%rbp), %rax
movq %rax, -0x70(%rbp)
jmp 0x4755
cmpl $0x0, -0xbc(%rbp)
jne 0x4989
movl -0xcc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xcc(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x58(%rbp)
jmp 0x4628
movl $0x41, -0xcc(%rbp)
movq -0x98(%rbp), %rsi
movq -0x88(%rbp), %rdx
movq -0x80(%rbp), %rcx
movl -0xbc(%rbp), %r8d
movq -0x50(%rbp), %r9
leaq -0xf8(%rbp), %rdi
callq 0x5c00
movq %rax, -0x98(%rbp)
cmpq $0x0, -0x98(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x49e7
movl $0x4b, -0x4(%rbp)
jmp 0x4b54
movl -0xbc(%rbp), %ecx
movq -0x88(%rbp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
cmpq -0x48(%rbp), %rax
jb 0x4a12
jmp 0x4b02
movq -0x60(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x88(%rbp), %rax
jae 0x4afd
movl -0xa8(%rbp), %eax
movl %eax, -0xa4(%rbp)
movl -0xd4(%rbp), %eax
movl %eax, -0xd0(%rbp)
movq -0x58(%rbp), %rax
movl -0xcc(%rbp), %ecx
shrl $0x6, %ecx
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
callq 0x5920
movl %eax, -0xa8(%rbp)
movl -0xa8(%rbp), %edi
movq -0x10(%rbp), %rax
movl 0x10(%rax), %esi
callq 0x5ba0
movl %eax, -0xd4(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0xd0(%rbp), %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0xa0(%rbp)
movq -0x58(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0xc8(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl -0xc8(%rbp), %ecx
movq -0x10(%rbp), %rdx
andl 0x1c(%rdx), %ecx
movl %ecx, %ecx
movq -0xa0(%rbp), %rdx
movq (%rdx), %rdx
movq %rdx, (%rax,%rcx,8)
movl -0xc8(%rbp), %ecx
movq -0xa0(%rbp), %rax
movl %ecx, (%rax)
movl -0xa4(%rbp), %ecx
movq -0xa0(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x60(%rbp), %rax
movq %rax, -0x58(%rbp)
jmp 0x4a1a
jmp 0x4628
movq -0x98(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x50(%rbp), %rcx
leaq -0xf8(%rbp), %rdi
callq 0x5ce0
movq %rax, -0x98(%rbp)
cmpq $0x0, -0x98(%rbp)
jne 0x4b37
movl $0x4b, -0x4(%rbp)
jmp 0x4b54
movq -0x98(%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 $0x100, %rsp            # imm = 0x100
popq %rbp
retq