user: 请从给定的汇编指令推导出C源代码：

```asm
<rle_compress_hdmv>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  movq   $0x0,(%rdi)
  mov    %rdi,0x8(%rsp)
  mov    %edx,0x14(%rsp)
  mov    %ecx,0x18(%rsp)
  movl   $0x0,(%r8)
  test   %ecx,%ecx
  jle    L73
  movslq %edx,%r15
  mov    %ecx,%eax
  mov    %r8,%rbx
  mov    %rsi,%r12
  imul   %r15d,%eax
  lea    0x0(,%r15,4),%edx
  mov    %edx,0x1c(%rsp)
  mov    %eax,%edx
  lea    0xf(%rax),%eax
  test   %edx,%edx
  cmovns %edx,%eax
  xor    %r8d,%r8d
  xor    %edi,%edi
  xor    %r14d,%r14d
  xor    %r13d,%r13d
  sar    $0x4,%eax
  cltq
  mov    %rax,0x28(%rsp)
  lea    0x0(,%r15,4),%rax
  mov    %rax,0x20(%rsp)
  lea    -0x2(%r15),%eax
  lea    0x8(%rsi,%rax,4),%rbp
  nopl   (%rax)
L23:
  mov    %rdi,%r15
  mov    %r14d,%eax
  sub    %r8,%r15
  mov    %r15,%rcx
  sar    $0x2,%rcx
  sub    %ecx,%eax
  cmp    0x1c(%rsp),%eax
  jge    L88
  test   %r14,%r14
  lea    (%r14,%r14,1),%rax
  cmove  0x28(%rsp),%rax
  mov    %r8,%rdi
  mov    %rax,%rsi
  mov    %rax,%r14
  call   <realloc@plt>
  mov    0x8(%rsp),%rcx
  lea    (%rax,%r15,1),%rdi
  mov    %rax,(%rcx)
L88:
  cmpl   $0x1,0x14(%rsp)
  mov    (%r12),%esi
  jle    L79
  lea    0x4(%r12),%r15
  mov    $0x1,%edx
  jmp    L91
  xchg   %ax,%ax
L46:
  add    $0x4,%r15
  add    $0x1,%edx
  cmp    %r15,%rbp
  je     L42
L91:
  cmp    %esi,(%r15)
  je     L46
  call   <write_rle_hdmv@plt>
  add    $0x4,%r15
  addl   $0x1,(%rbx)
  mov    $0x1,%edx
  mov    -0x4(%r15),%esi
  mov    %rax,%rdi
  cmp    %r15,%rbp
  jne    L91
L42:
  call   <write_rle_hdmv@plt>
  addl   $0x1,(%rbx)
  xor    %edx,%edx
  xor    %esi,%esi
  mov    %rax,%rdi
  add    $0x1,%r13d
  call   <write_rle_hdmv@plt>
  addl   $0x1,(%rbx)
  mov    %rax,%rdi
  mov    0x20(%rsp),%rax
  add    %rax,%r12
  add    %rax,%rbp
  cmp    %r13d,0x18(%rsp)
  je     L62
  mov    0x8(%rsp),%rax
  mov    (%rax),%r8
  jmp    L23
  nopl   0x0(%rax,%rax,1)
L79:
  mov    $0x1,%edx
  jmp    L42
  nopw   0x0(%rax,%rax,1)
L62:
  mov    0x8(%rsp),%rbx
  mov    %rdi,%rax
  sub    (%rbx),%rax
  add    $0x38,%rsp
  pop    %rbx
  sar    $0x2,%rax
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L73:
  add    $0x38,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
size_t rle_compress_hdmv(uint8_t **rle_data, const uint8_t *data, uint w, uint h, int *num_rle) {
  uint y;
  size_t rle_size = 0;
  uint8_t *rle = NULL;
  *rle_data = NULL;
  *num_rle = 0;
  for (y = 0; y < h; y++) {
    if ((ssize_t)(rle_size - (rle - *rle_data)) < w * 4) {
      size_t used = rle - *rle_data;
      rle_size = rle_size < 1 ? w * h / 16 : rle_size * 2;
      *rle_data = realloc(*rle_data, rle_size);
      rle = *rle_data + used;
    }
    uint color = *data;
    uint len = 1;
    uint x = 1;
    for (x = 1; x < w; x++) {
      if (data[x] == color) {
        len++;
      } else {
        rle = write_rle_hdmv(rle, color, len);
        (*num_rle)++;
        color = data[x];
        len = 1;
      }
    }
    if (len) {
      rle = write_rle_hdmv(rle, color, len);
      (*num_rle)++;
    }
    rle = write_rle_hdmv(rle, 0, 0);
    (*num_rle)++;
    data += w;
  }
  return rle - *rle_data;
}
```