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

```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,-0x1054(%rbp)
  mov    -0x1054(%rbp),%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x1040(%rbp)
  cmpq   $0x0,-0x1040(%rbp)
  jne    L24
  mov    $0xffffffff,%eax
  jmp    L128
L24:
  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,-0x1060(%rbp)
  movl   $0x0,-0x1058(%rbp)
  jmp    L145
L113:
  mov    -0x1060(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x1078(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%edx
  mov    -0x1058(%rbp),%eax
  cltq
  mov    %dl,-0x1030(%rbp,%rax,1)
  addl   $0x1,-0x1060(%rbp)
  addl   $0x1,-0x1058(%rbp)
L145:
  cmpl   $0x1f,-0x1058(%rbp)
  jg     L32
  mov    -0x1084(%rbp),%eax
  cmp    %eax,-0x1060(%rbp)
  jl     L113
L32:
  mov    -0x1054(%rbp),%eax
  shl    $0x3,%eax
  mov    %eax,-0x105c(%rbp)
  mov    -0x1084(%rbp),%eax
  mov    %eax,-0x1068(%rbp)
  jmp    L14
L65:
  lea    -0x106d(%rbp),%rcx
  lea    -0x106c(%rbp),%rdx
  lea    -0x1030(%rbp),%rsi
  lea    -0x1010(%rbp),%rax
  mov    %rax,%rdi
  call   <compare_win@plt>
  mov    %eax,-0x1050(%rbp)
  cmpl   $0x0,-0x1050(%rbp)
  je     L85
  movq   $0x2000000,-0x1048(%rbp)
  mov    -0x106c(%rbp),%eax
  shl    $0xd,%eax
  movslq %eax,%rdx
  mov    -0x1048(%rbp),%rax
  or     %rdx,%rax
  mov    %rax,-0x1048(%rbp)
  mov    -0x1050(%rbp),%eax
  shl    $0x8,%eax
  movslq %eax,%rdx
  mov    -0x1048(%rbp),%rax
  or     %rdx,%rax
  mov    %rax,-0x1048(%rbp)
  movzbl -0x106d(%rbp),%eax
  movzbl %al,%edx
  mov    -0x1048(%rbp),%rax
  or     %rdx,%rax
  mov    %rax,-0x1048(%rbp)
  movl   $0x1a,-0x1064(%rbp)
  jmp    L155
L85:
  movq   $0x0,-0x1048(%rbp)
  movzbl -0x106d(%rbp),%eax
  movzbl %al,%edx
  mov    -0x1048(%rbp),%rax
  or     %rdx,%rax
  mov    %rax,-0x1048(%rbp)
  movl   $0x9,-0x1064(%rbp)
L155:
  mov    -0x1048(%rbp),%rax
  mov    %rax,%rdi
  call   <htonl@plt>
  mov    %rax,-0x1048(%rbp)
  movl   $0x0,-0x1058(%rbp)
  jmp    L39
L13:
  mov    -0x105c(%rbp),%eax
  and    $0x7,%eax
  test   %eax,%eax
  jne    L35
  mov    -0x105c(%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    L140
  mov    -0x1040(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    $0xffffffff,%eax
  jmp    L128
L140:
  mov    -0x1038(%rbp),%rax
  mov    %rax,-0x1040(%rbp)
L35:
  mov    -0x1058(%rbp),%eax
  mov    -0x1064(%rbp),%edx
  sub    %edx,%eax
  add    $0x40,%eax
  mov    %eax,-0x104c(%rbp)
  mov    -0x104c(%rbp),%edx
  lea    -0x1048(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <bit_get@plt>
  mov    %eax,%edx
  mov    -0x105c(%rbp),%ecx
  mov    -0x1040(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <bit_set@plt>
  addl   $0x1,-0x105c(%rbp)
  addl   $0x1,-0x1058(%rbp)
L39:
  mov    -0x1058(%rbp),%eax
  cmp    -0x1064(%rbp),%eax
  jl     L13
  addl   $0x1,-0x1050(%rbp)
  mov    $0x1000,%eax
  sub    -0x1050(%rbp),%eax
  mov    %eax,%edx
  lea    -0x1010(%rbp),%rcx
  mov    -0x1050(%rbp),%eax
  cltq
  add    %rax,%rcx
  lea    -0x1010(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memmove@plt>
  mov    $0x1000,%eax
  sub    -0x1050(%rbp),%eax
  lea    -0x1010(%rbp),%rdx
  cltq
  lea    (%rdx,%rax,1),%rcx
  mov    -0x1050(%rbp),%edx
  lea    -0x1030(%rbp),%rax
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <memmove@plt>
  mov    $0x20,%eax
  sub    -0x1050(%rbp),%eax
  mov    %eax,%edx
  lea    -0x1030(%rbp),%rcx
  mov    -0x1050(%rbp),%eax
  cltq
  add    %rax,%rcx
  lea    -0x1030(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memmove@plt>
  mov    $0x20,%eax
  sub    -0x1050(%rbp),%eax
  mov    %eax,-0x1058(%rbp)
  jmp    L168
L102:
  mov    -0x1060(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x1078(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%edx
  mov    -0x1058(%rbp),%eax
  cltq
  mov    %dl,-0x1030(%rbp,%rax,1)
  addl   $0x1,-0x1060(%rbp)
  addl   $0x1,-0x1058(%rbp)
L168:
  cmpl   $0x1f,-0x1058(%rbp)
  jg     L29
  mov    -0x1084(%rbp),%eax
  cmp    %eax,-0x1060(%rbp)
  jl     L102
L29:
  mov    -0x1050(%rbp),%eax
  sub    %eax,-0x1068(%rbp)
L14:
  cmpl   $0x0,-0x1068(%rbp)
  jg     L65
  mov    -0x1080(%rbp),%rax
  mov    -0x1040(%rbp),%rdx
  mov    %rdx,(%rax)
  mov    -0x105c(%rbp),%eax
  sub    $0x1,%eax
  lea    0x7(%rax),%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  sar    $0x3,%eax
  add    $0x1,%eax
L128:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L104
  call   <__stack_chk_fail@plt>
L104:
  leave
  ret
```

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