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

```asm
<OptimizeHuffmanForRle>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %edi,-0x34(%rbp)
  mov    %rsi,-0x40(%rbp)
  jmp    L42
L344:
  cmpl   $0x0,-0x34(%rbp)
  je     L43
  mov    -0x34(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  test   %rax,%rax
  jne    L236
  subl   $0x1,-0x34(%rbp)
L42:
  cmpl   $0x0,-0x34(%rbp)
  jns    L344
  jmp    L181
L236:
  nop
L181:
  mov    -0x34(%rbp),%eax
  cltq
  shl    $0x2,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x8(%rbp)
  movl   $0x0,-0x30(%rbp)
  jmp    L166
L201:
  mov    -0x30(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movl   $0x0,(%rax)
  addl   $0x1,-0x30(%rbp)
L166:
  mov    -0x30(%rbp),%eax
  cmp    -0x34(%rbp),%eax
  jl     L201
  mov    -0x40(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,-0x20(%rbp)
  movl   $0x0,-0x28(%rbp)
  movl   $0x0,-0x30(%rbp)
  jmp    L336
L8:
  mov    -0x30(%rbp),%eax
  cmp    -0x34(%rbp),%eax
  je     L299
  mov    -0x30(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  cmp    %rax,-0x20(%rbp)
  je     L208
L299:
  cmpq   $0x0,-0x20(%rbp)
  jne    L47
  cmpl   $0x4,-0x28(%rbp)
  jg     L150
L47:
  cmpq   $0x0,-0x20(%rbp)
  je     L53
  cmpl   $0x6,-0x28(%rbp)
  jle    L53
L150:
  movl   $0x0,-0x2c(%rbp)
  jmp    L241
L123:
  mov    -0x30(%rbp),%eax
  sub    -0x2c(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movl   $0x1,(%rax)
  addl   $0x1,-0x2c(%rbp)
L241:
  mov    -0x2c(%rbp),%eax
  cmp    -0x28(%rbp),%eax
  jl     L123
L53:
  movl   $0x1,-0x28(%rbp)
  mov    -0x30(%rbp),%eax
  cmp    -0x34(%rbp),%eax
  je     L363
  mov    -0x30(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,-0x20(%rbp)
  jmp    L363
L208:
  addl   $0x1,-0x28(%rbp)
L363:
  addl   $0x1,-0x30(%rbp)
L336:
  mov    -0x34(%rbp),%eax
  cmp    -0x30(%rbp),%eax
  jge    L8
  movl   $0x0,-0x28(%rbp)
  mov    -0x40(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,-0x10(%rbp)
  movq   $0x0,-0x18(%rbp)
  movl   $0x0,-0x30(%rbp)
  jmp    L113
L167:
  mov    -0x30(%rbp),%eax
  cmp    -0x34(%rbp),%eax
  je     L137
  mov    -0x30(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  test   %eax,%eax
  jne    L137
  mov    -0x30(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    -0x10(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <AbsDiff@plt>
  cmp    $0x3,%eax
  jle    L164
L137:
  cmpl   $0x3,-0x28(%rbp)
  jg     L263
  cmpl   $0x2,-0x28(%rbp)
  jle    L355
  cmpq   $0x0,-0x18(%rbp)
  jne    L355
L263:
  mov    -0x28(%rbp),%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    -0x28(%rbp),%edx
  movslq %edx,%rsi
  mov    $0x0,%edx
  div    %rsi
  mov    %eax,-0x24(%rbp)
  cmpl   $0x0,-0x24(%rbp)
  jg     L46
  movl   $0x1,-0x24(%rbp)
L46:
  cmpq   $0x0,-0x18(%rbp)
  jne    L59
  movl   $0x0,-0x24(%rbp)
L59:
  movl   $0x0,-0x2c(%rbp)
  jmp    L86
L271:
  mov    -0x30(%rbp),%eax
  sub    -0x2c(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x40(%rbp),%rax
  add    %rax,%rdx
  mov    -0x24(%rbp),%eax
  cltq
  mov    %rax,(%rdx)
  addl   $0x1,-0x2c(%rbp)
L86:
  mov    -0x2c(%rbp),%eax
  cmp    -0x28(%rbp),%eax
  jl     L271
L355:
  movl   $0x0,-0x28(%rbp)
  movq   $0x0,-0x18(%rbp)
  mov    -0x34(%rbp),%eax
  sub    $0x3,%eax
  cmp    %eax,-0x30(%rbp)
  jge    L284
  mov    -0x30(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x30(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,8),%rcx
  mov    -0x40(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%rax
  add    %rax,%rdx
  mov    -0x30(%rbp),%eax
  cltq
  add    $0x2,%rax
  lea    0x0(,%rax,8),%rcx
  mov    -0x40(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%rax
  add    %rax,%rdx
  mov    -0x30(%rbp),%eax
  cltq
  add    $0x3,%rax
  lea    0x0(,%rax,8),%rcx
  mov    -0x40(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%rax
  add    %rdx,%rax
  add    $0x2,%rax
  shr    $0x2,%rax
  mov    %rax,-0x10(%rbp)
  jmp    L164
L284:
  mov    -0x30(%rbp),%eax
  cmp    -0x34(%rbp),%eax
  jge    L40
  mov    -0x30(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,-0x10(%rbp)
  jmp    L164
L40:
  movq   $0x0,-0x10(%rbp)
L164:
  addl   $0x1,-0x28(%rbp)
  mov    -0x30(%rbp),%eax
  cmp    -0x34(%rbp),%eax
  je     L180
  mov    -0x30(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  add    %rax,-0x18(%rbp)
L180:
  addl   $0x1,-0x30(%rbp)
L113:
  mov    -0x34(%rbp),%eax
  cmp    -0x30(%rbp),%eax
  jge    L167
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  jmp    L77
L43:
  nop
L77:
  leave
  ret
```

