user: 请从给定的汇编指令推导出C源代码：

```asm
<lz77_compress>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x98,%rsp
  mov    %rsi,0x40(%rsp)
  mov    %rdi,%r14
  mov    $0x4,%edi
  mov    %edx,0x4c(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x1088(%rsp)
  xor    %eax,%eax
  movq   $0x0,(%rsi)
  call   <malloc@plt>
  test   %rax,%rax
  je     L114
  lea    0x4c(%rsp),%rsi
  mov    $0x4,%edx
  mov    %rax,%rdi
  mov    %rax,%rbp
  call   <memcpy@plt>
  lea    0x80(%rsp),%rax
  lea    0x60(%rsp),%rbx
  xor    %esi,%esi
  mov    $0x1000,%edx
  mov    %rax,%rdi
  mov    %rax,0x18(%rsp)
  call   <memset@plt>
  xor    %esi,%esi
  mov    $0x20,%edx
  mov    %rbx,%rdi
  mov    %rbx,0x10(%rsp)
  call   <memset@plt>
  mov    0x4c(%rsp),%ecx
  xor    %eax,%eax
  mov    %rbx,%rsi
  mov    %ecx,0xc(%rsp)
  jmp    L124
  nopl   0x0(%rax,%rax,1)
L7:
  movzbl (%r14,%rax,1),%edx
  mov    %dl,(%rsi,%rax,1)
  add    $0x1,%rax
  cmp    $0x20,%rax
  je     L6
L124:
  mov    %eax,%ebx
  cmp    %eax,%ecx
  jg     L7
  mov    0xc(%rsp),%eax
  test   %eax,%eax
  jle    L175
L35:
  lea    0x57(%rsp),%rax
  mov    %ebx,0x24(%rsp)
  mov    $0x20,%r15d
  mov    %rax,0x28(%rsp)
  lea    0x5c(%rsp),%rax
  mov    %rax,0x30(%rsp)
  mov    %r14,%rax
  mov    %r15d,%r14d
  mov    %rax,%r15
L159:
  mov    0x28(%rsp),%rcx
  mov    0x30(%rsp),%rdx
  mov    0x10(%rsp),%rsi
  mov    0x18(%rsp),%rdi
  call   <compare_win@plt>
  mov    %eax,0x20(%rsp)
  test   %eax,%eax
  je     L205
  shl    $0x8,%eax
  mov    $0x6,%r12d
  mov    $0x1a,%r13d
  mov    %eax,%edi
  movzbl 0x57(%rsp),%eax
  or     %eax,%edi
  mov    0x5c(%rsp),%eax
  shl    $0xd,%eax
  or     %eax,%edi
  or     $0x2000000,%edi
L145:
  mov    %edi,0x58(%rsp)
  add    %r14d,%r13d
  mov    %r14d,%ebx
  sub    %r14d,%r12d
  call   <htonl@plt>
  mov    %eax,0x58(%rsp)
  jmp    L207
  nopl   0x0(%rax,%rax,1)
L20:
  mov    %r14d,%ebx
L207:
  test   $0x7,%r14b
  jne    L95
  mov    %r14d,%esi
  mov    %rbp,%rdi
  sar    $0x3,%esi
  add    $0x1,%esi
  call   <realloc@plt>
  test   %rax,%rax
  je     L60
  mov    %rax,%rbp
L95:
  lea    (%r12,%r14,1),%esi
  lea    0x58(%rsp),%rdi
  call   <bit_get@plt>
  mov    %r14d,%esi
  mov    %rbp,%rdi
  add    $0x1,%r14d
  mov    %eax,%edx
  call   <bit_set@plt>
  cmp    %r13d,%r14d
  jne    L20
  mov    0x20(%rsp),%eax
  mov    %ebx,0x48(%rsp)
  mov    $0x1000,%r12d
  mov    0x18(%rsp),%rbx
  lea    0x1(%rax),%r13d
  movslq %r13d,%rcx
  sub    %r13d,%r12d
  mov    %rbx,%rdi
  lea    (%rbx,%rcx,1),%rsi
  mov    %r12d,%edx
  mov    %rcx,0x38(%rsp)
  call   <memmove@plt>
  movslq %r12d,%rdi
  mov    %r13d,%edx
  mov    $0x20,%r12d
  add    %rbx,%rdi
  mov    0x10(%rsp),%rbx
  sub    %r13d,%r12d
  mov    %rbx,%rsi
  call   <memmove@plt>
  mov    0x38(%rsp),%rcx
  mov    %r12d,%edx
  mov    %rbx,%rdi
  lea    (%rbx,%rcx,1),%rsi
  call   <memmove@plt>
  cmp    $0x1f,%r12d
  jg     L108
  movslq 0x24(%rsp),%rax
  mov    0x20(%rsp),%edx
  movslq %r12d,%r12
  mov    0x4c(%rsp),%ecx
  sub    %rax,%r12
  lea    0x1(%rax,%rdx,1),%rsi
  lea    (%rbx,%r12,1),%rdx
  jmp    L62
  nopw   0x0(%rax,%rax,1)
L156:
  movzbl (%r15,%rax,1),%edi
  lea    0x1(%rax),%ebx
  mov    %dil,(%rdx,%rax,1)
  add    $0x1,%rax
  cmp    %rsi,%rax
  je     L198
L62:
  mov    %eax,%ebx
  cmp    %eax,%ecx
  jg     L156
L198:
  mov    %ebx,0x24(%rsp)
L108:
  sub    %r13d,0xc(%rsp)
  mov    0xc(%rsp),%eax
  test   %eax,%eax
  jg     L159
  mov    0x48(%rsp),%eax
  sar    $0x3,%eax
  add    $0x1,%eax
L37:
  mov    0x40(%rsp),%rcx
  mov    %rbp,(%rcx)
  jmp    L170
  nopl   0x0(%rax)
L205:
  movzbl 0x57(%rsp),%edi
  mov    $0x17,%r12d
  mov    $0x9,%r13d
  jmp    L145
  cs nopw 0x0(%rax,%rax,1)
L60:
  mov    %rbp,%rdi
  call   <free@plt>
  mov    $0xffffffff,%eax
L170:
  mov    0x1088(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L26
  add    $0x1098,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L6:
  mov    $0x20,%ebx
  jmp    L35
L175:
  mov    $0x4,%eax
  jmp    L37
L114:
  mov    $0xffffffff,%eax
  jmp    L170
L26:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int lz77_compress(const unsigned char *original, unsigned char **compressed, int size) {
  unsigned int token;
  unsigned char window[4096], buffer[32], *comp, *temp, next;
  int offset, length, remaining, tbits, hsize, ipos, opos, tpos, i;
  *compressed = NULL;
  hsize = sizeof(int);
  if ((comp = (unsigned char *)malloc(hsize)) == NULL)
    return -1;
  memcpy(comp, &size, sizeof(int));
  memset(window, 0, 4096);
  memset(buffer, 0, 32);
  ipos = 0;
  for (i = 0; i < 32 && ipos < size; i++) {
    buffer[i] = original[ipos];
    ipos++;
  }
  opos = hsize * 8;
  remaining = size;
  while (remaining > 0) {
    if ((length = compare_win(window, buffer, &offset, &next)) != 0) {
      token = 0x00000001 << ((1 + 12 + 8 + 5) - 1);
      token = token | (offset << ((1 + 12 + 8 + 5) - 1 - 12));
      token = token | (length << ((1 + 12 + 8 + 5) - 1 - 12 - 5));
      token = token | next;
      tbits = (1 + 12 + 8 + 5);
    } else {
      token = 0x00000000;
      token = token | next;
      tbits = (1 + 8);
    }
    token = htonl(token);
    for (i = 0; i < tbits; i++) {
      if (opos % 8 == 0) {
        if ((temp = (unsigned char *)realloc(comp, (opos / 8) + 1)) == NULL) {
          free(comp);
          return -1;
        }
        comp = temp;
      }
      tpos = (sizeof(unsigned int) * 8) - tbits + i;
      bit_set(comp, opos, bit_get((unsigned char *)&token, tpos));
      opos++;
    }
    length++;
    memmove(&window[0], &window[length], 4096 - length);
    memmove(&window[4096 - length], &buffer[0], length);
    memmove(&buffer[0], &buffer[length], 32 - length);
    for (i = 32 - length; i < 32 && ipos < size; i++) {
      buffer[i] = original[ipos];
      ipos++;
    }
    remaining = remaining - length;
  }
  *compressed = comp;
  return ((opos - 1) / 8) + 1;
}
```