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     L68
  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    L28
  nopl   0x0(%rax,%rax,1)
L57:
  movzbl (%r14,%rax,1),%edx
  mov    %dl,(%rsi,%rax,1)
  add    $0x1,%rax
  cmp    $0x20,%rax
  je     L168
L28:
  mov    %eax,%ebx
  cmp    %eax,%ecx
  jg     L57
  mov    0xc(%rsp),%eax
  test   %eax,%eax
  jle    L169
L183:
  lea    0x53(%rsp),%rax
  mov    %ebx,0x24(%rsp)
  mov    $0x20,%r15d
  mov    %rax,0x28(%rsp)
  lea    0x54(%rsp),%rax
  mov    %rax,0x30(%rsp)
  mov    %r14,0x38(%rsp)
L83:
  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     L17
  mov    0x54(%rsp),%edi
  shl    $0x8,%eax
  mov    $0x1a,%r13d
  shl    $0xd,%edi
  or     %eax,%edi
  movzbl 0x53(%rsp),%eax
  or     $0x2000000,%edi
  movslq %edi,%rdi
  or     %rax,%rdi
L133:
  mov    $0x40,%r12d
  mov    %rdi,0x58(%rsp)
  lea    0x0(%r13,%r15,1),%r14d
  mov    %r15d,%ebx
  call   <htonl@plt>
  sub    %r15d,%r12d
  sub    %r13d,%r12d
  mov    %rax,0x58(%rsp)
  lea    0x58(%rsp),%r13
  jmp    L99
  nopl   (%rax)
L2:
  mov    %r15d,%ebx
L99:
  test   $0x7,%r15b
  jne    L164
  mov    %r15d,%esi
  mov    %rbp,%rdi
  sar    $0x3,%esi
  add    $0x1,%esi
  call   <realloc@plt>
  test   %rax,%rax
  je     L205
  mov    %rax,%rbp
L164:
  lea    (%r12,%r15,1),%esi
  mov    %r13,%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    L2
  mov    0x20(%rsp),%eax
  mov    %ebx,0x48(%rsp)
  mov    $0x1000,%r12d
  mov    0x18(%rsp),%rbx
  lea    0x1(%rax),%r13d
  sub    %r13d,%r12d
  movslq %r13d,%r14
  mov    %rbx,%rdi
  lea    (%rbx,%r14,1),%rsi
  mov    %r12d,%edx
  call   <memmove@plt>
  movslq %r12d,%rdi
  mov    $0x20,%r12d
  mov    %r13d,%edx
  add    %rbx,%rdi
  mov    0x10(%rsp),%rbx
  sub    %r13d,%r12d
  mov    %rbx,%rsi
  call   <memmove@plt>
  lea    (%rbx,%r14,1),%rsi
  mov    %r12d,%edx
  mov    %rbx,%rdi
  call   <memmove@plt>
  cmp    $0x1f,%r12d
  jg     L112
  movslq 0x24(%rsp),%rax
  mov    0x20(%rsp),%edx
  movslq %r12d,%r12
  mov    0x4c(%rsp),%ecx
  mov    0x38(%rsp),%r8
  sub    %rax,%r12
  lea    0x1(%rax,%rdx,1),%rsi
  lea    (%rbx,%r12,1),%rdx
  jmp    L111
  nopl   0x0(%rax,%rax,1)
L208:
  movzbl (%r8,%rax,1),%edi
  lea    0x1(%rax),%ebx
  mov    %dil,(%rdx,%rax,1)
  add    $0x1,%rax
  cmp    %rsi,%rax
  je     L192
L111:
  mov    %eax,%ebx
  cmp    %eax,%ecx
  jg     L208
L192:
  mov    %ebx,0x24(%rsp)
L112:
  sub    %r13d,0xc(%rsp)
  mov    0xc(%rsp),%eax
  test   %eax,%eax
  jg     L83
  mov    0x48(%rsp),%eax
  sar    $0x3,%eax
  add    $0x1,%eax
L159:
  mov    0x40(%rsp),%rcx
  mov    %rbp,(%rcx)
  jmp    L90
  nopl   0x0(%rax)
L17:
  movzbl 0x53(%rsp),%edi
  mov    $0x9,%r13d
  jmp    L133
L205:
  mov    %rbp,%rdi
  call   <free@plt>
  mov    $0xffffffff,%eax
L90:
  mov    0x1088(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L176
  add    $0x1098,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L168:
  mov    $0x20,%ebx
  jmp    L183
L169:
  mov    $0x4,%eax
  jmp    L159
L68:
  mov    $0xffffffff,%eax
  jmp    L90
L176:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int lz77_compress(const unsigned char *original, unsigned char **compressed, int size) {
  unsigned long 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 long) * 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;
}
```