// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rcx, %r11
movl %edx, %eax
movq %rax, 0x78(%rsp)
movq %r8, 0x60(%rsp)
movl (%r8), %eax
movq %rax, 0x48(%rsp)
movq %rsi, 0x30(%rsp)
movl (%rsi), %esi
cmpl $0x0, 0x14(%rdi)
movq (%rdi), %r14
je 0x2076
xorl %eax, %eax
andl $0x0, (%r14,%rax,8)
movl %esi, 0x4(%r14,%rax,8)
incq %rax
movl 0x14(%rdi), %ecx
cmpq %rcx, %rax
jb 0x2058
movq 0x30(%rsp), %rbx
movl (%rbx), %esi
jmp 0x207b
movq 0x30(%rsp), %rbx
movq %rbx, 0xa0(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0xa8(%rsp)
andl $0x0, 0xb8(%rsp)
movl 0x10(%rdi), %r8d
imull $0x9e3779b1, %esi, %r9d # imm = 0x9E3779B1
movl %r8d, %ecx
negl %ecx
shrl %cl, %r9d
addq %r11, 0x48(%rsp)
movl 0x1(%rbx), %eax
movq 0x8(%rdi), %rcx
movq %rdi, 0x28(%rsp)
movq (%r14,%r9,8), %r10
movq %r10, (%rcx)
movq 0x28(%rsp), %r10
andl $0x0, (%r14,%r9,8)
movl %esi, 0x4(%r14,%r9,8)
movq %r11, 0x70(%rsp)
movq %r11, 0x10(%rsp)
cmpl $0xc, %edx
movq %rbx, %r11
jb 0x2685
movq 0x78(%rsp), %rcx
leaq (%r11,%rcx), %rdx
addq $-0x7, %rdx
movq %rdx, 0xe8(%rsp)
leaq -0xa(%r11,%rcx), %rcx
movq %rcx, 0x50(%rsp)
pushq $0x20
popq %rcx
subl %r8d, %ecx
leaq 0x1(%r11), %rbx
imull $0x9e3779b1, %eax, %edx # imm = 0x9E3779B1
shrl %cl, %edx
movq %r11, %rcx
negq %rcx
movq %rcx, 0xc0(%rsp)
xorl %ebp, %ebp
xorl %r14d, %r14d
movq 0x70(%rsp), %rcx
movq %rcx, 0x10(%rsp)
movl %r14d, 0x3c(%rsp)
movq %rbp, 0xc8(%rsp)
movq 0xa0(%rsp), %rcx
movq %rcx, 0x90(%rsp)
pushq $0x41
popq %r13
movl %eax, %ebp
movq %rsi, 0x20(%rsp)
movl %ebp, %r14d
movl %r13d, %r12d
shrl $0x6, %r12d
xorl %ecx, %ecx
subb 0x10(%r10), %cl
movl (%rbx,%r12), %ebp
movl %edx, %edx
movq (%r10), %rsi
movq 0x8(%r10), %rdi
movl (%rsi,%rdx,8), %r15d
movl 0x4(%rsi,%rdx,8), %eax
movl %ebx, %r8d
subl %r11d, %r8d
movl 0x1c(%r10), %r9d
andl %r8d, %r9d
movq (%rsi,%rdx,8), %r10
movq %r10, (%rdi,%r9,8)
movq %rbx, %r9
movl %r8d, (%rsi,%rdx,8)
movl %r14d, 0x4(%rsi,%rdx,8)
addq %r12, %rbx
imull $0x9e3779b1, %ebp, %edx # imm = 0x9E3779B1
shrl %cl, %edx
addq %r11, %r15
movq %r9, %rcx
subq %r15, %rcx
cmpq $0xfffffff, %rcx        # imm = 0xFFFFFFF
ja 0x24f0
movl %r14d, %edi
movl %r13d, 0x6c(%rsp)
movq %r12, 0xd0(%rsp)
movl %edx, 0x40(%rsp)
movl %ebp, 0x44(%rsp)
movq %rbx, 0x88(%rsp)
leaq 0x4(%r9), %rcx
movq %rcx, 0xf0(%rsp)
movl %r9d, %ecx
subl 0x90(%rsp), %ecx
movq %rcx, 0xe0(%rsp)
negq %rcx
movq %rcx, 0xd8(%rsp)
leaq -0x8(%r9), %r8
leal -0x8(%r9), %ecx
movl %ecx, 0x68(%rsp)
movq $0x0, 0x98(%rsp)
movq %r15, %r12
pushq $0x1
popq %r13
movl $0x0, 0x1c(%rsp)
movq $0x0, 0x58(%rsp)
movq 0x28(%rsp), %r10
movq 0x20(%rsp), %rsi
movl %r14d, 0xc(%rsp)
cmpl %eax, %edi
jne 0x23db
movl 0x1c(%rsp), %eax
testl %eax, %eax
je 0x226b
movl %eax, %eax
movb (%r9,%rax), %cl
cmpb (%r15,%rax), %cl
jne 0x23db
movq %r8, %rbp
movq %rsi, 0x20(%rsp)
movq %r9, %rbx
leaq 0x4(%r15), %rsi
movq 0xf0(%rsp), %rdi
movq 0xe8(%rsp), %rdx
callq 0x4d64
movq 0x30(%rsp), %r11
movl %eax, %r14d
xorl %ecx, %ecx
cmpq %r11, %r15
je 0x2365
movq %rbx, %r9
cmpq 0x90(%rsp), %rbx
je 0x235e
movb -0x1(%r9), %al
cmpb -0x1(%r15), %al
movq 0x28(%rsp), %r10
movq 0x20(%rsp), %rsi
movl 0xc(%rsp), %edi
movq %rbp, %r8
jne 0x2379
movq %r12, %rax
subq %r11, %rax
movq 0xd8(%rsp), %rcx
addq %r15, %rcx
cmpq %rax, 0xe0(%rsp)
cmovgeq %r11, %rcx
leaq 0x7(%rcx), %r8
movq %r9, %rax
movq %r15, %rdi
cmpq %r15, %r8
jae 0x2323
movq %rbp, 0x80(%rsp)
movq (%rbp), %rax
movq -0x8(%r15), %rdx
cmpq %rdx, %rax
jne 0x2465
leaq -0x8(%r15), %rdi
movq 0x80(%rsp), %rax
xorl %edx, %edx
leaq (%rdi,%rdx), %rsi
cmpq %r8, %rsi
jbe 0x2436
movq -0x8(%rax,%rdx), %rsi
movq -0x8(%rdi,%rdx), %r9
addq $-0x8, %rdx
cmpq %r9, %rsi
je 0x2325
xorq %rsi, %r9
bsrq %r9, %rsi
xorl $0x38, %esi
shrl $0x3, %esi
movl 0x68(%rsp), %ecx
subl %eax, %ecx
addl %esi, %ecx
subl %edx, %ecx
jmp 0x236a
movq 0x28(%rsp), %r10
jmp 0x236d
movq 0x28(%rsp), %r10
movq %rbx, %r9
movq 0x20(%rsp), %rsi
movl 0xc(%rsp), %edi
movq %rbp, %r8
addl $0x4, %r14d
movl %ecx, %eax
movq %r9, %rbp
subq %rax, %rbp
movq %r15, %rbx
subq %rax, %rbx
addl %ecx, %r14d
xorl %eax, %eax
movl %ebp, %ecx
subl %ebx, %ecx
sete %al
orl %ecx, %eax
bsrl %eax, %ecx
xorl $0x1f, %ecx
movl %r14d, %eax
leaq 0x43d7(%rip), %rdx      # 0x6780
subl (%rdx,%rcx,8), %eax
cmpl 0x98(%rsp), %eax
jbe 0x23db
movl %r14d, %ecx
addq %rbp, %rcx
movq %rbx, 0x58(%rsp)
movq %rbp, %rsi
movl %r14d, 0x1c(%rsp)
movq %rax, 0x98(%rsp)
cmpq 0x50(%rsp), %rcx
jae 0x2509
cmpl $0x80, %r13d
je 0x24fc
subl %r11d, %r12d
andl 0x1c(%r10), %r12d
movq 0x8(%r10), %rax
movl (%rax,%r12,8), %ecx
addq %r11, %rcx
cmpq %r15, %rcx
jae 0x24fc
incl %r13d
movl 0x4(%rax,%r12,8), %eax
movq %r9, %rdx
subq %rcx, %rdx
movq %rcx, %r12
movq %rcx, %r15
movq 0x58(%rsp), %rbx
movq %rsi, %rbp
movl 0x1c(%rsp), %r14d
cmpq $0x10000000, %rdx       # imm = 0x10000000
jb 0x224b
jmp 0x2509
leaq 0x3(%rcx), %r8
cmpq %r8, %rsi
jbe 0x2483
movl -0x4(%rax,%rdx), %esi
movl -0x4(%rdi,%rdx), %r8d
cmpl %r8d, %esi
movq %rbx, %r9
jne 0x24d5
addq %rdx, %rax
addq $-0x4, %rax
leaq (%rdi,%rdx), %rsi
addq $-0x4, %rsi
jmp 0x2489
xorq %rax, %rdx
bsrq %rdx, %rcx
xorl $0x38, %ecx
shrl $0x3, %ecx
movl 0xc(%rsp), %edi
movq 0x80(%rsp), %r8
jmp 0x2379
addq %rdx, %rax
movq %rbx, %r9
leaq 0x1(%rcx), %rdx
cmpq %rdx, %rsi
jbe 0x24ac
leaq -0x2(%rax), %rdx
leaq -0x2(%rsi), %rdi
movzwl -0x2(%rax), %r8d
cmpw -0x2(%rsi), %r8w
cmoveq %rdx, %rax
cmoveq %rdi, %rsi
movl 0xc(%rsp), %edi
movq %rbp, %r8
cmpq %rcx, %rsi
jbe 0x24c6
leaq -0x1(%rax), %rcx
movb -0x1(%rax), %dl
cmpb -0x1(%rsi), %dl
cmoveq %rcx, %rax
movq 0x20(%rsp), %rsi
movl %r9d, %ecx
subl %eax, %ecx
jmp 0x2379
xorl %esi, %r8d
bsrl %r8d, %esi
xorl $0x18, %esi
shrl $0x3, %esi
movl %r9d, %ecx
subl %eax, %ecx
addl %esi, %ecx
subl %edx, %ecx
jmp 0x236d
movq 0x28(%rsp), %r10
movq 0x20(%rsp), %rsi
jmp 0x2526
movq 0x58(%rsp), %rbx
movq %rsi, %rbp
movl 0x1c(%rsp), %r14d
testl %r14d, %r14d
jne 0x2539
movq %rbp, %rsi
movq 0x88(%rsp), %rbx
movl 0x44(%rsp), %ebp
movl 0x40(%rsp), %edx
movl 0x6c(%rsp), %r13d
incl %r13d
cmpq 0x50(%rsp), %rbx
jb 0x2157
jmp 0x2658
movl 0x3c(%rsp), %eax
testl %eax, %eax
movl 0x44(%rsp), %r15d
movl 0x40(%rsp), %r13d
je 0x2566
movl %eax, %eax
movq 0xc8(%rsp), %rcx
addq %rcx, %rax
cmpq %rbp, %rax
jbe 0x2578
leaq 0x4(%rcx), %rax
cmpq %rbp, %rax
jbe 0x256d
movq 0x10(%rsp), %rax
jmp 0x259f
movl %ebp, %eax
subl %ecx, %eax
movl %eax, 0xb8(%rsp)
leaq 0xa0(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq %r9, %r12
callq 0x4eb1
movq %r12, %r9
movq 0x28(%rsp), %r10
movq 0x30(%rsp), %r11
movq %rbp, 0xa8(%rsp)
movq %rbx, 0xb0(%rsp)
movl %r14d, 0xb8(%rsp)
testq %rax, %rax
je 0x26dc
movl %r14d, %esi
addq %rbp, %rsi
cmpq 0x50(%rsp), %rsi
movq %rax, 0x10(%rsp)
jae 0x265f
movq 0x88(%rsp), %rbx
cmpq %rsi, %rbx
jae 0x2645
addl 0xc0(%rsp), %r9d
addl 0xd0(%rsp), %r9d
movl 0x1(%rbx), %eax
incq %rbx
imull $0x9e3779b1, %eax, %edx # imm = 0x9E3779B1
xorl %ecx, %ecx
subb 0x10(%r10), %cl
shrl %cl, %edx
movl %r13d, %ecx
movq %rsi, %r13
movq (%r10), %rsi
movq 0x8(%r10), %rdi
movl 0x1c(%r10), %r8d
andl %r9d, %r8d
movq %r9, %r12
movq (%rsi,%rcx,8), %r9
movq %r9, (%rdi,%r8,8)
movq %r12, %r9
movl %r9d, (%rsi,%rcx,8)
movl %r15d, 0x4(%rsi,%rcx,8)
movq %r13, %rsi
incl %r9d
movl %edx, %r13d
movl %eax, %r15d
cmpq %rsi, %rbx
jb 0x25f3
jmp 0x264b
movl %r15d, %eax
movl %r13d, %edx
cmpq 0x50(%rsp), %rbx
jb 0x2134
jmp 0x265f
cmpl $0x0, 0x3c(%rsp)
je 0x2685
leaq 0xa0(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq 0x48(%rsp), %rdx
callq 0x4eb1
movq 0x30(%rsp), %r11
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x26dc
addq 0x78(%rsp), %r11
movq 0xa0(%rsp), %rsi
subq %rsi, %r11
movl %r11d, %ebx
movq 0x10(%rsp), %rcx
leaq (%rcx,%rbx), %rax
addq $0x11, %rax
cmpq 0x48(%rsp), %rax
pushq $0x4b
popq %rbp
ja 0x2726
movl $0x1, 0x1(%rcx)
leaq 0x2(%rcx), %r14
xorl %ebp, %ebp
testl %r11d, %r11d
je 0x26e1
cmpl $0xe, %r11d
ja 0x26eb
shlb $0x4, %r11b
movb %r11b, (%rcx)
movups (%rsi), %xmm0
movups %xmm0, (%r14)
movq 0x60(%rsp), %rax
jmp 0x2718
pushq $0x4b
popq %rbp
jmp 0x2726
xorl %r11d, %r11d
movq 0x60(%rsp), %rax
jmp 0x271b
movb $-0x10, (%rcx)
leal -0xf(%r11), %eax
cmpl $0xfb, %eax
ja 0x273a
leaq 0x3(%rcx), %r14
movb %al, 0x2(%rcx)
movq %r14, %rdi
movq %rbx, %rdx
callq 0x11c0
movb $-0x10, %r11b
movq 0x60(%rsp), %rax
movq 0x10(%rsp), %rcx
addq %rbx, %r14
movb %r11b, (%rcx)
subl 0x70(%rsp), %r14d
movl %r14d, (%rax)
movl %ebp, %eax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x1fb, %eax            # imm = 0x1FB
ja 0x2757
movq 0x10(%rsp), %rcx
movb $-0x4, 0x2(%rcx)
addb $0x4, %al
leaq 0x4(%rcx), %r14
movb %al, 0x3(%rcx)
xorl %ebp, %ebp
jmp 0x2700
cmpl $0x100fc, %eax          # imm = 0x100FC
ja 0x2776
movq 0x10(%rsp), %rcx
movb $-0x3, 0x2(%rcx)
addl $0xffffff03, %eax       # imm = 0xFFFFFF03
movw %ax, 0x3(%rcx)
leaq 0x5(%rcx), %r14
jmp 0x2753
cmpl $0x10000fd, %eax        # imm = 0x10000FD
ja 0x2796
movq 0x10(%rsp), %rcx
movb $-0x2, 0x2(%rcx)
leal -0x10d(%r11), %eax
movl %eax, 0x3(%rcx)
leaq 0x6(%rcx), %r14
jmp 0x2753
movq 0x10(%rsp), %rcx
movb $-0x1, 0x2(%rcx)
leal -0x10e(%r11), %eax
movl %eax, 0x3(%rcx)
leaq 0x7(%rcx), %r14
jmp 0x2753