// File: /workspace/github_c_makefile_star2_O0/bluecmd[P]fst-example/gtkwave/fastlz.c
// Function: fastlz2_decompress
static FASTLZ_INLINE int FASTLZ_DECOMPRESSOR(const void* input, int length, void* output, int maxout)
{
  const flzuint8* ip = (const flzuint8*) input;
  const flzuint8* ip_limit  = ip + length;
  flzuint8* op = (flzuint8*) output;
  flzuint8* op_limit = op + maxout;
  flzuint32 ctrl = (*ip++) & 31;
  int loop = 1;

  do
  {
    const flzuint8* ref = op;
    flzuint32 len = ctrl >> 5;
    flzuint32 ofs = (ctrl & 31) << 8;

    if(ctrl >= 32)
    {
#if FASTLZ_LEVEL==2
      flzuint8 code;
#endif
      len--;
      ref -= ofs;
      if (len == 7-1)
#if FASTLZ_LEVEL==1
        len += *ip++;
      ref -= *ip++;
#else
        do
        {
          code = *ip++;
          len += code;
        } while (code==255);
      code = *ip++;
      ref -= code;

      /* match from 16-bit distance */
      if(FASTLZ_UNEXPECT_CONDITIONAL(code==255))
      if(FASTLZ_EXPECT_CONDITIONAL(ofs==(31 << 8)))
      {
        ofs = (*ip++) << 8;
        ofs += *ip++;
        ref = op - ofs - MAX_DISTANCE;
      }
#endif

#ifdef FASTLZ_SAFE
      if (FASTLZ_UNEXPECT_CONDITIONAL(op + len + 3 > op_limit))
        return 0;

      if (FASTLZ_UNEXPECT_CONDITIONAL(ref-1 < (flzuint8 *)output))
        return 0;
#endif

      if(FASTLZ_EXPECT_CONDITIONAL(ip < ip_limit))
        ctrl = *ip++;
      else
        loop = 0;

      if(ref == op)
      {
        /* optimize copy for a run */
        flzuint8 b = ref[-1];
        *op++ = b;
        *op++ = b;
        *op++ = b;
        for(; len; --len)
          *op++ = b;
      }
      else
      {
#if !defined(FASTLZ_STRICT_ALIGN)
        const flzuint16* p;
        flzuint16* q;
#endif
        /* copy from reference */
        ref--;
        *op++ = *ref++;
        *op++ = *ref++;
        *op++ = *ref++;

#if !defined(FASTLZ_STRICT_ALIGN)
        /* copy a byte, so that now it's word aligned */
        if(len & 1)
        {
          *op++ = *ref++;
          len--;
        }

        /* copy 16-bit at once */
        q = (flzuint16*) op;
        op += len;
        p = (const flzuint16*) ref;
        for(len>>=1; len > 4; len-=4)
        {
          *q++ = *p++;
          *q++ = *p++;
          *q++ = *p++;
          *q++ = *p++;
        }
        for(; len; --len)
          *q++ = *p++;
#else
        for(; len; --len)
          *op++ = *ref++;
#endif
      }
    }
    else
    {
      ctrl++;
#ifdef FASTLZ_SAFE
      if (FASTLZ_UNEXPECT_CONDITIONAL(op + ctrl > op_limit))
        return 0;
      if (FASTLZ_UNEXPECT_CONDITIONAL(ip + ctrl > ip_limit))
        return 0;
#endif

      *op++ = *ip++;
      for(--ctrl; ctrl; ctrl--)
        *op++ = *ip++;

      loop = FASTLZ_EXPECT_CONDITIONAL(ip < ip_limit);
      if(loop)
        ctrl = *ip++;
    }
  }
  while(FASTLZ_EXPECT_CONDITIONAL(loop));

  return op - (flzuint8*)output;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movslq -0x14(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movslq -0x24(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movzbl (%rax), %eax
andl $0x1f, %eax
movl %eax, -0x4c(%rbp)
movl $0x1, -0x50(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x58(%rbp)
movl -0x4c(%rbp), %eax
shrl $0x5, %eax
movl %eax, -0x5c(%rbp)
movl -0x4c(%rbp), %eax
andl $0x1f, %eax
shll $0x8, %eax
movl %eax, -0x60(%rbp)
cmpl $0x20, -0x4c(%rbp)
jb 0x458d
movl -0x5c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x5c(%rbp)
movl -0x60(%rbp), %ecx
movq -0x58(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
cmpl $0x6, -0x5c(%rbp)
jne 0x4229
jmp 0x41fe
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movb (%rax), %al
movb %al, -0x61(%rbp)
movzbl -0x61(%rbp), %eax
addl -0x5c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movzbl -0x61(%rbp), %eax
cmpl $0xff, %eax
je 0x41fe
jmp 0x4229
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movb (%rax), %al
movb %al, -0x61(%rbp)
movzbl -0x61(%rbp), %ecx
movq -0x58(%rbp), %rax
movslq %ecx, %rdx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movzbl -0x61(%rbp), %eax
cmpl $0xff, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x42d1
cmpl $0x1f00, -0x60(%rbp)    # imm = 0x1F00
sete %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x42cf
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movzbl (%rax), %eax
shll $0x8, %eax
movl %eax, -0x60(%rbp)
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movzbl (%rax), %eax
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
movq -0x40(%rbp), %rax
movl -0x60(%rbp), %ecx
movl %ecx, %edx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
addq $-0x1fff, %rax          # imm = 0xE001
movq %rax, -0x58(%rbp)
jmp 0x42d1
movq -0x40(%rbp), %rax
movl -0x5c(%rbp), %ecx
addq %rcx, %rax
addq $0x3, %rax
cmpq -0x48(%rbp), %rax
seta %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x42ff
movl $0x0, -0x4(%rbp)
jmp 0x4698
movq -0x58(%rbp), %rax
addq $-0x1, %rax
cmpq -0x20(%rbp), %rax
setb %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x4327
movl $0x0, -0x4(%rbp)
jmp 0x4698
movq -0x30(%rbp), %rax
cmpq -0x38(%rbp), %rax
setb %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x4356
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movzbl (%rax), %eax
movl %eax, -0x4c(%rbp)
jmp 0x435d
movl $0x0, -0x50(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x40(%rbp), %rax
jne 0x43d7
movq -0x58(%rbp), %rax
movb -0x1(%rax), %al
movb %al, -0x62(%rbp)
movb -0x62(%rbp), %cl
movq -0x40(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x40(%rbp)
movb %cl, (%rax)
movb -0x62(%rbp), %cl
movq -0x40(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x40(%rbp)
movb %cl, (%rax)
movb -0x62(%rbp), %cl
movq -0x40(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x40(%rbp)
movb %cl, (%rax)
cmpl $0x0, -0x5c(%rbp)
je 0x43d2
movb -0x62(%rbp), %cl
movq -0x40(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x40(%rbp)
movb %cl, (%rax)
movl -0x5c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x43ad
jmp 0x4588
movq -0x58(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x58(%rbp)
movb (%rax), %cl
movq -0x40(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x40(%rbp)
movb %cl, (%rax)
movq -0x58(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x58(%rbp)
movb (%rax), %cl
movq -0x40(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x40(%rbp)
movb %cl, (%rax)
movq -0x58(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x58(%rbp)
movb (%rax), %cl
movq -0x40(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x40(%rbp)
movb %cl, (%rax)
movl -0x5c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x447f
movq -0x58(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x58(%rbp)
movb (%rax), %cl
movq -0x40(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x40(%rbp)
movb %cl, (%rax)
movl -0x5c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x5c(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x78(%rbp)
movl -0x5c(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x70(%rbp)
movl -0x5c(%rbp), %eax
shrl %eax
movl %eax, -0x5c(%rbp)
cmpl $0x4, -0x5c(%rbp)
jbe 0x454f
movq -0x70(%rbp), %rax
movq %rax, %rcx
addq $0x2, %rcx
movq %rcx, -0x70(%rbp)
movw (%rax), %cx
movq -0x78(%rbp), %rax
movq %rax, %rdx
addq $0x2, %rdx
movq %rdx, -0x78(%rbp)
movw %cx, (%rax)
movq -0x70(%rbp), %rax
movq %rax, %rcx
addq $0x2, %rcx
movq %rcx, -0x70(%rbp)
movw (%rax), %cx
movq -0x78(%rbp), %rax
movq %rax, %rdx
addq $0x2, %rdx
movq %rdx, -0x78(%rbp)
movw %cx, (%rax)
movq -0x70(%rbp), %rax
movq %rax, %rcx
addq $0x2, %rcx
movq %rcx, -0x70(%rbp)
movw (%rax), %cx
movq -0x78(%rbp), %rax
movq %rax, %rdx
addq $0x2, %rdx
movq %rdx, -0x78(%rbp)
movw %cx, (%rax)
movq -0x70(%rbp), %rax
movq %rax, %rcx
addq $0x2, %rcx
movq %rcx, -0x70(%rbp)
movw (%rax), %cx
movq -0x78(%rbp), %rax
movq %rax, %rdx
addq $0x2, %rdx
movq %rdx, -0x78(%rbp)
movw %cx, (%rax)
movl -0x5c(%rbp), %eax
subl $0x4, %eax
movl %eax, -0x5c(%rbp)
jmp 0x44a7
jmp 0x4551
cmpl $0x0, -0x5c(%rbp)
je 0x4586
movq -0x70(%rbp), %rax
movq %rax, %rcx
addq $0x2, %rcx
movq %rcx, -0x70(%rbp)
movw (%rax), %cx
movq -0x78(%rbp), %rax
movq %rax, %rdx
addq $0x2, %rdx
movq %rdx, -0x78(%rbp)
movw %cx, (%rax)
movl -0x5c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x4551
jmp 0x4588
jmp 0x467a
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movq -0x40(%rbp), %rax
movl -0x4c(%rbp), %ecx
addq %rcx, %rax
cmpq -0x48(%rbp), %rax
seta %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x45c0
movl $0x0, -0x4(%rbp)
jmp 0x4698
movq -0x30(%rbp), %rax
movl -0x4c(%rbp), %ecx
addq %rcx, %rax
cmpq -0x38(%rbp), %rax
seta %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x45ea
movl $0x0, -0x4(%rbp)
jmp 0x4698
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movb (%rax), %cl
movq -0x40(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x40(%rbp)
movb %cl, (%rax)
movl -0x4c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
je 0x4648
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movb (%rax), %cl
movq -0x40(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x40(%rbp)
movb %cl, (%rax)
movl -0x4c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x4615
movq -0x30(%rbp), %rax
cmpq -0x38(%rbp), %rax
setb %al
andb $0x1, %al
movzbl %al, %eax
cltq
movl %eax, -0x50(%rbp)
cmpl $0x0, -0x50(%rbp)
je 0x4678
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movzbl (%rax), %eax
movl %eax, -0x4c(%rbp)
jmp 0x467a
jmp 0x467c
movslq -0x50(%rbp), %rax
cmpq $0x0, %rax
jne 0x41af
movq -0x40(%rbp), %rax
movq -0x20(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopl (%rax)