user: Converte this assembly snippet into its equivalent C code:

```asm
<AddLZ77Data>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x58,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    %rcx,-0x50(%rbp)
  mov    %r8,-0x58(%rbp)
  mov    %r9,-0x60(%rbp)
  movq   $0x0,-0x20(%rbp)
  mov    -0x48(%rbp),%rax
  mov    %rax,-0x18(%rbp)
  jmp    L75
L87:
  mov    -0x18(%rbp),%rax
  lea    (%rax,%rax,1),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  movzwl (%rax),%eax
  movzwl %ax,%eax
  mov    %eax,-0x30(%rbp)
  mov    -0x18(%rbp),%rax
  lea    (%rax,%rax,1),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  movzwl (%rax),%eax
  movzwl %ax,%eax
  mov    %eax,-0x2c(%rbp)
  cmpl   $0x0,-0x30(%rbp)
  jne    L13
  cmpl   $0xff,-0x2c(%rbp)
  setbe  %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  mov    -0x2c(%rbp),%eax
  lea    0x0(,%rax,4),%rdx
  mov    0x10(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  test   %eax,%eax
  setne  %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  mov    -0x2c(%rbp),%eax
  lea    0x0(,%rax,4),%rdx
  mov    0x10(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%esi
  mov    -0x2c(%rbp),%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    0x38(%rbp),%rdi
  mov    0x30(%rbp),%rcx
  mov    0x28(%rbp),%rdx
  mov    %rdi,%r8
  mov    %eax,%edi
  call   <AddHuffmanBits@plt>
  addq   $0x1,-0x20(%rbp)
  jmp    L68
L13:
  mov    -0x2c(%rbp),%eax
  mov    %eax,%edi
  call   <GetLengthSymbol@plt>
  mov    %eax,-0x28(%rbp)
  mov    -0x30(%rbp),%eax
  mov    %eax,%edi
  call   <GetDistSymbol@plt>
  mov    %eax,-0x24(%rbp)
  cmpl   $0x2,-0x2c(%rbp)
  jbe    L63
  cmpl   $0x120,-0x2c(%rbp)
  ja     L63
  mov    $0x1,%eax
  jmp    L35
L63:
  mov    $0x0,%eax
L35:
  mov    %eax,%edi
  call   <assert@plt>
  mov    -0x28(%rbp),%eax
  lea    0x0(,%rax,4),%rdx
  mov    0x10(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  test   %eax,%eax
  setne  %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  mov    -0x24(%rbp),%eax
  lea    0x0(,%rax,4),%rdx
  mov    0x20(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  test   %eax,%eax
  setne  %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  mov    -0x28(%rbp),%eax
  lea    0x0(,%rax,4),%rdx
  mov    0x10(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%esi
  mov    -0x28(%rbp),%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    0x38(%rbp),%rdi
  mov    0x30(%rbp),%rcx
  mov    0x28(%rbp),%rdx
  mov    %rdi,%r8
  mov    %eax,%edi
  call   <AddHuffmanBits@plt>
  mov    -0x2c(%rbp),%eax
  mov    %eax,%edi
  call   <GetLengthExtraBits@plt>
  mov    %eax,%ebx
  mov    -0x2c(%rbp),%eax
  mov    %eax,%edi
  call   <GetLengthExtraBitsValue@plt>
  mov    %eax,%edi
  mov    0x38(%rbp),%rcx
  mov    0x30(%rbp),%rdx
  mov    0x28(%rbp),%rax
  mov    %rcx,%r8
  mov    %rdx,%rcx
  mov    %rax,%rdx
  mov    %ebx,%esi
  call   <AddBits@plt>
  mov    -0x24(%rbp),%eax
  lea    0x0(,%rax,4),%rdx
  mov    0x20(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%esi
  mov    -0x24(%rbp),%eax
  lea    0x0(,%rax,4),%rdx
  mov    0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    0x38(%rbp),%rdi
  mov    0x30(%rbp),%rcx
  mov    0x28(%rbp),%rdx
  mov    %rdi,%r8
  mov    %eax,%edi
  call   <AddHuffmanBits@plt>
  mov    -0x30(%rbp),%eax
  mov    %eax,%edi
  call   <GetDistExtraBits@plt>
  mov    %eax,%ebx
  mov    -0x30(%rbp),%eax
  mov    %eax,%edi
  call   <GetDistExtraBitsValue@plt>
  mov    %eax,%edi
  mov    0x38(%rbp),%rcx
  mov    0x30(%rbp),%rdx
  mov    0x28(%rbp),%rax
  mov    %rcx,%r8
  mov    %rdx,%rcx
  mov    %rax,%rdx
  mov    %ebx,%esi
  call   <AddBits@plt>
  mov    -0x2c(%rbp),%eax
  add    %rax,-0x20(%rbp)
L68:
  addq   $0x1,-0x18(%rbp)
L75:
  mov    -0x18(%rbp),%rax
  cmp    -0x50(%rbp),%rax
  jb     L87
  cmpq   $0x0,-0x58(%rbp)
  je     L36
  mov    -0x20(%rbp),%rax
  cmp    -0x58(%rbp),%rax
  jne    L48
L36:
  mov    $0x1,%eax
  jmp    L93
L48:
  mov    $0x0,%eax
L93:
  mov    %eax,%edi
  call   <assert@plt>
  nop
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

assistant: ```c
void AddLZ77Data(const unsigned short *litlens, const unsigned short *dists, size_t lstart, size_t lend, size_t expected_data_size, const unsigned *ll_symbols, const unsigned *ll_lengths, const unsigned *d_symbols, const unsigned *d_lengths, unsigned char *bp, unsigned char **out, size_t *outsize) {
  size_t testlength = 0;
  size_t i;
  for (i = lstart; i < lend; i++) {
    unsigned dist = dists[i];
    unsigned litlen = litlens[i];
    if (dist == 0) {
      assert(litlen < 256);
      assert(ll_lengths[litlen] > 0);
      AddHuffmanBits(ll_symbols[litlen], ll_lengths[litlen], bp, out, outsize);
      testlength++;
    } else {
      unsigned lls = GetLengthSymbol(litlen);
      unsigned ds = GetDistSymbol(dist);
      assert(litlen >= 3 && litlen <= 288);
      assert(ll_lengths[lls] > 0);
      assert(d_lengths[ds] > 0);
      AddHuffmanBits(ll_symbols[lls], ll_lengths[lls], bp, out, outsize);
      AddBits(GetLengthExtraBitsValue(litlen), GetLengthExtraBits(litlen), bp, out, outsize);
      AddHuffmanBits(d_symbols[ds], d_lengths[ds], bp, out, outsize);
      AddBits(GetDistExtraBitsValue(dist), GetDistExtraBits(dist), bp, out, outsize);
      testlength += litlen;
    }
  }
  assert(expected_data_size == 0 || testlength == expected_data_size);
}
```