// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/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
          do
            *op++ = *ip++;
          while (--ctrl);
#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
          *op++ = *ref++;
          *op++ = *ref++;

          do
            *op++ = *ref++;
          while (--len);
#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, %rbx
movl %esi, %r15d
addq %rdi, %r15
movl %ecx, %r12d
addq %rdx, %r12
movq %rdx, %r14
leaq 0x1(%rdi), %r13
movzbl (%rdi), %eax
cmpl $0x1f, %eax
ja 0x29b80
leaq (%r14,%rax), %rcx
incq %rcx
movl $0x7, %ebp
cmpq %r12, %rcx
ja 0x29bdc
incq %rax
leaq (%rax,%r13), %rcx
movl $0x16, %ebp
cmpq %r15, %rcx
ja 0x29bdc
movb (%r13), %cl
incq %r13
movb %cl, (%r14)
incq %r14
decl %eax
jne 0x29b6b
movb $0x1, %al
jmp 0x29be5
movl $0x16, %ebp
cmpq %r15, %r13
jae 0x29bdc
movl %eax, %ecx
shrl $0x5, %ecx
cmpl $0x7, %ecx
jne 0x29ba4
leaq 0x2(%rdi), %r13
cmpq %r15, %r13
jae 0x29bdc
movzbl 0x1(%rdi), %ecx
addl $0x7, %ecx
leaq 0x1(%r13), %rdi
movl %ecx, %edx
addq %r14, %rdx
addq $0x2, %rdx
cmpq %r12, %rdx
jbe 0x29bbd
movl $0x7, %ebp
jmp 0x29bd9
andl $0x1f, %eax
shll $0x8, %eax
movq %rax, %rsi
notq %rsi
addq %r14, %rsi
movzbl (%r13), %edx
subq %rdx, %rsi
cmpq %rbx, %rsi
jae 0x29bf7
movq %rdi, %r13
callq 0x1f810
movl %ebp, (%rax)
xorl %eax, %eax
movq %r13, %rdi
testb %al, %al
je 0x29c22
cmpq %r15, %rdi
jb 0x29b39
jmp 0x29c27
negq %rdx
movb (%rsi), %r8b
movb %r8b, (%r14)
movb 0x1(%rsi), %sil
movb %sil, 0x1(%r14)
addq $0x2, %r14
subq %rax, %rdx
movb -0x1(%r14,%rdx), %al
movb %al, (%r14)
incq %r14
decl %ecx
jne 0x29c0f
movb $0x1, %al
jmp 0x29be8
xorl %r14d, %r14d
jmp 0x29c2a
subl %ebx, %r14d
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq