// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/lzf_c.c
// Function: lzf_compress
unsigned int
lzf_compress (const void *const in_data, unsigned int in_len,
	      void *out_data, unsigned int out_len
#if LZF_STATE_ARG
              , LZF_STATE htab
#endif
              )
{
#if !LZF_STATE_ARG
  LZF_STATE htab;
#endif
  const u8 **hslot;
  const u8 *ip = (const u8 *)in_data;
        u8 *op = (u8 *)out_data;
  const u8 *in_end  = ip + in_len;
        u8 *out_end = op + out_len;
  const u8 *ref;

  /* off requires a type wide enough to hold a general pointer difference.
   * ISO C doesn't have that (size_t might not be enough and ptrdiff_t only
   * works for differences within a single object). We also assume that no
   * no bit pattern traps. Since the only platform that is both non-POSIX
   * and fails to support both assumptions is windows 64 bit, we make a
   * special workaround for it.
   */
#if defined (WIN32) && defined (_M_X64)
  unsigned _int64 off; /* workaround for missing POSIX compliance */
#else
  unsigned long off;
#endif
  unsigned int hval;
  int lit;

  if (!in_len || !out_len)
    return 0;

#if INIT_HTAB
  memset (htab, 0, sizeof (htab));
# if 0
  for (hslot = htab; hslot < htab + HSIZE; hslot++)
    *hslot++ = ip;
# endif
#endif

  lit = 0; op++; /* start run */

  hval = FRST (ip);
  while (ip < in_end - 2)
    {
      hval = NEXT (hval, ip);
      hslot = htab + IDX (hval);
      ref = *hslot; *hslot = ip;

      if (1
#if INIT_HTAB
          && ref < ip /* the next test will actually take care of this, but this is faster */
#endif
          && (off = ip - ref - 1) < MAX_OFF
          && ip + 4 < in_end
          && ref > (u8 *)in_data
#if STRICT_ALIGN
          && ref[0] == ip[0]
          && ref[1] == ip[1]
          && ref[2] == ip[2]
#else
          && *(u16 *)ref == *(u16 *)ip
          && ref[2] == ip[2]
#endif
        )
        {
          /* match found at *ref++ */
          unsigned int len = 2;
          unsigned int maxlen = in_end - ip - len;
          maxlen = maxlen > MAX_REF ? MAX_REF : maxlen;

          op [- lit - 1] = lit - 1; /* stop run */
          op -= !lit; /* undo run if length is zero */

          if (expect_false (op + 3 + 1 >= out_end))
            return 0;

          for (;;)
            {
              if (expect_true (maxlen > 16))
                {
                  len++; if (ref [len] != ip [len]) break;
                  len++; if (ref [len] != ip [len]) break;
                  len++; if (ref [len] != ip [len]) break;
                  len++; if (ref [len] != ip [len]) break;

                  len++; if (ref [len] != ip [len]) break;
                  len++; if (ref [len] != ip [len]) break;
                  len++; if (ref [len] != ip [len]) break;
                  len++; if (ref [len] != ip [len]) break;

                  len++; if (ref [len] != ip [len]) break;
                  len++; if (ref [len] != ip [len]) break;
                  len++; if (ref [len] != ip [len]) break;
                  len++; if (ref [len] != ip [len]) break;

                  len++; if (ref [len] != ip [len]) break;
                  len++; if (ref [len] != ip [len]) break;
                  len++; if (ref [len] != ip [len]) break;
                  len++; if (ref [len] != ip [len]) break;
                }

              do
                len++;
              while (len < maxlen && ref[len] == ip[len]);

              break;
            }

          len -= 2; /* len is now #octets - 1 */
          ip++;

          if (len < 7)
            {
              *op++ = (off >> 8) + (len << 5);
            }
          else
            {
              *op++ = (off >> 8) + (  7 << 5);
              *op++ = len - 7;
            }

          *op++ = off;
          lit = 0; op++; /* start run */

          ip += len + 1;

          if (expect_false (ip >= in_end - 2))
            break;

#if ULTRA_FAST || VERY_FAST
          --ip;
# if VERY_FAST && !ULTRA_FAST
          --ip;
# endif
          hval = FRST (ip);

          hval = NEXT (hval, ip);
          htab[IDX (hval)] = ip;
          ip++;

# if VERY_FAST && !ULTRA_FAST
          hval = NEXT (hval, ip);
          htab[IDX (hval)] = ip;
          ip++;
# endif
#else
          ip -= len + 1;

          do
            {
              hval = NEXT (hval, ip);
              htab[IDX (hval)] = ip;
              ip++;
            }
          while (len--);
#endif
        }
      else
        {
          /* one more literal byte we must copy */
          if (expect_false (op >= out_end))
            return 0;

          lit++; *op++ = *ip++;

          if (expect_false (lit == MAX_LIT))
            {
              op [- lit - 1] = lit - 1; /* stop run */
              lit = 0; op++; /* start run */
            }
        }
    }

  if (op + 3 > out_end) /* at most 3 bytes can be missing here */
    return 0;

  while (ip < in_end)
    {
      lit++; *op++ = *ip++;

      if (expect_false (lit == MAX_LIT))
        {
          op [- lit - 1] = lit - 1; /* stop run */
          lit = 0; op++; /* start run */
        }
    }

  op [- lit - 1] = lit - 1; /* end run */
  op -= !lit; /* undo run if length is zero */

  return op - (u8 *)out_data;
}

