// File: /workspace/github_c_makefile_star2_O2/bluecmd[P]fst-example/gtkwave/fastlz.c
// Function: fastlz_decompress
int fastlz_decompress(const void* input, int length, void* output, int maxout)
{
  /* magic identifier for compression level */
  int level = ((*(const flzuint8*)input) >> 5) + 1;

  if(level == 1)
    return fastlz1_decompress(input, length, output, maxout);
  if(level == 2)
    return fastlz2_decompress(input, length, output, maxout);

  /* unknown level, trigger error */
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movzbl (%rdi), %r8d
movslq %esi, %rsi
movslq %ecx, %r12
cmpl $0x1f, %r8d
movq %rdx, -0x38(%rbp)
ja 0x30ba
addq %rdi, %rsi
addq %rdx, %r12
incq %rdi
movl $0x1, %r11d
movq %rdx, %r15
movq %r12, -0x30(%rbp)
cmpl $0x20, %r8d
jb 0x2fae
movl %r8d, %ebx
shrl $0x5, %ebx
decl %ebx
cmpl $0x6, %ebx
jne 0x2f2d
movzbl (%rdi), %ebx
incq %rdi
addl $0x6, %ebx
movl %ebx, %r14d
leaq (%r15,%r14), %r9
addq $0x3, %r9
xorl %eax, %eax
cmpq %r12, %r9
ja 0x32e9
movl %r8d, %r9d
andl $0x1f, %r9d
shll $0x8, %r9d
movq %r15, %r10
subq %r9, %r10
movzbl (%rdi), %r9d
subq %r9, %r10
leaq -0x1(%r10), %r9
cmpq %rdx, %r9
jb 0x32e9
leaq 0x1(%rdi), %rax
cmpq %rsi, %rax
jae 0x30b2
movzbl 0x1(%rdi), %r8d
addq $0x2, %rdi
movq %rdi, %rax
movb -0x1(%r10), %dil
movb %dil, (%r15)
cmpq %r15, %r10
je 0x3002
movb (%r10), %dil
movb %dil, 0x1(%r15)
movb 0x1(%r10), %dil
movb %dil, 0x2(%r15)
testb $0x1, %bl
jne 0x301f
addq $0x2, %r10
addq $0x3, %r15
jmp 0x3034
movl %r8d, %r9d
leaq (%r15,%r9), %rcx
incq %rcx
xorl %eax, %eax
cmpq %r12, %rcx
ja 0x32e9
leaq (%rdi,%r9), %rcx
incq %rcx
cmpq %rsi, %rcx
ja 0x32e9
movb (%rdi), %al
movb %al, (%r15)
incq %r15
incq %rdi
subl $0x1, %r8d
jae 0x2fd3
cmpq %rsi, %rdi
jae 0x32db
movzbl (%rdi), %r8d
incq %rdi
movl $0x1, %r11d
movq %rdi, %rax
jmp 0x30a1
movb %dil, 0x1(%r15)
movb %dil, 0x2(%r15)
addq $0x3, %r15
subl $0x1, %ebx
jb 0x30a1
movb %dil, (%r15)
incq %r15
jmp 0x300e
movb 0x2(%r10), %dil
addq $0x3, %r10
movb %dil, 0x3(%r15)
addq $0x4, %r15
decl %ebx
movq %rbx, %r14
movl %ebx, %r12d
shrl %r12d
xorl %edi, %edi
movq %r10, %r13
movq %r15, %r9
cmpl $0x4, %r12d
jbe 0x3081
movzwl (%r13), %ecx
movw %cx, (%r9)
movzwl 0x2(%r13), %ecx
movw %cx, 0x2(%r9)
movzwl 0x4(%r13), %ecx
movw %cx, 0x4(%r9)
movzwl 0x6(%r13), %ecx
addq $0x8, %r13
movw %cx, 0x6(%r9)
addq $0x8, %r9
addl $-0x4, %r12d
addq $0x4, %rdi
jmp 0x3042
shrl %ebx
movq -0x38(%rbp), %rdx
movq -0x30(%rbp), %r12
cmpl %edi, %ebx
je 0x309e
movzwl (%r10,%rdi,2), %ecx
movw %cx, (%r15,%rdi,2)
incq %rdi
jmp 0x308b
addq %r14, %r15
movq %rax, %rdi
testl %r11d, %r11d
jne 0x2f0d
jmp 0x32db
xorl %r11d, %r11d
jmp 0x2f81
movl %r8d, %ecx
andb $-0x20, %cl
xorl %eax, %eax
cmpb $0x20, %cl
jne 0x32e9
movl $0x1, %ebx
addq %rdi, %rsi
addq %rdx, %r12
incq %rdi
andl $0x1f, %r8d
movq %rdx, %r11
movq %r12, -0x30(%rbp)
cmpl $0x20, %r8d
jb 0x319f
movl %r8d, %r14d
shrl $0x5, %r14d
decl %r14d
cmpl $0x6, %r14d
jne 0x3116
movl $0x6, %eax
movl %eax, %r14d
movzbl (%rdi), %eax
incq %rdi
addl %eax, %r14d
cmpl $0xff, %eax
je 0x3106
movl %r8d, %eax
andl $0x1f, %eax
shll $0x8, %eax
movl %eax, %ecx
movq %r11, %r9
subq %rcx, %r9
leaq 0x1(%rdi), %r15
movzbl (%rdi), %ecx
subq %rcx, %r9
cmpq $0xff, %rcx
je 0x32a5
movl %r14d, %edi
leaq (%r11,%rdi), %rcx
addq $0x3, %rcx
xorl %eax, %eax
cmpq %r12, %rcx
ja 0x32e9
leaq -0x1(%r9), %rcx
cmpq %rdx, %rcx
jb 0x32e9
cmpq %rsi, %r15
jae 0x32d4
movzbl (%r15), %r8d
incq %r15
movb -0x1(%r9), %al
movb %al, (%r11)
cmpq %r11, %r9
je 0x31f2
movb (%r9), %al
movb %al, 0x1(%r11)
movb 0x1(%r9), %al
movb %al, 0x2(%r11)
testb $0x1, %r14b
jne 0x3210
addq $0x2, %r9
addq $0x3, %r11
jmp 0x3226
movl %r8d, %r9d
leaq (%r11,%r9), %rcx
incq %rcx
xorl %eax, %eax
cmpq %r12, %rcx
ja 0x32e9
leaq (%rdi,%r9), %rcx
incq %rcx
cmpq %rsi, %rcx
ja 0x32e9
movb (%rdi), %al
movb %al, (%r11)
incq %r11
incq %rdi
subl $0x1, %r8d
jae 0x31c4
cmpq %rsi, %rdi
jae 0x32e3
movzbl (%rdi), %r8d
incq %rdi
movq %rdi, %r15
movl $0x1, %ebx
jmp 0x3298
movb %al, 0x1(%r11)
movb %al, 0x2(%r11)
addq $0x3, %r11
subl $0x1, %r14d
jb 0x3298
movb %al, (%r11)
incq %r11
jmp 0x31fe
movb 0x2(%r9), %al
addq $0x3, %r9
movb %al, 0x3(%r11)
addq $0x4, %r11
decl %r14d
movq %r14, %rdi
movl %r14d, %r13d
shrl %r13d
xorl %eax, %eax
movq %r9, %r12
movq %r11, %r10
cmpl $0x4, %r13d
jbe 0x3276
movzwl (%r12), %ecx
movw %cx, (%r10)
movzwl 0x2(%r12), %ecx
movw %cx, 0x2(%r10)
movzwl 0x4(%r12), %ecx
movw %cx, 0x4(%r10)
movzwl 0x6(%r12), %ecx
addq $0x8, %r12
movw %cx, 0x6(%r10)
addq $0x8, %r10
addl $-0x4, %r13d
addq $0x4, %rax
jmp 0x3234
shrl %r14d
movq -0x38(%rbp), %rdx
movq -0x30(%rbp), %r12
cmpl %eax, %r14d
je 0x3295
movzwl (%r9,%rax,2), %ecx
movw %cx, (%r11,%rax,2)
incq %rax
jmp 0x3281
addq %rdi, %r11
movq %r15, %rdi
testl %ebx, %ebx
jne 0x30e4
jmp 0x32e3
cmpl $0x1f00, %eax           # imm = 0x1F00
jne 0x313e
movzwl 0x1(%rdi), %eax
addq $0x3, %rdi
rolw $0x8, %ax
movzwl %ax, %eax
movq %r11, %r9
subq %rax, %r9
addq $-0x1fff, %r9           # imm = 0xE001
movq %rdi, %r15
jmp 0x313e
xorl %ebx, %ebx
jmp 0x3171
subl %edx, %r15d
movl %r15d, %eax
jmp 0x32e9
subl %edx, %r11d
movl %r11d, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq