user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<HuffmanCodeLengthsToCodes>:
  endbr64
  push   %r12
  pxor   %xmm0,%xmm0
  mov    %esi,%r12d
  push   %rbp
  mov    %rdx,%rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x90,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x88(%rsp)
  xor    %eax,%eax
  test   %rdi,%rdi
  movaps %xmm0,(%rsp)
  setne  %dil
  movaps %xmm0,0x10(%rsp)
  movzbl %dil,%edi
  movaps %xmm0,0x20(%rsp)
  movaps %xmm0,0x30(%rsp)
  movaps %xmm0,0x40(%rsp)
  movaps %xmm0,0x50(%rsp)
  movaps %xmm0,0x60(%rsp)
  movaps %xmm0,0x70(%rsp)
  call   <assert@plt>
  xor    %edi,%edi
  test   %r12d,%r12d
  setg   %dil
  call   <assert@plt>
  xor    %edi,%edi
  test   %rbp,%rbp
  setne  %dil
  call   <assert@plt>
  test   %r12d,%r12d
  jle    L86
  lea    -0x1(%r12),%ecx
  cmp    $0x2,%ecx
  jbe    L109
  mov    %r12d,%edx
  mov    %rbx,%rax
  pxor   %xmm2,%xmm2
  shr    $0x2,%edx
  sub    $0x1,%edx
  shl    $0x4,%rdx
  lea    0x10(%rbx,%rdx,1),%rdx
  nopw   0x0(%rax,%rax,1)
L236:
  movdqu (%rax),%xmm0
  add    $0x10,%rax
  movdqa %xmm0,%xmm1
  pcmpgtd %xmm2,%xmm1
  pand   %xmm1,%xmm0
  pandn  %xmm2,%xmm1
  movdqa %xmm1,%xmm2
  por    %xmm0,%xmm2
  cmp    %rdx,%rax
  jne    L236
  movdqa %xmm2,%xmm1
  mov    %r12d,%eax
  psrldq $0x8,%xmm1
  and    $0xfffffffc,%eax
  movdqa %xmm1,%xmm0
  pcmpgtd %xmm2,%xmm0
  pand   %xmm0,%xmm1
  pandn  %xmm2,%xmm0
  por    %xmm1,%xmm0
  movdqa %xmm0,%xmm2
  psrldq $0x4,%xmm2
  movdqa %xmm2,%xmm1
  pcmpgtd %xmm0,%xmm1
  pand   %xmm1,%xmm2
  pandn  %xmm0,%xmm1
  por    %xmm2,%xmm1
  movd   %xmm1,%edx
  test   $0x3,%r12b
  je     L237
L23:
  movslq %eax,%rsi
  lea    0x0(,%rsi,4),%rdi
  mov    (%rbx,%rsi,4),%esi
  cmp    %esi,%edx
  cmovl  %esi,%edx
  lea    0x1(%rax),%esi
  cmp    %esi,%r12d
  jle    L237
  mov    0x4(%rbx,%rdi,1),%esi
  cmp    %esi,%edx
  cmovl  %esi,%edx
  add    $0x2,%eax
  cmp    %eax,%r12d
  jle    L237
  mov    0x8(%rbx,%rdi,1),%eax
  cmp    %eax,%edx
  cmovl  %eax,%edx
L237:
  xor    %eax,%eax
  cmp    $0xf,%edx
  jg     L55
  mov    %rbx,%rax
  lea    0x4(%rbx,%rcx,4),%rsi
  nop
L273:
  movslq (%rax),%rcx
  add    $0x4,%rax
  addl   $0x1,(%rsp,%rcx,4)
  cmp    %rsi,%rax
  jne    L273
  movl   $0xffffffff,0x40(%rsp)
  test   %edx,%edx
  jle    L206
  cmp    $0x1,%edx
  je     L206
  mov    0x4(%rsp),%eax
  add    %eax,%eax
  mov    %eax,0x48(%rsp)
  cmp    $0x2,%edx
  je     L206
  add    0x8(%rsp),%eax
  add    %eax,%eax
  mov    %eax,0x4c(%rsp)
  cmp    $0x3,%edx
  je     L206
  add    0xc(%rsp),%eax
  add    %eax,%eax
  mov    %eax,0x50(%rsp)
  cmp    $0x4,%edx
  je     L206
  add    0x10(%rsp),%eax
  add    %eax,%eax
  mov    %eax,0x54(%rsp)
  cmp    $0x5,%edx
  je     L206
  add    0x14(%rsp),%eax
  add    %eax,%eax
  mov    %eax,0x58(%rsp)
  cmp    $0x6,%edx
  je     L206
  add    0x18(%rsp),%eax
  add    %eax,%eax
  mov    %eax,0x5c(%rsp)
  cmp    $0x7,%edx
  je     L206
  add    0x1c(%rsp),%eax
  add    %eax,%eax
  mov    %eax,0x60(%rsp)
  cmp    $0x8,%edx
  je     L206
  add    0x20(%rsp),%eax
  add    %eax,%eax
  mov    %eax,0x64(%rsp)
  cmp    $0x9,%edx
  je     L206
  add    0x24(%rsp),%eax
  add    %eax,%eax
  mov    %eax,0x68(%rsp)
  cmp    $0xa,%edx
  je     L206
  add    0x28(%rsp),%eax
  add    %eax,%eax
  mov    %eax,0x6c(%rsp)
  cmp    $0xb,%edx
  je     L206
  add    0x2c(%rsp),%eax
  add    %eax,%eax
  mov    %eax,0x70(%rsp)
  cmp    $0xc,%edx
  je     L206
  add    0x30(%rsp),%eax
  add    %eax,%eax
  mov    %eax,0x74(%rsp)
  cmp    $0xd,%edx
  je     L206
  add    0x34(%rsp),%eax
  add    %eax,%eax
  mov    %eax,0x78(%rsp)
  cmp    $0xf,%edx
  jne    L206
  add    0x38(%rsp),%eax
  add    %eax,%eax
  mov    %eax,0x7c(%rsp)
  nopw   0x0(%rax,%rax,1)
L206:
  mov    %r12d,%r12d
  xor    %eax,%eax
  nopl   (%rax)
L148:
  movslq (%rbx,%rax,4),%rdx
  test   %edx,%edx
  jle    L36
  mov    0x40(%rsp,%rdx,4),%ecx
  mov    %ecx,0x0(%rbp,%rax,4)
  lea    0x1(%rcx),%esi
  add    $0x1,%rax
  mov    %esi,0x40(%rsp,%rdx,4)
  cmp    %r12,%rax
  jne    L148
L86:
  mov    $0x1,%eax
L55:
  mov    0x88(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L281
  add    $0x90,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax)
L36:
  movl   $0xffffffff,0x0(%rbp,%rax,4)
  add    $0x1,%rax
  cmp    %rax,%r12
  jne    L148
  jmp    L86
L109:
  xor    %edx,%edx
  xor    %eax,%eax
  jmp    L23
L281:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int HuffmanCodeLengthsToCodes(const int *const code_lengths, int code_lengths_size, int *const huff_codes) {
  int symbol;
  int code_len;
  int code_length_hist[15 + 1] = {0};
  int curr_code;
  int next_codes[15 + 1] = {0};
  int max_code_length = 0;
  assert(code_lengths != NULL);
  assert(code_lengths_size > 0);
  assert(huff_codes != NULL);
  for (symbol = 0; symbol < code_lengths_size; ++symbol) {
    if (code_lengths[symbol] > max_code_length) {
      max_code_length = code_lengths[symbol];
    }
  }
  if (max_code_length > 15)
    return 0;
  for (symbol = 0; symbol < code_lengths_size; ++symbol) {
    ++code_length_hist[code_lengths[symbol]];
  }
  code_length_hist[0] = 0;
  curr_code = 0;
  next_codes[0] = -1;
  for (code_len = 1; code_len <= max_code_length; ++code_len) {
    curr_code = (curr_code + code_length_hist[code_len - 1]) << 1;
    next_codes[code_len] = curr_code;
  }
  for (symbol = 0; symbol < code_lengths_size; ++symbol) {
    if (code_lengths[symbol] > 0) {
      huff_codes[symbol] = next_codes[code_lengths[symbol]]++;
    } else {
      huff_codes[symbol] = (-1);
    }
  }
  return 1;
}
```