// Assembly:
testl %esi, %esi
sete %al
testl %ecx, %ecx
sete %r8b
orb %al, %r8b
jne 0x20059
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x7ff98, %rsp          # imm = 0x7FF98
movl %esi, %esi
addq %rdi, %rsi
movl %ecx, %r9d
addq %rdx, %r9
movq %rdx, -0x78(%rsp)
leaq 0x1(%rdx), %rcx
leaq -0x2(%rsi), %r10
xorl %eax, %eax
cmpq %rdi, %r10
jbe 0x2005c
movzwl (%rdi), %edx
rolw $0x8, %dx
movzwl %dx, %r13d
xorl %r11d, %r11d
movq %rdi, %r8
movl %r13d, %edx
movl %r13d, %ebx
shll $0x8, %ebx
movzbl 0x2(%r8), %r13d
orl %ebx, %r13d
imull $0xfffb, %r13d, %ebx    # imm = 0xFFFB
addl %edx, %ebx
movzwl %bx, %edx
movq -0x70(%rsp,%rdx,8), %r15
movq %r8, -0x70(%rsp,%rdx,8)
movq %r15, %r12
notq %r12
addq %r8, %r12
cmpq $0x1fff, %r12           # imm = 0x1FFF
ja 0x1ff66
leaq 0x4(%r8), %r14
cmpq %rsi, %r14
jae 0x1ff66
cmpq %rdi, %r15
jbe 0x1ff66
movzwl (%r15), %edx
cmpw (%r8), %dx
jne 0x1ff66
movb 0x2(%r15), %dl
cmpb 0x2(%r8), %dl
jne 0x1ff66
movl %esi, %ebx
subl %r8d, %ebx
addl $-0x2, %ebx
movl $0x108, %eax            # imm = 0x108
cmpl %eax, %ebx
cmovbl %ebx, %eax
leal -0x1(%r11), %ebp
movl %r11d, %edx
notl %edx
movslq %edx, %rdx
movb %bpl, (%rcx,%rdx)
cmpl $0x1, %r11d
sbbq $0x0, %rcx
leaq 0x4(%rcx), %rdx
cmpq %r9, %rdx
jae 0x20046
movl $0x2, %ebp
cmpl $0x11, %ebx
jb 0x1ff1b
movb 0x3(%r15), %dl
movl $0x3, %r11d
cmpb 0x3(%r8), %dl
jne 0x1ff4a
movb 0x4(%r15), %dl
movl $0x4, %r11d
cmpb (%r14), %dl
jne 0x1ff4a
movb 0x5(%r15), %dl
movl $0x5, %r11d
cmpb 0x5(%r8), %dl
jne 0x1ff4a
movb 0x6(%r15), %dl
movl $0x6, %r11d
cmpb 0x6(%r8), %dl
jne 0x1ff4a
movb 0x7(%r15), %dl
movl $0x7, %r11d
cmpb 0x7(%r8), %dl
jne 0x1ff4a
movb 0x8(%r15), %dl
movl $0x8, %r11d
cmpb 0x8(%r8), %dl
jne 0x1ff4a
movb 0x9(%r15), %dl
movl $0x9, %r11d
cmpb 0x9(%r8), %dl
jne 0x1ff4a
movb 0xa(%r15), %dl
movl $0xa, %r11d
cmpb 0xa(%r8), %dl
jne 0x1ff4a
movb 0xb(%r15), %dl
movl $0xb, %r11d
cmpb 0xb(%r8), %dl
jne 0x1ff4a
movb 0xc(%r15), %dl
movl $0xc, %r11d
cmpb 0xc(%r8), %dl
jne 0x1ff4a
movb 0xd(%r15), %dl
movl $0xd, %r11d
cmpb 0xd(%r8), %dl
jne 0x1ff4a
movb 0xe(%r15), %dl
movl $0xe, %r11d
cmpb 0xe(%r8), %dl
jne 0x1ff4a
movb 0xf(%r15), %dl
movl $0xf, %r11d
cmpb 0xf(%r8), %dl
jne 0x1ff4a
movb 0x10(%r15), %dl
movl $0x10, %r11d
cmpb 0x10(%r8), %dl
jne 0x1ff4a
movb 0x11(%r15), %dl
movl $0x11, %r11d
cmpb 0x11(%r8), %dl
jne 0x1ff4a
movb 0x12(%r15), %dl
movl $0x12, %r11d
movl %r11d, %ebp
cmpb 0x12(%r8), %dl
jne 0x1ff4a
movl %ebp, %ebx
movl %eax, %r14d
orl $0x1, %ebp
cmpl %ebp, %eax
movl %ebp, %r11d
cmoval %eax, %r11d
incq %rbx
cmpq %r14, %rbx
jae 0x1ff4a
movb (%r15,%rbx), %al
leaq 0x1(%rbx), %rdx
cmpb (%r8,%rbx), %al
movq %rdx, %rbx
je 0x1ff2f
decl %edx
movl %edx, %r11d
leal -0x2(%r11), %ebx
movq %r12, %rdx
shrq $0x8, %rdx
cmpl $0x6, %ebx
ja 0x1ff99
shll $0x5, %ebx
orl %ebx, %edx
movb %dl, (%rcx)
incq %rcx
jmp 0x1ffa9
cmpq %r9, %rcx
jae 0x200ca
leal 0x1(%r11), %r15d
movb (%r8), %dl
incq %r8
movb %dl, (%rcx)
cmpl $0x20, %r15d
je 0x20036
incq %rcx
movl %r15d, %r11d
cmpq %r10, %r8
jb 0x1fd39
jmp 0x20062
orb $-0x20, %dl
movb %dl, (%rcx)
leal -0x9(%r11), %eax
movb %al, 0x1(%rcx)
addq $0x2, %rcx
xorl %eax, %eax
movq %r8, %rdx
incq %rdx
movb %r12b, (%rcx)
addq $0x2, %rcx
decl %r11d
movq %r11, %r8
addq %rdx, %r8
cmpq %r10, %r8
jae 0x2004f
leaq -0x2(%r8), %r15
movzbl -0x2(%r8), %edx
leaq -0x1(%r8), %r11
movzbl -0x1(%r8), %ebx
shll $0x10, %edx
shll $0x8, %ebx
orl %edx, %ebx
movzbl (%r8), %edx
orl %ebx, %edx
shrl $0x8, %ebx
imull $0xfffb, %edx, %r14d    # imm = 0xFFFB
addl %ebx, %r14d
movl $0xffff, %ebp           # imm = 0xFFFF
andl %ebp, %r14d
movq %r15, -0x70(%rsp,%r14,8)
movl %edx, %ebx
shll $0x8, %ebx
movzbl 0x1(%r8), %r13d
orl %ebx, %r13d
imull $0xfffb, %r13d, %ebx    # imm = 0xFFFB
addl %edx, %ebx
andl %ebp, %ebx
movq %r11, -0x70(%rsp,%rbx,8)
xorl %r11d, %r11d
xorl %edx, %edx
movl %r11d, %r15d
testl %edx, %edx
je 0x1ff88
jmp 0x200c5
movb %r11b, -0x20(%rcx)
addq $0x2, %rcx
xorl %r15d, %r15d
jmp 0x1ff88
movl $0x1, %edx
xorl %eax, %eax
jmp 0x20026
xorl %r11d, %r11d
movl $0x3, %edx
jmp 0x20026
xorl %eax, %eax
retq
movq %rdi, %r8
xorl %r15d, %r15d
leaq 0x3(%rcx), %rdx
cmpq %r9, %rdx
ja 0x200b3
cmpq %rsi, %r8
jae 0x2009a
leal 0x1(%r15), %eax
movb (%r8), %dl
movb %dl, (%rcx)
cmpl $0x20, %eax
je 0x2008e
incq %rcx
incq %r8
movl %eax, %r15d
cmpq %rsi, %r8
jb 0x20070
jmp 0x2009d
movb %r15b, -0x20(%rcx)
addq $0x2, %rcx
xorl %eax, %eax
jmp 0x20081
movl %r15d, %eax
leal -0x1(%rax), %edx
cmpl $0x1, %eax
notl %eax
cltq
movb %dl, (%rcx,%rax)
sbbl $0x0, %ecx
subl -0x78(%rsp), %ecx
movl %ecx, %eax
addq $0x7ff98, %rsp          # imm = 0x7FF98
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x3, %edx
je 0x20062
xorl %eax, %eax
jmp 0x200b3