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

```asm
<OptimizeHuffmanForRle>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  test   %edi,%edi
  js     L328
  je     L53
  mov    %rsi,%rbx
  movslq %edi,%rax
  jmp    L298
  nopl   0x0(%rax,%rax,1)
L365:
  sub    $0x1,%rax
  test   %eax,%eax
  je     L53
L298:
  cmpq   $0x0,-0x8(%rbx,%rax,8)
  mov    %eax,%ebp
  je     L365
  lea    0x0(,%rax,4),%edi
  call   <malloc@plt>
  mov    %rax,0x18(%rsp)
  mov    %rax,%rcx
  test   %ebp,%ebp
  jle    L218
  lea    -0x1(%rbp),%eax
  mov    %rcx,%rdi
  xor    %esi,%esi
  lea    0x4(,%rax,4),%rdx
  call   <memset@plt>
  mov    (%rbx),%r8
  mov    %rax,%rcx
L61:
  mov    %rcx,%rdi
  mov    %r8,%r10
  xor    %edx,%edx
  xor    %r9d,%r9d
  jmp    L137
  nopw   0x0(%rax,%rax,1)
L259:
  cmp    $0x4,%r9d
  jg     L345
  test   %r10,%r10
  jne    L194
L27:
  cmp    %r11d,%ebp
  je     L180
  mov    (%rbx,%rdx,8),%r10
L180:
  add    $0x1,%rdx
  mov    $0x1,%r9d
  add    $0x4,%rdi
  cmp    %edx,%ebp
  jl     L290
L137:
  mov    %edx,%r11d
  cmp    %edx,%ebp
  je     L10
  cmp    %r10,(%rbx,%rdx,8)
  je     L286
L10:
  test   %r10,%r10
  je     L259
L194:
  cmp    $0x6,%r9d
  jle    L27
L345:
  sub    $0x1,%r9d
  lea    -0x8(%rdi),%rsi
  lea    -0x4(%rdi),%rax
  shl    $0x2,%r9
  sub    %r9,%rsi
  nopl   0x0(%rax)
L367:
  movl   $0x1,(%rax)
  sub    $0x4,%rax
  cmp    %rax,%rsi
  jne    L367
  jmp    L27
  nopl   0x0(%rax)
L286:
  add    $0x1,%rdx
  add    $0x1,%r9d
  add    $0x4,%rdi
  cmp    %edx,%ebp
  jge    L137
L290:
  xor    %r13d,%r13d
  xor    %r15d,%r15d
  lea    -0x3(%rbp),%r12d
  xor    %r14d,%r14d
  jmp    L315
  nop
L235:
  mov    0x10(%rbx),%rdx
  mov    0x8(%rbx),%rax
  add    (%rbx),%rax
  lea    0x2(%rax,%rdx,1),%r8
  add    0x18(%rbx),%r8
  shr    $0x2,%r8
L141:
  cmp    %r14d,%ebp
  je     L350
  mov    (%rbx),%r13
  mov    $0x1,%r15d
L150:
  add    $0x1,%r14d
  add    $0x8,%rbx
  add    $0x4,%rcx
  cmp    %r14d,%ebp
  jl     L42
L315:
  cmp    %r14d,%ebp
  je     L358
  mov    (%rcx),%eax
  test   %eax,%eax
  je     L154
L358:
  cmp    $0x3,%r15d
  jg     L197
  jne    L69
  test   %r13,%r13
  je     L63
L69:
  cmp    %r14d,%r12d
  jg     L235
  cmp    %r14d,%ebp
  jle    L293
  mov    (%rbx),%r8
  mov    $0x1,%r15d
  mov    %r8,%r13
  jmp    L150
  nopw   0x0(%rax,%rax,1)
L154:
  mov    (%rbx),%rdi
  mov    %r8,%rsi
  mov    %rcx,0x8(%rsp)
  mov    %r8,0x10(%rsp)
  call   <AbsDiff@plt>
  mov    0x8(%rsp),%rcx
  cmp    $0x3,%eax
  jg     L358
  mov    0x10(%rsp),%r8
  add    $0x1,%r15d
  add    (%rbx),%r13
  jmp    L150
L197:
  mov    %r15d,%eax
  xor    %edx,%edx
  movslq %r15d,%rsi
  sar    %eax
  cltq
  add    %r13,%rax
  div    %rsi
  mov    $0x1,%edx
  test   %eax,%eax
  cmovle %edx,%eax
  test   %r13,%r13
  cltq
  cmovne %rax,%r13
L129:
  mov    %rbx,%rdx
  xor    %eax,%eax
  nopw   0x0(%rax,%rax,1)
L175:
  add    $0x1,%eax
  mov    %r13,-0x8(%rdx)
  sub    $0x8,%rdx
  cmp    %r15d,%eax
  jl     L175
  jmp    L69
  nopl   (%rax)
L350:
  mov    $0x1,%r15d
  xor    %r13d,%r13d
  jmp    L150
  cs nopw 0x0(%rax,%rax,1)
L63:
  xor    %r13d,%r13d
  jmp    L129
  nopl   (%rax)
L293:
  xor    %r8d,%r8d
  jmp    L141
L218:
  je     L134
L42:
  mov    0x18(%rsp),%rdi
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1080 <free@plt>
  nopw   0x0(%rax,%rax,1)
L53:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L328:
  shl    $0x2,%edi
  call   <malloc@plt>
  mov    %rax,0x18(%rsp)
  jmp    L42
L134:
  mov    (%rbx),%r8
  jmp    L61
```

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