assistant: ```c
void OptimizeHuffmanForRle(int length, size_t *counts) {
  int i, k, stride;
  size_t symbol, sum, limit;
  int *good_for_rle;
  for (; length >= 0; --length) {
    if (length == 0) {
      return;
    }
    if (counts[length - 1] != 0) {
      break;
    }
  }
  good_for_rle = (int *)malloc(length * sizeof(int));
  for (i = 0; i < length; ++i)
    good_for_rle[i] = 0;
  symbol = counts[0];
  stride = 0;
  for (i = 0; i < length + 1; ++i) {
    if (i == length || counts[i] != symbol) {
      if ((symbol == 0 && stride >= 5) || (symbol != 0 && stride >= 7)) {
        for (k = 0; k < stride; ++k) {
          good_for_rle[i - k - 1] = 1;
        }
      }
      stride = 1;
      if (i != length) {
        symbol = counts[i];
      }
    } else {
      ++stride;
    }
  }
  stride = 0;
  limit = counts[0];
  sum = 0;
  for (i = 0; i < length + 1; ++i) {
    if (i == length || good_for_rle[i] || AbsDiff(counts[i], limit) >= 4) {
      if (stride >= 4 || (stride >= 3 && sum == 0)) {
        int count = (sum + stride / 2) / stride;
        if (count < 1)
          count = 1;
        if (sum == 0) {
          count = 0;
        }
        for (k = 0; k < stride; ++k) {
          counts[i - k - 1] = count;
        }
      }
      stride = 0;
      sum = 0;
      if (i < length - 3) {
        limit = (counts[i] + counts[i + 1] + counts[i + 2] + counts[i + 3] + 2) / 4;
      } else if (i < length) {
        limit = counts[i];
      } else {
        limit = 0;
      }
    }
    ++stride;
    if (i != length) {
      sum += counts[i];
    }
  }
  free(good_for_rle);
}
```