user: What would the C source look like for the assembly code provided here:

```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     L57
  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    L102
  nopl   0x0(%rax,%rax,1)
L140:
  movzbl (%r14,%rax,1),%edx
  mov    %dl,(%rsi,%rax,1)
  add    $0x1,%rax
  cmp    $0x20,%rax
  je     L173
L102:
  mov    %eax,%r13d
  cmp    %eax,%ecx
  jg     L140
  mov    0xc(%rsp),%eax
  test   %eax,%eax
  jle    L72
L132:
  lea    0x57(%rsp),%rax
  mov    %r13d,0x24(%rsp)
  mov    $0x20,%r15d
  mov    %rax,0x28(%rsp)
  lea    0x5c(%rsp),%rax
  mov    %rax,0x30(%rsp)
  mov    %r14,0x38(%rsp)
L95:
  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     L164
  shl    $0x8,%eax
  mov    $0x1a,%r12d
  mov    %eax,%edi
  movzbl 0x57(%rsp),%eax
  or     %eax,%edi
  mov    0x5c(%rsp),%eax
  shl    $0xd,%eax
  or     %eax,%edi
  or     $0x2000000,%edi
L196:
  mov    $0x20,%ebx
  mov    %edi,0x58(%rsp)
  lea    (%r12,%r15,1),%r14d
  mov    %r15d,%r13d
  call   <htonl@plt>
  sub    %r15d,%ebx
  sub    %r12d,%ebx
  mov    %eax,0x58(%rsp)
  lea    0x58(%rsp),%r12
  jmp    L70
  nopl   0x0(%rax)
L204:
  mov    %r15d,%r13d
L70:
  test   $0x7,%r15b
  jne    L100
  mov    %r15d,%esi
  mov    %rbp,%rdi
  sar    $0x3,%esi
  add    $0x1,%esi
  call   <realloc@plt>
  test   %rax,%rax
  je     L182
  mov    %rax,%rbp
L100:
  lea    (%rbx,%r15,1),%esi
  mov    %r12,%rdi
  call   <bit_get@plt>
  mov    %r15d,%esi
  mov    %rbp,%rdi
  add    $0x1,%r15d
  mov    %eax,%edx
  call   <bit_set@plt>
  cmp    %r14d,%r15d
  jne    L204
  mov    0x20(%rsp),%eax
  mov    %r13d,0x48(%rsp)
  mov    $0x1000,%ebx
  mov    0x18(%rsp),%r13
  lea    0x1(%rax),%r12d
  sub    %r12d,%ebx
  movslq %r12d,%r14
  mov    %r13,%rdi
  lea    0x0(%r13,%r14,1),%rsi
  mov    %ebx,%edx
  call   <memmove@plt>
  movslq %ebx,%rdi
  mov    $0x20,%ebx
  mov    %r12d,%edx
  add    %r13,%rdi
  mov    0x10(%rsp),%r13
  sub    %r12d,%ebx
  mov    %r13,%rsi
  call   <memmove@plt>
  lea    0x0(%r13,%r14,1),%rsi
  mov    %ebx,%edx
  mov    %r13,%rdi
  call   <memmove@plt>
  cmp    $0x1f,%ebx
  jg     L109
  movslq 0x24(%rsp),%rax
  mov    0x20(%rsp),%edx
  movslq %ebx,%rbx
  mov    0x4c(%rsp),%ecx
  mov    0x38(%rsp),%r8
  sub    %rax,%rbx
  lea    0x1(%rax,%rdx,1),%rsi
  lea    0x0(%r13,%rbx,1),%rdx
  jmp    L73
  nopw   0x0(%rax,%rax,1)
L171:
  movzbl (%r8,%rax,1),%edi
  lea    0x1(%rax),%r13d
  mov    %dil,(%rdx,%rax,1)
  add    $0x1,%rax
  cmp    %rsi,%rax
  je     L199
L73:
  mov    %eax,%r13d
  cmp    %eax,%ecx
  jg     L171
L199:
  mov    %r13d,0x24(%rsp)
L109:
  sub    %r12d,0xc(%rsp)
  mov    0xc(%rsp),%eax
  test   %eax,%eax
  jg     L95
  mov    0x48(%rsp),%eax
  sar    $0x3,%eax
  add    $0x1,%eax
L105:
  mov    0x40(%rsp),%rcx
  mov    %rbp,(%rcx)
  jmp    L157
  nop
L164:
  movzbl 0x57(%rsp),%edi
  mov    $0x9,%r12d
  jmp    L196
L182:
  mov    %rbp,%rdi
  call   <free@plt>
  mov    $0xffffffff,%eax
L157:
  mov    0x1088(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L197
  add    $0x1098,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L173:
  mov    $0x20,%r13d
  jmp    L132
L72:
  mov    $0x4,%eax
  jmp    L105
L57:
  mov    $0xffffffff,%eax
  jmp    L157
L197:
  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;
}
```