// File: /workspace/github_c_makefile_star2_O0/zhiyb[P]png2tlg/png2tlg.cpp
// Function: SlideCompressor::Encode(unsigned char const*, long, unsigned char*, long&)
void SlideCompressor::Encode(const unsigned char *in, long inlen,
		unsigned char *out, long & outlen)
{
	unsigned char code[40], codeptr, mask;

	if(inlen == 0) return;

	outlen = 0;
	code[0] = 0;
	codeptr = mask = 1;

	int s = S;
	while(inlen > 0)
	{
		int pos = 0;
		int len = GetMatch(in, inlen, pos, s);
		if(len >= 3)
		{
			code[0] |= mask;
			if(len >= 18)
			{
				code[codeptr++] = pos & 0xff;
				code[codeptr++] = ((pos &0xf00)>> 8) | 0xf0;
				code[codeptr++] = len - 18;
			}
			else
			{
				code[codeptr++] = pos & 0xff;
				code[codeptr++] = ((pos&0xf00)>> 8) | ((len-3)<<4);
			}
			while(len--)
			{
				unsigned char c = 0[in++];
				DeleteMap((s - 1) & (SLIDE_N - 1));
				DeleteMap(s);
				if(s < SLIDE_M - 1) Text[s + SLIDE_N] = c;
				Text[s] = c;
				AddMap((s - 1) & (SLIDE_N - 1));
				AddMap(s);
				s++;
				inlen--;
				s &= (SLIDE_N - 1);
			}
		}
		else
		{
			unsigned char c = 0[in++];
			DeleteMap((s - 1) & (SLIDE_N - 1));
			DeleteMap(s);
			if(s < SLIDE_M - 1) Text[s + SLIDE_N] = c;
			Text[s] = c;
	 		AddMap((s - 1) & (SLIDE_N - 1));
			AddMap(s);
			s++;
			inlen--;
			s &= (SLIDE_N - 1);
			code[codeptr++] = c;
		}
		mask <<= 1;

		if(mask == 0)
		{
			for(int i = 0; i < codeptr; i++)
				out[outlen++] = code[i];
			mask = codeptr = 1;
			code[0] = 0;
		}
	}

	if(mask != 1)
	{
		for(int i = 0; i < codeptr; i++)
			out[outlen++] = code[i];
	}

	S = s;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x4433
jmp 0x4772
movq -0x78(%rbp), %rax
movq -0x28(%rbp), %rcx
movq $0x0, (%rcx)
movb $0x0, -0x50(%rbp)
movb $0x1, -0x52(%rbp)
movb $0x1, -0x51(%rbp)
movl 0x92228(%rax), %eax
movl %eax, -0x58(%rbp)
cmpq $0x0, -0x18(%rbp)
jle 0x471d
movq -0x78(%rbp), %rdi
movl $0x0, -0x5c(%rbp)
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rax
movl %eax, %edx
movl -0x58(%rbp), %r8d
leaq -0x5c(%rbp), %rcx
callq 0x4100
movl %eax, -0x60(%rbp)
cmpl $0x3, -0x60(%rbp)
jl 0x4607
movzbl -0x52(%rbp), %ecx
movzbl -0x50(%rbp), %eax
orl %ecx, %eax
movb %al, -0x50(%rbp)
cmpl $0x12, -0x60(%rbp)
jl 0x4500
movl -0x5c(%rbp), %eax
andl $0xff, %eax
movb %al, %cl
movb -0x51(%rbp), %al
movb %al, %dl
addb $0x1, %dl
movb %dl, -0x51(%rbp)
movzbl %al, %eax
movb %cl, -0x50(%rbp,%rax)
movl -0x5c(%rbp), %eax
andl $0xf00, %eax            # imm = 0xF00
sarl $0x8, %eax
orl $0xf0, %eax
movb %al, %cl
movb -0x51(%rbp), %al
movb %al, %dl
addb $0x1, %dl
movb %dl, -0x51(%rbp)
movzbl %al, %eax
movb %cl, -0x50(%rbp,%rax)
movl -0x60(%rbp), %eax
subl $0x12, %eax
movb %al, %cl
movb -0x51(%rbp), %al
movb %al, %dl
addb $0x1, %dl
movb %dl, -0x51(%rbp)
movzbl %al, %eax
movb %cl, -0x50(%rbp,%rax)
jmp 0x4546
movl -0x5c(%rbp), %eax
andl $0xff, %eax
movb %al, %cl
movb -0x51(%rbp), %al
movb %al, %dl
addb $0x1, %dl
movb %dl, -0x51(%rbp)
movzbl %al, %eax
movb %cl, -0x50(%rbp,%rax)
movl -0x5c(%rbp), %eax
andl $0xf00, %eax            # imm = 0xF00
sarl $0x8, %eax
movl -0x60(%rbp), %ecx
subl $0x3, %ecx
shll $0x4, %ecx
orl %ecx, %eax
movb %al, %cl
movb -0x51(%rbp), %al
movb %al, %dl
addb $0x1, %dl
movb %dl, -0x51(%rbp)
movzbl %al, %eax
movb %cl, -0x50(%rbp,%rax)
jmp 0x4548
movl -0x60(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x60(%rbp)
cmpl $0x0, %eax
je 0x4602
movq -0x78(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movb (%rax), %al
movb %al, -0x61(%rbp)
movl -0x58(%rbp), %esi
subl $0x1, %esi
andl $0xfff, %esi            # imm = 0xFFF
callq 0x42d0
movq -0x78(%rbp), %rdi
movl -0x58(%rbp), %esi
callq 0x42d0
cmpl $0x110, -0x58(%rbp)     # imm = 0x110
jge 0x45b1
movq -0x78(%rbp), %rax
movb -0x61(%rbp), %dl
movl -0x58(%rbp), %ecx
addl $0x1000, %ecx           # imm = 0x1000
movslq %ecx, %rcx
movb %dl, 0x8(%rax,%rcx)
movq -0x78(%rbp), %rdi
movb -0x61(%rbp), %cl
movslq -0x58(%rbp), %rax
movb %cl, 0x8(%rdi,%rax)
movl -0x58(%rbp), %esi
subl $0x1, %esi
andl $0xfff, %esi            # imm = 0xFFF
callq 0x4010
movq -0x78(%rbp), %rdi
movl -0x58(%rbp), %esi
callq 0x4010
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
movq -0x18(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x18(%rbp)
movl -0x58(%rbp), %eax
andl $0xfff, %eax            # imm = 0xFFF
movl %eax, -0x58(%rbp)
jmp 0x4548
jmp 0x46bd
movq -0x78(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movb (%rax), %al
movb %al, -0x62(%rbp)
movl -0x58(%rbp), %esi
subl $0x1, %esi
andl $0xfff, %esi            # imm = 0xFFF
callq 0x42d0
movq -0x78(%rbp), %rdi
movl -0x58(%rbp), %esi
callq 0x42d0
cmpl $0x110, -0x58(%rbp)     # imm = 0x110
jge 0x465c
movq -0x78(%rbp), %rax
movb -0x62(%rbp), %dl
movl -0x58(%rbp), %ecx
addl $0x1000, %ecx           # imm = 0x1000
movslq %ecx, %rcx
movb %dl, 0x8(%rax,%rcx)
movq -0x78(%rbp), %rdi
movb -0x62(%rbp), %cl
movslq -0x58(%rbp), %rax
movb %cl, 0x8(%rdi,%rax)
movl -0x58(%rbp), %esi
subl $0x1, %esi
andl $0xfff, %esi            # imm = 0xFFF
callq 0x4010
movq -0x78(%rbp), %rdi
movl -0x58(%rbp), %esi
callq 0x4010
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
movq -0x18(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x18(%rbp)
movl -0x58(%rbp), %eax
andl $0xfff, %eax            # imm = 0xFFF
movl %eax, -0x58(%rbp)
movb -0x62(%rbp), %cl
movb -0x51(%rbp), %al
movb %al, %dl
addb $0x1, %dl
movb %dl, -0x51(%rbp)
movzbl %al, %eax
movb %cl, -0x50(%rbp,%rax)
movzbl -0x52(%rbp), %eax
shll %eax
movb %al, -0x52(%rbp)
movzbl -0x52(%rbp), %eax
cmpl $0x0, %eax
jne 0x4718
movl $0x0, -0x68(%rbp)
movl -0x68(%rbp), %eax
movzbl -0x51(%rbp), %ecx
cmpl %ecx, %eax
jge 0x470c
movslq -0x68(%rbp), %rax
movb -0x50(%rbp,%rax), %dl
movq -0x20(%rbp), %rax
movq -0x28(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movb %dl, (%rax,%rcx)
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x46d6
movb $0x1, -0x51(%rbp)
movb $0x1, -0x52(%rbp)
movb $0x0, -0x50(%rbp)
jmp 0x4457
movzbl -0x52(%rbp), %eax
cmpl $0x1, %eax
je 0x4765
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movzbl -0x51(%rbp), %ecx
cmpl %ecx, %eax
jge 0x4763
movslq -0x6c(%rbp), %rax
movb -0x50(%rbp,%rax), %dl
movq -0x20(%rbp), %rax
movq -0x28(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movb %dl, (%rax,%rcx)
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x472d
jmp 0x4765
movq -0x78(%rbp), %rax
movl -0x58(%rbp), %ecx
movl %ecx, 0x92228(%rax)
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)