// File: /workspace/github_c_makefile_star2_O1/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
subq $0x28, %rsp
movq %rdx, %r8
movq %rdi, %r15
movzbl (%rdi), %r12d
cmpl $0x1f, %r12d
movq %rdx, -0x48(%rbp)
ja 0x3639
movslq %esi, %r9
addq %r15, %r9
movslq %ecx, %r10
addq %r8, %r10
incq %r15
movl $0x1, %eax
movq %r8, %r14
movq %r9, -0x40(%rbp)
movq %r10, -0x38(%rbp)
cmpl $0x20, %r12d
jb 0x34f5
movl %r12d, %r13d
shrl $0x5, %r13d
decl %r13d
cmpl $0x6, %r13d
jne 0x346f
movzbl (%r15), %r13d
incq %r15
addl $0x6, %r13d
movq %r15, %rsi
incq %r15
movl %r13d, %edx
leaq (%r14,%rdx), %rcx
addq $0x3, %rcx
cmpq %r10, %rcx
ja 0x3635
movl %r12d, %edi
andl $0x1f, %edi
shll $0x8, %edi
movq %r14, %rcx
subq %rdi, %rcx
movzbl (%rsi), %edi
subq %rdi, %rcx
leaq -0x1(%rcx), %rdi
xorl %r11d, %r11d
cmpq %r8, %rdi
jb 0x3635
cmpq %r9, %r15
jae 0x34c2
movzbl 0x1(%rsi), %r12d
addq $0x2, %rsi
movl %eax, %r11d
movq %rsi, %r15
movb -0x1(%rcx), %al
movb %al, (%r14)
cmpq %r14, %rcx
je 0x3568
movb (%rcx), %al
movb %al, 0x1(%r14)
movb 0x1(%rcx), %al
movb %al, 0x2(%r14)
testb $0x1, %r13b
jne 0x35a6
addq $0x2, %rcx
addq $0x3, %r14
jmp 0x35b8
leal 0x1(%r12), %ecx
movl %r12d, %edx
leaq (%r14,%rdx), %rsi
incq %rsi
xorl %ebx, %ebx
cmpq %r10, %rsi
ja 0x3630
addq %r15, %rdx
incq %rdx
cmpq %r9, %rdx
ja 0x3630
movb (%r15), %al
movb %al, (%r14)
incq %r14
leaq 0x1(%r15), %rcx
testl %r12d, %r12d
je 0x3544
movb (%rcx), %al
movb %al, (%r14)
incq %r14
incq %rcx
decl %r12d
jne 0x3530
leaq -0x1(%rcx), %r15
xorl %r12d, %r12d
xorl %eax, %eax
movb $0x1, %bl
cmpq %r9, %rcx
setb %al
jae 0x3560
addq $0x2, %r15
movzbl (%rcx), %r12d
jmp 0x361b
movq %rcx, %r15
jmp 0x361b
movb %al, 0x1(%r14)
leaq 0x3(%r14), %rdi
movb %al, 0x2(%r14)
movb $0x1, %bl
testl %r13d, %r13d
je 0x3615
movzbl %al, %esi
movl %r11d, -0x2c(%rbp)
callq 0x2190
movq -0x38(%rbp), %r10
movq -0x40(%rbp), %r9
movq -0x48(%rbp), %r8
decl %r13d
addq %r13, %r14
addq $0x4, %r14
movl -0x2c(%rbp), %eax
jmp 0x361b
movb 0x2(%rcx), %al
addq $0x3, %rcx
movb %al, 0x3(%r14)
addq $0x4, %r14
decl %r13d
movl %r13d, %edx
shrl %edx
movq %r14, %rax
cmpl $0xa, %r13d
jb 0x35f4
movzwl (%rcx), %esi
movw %si, (%rax)
movzwl 0x2(%rcx), %esi
movw %si, 0x2(%rax)
movzwl 0x4(%rcx), %esi
movw %si, 0x4(%rax)
movzwl 0x6(%rcx), %esi
addq $0x8, %rcx
movw %si, 0x6(%rax)
addq $0x8, %rax
addl $-0x4, %edx
cmpl $0x4, %edx
ja 0x35c6
movl %r13d, %esi
addq %rsi, %r14
movb $0x1, %bl
testl %edx, %edx
je 0x3618
movl %edx, %edx
xorl %esi, %esi
movzwl (%rcx,%rsi,2), %edi
movw %di, (%rax,%rsi,2)
incq %rsi
cmpl %esi, %edx
jne 0x3604
jmp 0x3618
movq %rdi, %r14
movl %r11d, %eax
testb %bl, %bl
je 0x38a9
testl %eax, %eax
jne 0x344a
jmp 0x38be
movl %ecx, %r12d
jmp 0x361b
xorl %ebx, %ebx
jmp 0x361b
movl %r12d, %eax
andb $-0x20, %al
cmpb $0x20, %al
jne 0x38a9
movslq %esi, %r9
addq %r15, %r9
movslq %ecx, %r10
addq %r8, %r10
incq %r15
andl $0x1f, %r12d
movl $0x1, %r11d
movq %r8, %r14
movq %r9, -0x40(%rbp)
movq %r10, -0x38(%rbp)
cmpl $0x20, %r12d
jb 0x372d
movl %r12d, %r13d
shrl $0x5, %r13d
decl %r13d
cmpl $0x6, %r13d
jne 0x369b
movl $0x6, %r13d
movzbl (%r15), %eax
incq %r15
addl %eax, %r13d
cmpl $0xff, %eax
je 0x368a
movl %r12d, %edx
andl $0x1f, %edx
shll $0x8, %edx
movl %edx, %ecx
movq %r14, %rax
subq %rcx, %rax
leaq 0x1(%r15), %rcx
movzbl (%r15), %esi
subq %rsi, %rax
cmpq $0xff, %rsi
je 0x3867
movl %r13d, %edx
leaq (%r14,%rdx), %rsi
addq $0x3, %rsi
cmpq %r10, %rsi
ja 0x3897
leaq -0x1(%rax), %rsi
xorl %ebx, %ebx
cmpq %r8, %rsi
jb 0x3899
cmpq %r9, %rcx
jae 0x389e
movzbl (%rcx), %r12d
incq %rcx
movq %rcx, %r15
movb -0x1(%rax), %cl
movb %cl, (%r14)
cmpq %r14, %rax
je 0x37a2
movb (%rax), %cl
movb %cl, 0x1(%r14)
movb 0x1(%rax), %cl
movb %cl, 0x2(%r14)
testb $0x1, %r13b
jne 0x37e1
addq $0x2, %rax
addq $0x3, %r14
jmp 0x37f3
leal 0x1(%r12), %eax
movl %r12d, %ecx
leaq (%r14,%rcx), %rdx
incq %rdx
xorl %ebx, %ebx
cmpq %r10, %rdx
ja 0x3862
addq %r15, %rcx
incq %rcx
cmpq %r9, %rcx
ja 0x3862
movb (%r15), %al
movb %al, (%r14)
incq %r14
leaq 0x1(%r15), %rax
testl %r12d, %r12d
je 0x377c
movb (%rax), %cl
movb %cl, (%r14)
incq %r14
incq %rax
decl %r12d
jne 0x3768
leaq -0x1(%rax), %r15
xorl %r12d, %r12d
xorl %r11d, %r11d
movb $0x1, %bl
cmpq %r9, %rax
setb %r11b
jae 0x379a
addq $0x2, %r15
movzbl (%rax), %r12d
jmp 0x3853
movq %rax, %r15
jmp 0x3853
movb %cl, 0x1(%r14)
leaq 0x3(%r14), %rdi
movb %cl, 0x2(%r14)
movb $0x1, %bl
testl %r13d, %r13d
je 0x3850
movzbl %cl, %esi
movl %r11d, -0x2c(%rbp)
callq 0x2190
movl -0x2c(%rbp), %r11d
movq -0x38(%rbp), %r10
movq -0x40(%rbp), %r9
movq -0x48(%rbp), %r8
decl %r13d
addq %r13, %r14
addq $0x4, %r14
jmp 0x3853
movb 0x2(%rax), %cl
addq $0x3, %rax
movb %cl, 0x3(%r14)
addq $0x4, %r14
decl %r13d
movl %r13d, %edx
shrl %edx
movq %r14, %rcx
cmpl $0xa, %r13d
jb 0x382f
movzwl (%rax), %esi
movw %si, (%rcx)
movzwl 0x2(%rax), %esi
movw %si, 0x2(%rcx)
movzwl 0x4(%rax), %esi
movw %si, 0x4(%rcx)
movzwl 0x6(%rax), %esi
addq $0x8, %rax
movw %si, 0x6(%rcx)
addq $0x8, %rcx
addl $-0x4, %edx
cmpl $0x4, %edx
ja 0x3801
movl %r13d, %esi
addq %rsi, %r14
movb $0x1, %bl
testl %edx, %edx
je 0x3853
movl %edx, %edx
xorl %esi, %esi
movzwl (%rax,%rsi,2), %edi
movw %di, (%rcx,%rsi,2)
incq %rsi
cmpl %esi, %edx
jne 0x383f
jmp 0x3853
movq %rdi, %r14
testb %bl, %bl
je 0x38a9
testl %r11d, %r11d
jne 0x366a
jmp 0x38be
movl %eax, %r12d
jmp 0x3853
cmpl $0x1f00, %edx           # imm = 0x1F00
jne 0x36c4
movzwl 0x1(%r15), %eax
addq $0x3, %r15
rolw $0x8, %ax
movzwl %ax, %ecx
movq %r14, %rax
subq %rcx, %rax
addq $-0x1fff, %rax          # imm = 0xE001
movq %r15, %rcx
jmp 0x36c4
xorl %ebx, %ebx
movq %rcx, %r15
jmp 0x3853
movq %rcx, %r15
xorl %r11d, %r11d
jmp 0x36fa
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
subl %r8d, %r14d
jmp 0x38ac