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    $0x88,%rsp
  mov    %rdi,%r14
  mov    %rsi,0x30(%rsp)
  mov    %edx,0x3c(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x1078(%rsp)
  xor    %eax,%eax
  movq   $0x0,(%rsi)
  mov    $0x4,%edi
  call   <malloc@plt>
  test   %rax,%rax
  je     L66
  mov    %rax,%rbp
  lea    0x3c(%rsp),%rsi
  mov    $0x4,%edx
  mov    %rax,%rdi
  call   <memcpy@plt>
  lea    0x70(%rsp),%rdi
  mov    $0x1000,%edx
  mov    $0x0,%esi
  call   <memset@plt>
  lea    0x50(%rsp),%rdi
  mov    $0x20,%edx
  mov    $0x0,%esi
  call   <memset@plt>
  mov    0x3c(%rsp),%ecx
  mov    %ecx,0x10(%rsp)
  mov    $0x0,%eax
L193:
  mov    %eax,%r13d
  cmp    %eax,%ecx
  jle    L60
  movzbl (%r14,%rax,1),%edx
  mov    %dl,0x50(%rsp,%rax,1)
  lea    0x1(%rax),%r13d
  add    $0x1,%rax
  cmp    $0x20,%rax
  jne    L193
L60:
  cmpl   $0x0,0x10(%rsp)
  jle    L173
  mov    $0x20,%ebx
  lea    0x43(%rsp),%rax
  mov    %rax,0x18(%rsp)
  lea    0x44(%rsp),%rax
  mov    %rax,0x20(%rsp)
  mov    %r13d,0x38(%rsp)
  jmp    L191
L44:
  movzbl 0x43(%rsp),%edi
  mov    $0x9,%r12d
  jmp    L30
L121:
  mov    %rbp,%rdi
  call   <free@plt>
  mov    $0xffffffff,%eax
L157:
  mov    0x1078(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L1
  add    $0x1088,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L82:
  mov    0x8(%rsp),%eax
  lea    (%rax,%r12,1),%esi
  mov    %r13,%rdi
  call   <bit_get@plt>
  mov    %eax,%edx
  mov    %ebx,%esi
  mov    %rbp,%rdi
  call   <bit_set@plt>
  add    $0x1,%ebx
  cmp    %r15d,%ebx
  je     L12
L125:
  mov    %ebx,%r12d
  test   $0x7,%bl
  jne    L82
  lea    0x7(%rbx),%esi
  test   %ebx,%ebx
  cmovns %ebx,%esi
  sar    $0x3,%esi
  add    $0x1,%esi
  mov    %rbp,%rdi
  call   <realloc@plt>
  test   %rax,%rax
  je     L121
  mov    %rax,%rbp
  jmp    L82
L12:
  mov    0x14(%rsp),%eax
  lea    0x1(%rax),%r15d
  mov    $0x1000,%r12d
  sub    %r15d,%r12d
  movslq %r15d,%rcx
  lea    0x70(%rsp),%rax
  mov    %rax,%rsi
  mov    %rcx,0x8(%rsp)
  add    %rcx,%rsi
  mov    %r12d,%edx
  mov    %rax,0x28(%rsp)
  mov    %rax,%rdi
  call   <memmove@plt>
  lea    0x50(%rsp),%r13
  movslq %r12d,%r12
  mov    0x28(%rsp),%rax
  lea    (%rax,%r12,1),%rdi
  mov    %r15d,%edx
  mov    %r13,%rsi
  call   <memmove@plt>
  mov    $0x20,%r12d
  sub    %r15d,%r12d
  mov    0x8(%rsp),%rcx
  lea    0x0(%r13,%rcx,1),%rsi
  mov    %r12d,%edx
  mov    %r13,%rdi
  call   <memmove@plt>
  cmp    $0x1f,%r12d
  jg     L73
  mov    0x3c(%rsp),%ecx
  movslq 0x38(%rsp),%rdx
  mov    0x14(%rsp),%eax
  lea    0x1(%rdx,%rax,1),%rdi
  mov    %rdx,%rax
  movslq %r12d,%r12
  sub    %rdx,%r12
  lea    0x50(%rsp,%r12,1),%rsi
L77:
  cmp    %eax,%ecx
  jle    L69
  movzbl (%r14,%rax,1),%edx
  mov    %dl,(%rsi,%rax,1)
  lea    0x1(%rax),%edx
  add    $0x1,%rax
  cmp    %rdi,%rax
  jne    L77
  mov    %edx,0x38(%rsp)
  jmp    L73
L69:
  mov    %eax,0x38(%rsp)
L73:
  sub    %r15d,0x10(%rsp)
  mov    0x10(%rsp),%eax
  test   %eax,%eax
  jle    L166
L191:
  lea    0x50(%rsp),%rsi
  lea    0x70(%rsp),%rdi
  mov    0x18(%rsp),%rcx
  mov    0x20(%rsp),%rdx
  call   <compare_win@plt>
  mov    %eax,0x14(%rsp)
  test   %eax,%eax
  je     L44
  mov    0x44(%rsp),%edi
  shl    $0xd,%edi
  shl    $0x8,%eax
  or     %eax,%edi
  or     $0x2000000,%edi
  movslq %edi,%rdi
  movzbl 0x43(%rsp),%eax
  or     %rax,%rdi
  mov    $0x1a,%r12d
L30:
  mov    %rdi,0x48(%rsp)
  call   <htonl@plt>
  mov    %rax,0x48(%rsp)
  lea    (%r12,%rbx,1),%r15d
  mov    $0x40,%eax
  sub    %ebx,%eax
  sub    %r12d,%eax
  mov    %eax,0x8(%rsp)
  lea    0x48(%rsp),%r13
  jmp    L125
L173:
  mov    $0x20,%ebx
L166:
  mov    0x30(%rsp),%rax
  mov    %rbp,(%rax)
  lea    0x6(%rbx),%eax
  sub    $0x1,%ebx
  cmovns %ebx,%eax
  sar    $0x3,%eax
  add    $0x1,%eax
  jmp    L157
L66:
  mov    $0xffffffff,%eax
  jmp    L157
L1:
  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;
}
```