// File: /workspace/github_c_makefile_star2_O1/ebiggers[P]xpack/lib/xpack_compress.c
// Function: find_longest_repeat_offset_match
static u32
find_longest_repeat_offset_match(const u8 * const in_next,
				 const u32 max_len,
				 const u32 recent_offsets[],
				 unsigned *rep_max_idx_ret)
{
#if MIN_MATCH_LEN == 2
#  define load_initial  load_u16_unaligned
#elif MIN_MATCH_LEN == 3
#  define load_initial	load_u24_unaligned
#elif MIN_MATCH_LEN == 4
#  define load_initial	load_u32_unaligned
#else
#  error "unsupported MIN_MATCH_LEN"
#endif
	const u32 next_bytes = load_initial(in_next);
	const u8 *matchptr;
	u32 rep_len;
	u32 rep_max_len;
	unsigned rep_max_idx;

	STATIC_ASSERT(NUM_REPS >= 1 && NUM_REPS <= 4);

	matchptr = in_next - recent_offsets[0];
	if (load_initial(matchptr) == next_bytes)
		rep_max_len = lz_extend(in_next, matchptr, MIN_MATCH_LEN, max_len);
	else
		rep_max_len = 0;
	rep_max_idx = 0;

#if NUM_REPS >= 2
	matchptr = in_next - recent_offsets[1];
	if (load_initial(matchptr) == next_bytes) {
		rep_len = lz_extend(in_next, matchptr, MIN_MATCH_LEN, max_len);
		if (rep_len > rep_max_len) {
			rep_max_len = rep_len;
			rep_max_idx = 1;
		}
	}
#endif

#if NUM_REPS >= 3
	matchptr = in_next - recent_offsets[2];
	if (load_initial(matchptr) == next_bytes) {
		rep_len = lz_extend(in_next, matchptr, MIN_MATCH_LEN, max_len);
		if (rep_len > rep_max_len) {
			rep_max_len = rep_len;
			rep_max_idx = 2;
		}
	}
#endif

#if NUM_REPS >= 4
	matchptr = in_next - recent_offsets[3];
	if (load_initial(matchptr) == next_bytes) {
		rep_len = lz_extend(in_next, matchptr, MIN_MATCH_LEN, max_len);
		if (rep_len > rep_max_len) {
			rep_max_len = rep_len;
			rep_max_idx = 3;
		}
	}
#endif

	*rep_max_idx_ret = rep_max_idx;
	return rep_max_len;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movzwl (%rdi), %r9d
movl (%rdx), %r10d
movq %rdi, %r11
subq %r10, %r11
xorl %r8d, %r8d
movl $0x0, %eax
cmpw %r9w, (%r11)
jne 0x4e7f
leal -0x22(%rsi), %eax
cmpl $-0x21, %eax
ja 0x509c
movq 0x2(%r11), %rax
movq 0x2(%rdi), %rbx
cmpq %rbx, %rax
jne 0x4e4b
movq 0xa(%r11), %rax
movq 0xa(%rdi), %rbx
cmpq %rbx, %rax
jne 0x4e55
movq 0x12(%r11), %rax
movq 0x12(%rdi), %rbx
cmpq %rbx, %rax
jne 0x4e5f
movq 0x1a(%r11), %rax
movq 0x1a(%rdi), %rbx
movl $0x22, %ebp
cmpq %rbx, %rax
jne 0x4e69
negq %r10
movl %ebp, %eax
leal 0x8(%rax), %ebp
cmpl %esi, %ebp
ja 0x5017
movl %eax, %ebx
movq (%r11,%rbx), %r14
movq (%rdi,%rbx), %rbx
cmpq %rbx, %r14
je 0x4e2a
xorq %r14, %rbx
jmp 0x4e71
xorq %rax, %rbx
movl $0x2, %eax
jmp 0x4e71
xorq %rax, %rbx
movl $0xa, %eax
jmp 0x4e71
xorq %rax, %rbx
movl $0x12, %eax
jmp 0x4e71
xorq %rax, %rbx
movl $0x1a, %eax
bsfq %rbx, %r10
shrl $0x3, %r10d
addl %eax, %r10d
movl %r10d, %eax
movl 0x4(%rdx), %r11d
movq %rdi, %rbx
subq %r11, %rbx
cmpw %r9w, (%rbx)
jne 0x4f47
leal -0x22(%rsi), %r8d
cmpl $-0x21, %r8d
ja 0x50a6
movq 0x2(%rbx), %r10
movq 0x2(%rdi), %r8
cmpq %r8, %r10
jne 0x4f01
movq 0xa(%rbx), %r10
movq 0xa(%rdi), %r8
cmpq %r8, %r10
jne 0x4f0c
movq 0x12(%rbx), %r10
movq 0x12(%rdi), %r8
cmpq %r8, %r10
jne 0x4f17
movq 0x1a(%rbx), %r10
movq 0x1a(%rdi), %r8
movl $0x22, %ebp
cmpq %r8, %r10
jne 0x4f22
negq %r11
movl %ebp, %r10d
leal 0x8(%r10), %ebp
cmpl %esi, %ebp
ja 0x5042
movl %r10d, %r8d
movq (%rbx,%r8), %r14
movq (%rdi,%r8), %r8
cmpq %r8, %r14
je 0x4edd
xorq %r14, %r8
jmp 0x4f2b
xorq %r10, %r8
movl $0x2, %r10d
jmp 0x4f2b
xorq %r10, %r8
movl $0xa, %r10d
jmp 0x4f2b
xorq %r10, %r8
movl $0x12, %r10d
jmp 0x4f2b
xorq %r10, %r8
movl $0x1a, %r10d
bsfq %r8, %r8
shrl $0x3, %r8d
addl %r10d, %r8d
movl %r8d, %r10d
xorl %r8d, %r8d
cmpl %eax, %r10d
seta %r8b
cmoval %r10d, %eax
movl 0x8(%rdx), %edx
movq %rdi, %r10
subq %rdx, %r10
cmpw %r9w, (%r10)
jne 0x500f
leal -0x22(%rsi), %r9d
cmpl $-0x21, %r9d
ja 0x50b0
movq 0x2(%r10), %r9
movq 0x2(%rdi), %r11
cmpq %r11, %r9
jne 0x4fc8
movq 0xa(%r10), %r9
movq 0xa(%rdi), %r11
cmpq %r11, %r9
jne 0x4fd3
movq 0x12(%r10), %r9
movq 0x12(%rdi), %r11
cmpq %r11, %r9
jne 0x4fde
movq 0x1a(%r10), %r9
movq 0x1a(%rdi), %r11
movl $0x22, %ebx
cmpq %r11, %r9
jne 0x4fe9
negq %rdx
movl %ebx, %r9d
leal 0x8(%r9), %ebx
cmpl %esi, %ebx
ja 0x5071
movl %r9d, %r11d
movq (%r10,%r11), %r14
movq (%rdi,%r11), %r11
cmpq %r11, %r14
je 0x4fa4
xorq %r14, %r11
jmp 0x4ff2
xorq %r9, %r11
movl $0x2, %r9d
jmp 0x4ff2
xorq %r9, %r11
movl $0xa, %r9d
jmp 0x4ff2
xorq %r9, %r11
movl $0x12, %r9d
jmp 0x4ff2
xorq %r9, %r11
movl $0x1a, %r9d
bsfq %r11, %rdx
shrl $0x3, %edx
addl %r9d, %edx
movl %edx, %r9d
cmpl %eax, %r9d
cmoval %r9d, %eax
movl $0x2, %edx
cmoval %edx, %r8d
movl %r8d, (%rcx)
popq %rbx
popq %r14
popq %rbp
retq
cmpl %esi, %eax
jae 0x4e7f
movl %eax, %r11d
addq %rdi, %r11
movb (%r11,%r10), %bl
cmpb (%r11), %bl
jne 0x4e7f
incl %eax
incq %r11
cmpl %esi, %eax
jb 0x5025
movl %esi, %eax
jmp 0x4e7f
cmpl %esi, %r10d
jae 0x4f39
movl %r10d, %r8d
addq %rdi, %r8
movb (%r8,%r11), %bl
cmpb (%r8), %bl
jne 0x4f39
incl %r10d
incq %r8
cmpl %esi, %r10d
jb 0x5051
movl %esi, %r10d
jmp 0x4f39
cmpl %esi, %r9d
jae 0x4fff
movl %r9d, %r10d
addq %r10, %rdi
movb (%rdi,%rdx), %r10b
cmpb (%rdi), %r10b
jne 0x4fff
incl %r9d
incq %rdi
cmpl %esi, %r9d
jb 0x507c
movl %esi, %r9d
jmp 0x4fff
movl $0x2, %ebp
jmp 0x4e27
movl $0x2, %ebp
jmp 0x4eda
movl $0x2, %ebx
jmp 0x4fa1
nop