// File: /workspace/github_c_makefile_star2_O3/gplessis[P]dotdeb-redis/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 *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));
#endif

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

  hval = FRST (ip);
  while (ip < in_end - 2)
    {
      LZF_HSLOT *hslot;

      hval = NEXT (hval, ip);
      hslot = htab + IDX (hval);
      ref = *hslot + LZF_HSLOT_BIAS; *hslot = ip - LZF_HSLOT_BIAS;

      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
          && ref > (u8 *)in_data
          && ref[2] == ip[2]
#if STRICT_ALIGN
          && ((ref[1] << 8) | ref[0]) == ((ip[1] << 8) | ip[0])
#else
          && *(u16 *)ref == *(u16 *)ip
#endif
        )
        {
          /* match found at *ref++ */
          unsigned int len = 2;
          unsigned int maxlen = in_end - ip - len;
          maxlen = maxlen > MAX_REF ? MAX_REF : maxlen;

          if (expect_false (op + 3 + 1 >= out_end)) /* first a faster conservative test */
            if (op - !lit + 3 + 1 >= out_end) /* second the exact but rare test */
              return 0;

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

          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 - LZF_HSLOT_BIAS;
          ip++;

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

          do
            {
              hval = NEXT (hval, ip);
              htab[IDX (hval)] = ip - LZF_HSLOT_BIAS;
              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 0x2751d
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3ff98, %rsp          # imm = 0x3FF98
movl %esi, %esi
addq %rdi, %rsi
movl %ecx, %r9d
addq %rdx, %r9
leaq 0x1(%rdx), %rcx
leaq -0x2(%rsi), %r10
xorl %eax, %eax
cmpq %rdi, %r10
jbe 0x27520
leaq 0x1(%rdi), %r8
movq %r8, -0x78(%rsp)
movzwl (%rdi), %r8d
rolw $0x8, %r8w
movzwl %r8w, %ebx
xorl %r14d, %r14d
movq %rdi, %r8
movl %ebx, %r11d
movl %ebx, %ebp
shll $0x8, %ebp
movzbl 0x2(%r8), %ebx
orl %ebp, %ebx
imull $0xfffb, %ebx, %ebp     # imm = 0xFFFB
addl %r11d, %ebp
movzwl %bp, %r11d
movl -0x70(%rsp,%r11,4), %r12d
movl %r8d, %ebp
subl %edi, %ebp
movl %ebp, -0x70(%rsp,%r11,4)
testq %r12, %r12
je 0x27405
leaq (%rdi,%r12), %r15
movq %r15, %r11
notq %r11
addq %r8, %r11
cmpq $0x1fff, %r11           # imm = 0x1FFF
ja 0x27405
movb 0x2(%r15), %bpl
cmpb 0x2(%r8), %bpl
jne 0x27405
movzwl (%r15), %ebp
cmpw (%r8), %bp
jne 0x27405
movl %esi, %ebp
subl %r8d, %ebp
addl $-0x2, %ebp
movl $0x108, %ebx            # imm = 0x108
cmpl %ebx, %ebp
cmovbl %ebp, %ebx
leaq 0x4(%rcx), %r13
cmpq %r9, %r13
jae 0x27501
leal -0x1(%r14), %r13d
cmpl $0x1, %r14d
notl %r14d
movslq %r14d, %r14
movb %r13b, (%rcx,%r14)
sbbq $0x0, %rcx
movl $0x2, %r13d
cmpl $0x11, %ebp
jb 0x273b6
movb 0x3(%r15), %bpl
movl $0x3, %r14d
cmpb 0x3(%r8), %bpl
jne 0x27439
movb 0x4(%r15), %bpl
movl $0x4, %r14d
cmpb 0x4(%r8), %bpl
jne 0x27439
movb 0x5(%r15), %bpl
movl $0x5, %r14d
cmpb 0x5(%r8), %bpl
jne 0x27439
movb 0x6(%r15), %bpl
movl $0x6, %r14d
cmpb 0x6(%r8), %bpl
jne 0x27439
movb 0x7(%r15), %bpl
movl $0x7, %r14d
cmpb 0x7(%r8), %bpl
jne 0x27439
movb 0x8(%r15), %bpl
movl $0x8, %r14d
cmpb 0x8(%r8), %bpl
jne 0x27439
movb 0x9(%r15), %bpl
movl $0x9, %r14d
cmpb 0x9(%r8), %bpl
jne 0x274d9
movb 0xa(%r15), %bpl
movl $0xa, %r14d
cmpb 0xa(%r8), %bpl
jne 0x274d9
movb 0xb(%r15), %bpl
movl $0xb, %r14d
cmpb 0xb(%r8), %bpl
jne 0x274d9
movb 0xc(%r15), %bpl
movl $0xc, %r14d
cmpb 0xc(%r8), %bpl
jne 0x274d9
movb 0xd(%r15), %bpl
movl $0xd, %r14d
cmpb 0xd(%r8), %bpl
jne 0x274d9
movb 0xe(%r15), %bpl
movl $0xe, %r14d
cmpb 0xe(%r8), %bpl
jne 0x274d9
movb 0xf(%r15), %bpl
movl $0xf, %r14d
cmpb 0xf(%r8), %bpl
jne 0x274d9
movb 0x10(%r15), %bpl
movl $0x10, %r14d
cmpb 0x10(%r8), %bpl
jne 0x274d9
movb 0x11(%r15), %bpl
movl $0x11, %r14d
cmpb 0x11(%r8), %bpl
jne 0x274d9
movb 0x12(%r15), %bpl
movl $0x12, %r14d
movl %r14d, %r13d
cmpb 0x12(%r8), %bpl
jne 0x274d9
movl %r13d, %r15d
orl $0x1, %r13d
cmpl %r13d, %ebx
movl %r13d, %r14d
cmoval %ebx, %r14d
movl %ebx, %ebx
movq %rbx, -0x80(%rsp)
leal -0x1(%r14), %ebx
addq -0x78(%rsp), %r12
leaq 0x1(%r15), %rbp
cmpq -0x80(%rsp), %rbp
jae 0x273f6
movb (%r12,%r15), %r13b
cmpb 0x1(%r8,%r15), %r13b
movq %rbp, %r15
je 0x273d7
leal -0x1(%rbp), %ebx
movl %ebp, %r14d
decl %ebx
incq %r8
cmpl $0x6, %ebx
jbe 0x27440
jmp 0x274dc
cmpq %r9, %rcx
jae 0x27519
leal 0x1(%r14), %r11d
movb (%r8), %bpl
incq %r8
movb %bpl, (%rcx)
cmpl $0x20, %r11d
je 0x274f7
incq %rcx
movl %r11d, %r14d
cmpq %r10, %r8
jb 0x271c5
jmp 0x27526
leal -0x2(%r14), %ebx
incq %r8
movl %r11d, %ebp
shrl $0x8, %ebp
shll $0x5, %ebx
orl %ebp, %ebx
movb %bl, (%rcx)
incq %rcx
movq %r8, %rbx
movl %r14d, %r8d
movb %r11b, (%rcx)
addq $0x2, %rcx
decl %r8d
addq %rbx, %r8
cmpq %r10, %r8
jae 0x27523
leaq -0x2(%r8), %rbx
movzbl -0x2(%r8), %ebp
leaq -0x1(%r8), %r11
movzbl -0x1(%r8), %r14d
shll $0x10, %ebp
shll $0x8, %r14d
orl %ebp, %r14d
movzbl (%r8), %ebp
orl %r14d, %ebp
subl %edi, %ebx
shrl $0x8, %r14d
imull $0xfffb, %ebp, %r15d    # imm = 0xFFFB
addl %r14d, %r15d
movl $0xffff, %r12d          # imm = 0xFFFF
andl %r12d, %r15d
movl %ebx, -0x70(%rsp,%r15,4)
movl %ebp, %r14d
shll $0x8, %r14d
movzbl 0x1(%r8), %ebx
orl %r14d, %ebx
subl %edi, %r11d
imull $0xfffb, %ebx, %r14d    # imm = 0xFFFB
addl %ebp, %r14d
andl %r12d, %r14d
movl %r11d, -0x70(%rsp,%r14,4)
xorl %r11d, %r11d
jmp 0x27428
incq %r8
movl %r11d, %ebx
shrl $0x8, %ebx
orb $-0x20, %bl
movb %bl, (%rcx)
leal -0x9(%r14), %ebx
movb %bl, 0x1(%rcx)
addq $0x2, %rcx
jmp 0x27450
movb %r14b, -0x20(%rcx)
addq $0x2, %rcx
jmp 0x274d1
cmpl $0x1, %r14d
movq %rcx, %r13
sbbq $0x0, %r13
addq $0x4, %r13
cmpq %r9, %r13
jb 0x2724e
xorl %eax, %eax
jmp 0x27577
xorl %eax, %eax
retq
movq %rdi, %r8
xorl %r11d, %r11d
leaq 0x3(%rcx), %rdi
cmpq %r9, %rdi
ja 0x27577
cmpq %rsi, %r8
jae 0x2755f
leal 0x1(%r11), %eax
movb (%r8), %dil
movb %dil, (%rcx)
cmpl $0x20, %eax
je 0x27553
incq %rcx
incq %r8
movl %eax, %r11d
cmpq %rsi, %r8
jb 0x27534
jmp 0x27562
movb %r11b, -0x20(%rcx)
addq $0x2, %rcx
xorl %eax, %eax
jmp 0x27546
movl %r11d, %eax
leal -0x1(%rax), %esi
cmpl $0x1, %eax
notl %eax
cltq
movb %sil, (%rcx,%rax)
sbbl $0x0, %ecx
subl %edx, %ecx
movl %ecx, %eax
addq $0x3ff98, %rsp          # imm = 0x3FF98
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq