// File: /workspace/github_c_makefile_star2_O0/lmcilroy[P]lzm/lzmencode.c
// Function: matchlen
static inline int
matchlen(const unsigned char * const start, const unsigned char * const match,
    const unsigned char * const end)
{
	const unsigned char *curr = start;
	const unsigned char *last = match;
	unsigned long currval, lastval;
	const unsigned int off = start - match;

	if (off <= 8)
		return matchlen_run(start, match, end, run[off]);

	if (likely(curr < (end - 7))) {
		lastval = readmem64(last);
		currval = readmem64(curr);
		if (likely(lastval != currval))
			return (__builtin_ctzl(lastval ^ currval) >> 3);
		last += 8;
		curr += 8;
	}
	while (curr < (end - 7)) {
		lastval = readmem64(last);
		currval = readmem64(curr);
		if (lastval != currval) {
			return (curr - start) +
			    (__builtin_ctzl(lastval ^ currval) >> 3);
		}
		last += 8;
		curr += 8;
	}
	if (curr < (end - 3)) {
		lastval = readmem32(last);
		currval = readmem32(curr);
		if (lastval != currval) {
			return (curr - start) +
			    (__builtin_ctz(lastval ^ currval) >> 3);
		}
		last += 4;
		curr += 4;
	}
	if (curr < (end - 1) && readmem16(last) == readmem16(curr)) {
		last += 2;
		curr += 2;
	}
	if (curr < end && *last == *curr)
		curr++;

	return curr - start;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x44(%rbp)
cmpl $0x8, -0x44(%rbp)
ja 0x5371
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movl -0x44(%rbp), %eax
movl %eax, %ecx
leaq 0x4e20(%rip), %rax      # 0xa180
movzbl (%rax,%rcx), %ecx
callq 0x5940
movl %eax, -0x4(%rbp)
jmp 0x5569
movq -0x28(%rbp), %rax
movq -0x20(%rbp), %rcx
addq $-0x7, %rcx
cmpq %rcx, %rax
setb %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x53f2
movq -0x30(%rbp), %rdi
callq 0x52d0
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rdi
callq 0x52d0
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
setne %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x53da
movq -0x40(%rbp), %rax
xorq -0x38(%rbp), %rax
tzcntq %rax, %rax
sarl $0x3, %eax
movl %eax, -0x4(%rbp)
jmp 0x5569
movq -0x30(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x28(%rbp)
jmp 0x53f4
movq -0x28(%rbp), %rax
movq -0x20(%rbp), %rcx
addq $-0x7, %rcx
cmpq %rcx, %rax
jae 0x546c
movq -0x30(%rbp), %rdi
callq 0x52d0
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rdi
callq 0x52d0
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
je 0x5452
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
movq -0x40(%rbp), %rcx
xorq -0x38(%rbp), %rcx
tzcntq %rcx, %rcx
sarl $0x3, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movl %eax, -0x4(%rbp)
jmp 0x5569
movq -0x30(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x28(%rbp)
jmp 0x53f4
movq -0x28(%rbp), %rax
movq -0x20(%rbp), %rcx
addq $-0x3, %rcx
cmpq %rcx, %rax
jae 0x54e5
movq -0x30(%rbp), %rdi
callq 0x5920
movl %eax, %eax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rdi
callq 0x5920
movl %eax, %eax
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
je 0x54cd
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
movq -0x40(%rbp), %rcx
xorq -0x38(%rbp), %rcx
tzcntl %ecx, %ecx
sarl $0x3, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movl %eax, -0x4(%rbp)
jmp 0x5569
movq -0x30(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x20(%rbp), %rcx
addq $-0x1, %rcx
cmpq %rcx, %rax
jae 0x5533
movq -0x30(%rbp), %rdi
callq 0x5b80
movzwl %ax, %eax
movl %eax, -0x48(%rbp)
movq -0x28(%rbp), %rdi
callq 0x5b80
movw %ax, %cx
movl -0x48(%rbp), %eax
movzwl %cx, %ecx
cmpl %ecx, %eax
jne 0x5533
movq -0x30(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0x555b
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
movq -0x28(%rbp), %rcx
movzbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x555b
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)