// File: /workspace/github_c_makefile_star2_O1/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 $0xd8, %rsp
movq %rcx, %r10
movl %edx, %eax
movq %rax, 0x80(%rsp)
movq %r8, 0x98(%rsp)
movl (%r8), %r9d
cmpl $0x0, 0x14(%rdi)
je 0x207e
movl (%rsi), %eax
movq (%rdi), %rcx
xorl %r8d, %r8d
andl $0x0, (%rcx,%r8,8)
movl %eax, 0x4(%rcx,%r8,8)
incq %r8
movl 0x14(%rdi), %r11d
cmpq %r11, %r8
jb 0x2068
addq %r10, %r9
movq %r9, 0x38(%rsp)
movq %rsi, 0x58(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x60(%rsp)
andl $0x0, 0x70(%rsp)
movl 0x10(%rdi), %eax
movq %rdi, 0x8(%rsp)
movl (%rsi), %r11d
imull $0x9e3779b1, %r11d, %edi # imm = 0x9E3779B1
movl %eax, %ecx
negl %ecx
shrl %cl, %edi
movl 0x1(%rsi), %ebx
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movq 0x8(%rsp), %r8
movq 0x8(%r8), %r8
movq (%rcx,%rdi,8), %r9
movq %r9, (%r8)
andl $0x0, (%rcx,%rdi,8)
movl %r11d, 0x4(%rcx,%rdi,8)
movq 0x8(%rsp), %r11
movq %r10, 0x78(%rsp)
cmpl $0xc, %edx
movq %rsi, 0x48(%rsp)
jb 0x2618
movl %ebx, %r9d
movq 0x80(%rsp), %rcx
leaq (%rsi,%rcx), %rdx
addq $-0x7, %rdx
movq %rdx, 0xc0(%rsp)
leaq -0xa(%rsi,%rcx), %rcx
movq %rcx, 0x28(%rsp)
pushq $0x20
popq %rcx
subl %eax, %ecx
imull $0x9e3779b1, %ebx, %eax # imm = 0x9E3779B1
shrl %cl, %eax
leaq 0x1(%rsi), %r14
movq %rsi, %rcx
negq %rcx
movq %rcx, 0xa0(%rsp)
movq 0x78(%rsp), %r10
movq %r10, 0x40(%rsp)
movq 0x58(%rsp), %rcx
movq %rcx, 0x88(%rsp)
movl %eax, %ecx
pushq $0x41
popq %rdx
movq %r14, %r8
movl %r9d, 0x4(%rsp)
movq %r8, 0x18(%rsp)
movl %ecx, %eax
movl %edx, 0x54(%rsp)
movl %edx, %ecx
shrl $0x6, %ecx
movq %rcx, 0xc8(%rsp)
movl (%r8,%rcx), %ebx
movb 0x10(%r11), %dl
movl %eax, %ecx
movq %r11, %r9
movq (%r11), %r11
movq 0x8(%r9), %rdi
movl (%r11,%rcx,8), %r13d
movl 0x4(%r11,%rcx,8), %eax
subl %esi, %r8d
movl 0x1c(%r9), %r9d
andl %r8d, %r9d
movq (%r11,%rcx,8), %r10
movq %r10, (%rdi,%r9,8)
movl 0x4(%rsp), %r9d
movq 0x18(%rsp), %r10
movl %r8d, (%r11,%rcx,8)
movl %r9d, 0x4(%r11,%rcx,8)
movl %ebx, 0x20(%rsp)
imull $0x9e3779b1, %ebx, %edi # imm = 0x9E3779B1
xorl %ecx, %ecx
subb %dl, %cl
xorl %r12d, %r12d
shrl %cl, %edi
movl %edi, 0x24(%rsp)
addq %rsi, %r13
movq %r10, %rcx
subq %r13, %rcx
cmpq $0xfffffff, %rcx        # imm = 0xFFFFFFF
ja 0x24cd
leaq 0x4(%r10), %rcx
movq %rcx, 0xd0(%rsp)
movl %r10d, %ecx
subl 0x88(%rsp), %ecx
movq %rcx, 0xb8(%rsp)
negq %rcx
movq %rcx, 0xb0(%rsp)
leaq -0x8(%r10), %rcx
movq %rcx, 0xa8(%rsp)
leal -0x8(%r10), %ecx
movl %ecx, 0x50(%rsp)
movq $0x0, 0x90(%rsp)
movq %r13, %r14
pushq $0x1
popq %r15
xorl %edi, %edi
movq %rbp, %r8
movq $0x0, 0x30(%rsp)
movq 0x8(%rsp), %r11
cmpl %eax, %r9d
jne 0x23c4
testl %edi, %edi
je 0x225c
movl %edi, %eax
movb (%r10,%rax), %cl
cmpb (%r13,%rax), %cl
jne 0x23c4
movq %r8, 0x10(%rsp)
movl %edi, %ebp
leaq 0x4(%r13), %rsi
movq 0xd0(%rsp), %rdi
movq 0xc0(%rsp), %rdx
callq 0x4d8c
movq 0x48(%rsp), %rsi
movl %eax, %r12d
xorl %ecx, %ecx
cmpq %rsi, %r13
je 0x234e
movq 0x18(%rsp), %r10
cmpq 0x88(%rsp), %r10
je 0x2347
movb -0x1(%r10), %al
cmpb -0x1(%r13), %al
movq 0x8(%rsp), %r11
movl 0x4(%rsp), %r9d
movl %ebp, %edi
movq 0x10(%rsp), %r8
jne 0x2364
movq %r14, %rax
subq %rsi, %rax
movq 0xb0(%rsp), %rcx
addq %r13, %rcx
cmpq %rax, 0xb8(%rsp)
cmovgeq %rsi, %rcx
leaq 0x7(%rcx), %r8
movq %r10, %rax
movq %r13, %rdi
cmpq %r13, %r8
movq 0xa8(%rsp), %rbx
jae 0x230c
movq (%rbx), %rax
movq -0x8(%r13), %rdx
cmpq %rdx, %rax
jne 0x244b
leaq -0x8(%r13), %rdi
movq %rbx, %rax
xorl %edx, %edx
leaq (%rdi,%rdx), %r9
cmpq %r8, %r9
jbe 0x241d
movq -0x8(%rax,%rdx), %r10
movq -0x8(%rdi,%rdx), %r9
addq $-0x8, %rdx
cmpq %r9, %r10
je 0x230e
xorq %r10, %r9
bsrq %r9, %rdi
xorl $0x38, %edi
shrl $0x3, %edi
movl 0x50(%rsp), %ecx
subl %eax, %ecx
addl %edi, %ecx
subl %edx, %ecx
jmp 0x2353
movq 0x8(%rsp), %r11
jmp 0x2358
movq 0x8(%rsp), %r11
movq 0x18(%rsp), %r10
movl 0x4(%rsp), %r9d
movl %ebp, %edi
movq 0x10(%rsp), %r8
addl $0x4, %r12d
movl %ecx, %eax
movq %r10, %rbp
subq %rax, %rbp
movq %r13, %rbx
subq %rax, %rbx
addl %ecx, %r12d
xorl %eax, %eax
movl %ebp, %ecx
subl %ebx, %ecx
sete %al
orl %ecx, %eax
bsrl %eax, %ecx
xorl $0x1f, %ecx
movl %r12d, %eax
leaq 0x43ec(%rip), %rdx      # 0x6780
subl (%rdx,%rcx,8), %eax
cmpl 0x90(%rsp), %eax
jbe 0x23c4
movl %r12d, %ecx
addq %rbp, %rcx
movq %rbx, 0x30(%rsp)
movq %rbp, %r8
movl %r12d, %edi
movq %rax, 0x90(%rsp)
cmpq 0x28(%rsp), %rcx
jae 0x24e1
cmpl $0x80, %r15d
je 0x24d6
subl %esi, %r14d
andl 0x1c(%r11), %r14d
movq 0x8(%r11), %rax
movl (%rax,%r14,8), %ecx
addq %rsi, %rcx
cmpq %r13, %rcx
jae 0x24d6
incl %r15d
movl 0x4(%rax,%r14,8), %eax
movq %r10, %rdx
subq %rcx, %rdx
movq %rcx, %r14
movq %rcx, %r13
movq 0x30(%rsp), %rbx
movq %r8, %rbp
movl %edi, %r12d
cmpq $0x10000000, %rdx       # imm = 0x10000000
jb 0x223e
jmp 0x24e1
leaq 0x3(%rcx), %r8
cmpq %r8, %r9
jbe 0x245d
movl -0x4(%rax,%rdx), %r9d
movl -0x4(%rdi,%rdx), %r8d
cmpl %r8d, %r9d
movq 0x18(%rsp), %r10
jne 0x24b2
addq %rdx, %rax
addq $-0x4, %rax
leaq (%rdi,%rdx), %r9
addq $-0x4, %r9
jmp 0x2465
xorq %rax, %rdx
bsrq %rdx, %rcx
xorl $0x38, %ecx
shrl $0x3, %ecx
jmp 0x235d
addq %rdx, %rax
movq 0x18(%rsp), %r10
leaq 0x1(%rcx), %rdx
cmpq %rdx, %r9
jbe 0x2488
leaq -0x2(%rax), %rdx
leaq -0x2(%r9), %rdi
movzwl -0x2(%rax), %r8d
cmpw -0x2(%r9), %r8w
cmoveq %rdx, %rax
cmoveq %rdi, %r9
movl %ebp, %edi
movq 0x10(%rsp), %r8
cmpq %rcx, %r9
jbe 0x24a3
leaq -0x1(%rax), %rcx
movb -0x1(%rax), %dl
cmpb -0x1(%r9), %dl
cmoveq %rcx, %rax
movl 0x4(%rsp), %r9d
movl %r10d, %ecx
subl %eax, %ecx
jmp 0x2364
xorl %r9d, %r8d
bsrl %r8d, %edi
xorl $0x18, %edi
shrl $0x3, %edi
movl %r10d, %ecx
subl %eax, %ecx
addl %edi, %ecx
subl %edx, %ecx
jmp 0x2358
xorl %ebx, %ebx
movq 0x8(%rsp), %r11
jmp 0x24e1
movq 0x30(%rsp), %rbx
movq %r8, %rbp
movl %edi, %r12d
movq 0xc8(%rsp), %r15
leaq (%r10,%r15), %r14
testl %r12d, %r12d
jne 0x2514
movl 0x54(%rsp), %edx
incl %edx
movq %r14, %r8
movl 0x20(%rsp), %r9d
cmpq 0x28(%rsp), %r14
movl 0x24(%rsp), %ecx
jb 0x214f
jmp 0x2613
movl 0x70(%rsp), %ecx
testq %rcx, %rcx
movl 0x24(%rsp), %r13d
je 0x2609
movq 0x60(%rsp), %rax
addq %rax, %rcx
cmpq %rbp, %rcx
movq 0x40(%rsp), %r10
jbe 0x2549
leaq 0x4(%rax), %rcx
cmpq %rbp, %rcx
ja 0x2568
movl %ebp, %ecx
subl %eax, %ecx
movl %ecx, 0x70(%rsp)
leaq 0x58(%rsp), %rdi
movq %r10, %rsi
movq 0x38(%rsp), %rdx
callq 0x4ede
movq 0x8(%rsp), %r11
movq 0x48(%rsp), %rsi
movq %rax, %r10
movq %rbp, 0x60(%rsp)
movq %rbx, 0x68(%rsp)
movl %r12d, 0x70(%rsp)
testq %r10, %r10
je 0x26ee
movl %r12d, %eax
addq %rax, %rbp
cmpq 0x28(%rsp), %rbp
jae 0x2618
cmpq %rbp, %r14
jae 0x25f4
movq 0x18(%rsp), %rbx
addl 0xa0(%rsp), %ebx
addl %r15d, %ebx
movl 0x20(%rsp), %r15d
movl 0x1(%r14), %r12d
incq %r14
imull $0x9e3779b1, %r12d, %eax # imm = 0x9E3779B1
movb 0x10(%r11), %dl
xorl %ecx, %ecx
subb %dl, %cl
shrl %cl, %eax
movl %r13d, %ecx
movq (%r11), %rdx
movq 0x8(%r11), %r9
movl 0x1c(%r11), %edi
andl %ebx, %edi
movq (%rdx,%rcx,8), %r8
movq %r8, (%r9,%rdi,8)
movl %r12d, %r9d
movl %ebx, (%rdx,%rcx,8)
movl %r15d, 0x4(%rdx,%rcx,8)
incl %ebx
movl %eax, %r13d
movl %r12d, %r15d
cmpq %rbp, %r14
jb 0x25aa
jmp 0x25fc
movl 0x20(%rsp), %r9d
movl %r13d, %eax
cmpq 0x28(%rsp), %r14
jb 0x2135
jmp 0x2618
movq 0x40(%rsp), %r10
jmp 0x2568
movq 0x40(%rsp), %r10
cmpl $0x0, 0x70(%rsp)
je 0x26f3
leaq 0x58(%rsp), %rdi
movq %r10, %rsi
movq 0x38(%rsp), %r14
movq %r14, %rdx
callq 0x4ede
movq %rax, %r10
testq %rax, %rax
je 0x266c
movq 0x48(%rsp), %rcx
addq 0x80(%rsp), %rcx
movq 0x58(%rsp), %rsi
subq %rsi, %rcx
movl %ecx, %ebx
leaq (%r10,%rbx), %rax
addq $0x11, %rax
cmpq %r14, %rax
pushq $0x4b
popq %rbp
jbe 0x2674
xorl %r14d, %r14d
jmp 0x26c3
xorl %r14d, %r14d
pushq $0x4b
popq %rbp
jmp 0x26c3
movb $0x0, (%r10)
movl $0x1, 0x1(%r10)
leaq 0x2(%r10), %r14
testl %ecx, %ecx
je 0x26c3
cmpl $0xe, %ecx
ja 0x269c
shlb $0x4, %cl
movb %cl, (%r10)
movups (%rsi), %xmm0
movups %xmm0, (%r14)
jmp 0x26c0
movb $-0x10, (%r10)
leal -0xf(%rcx), %eax
cmpl $0xfb, %eax
ja 0x26fd
movb %al, 0x2(%r10)
addq $0x3, %r10
movq %r10, %r14
movq %r10, %rdi
movq %rbx, %rdx
callq 0x11c0
addq %rbx, %r14
testq %r14, %r14
je 0x26da
subl 0x78(%rsp), %r14d
movq 0x98(%rsp), %rax
movl %r14d, (%rax)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x4b
popq %rbp
jmp 0x26da
movq 0x38(%rsp), %r14
jmp 0x2640
cmpl $0x1fb, %eax            # imm = 0x1FB
ja 0x2715
movb $-0x4, 0x2(%r10)
addb $0x4, %al
movb %al, 0x3(%r10)
addq $0x4, %r10
jmp 0x26b2
cmpl $0x100fc, %eax          # imm = 0x100FC
ja 0x2731
movb $-0x3, 0x2(%r10)
addl $0xffffff03, %eax       # imm = 0xFFFFFF03
movw %ax, 0x3(%r10)
addq $0x5, %r10
jmp 0x26b2
cmpl $0x10000fd, %eax        # imm = 0x10000FD
ja 0x2750
movb $-0x2, 0x2(%r10)
leal -0x10d(%rcx), %eax
movl %eax, 0x3(%r10)
addq $0x6, %r10
jmp 0x26b2
movb $-0x1, 0x2(%r10)
leal -0x10e(%rcx), %eax
movl %eax, 0x3(%r10)
addq $0x7, %r10
jmp 0x26b2