// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/lzf_d.c
// Function: lzf_decompress
unsigned int
lzf_decompress (const void *const in_data,  unsigned int in_len,
                void             *out_data, unsigned int out_len)
{
  u8 const *ip = (const u8 *)in_data;
  u8       *op = (u8 *)out_data;
  u8 const *const in_end  = ip + in_len;
  u8       *const out_end = op + out_len;

  do
    {
      unsigned int ctrl = *ip++;

      if (ctrl < (1 << 5)) /* literal run */
        {
          ctrl++;

          if (op + ctrl > out_end)
            {
              SET_ERRNO (E2BIG);
              return 0;
            }

#if CHECK_INPUT
          if (ip + ctrl > in_end)
            {
              SET_ERRNO (EINVAL);
              return 0;
            }
#endif

#ifdef lzf_movsb
          lzf_movsb (op, ip, ctrl);
#else
          switch (ctrl)
            {
              case 32: *op++ = *ip++; case 31: *op++ = *ip++; case 30: *op++ = *ip++; case 29: *op++ = *ip++;
              case 28: *op++ = *ip++; case 27: *op++ = *ip++; case 26: *op++ = *ip++; case 25: *op++ = *ip++;
              case 24: *op++ = *ip++; case 23: *op++ = *ip++; case 22: *op++ = *ip++; case 21: *op++ = *ip++;
              case 20: *op++ = *ip++; case 19: *op++ = *ip++; case 18: *op++ = *ip++; case 17: *op++ = *ip++;
              case 16: *op++ = *ip++; case 15: *op++ = *ip++; case 14: *op++ = *ip++; case 13: *op++ = *ip++;
              case 12: *op++ = *ip++; case 11: *op++ = *ip++; case 10: *op++ = *ip++; case  9: *op++ = *ip++;
              case  8: *op++ = *ip++; case  7: *op++ = *ip++; case  6: *op++ = *ip++; case  5: *op++ = *ip++;
              case  4: *op++ = *ip++; case  3: *op++ = *ip++; case  2: *op++ = *ip++; case  1: *op++ = *ip++;
            }
#endif
        }
      else /* back reference */
        {
          unsigned int len = ctrl >> 5;

          u8 *ref = op - ((ctrl & 0x1f) << 8) - 1;

#if CHECK_INPUT
          if (ip >= in_end)
            {
              SET_ERRNO (EINVAL);
              return 0;
            }
#endif
          if (len == 7)
            {
              len += *ip++;
#if CHECK_INPUT
              if (ip >= in_end)
                {
                  SET_ERRNO (EINVAL);
                  return 0;
                }
#endif
            }

          ref -= *ip++;

          if (op + len + 2 > out_end)
            {
              SET_ERRNO (E2BIG);
              return 0;
            }

          if (ref < (u8 *)out_data)
            {
              SET_ERRNO (EINVAL);
              return 0;
            }

#ifdef lzf_movsb
          len += 2;
          lzf_movsb (op, ref, len);
#else
          switch (len)
            {
              default:
                len += 2;

                if (op >= ref + len)
                  {
                    /* disjunct areas */
                    memcpy (op, ref, len);
                    op += len;
                  }
                else
                  {
                    /* overlapping, use octte by octte copying */
                    do
                      *op++ = *ref++;
                    while (--len);
                  }

                break;

              case 9: *op++ = *ref++;
              case 8: *op++ = *ref++;
              case 7: *op++ = *ref++;
              case 6: *op++ = *ref++;
              case 5: *op++ = *ref++;
              case 4: *op++ = *ref++;
              case 3: *op++ = *ref++;
              case 2: *op++ = *ref++;
              case 1: *op++ = *ref++;
              case 0: *op++ = *ref++; /* two octets more */
                      *op++ = *ref++;
            }
#endif
        }
    }
  while (ip < in_end);

  return op - (u8 *)out_data;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rdi, %rbx
movl %esi, %r13d
addq %rdi, %r13
movl %ecx, %ebp
addq %rdx, %rbp
movq %rdx, (%rsp)
leaq 0x1(%rbx), %r15
movzbl (%rbx), %eax
cmpl $0x1f, %eax
ja 0x3bb31
leaq (%r14,%rax), %rcx
incq %rcx
cmpq %rbp, %rcx
jbe 0x3bb78
callq 0x26890
movl $0x7, (%rax)
jmp 0x3bb8f
cmpq %r13, %r15
jae 0x3bb84
movl %eax, %ecx
shrl $0x5, %ecx
cmpl $0x7, %ecx
jne 0x3bb50
leaq 0x2(%rbx), %r15
cmpq %r13, %r15
jae 0x3bb84
movzbl 0x1(%rbx), %ecx
addl $0x7, %ecx
leaq 0x1(%r15), %rbx
movl %ecx, %r12d
leaq (%r14,%r12), %rdx
addq $0x2, %rdx
cmpq %rbp, %rdx
jbe 0x3bd47
callq 0x26890
movl $0x7, (%rax)
jmp 0x3bd6e
leaq 0x1(%rax), %rcx
addq %r15, %rcx
cmpq %r13, %rcx
jbe 0x3bbaa
callq 0x26890
movl $0x16, (%rax)
xorl %eax, %eax
movq %r15, %rbx
testb %al, %al
je 0x3be46
cmpq %r13, %rbx
jb 0x3bb0c
jmp 0x3be4b
movl %eax, %eax
leaq 0x86efd(%rip), %rcx     # 0xc2ab0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movb 0x1(%rbx), %al
addq $0x2, %rbx
movb %al, (%r14)
incq %r14
movq %rbx, %r15
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
movb $0x1, %al
jmp 0x3bb91
andl $0x1f, %eax
shll $0x8, %eax
movq %rax, %rsi
notq %rsi
addq %r14, %rsi
movzbl (%r15), %edx
subq %rdx, %rsi
cmpq (%rsp), %rsi
jae 0x3bd75
callq 0x26890
movl $0x16, (%rax)
xorl %eax, %eax
jmp 0x3bb94
leal -0x1(%rcx), %edi
cmpl $0x8, %edi
ja 0x3be07
leaq 0x86d04(%rip), %rcx     # 0xc2a8c
movslq (%rcx,%rdi,4), %rax
addq %rcx, %rax
jmpq *%rax
movb (%rsi), %al
incq %rsi
movb %al, (%r14)
incq %r14
movb (%rsi), %al
incq %rsi
movb %al, (%r14)
incq %r14
movb (%rsi), %al
incq %rsi
movb %al, (%r14)
incq %r14
movb (%rsi), %al
incq %rsi
movb %al, (%r14)
incq %r14
movb (%rsi), %al
incq %rsi
movb %al, (%r14)
incq %r14
movb (%rsi), %al
incq %rsi
movb %al, (%r14)
incq %r14
movb (%rsi), %al
incq %rsi
movb %al, (%r14)
incq %r14
movb (%rsi), %al
incq %rsi
movb %al, (%r14)
incq %r14
movb (%rsi), %al
movb %al, (%r14)
movb 0x1(%rsi), %al
movb %al, 0x1(%r14)
movb 0x2(%rsi), %al
movb %al, 0x2(%r14)
addq $0x3, %r14
movb $0x1, %al
jmp 0x3bb94
leaq (%rsi,%r12), %rdi
addq $0x2, %rdi
cmpq %rdi, %r14
jae 0x3be32
addl $0x2, %ecx
addq %rax, %rdx
notq %rdx
movb (%r14,%rdx), %al
movb %al, (%r14)
incq %r14
movb $0x1, %al
decl %ecx
jne 0x3be1d
jmp 0x3bb94
addq $0x2, %r12
movq %r14, %rdi
movq %r12, %rdx
callq 0x26c60
addq %r12, %r14
jmp 0x3be00
xorl %r14d, %r14d
jmp 0x3be4f
subl (%rsp), %r14d
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)