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

```asm
<AddLZ77Data>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %rdi,0x8(%rsp)
  mov    %rsi,0x10(%rsp)
  mov    %rcx,0x18(%rsp)
  mov    %r8,0x38(%rsp)
  mov    %r9,0x20(%rsp)
  cmp    %rcx,%rdx
  jae    L27
  mov    %rdx,%r15
  movq   $0x0,(%rsp)
  jmp    L8
L19:
  mov    %ebp,%edi
  call   <ZopfliGetLengthSymbol@plt>
  mov    %eax,%r12d
  mov    %ebx,%edi
  call   <ZopfliGetDistSymbol@plt>
  mov    %eax,%r13d
  lea    -0x3(%rbp),%eax
  cmp    $0x11d,%eax
  setbe  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    %r12d,%eax
  mov    0x80(%rsp),%rsi
  mov    %rax,0x28(%rsp)
  lea    (%rsi,%rax,4),%r12
  cmpl   $0x0,(%r12)
  setne  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    %r13d,%edx
  mov    0x90(%rsp),%rsi
  mov    %rdx,0x30(%rsp)
  lea    (%rsi,%rdx,4),%r13
  cmpl   $0x0,0x0(%r13)
  setne  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    0x20(%rsp),%rcx
  mov    0x28(%rsp),%rax
  mov    (%rcx,%rax,4),%edi
  mov    0xa8(%rsp),%r8
  mov    0xa0(%rsp),%rcx
  mov    0x98(%rsp),%rdx
  mov    (%r12),%esi
  call   <AddHuffmanBits@plt>
  mov    %ebp,%edi
  call   <ZopfliGetLengthExtraBits@plt>
  mov    %eax,%r12d
  mov    %ebp,%edi
  call   <ZopfliGetLengthExtraBitsValue@plt>
  mov    %eax,%edi
  mov    0xa8(%rsp),%r8
  mov    0xa0(%rsp),%rcx
  mov    0x98(%rsp),%rdx
  mov    %r12d,%esi
  call   <AddBits@plt>
  mov    0x88(%rsp),%rax
  mov    0x30(%rsp),%rdx
  mov    (%rax,%rdx,4),%edi
  mov    0xa8(%rsp),%r8
  mov    0xa0(%rsp),%rcx
  mov    0x98(%rsp),%rdx
  mov    0x0(%r13),%esi
  call   <AddHuffmanBits@plt>
  mov    %ebx,%edi
  call   <ZopfliGetDistExtraBits@plt>
  mov    %eax,%ebp
  mov    %ebx,%edi
  call   <ZopfliGetDistExtraBitsValue@plt>
  mov    %eax,%edi
  mov    0xa8(%rsp),%r8
  mov    0xa0(%rsp),%rcx
  mov    0x98(%rsp),%rdx
  mov    %ebp,%esi
  call   <AddBits@plt>
  movzwl %r14w,%eax
  add    %rax,(%rsp)
L5:
  add    $0x1,%r15
  cmp    %r15,0x18(%rsp)
  je     L32
L8:
  mov    0x10(%rsp),%rax
  movzwl (%rax,%r15,2),%ebx
  mov    0x8(%rsp),%rax
  movzwl (%rax,%r15,2),%r14d
  movzwl %r14w,%ebp
  test   %ebx,%ebx
  jne    L19
  cmp    $0xff,%ebp
  setbe  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  movzwl %r14w,%r14d
  mov    0x80(%rsp),%rax
  lea    (%rax,%r14,4),%rbx
  cmpl   $0x0,(%rbx)
  setne  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    0x20(%rsp),%rax
  mov    (%rax,%r14,4),%edi
  mov    0xa8(%rsp),%r8
  mov    0xa0(%rsp),%rcx
  mov    0x98(%rsp),%rdx
  mov    (%rbx),%esi
  call   <AddHuffmanBits@plt>
  addq   $0x1,(%rsp)
  jmp    L5
L27:
  movq   $0x0,(%rsp)
L32:
  mov    0x38(%rsp),%rax
  test   %rax,%rax
  sete   %dil
  cmp    (%rsp),%rax
  sete   %al
  or     %eax,%edi
  movzbl %dil,%edi
  call   <assert@plt>
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  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 = ZopfliGetLengthSymbol(litlen);
      unsigned ds = ZopfliGetDistSymbol(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(ZopfliGetLengthExtraBitsValue(litlen), ZopfliGetLengthExtraBits(litlen), bp, out, outsize);
      AddHuffmanBits(d_symbols[ds], d_lengths[ds], bp, out, outsize);
      AddBits(ZopfliGetDistExtraBitsValue(dist), ZopfliGetDistExtraBits(dist), bp, out, outsize);
      testlength += litlen;
    }
  }
  assert(expected_data_size == 0 || testlength == expected_data_size);
}
```