// File: /workspace/github_c_makefile_star2_O0/lmcilroy[P]lzm/lzdata.c
// Function: gen_match
static unsigned int
gen_match(unsigned char * const buffer, unsigned int pos,
    const unsigned int size, struct lzdata_args * const args)
{
	unsigned int length;
	unsigned int offset;
	unsigned int maxoff;
	unsigned int end;

	length = args->match_len_scale / (1 - rngd()) -
	    args->match_len_scale + args->min_match_len;

	if (length > args->max_match_len)
		length = args->max_match_len;

	if (pos + length > size)
		length = size - pos;

	maxoff = args->max_offset;
	if (maxoff > pos)
		maxoff = pos;

	offset = rngl() % (maxoff - args->min_offset + 1) +
	    args->min_offset;

	LOG("M %d %d %d\n", pos, length, offset);

	args->matches++;
	args->match_bytes += length;

	end = pos + length;

	if (end > 3) {
		while (pos < end - 3) {
			memcpy(&buffer[pos], &buffer[offset], 4);
			pos += 4;
			offset += 4;
		}
	}

	while (pos < end)
		buffer[pos++] = buffer[offset++]; 

	return pos;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq -0x18(%rbp), %rax
movsd 0x40(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x1f50
movaps %xmm0, %xmm2
movsd -0x30(%rbp), %xmm0
movsd 0x107f(%rip), %xmm1     # 0x3018
subsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movsd 0x40(%rax), %xmm1
subsd %xmm1, %xmm0
movl 0x1c(%rax), %eax
cvtsi2sd %rax, %xmm1
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x20(%rcx), %eax
jbe 0x1fd8
movq -0x18(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0x1c(%rbp)
movl -0xc(%rbp), %eax
addl -0x1c(%rbp), %eax
cmpl -0x10(%rbp), %eax
jbe 0x1fec
movl -0x10(%rbp), %eax
subl -0xc(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movl 0x28(%rax), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0xc(%rbp), %eax
jbe 0x2004
movl -0xc(%rbp), %eax
movl %eax, -0x24(%rbp)
callq 0x2100
movl -0x24(%rbp), %ecx
movq -0x18(%rbp), %rdx
subl 0x24(%rdx), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
xorl %edx, %edx
divq %rcx
movq -0x18(%rbp), %rax
movl 0x24(%rax), %eax
addq %rax, %rdx
movl %edx, %eax
movl %eax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x58(%rax)
movl -0x1c(%rbp), %eax
movl %eax, %ecx
movq -0x18(%rbp), %rax
addq 0x68(%rax), %rcx
movq %rcx, 0x68(%rax)
movl -0xc(%rbp), %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x28(%rbp)
cmpl $0x3, -0x28(%rbp)
jbe 0x2095
jmp 0x205e
movl -0xc(%rbp), %eax
movl -0x28(%rbp), %ecx
subl $0x3, %ecx
cmpl %ecx, %eax
jae 0x2093
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
movq -0x8(%rbp), %rdx
movl -0x20(%rbp), %esi
movl (%rdx,%rsi), %edx
movl %edx, (%rax,%rcx)
movl -0xc(%rbp), %eax
addl $0x4, %eax
movl %eax, -0xc(%rbp)
movl -0x20(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x20(%rbp)
jmp 0x205e
jmp 0x2095
jmp 0x2097
movl -0xc(%rbp), %eax
cmpl -0x28(%rbp), %eax
jae 0x20c9
movq -0x8(%rbp), %rax
movl -0x20(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x20(%rbp)
movl %ecx, %ecx
movb (%rax,%rcx), %dl
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0xc(%rbp)
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
jmp 0x2097
movl -0xc(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)