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

```asm
<lz77_compress>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x90,%rsp
  mov    %rdi,-0x1078(%rbp)
  mov    %rsi,-0x1080(%rbp)
  mov    %edx,-0x1084(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x1080(%rbp),%rax
  movq   $0x0,(%rax)
  movl   $0x4,-0x104c(%rbp)
  mov    -0x104c(%rbp),%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x1040(%rbp)
  cmpq   $0x0,-0x1040(%rbp)
  jne    L166
  mov    $0xffffffff,%eax
  jmp    L10
L166:
  lea    -0x1084(%rbp),%rcx
  mov    -0x1040(%rbp),%rax
  mov    $0x4,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  lea    -0x1010(%rbp),%rax
  mov    $0x1000,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  lea    -0x1030(%rbp),%rax
  mov    $0x20,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  movl   $0x0,-0x1058(%rbp)
  movl   $0x0,-0x1050(%rbp)
  jmp    L175
L70:
  mov    -0x1058(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x1078(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%edx
  mov    -0x1050(%rbp),%eax
  cltq
  mov    %dl,-0x1030(%rbp,%rax,1)
  addl   $0x1,-0x1058(%rbp)
  addl   $0x1,-0x1050(%rbp)
L175:
  cmpl   $0x1f,-0x1050(%rbp)
  jg     L92
  mov    -0x1084(%rbp),%eax
  cmp    %eax,-0x1058(%rbp)
  jl     L70
L92:
  mov    -0x104c(%rbp),%eax
  shl    $0x3,%eax
  mov    %eax,-0x1054(%rbp)
  mov    -0x1084(%rbp),%eax
  mov    %eax,-0x1060(%rbp)
  jmp    L7
L58:
  lea    -0x1069(%rbp),%rcx
  lea    -0x1064(%rbp),%rdx
  lea    -0x1030(%rbp),%rsi
  lea    -0x1010(%rbp),%rax
  mov    %rax,%rdi
  call   <compare_win@plt>
  mov    %eax,-0x1048(%rbp)
  cmpl   $0x0,-0x1048(%rbp)
  je     L170
  movl   $0x2000000,-0x1068(%rbp)
  mov    -0x1064(%rbp),%eax
  shl    $0xd,%eax
  mov    %eax,%edx
  mov    -0x1068(%rbp),%eax
  or     %edx,%eax
  mov    %eax,-0x1068(%rbp)
  mov    -0x1048(%rbp),%eax
  shl    $0x8,%eax
  mov    %eax,%edx
  mov    -0x1068(%rbp),%eax
  or     %edx,%eax
  mov    %eax,-0x1068(%rbp)
  movzbl -0x1069(%rbp),%eax
  movzbl %al,%edx
  mov    -0x1068(%rbp),%eax
  or     %edx,%eax
  mov    %eax,-0x1068(%rbp)
  movl   $0x1a,-0x105c(%rbp)
  jmp    L42
L170:
  movl   $0x0,-0x1068(%rbp)
  movzbl -0x1069(%rbp),%eax
  movzbl %al,%edx
  mov    -0x1068(%rbp),%eax
  or     %edx,%eax
  mov    %eax,-0x1068(%rbp)
  movl   $0x9,-0x105c(%rbp)
L42:
  mov    -0x1068(%rbp),%eax
  mov    %eax,%edi
  call   <htonl@plt>
  mov    %eax,-0x1068(%rbp)
  movl   $0x0,-0x1050(%rbp)
  jmp    L99
L68:
  mov    -0x1054(%rbp),%eax
  and    $0x7,%eax
  test   %eax,%eax
  jne    L94
  mov    -0x1054(%rbp),%eax
  lea    0x7(%rax),%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  sar    $0x3,%eax
  lea    0x1(%rax),%edx
  mov    -0x1040(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <realloc@plt>
  mov    %rax,-0x1038(%rbp)
  cmpq   $0x0,-0x1038(%rbp)
  jne    L56
  mov    -0x1040(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    $0xffffffff,%eax
  jmp    L10
L56:
  mov    -0x1038(%rbp),%rax
  mov    %rax,-0x1040(%rbp)
L94:
  mov    -0x1050(%rbp),%eax
  mov    -0x105c(%rbp),%edx
  sub    %edx,%eax
  add    $0x20,%eax
  mov    %eax,-0x1044(%rbp)
  mov    -0x1044(%rbp),%edx
  lea    -0x1068(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <bit_get@plt>
  mov    %eax,%edx
  mov    -0x1054(%rbp),%ecx
  mov    -0x1040(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <bit_set@plt>
  addl   $0x1,-0x1054(%rbp)
  addl   $0x1,-0x1050(%rbp)
L99:
  mov    -0x1050(%rbp),%eax
  cmp    -0x105c(%rbp),%eax
  jl     L68
  addl   $0x1,-0x1048(%rbp)
  mov    $0x1000,%eax
  sub    -0x1048(%rbp),%eax
  mov    %eax,%edx
  lea    -0x1010(%rbp),%rcx
  mov    -0x1048(%rbp),%eax
  cltq
  add    %rax,%rcx
  lea    -0x1010(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memmove@plt>
  mov    $0x1000,%eax
  sub    -0x1048(%rbp),%eax
  lea    -0x1010(%rbp),%rdx
  cltq
  lea    (%rdx,%rax,1),%rcx
  mov    -0x1048(%rbp),%edx
  lea    -0x1030(%rbp),%rax
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <memmove@plt>
  mov    $0x20,%eax
  sub    -0x1048(%rbp),%eax
  mov    %eax,%edx
  lea    -0x1030(%rbp),%rcx
  mov    -0x1048(%rbp),%eax
  cltq
  add    %rax,%rcx
  lea    -0x1030(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memmove@plt>
  mov    $0x20,%eax
  sub    -0x1048(%rbp),%eax
  mov    %eax,-0x1050(%rbp)
  jmp    L64
L140:
  mov    -0x1058(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x1078(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%edx
  mov    -0x1050(%rbp),%eax
  cltq
  mov    %dl,-0x1030(%rbp,%rax,1)
  addl   $0x1,-0x1058(%rbp)
  addl   $0x1,-0x1050(%rbp)
L64:
  cmpl   $0x1f,-0x1050(%rbp)
  jg     L53
  mov    -0x1084(%rbp),%eax
  cmp    %eax,-0x1058(%rbp)
  jl     L140
L53:
  mov    -0x1048(%rbp),%eax
  sub    %eax,-0x1060(%rbp)
L7:
  cmpl   $0x0,-0x1060(%rbp)
  jg     L58
  mov    -0x1080(%rbp),%rax
  mov    -0x1040(%rbp),%rdx
  mov    %rdx,(%rax)
  mov    -0x1054(%rbp),%eax
  sub    $0x1,%eax
  lea    0x7(%rax),%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  sar    $0x3,%eax
  add    $0x1,%eax
L10:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L13
  call   <__stack_chk_fail@plt>
L13:
  leave
  ret
```

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;
}
```