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

```asm
<decodeRLE>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x60,%rsp
  mov    %edi,-0x44(%rbp)
  mov    %esi,-0x48(%rbp)
  mov    %edx,-0x4c(%rbp)
  mov    %rcx,-0x58(%rbp)
  mov    %r8d,-0x50(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x4c(%rbp),%eax
  lea    0x7(%rax),%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  sar    $0x3,%eax
  mov    %eax,-0x2c(%rbp)
  mov    -0x2c(%rbp),%eax
  imul   -0x44(%rbp),%eax
  mov    -0x48(%rbp),%edx
  imul   %edx,%eax
  mov    %eax,-0x28(%rbp)
  mov    -0x28(%rbp),%eax
  mov    %eax,%edi
  call   <tgaMalloc@plt>
  mov    %rax,-0x18(%rbp)
  movl   $0x0,-0x3c(%rbp)
  jmp    L19
L90:
  mov    -0x50(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x50(%rbp)
  movslq %eax,%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,-0x24(%rbp)
  mov    -0x24(%rbp),%eax
  and    $0x80,%eax
  test   %eax,%eax
  je     L2
  movl   $0x0,-0x38(%rbp)
  jmp    L85
L15:
  mov    -0x50(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x50(%rbp)
  movslq %eax,%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%edx
  mov    -0x38(%rbp),%eax
  cltq
  mov    %dl,-0xc(%rbp,%rax,1)
  addl   $0x1,-0x38(%rbp)
L85:
  mov    -0x38(%rbp),%eax
  cmp    -0x2c(%rbp),%eax
  jl     L15
  mov    -0x24(%rbp),%eax
  and    $0x7f,%eax
  add    $0x1,%eax
  mov    %eax,-0x1c(%rbp)
  movl   $0x0,-0x38(%rbp)
  jmp    L62
L55:
  movl   $0x0,-0x34(%rbp)
  jmp    L42
L109:
  mov    -0x3c(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x3c(%rbp)
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0x34(%rbp),%eax
  cltq
  movzbl -0xc(%rbp,%rax,1),%eax
  mov    %al,(%rdx)
  addl   $0x1,-0x34(%rbp)
L42:
  mov    -0x34(%rbp),%eax
  cmp    -0x2c(%rbp),%eax
  jl     L109
  addl   $0x1,-0x38(%rbp)
L62:
  mov    -0x38(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jl     L55
  jmp    L19
L2:
  mov    -0x24(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    -0x2c(%rbp),%eax
  imul   %edx,%eax
  mov    %eax,-0x20(%rbp)
  movl   $0x0,-0x30(%rbp)
  jmp    L3
L73:
  mov    -0x50(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x50(%rbp)
  movslq %eax,%rdx
  mov    -0x58(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x3c(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x3c(%rbp)
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  movzbl (%rcx),%eax
  mov    %al,(%rdx)
  addl   $0x1,-0x30(%rbp)
L3:
  mov    -0x30(%rbp),%eax
  cmp    -0x20(%rbp),%eax
  jl     L73
L19:
  mov    -0x3c(%rbp),%eax
  cmp    -0x28(%rbp),%eax
  jl     L90
  mov    -0x18(%rbp),%rax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L91
  call   <__stack_chk_fail@plt>
L91:
  leave
  ret
```

assistant: ```c
unsigned char *decodeRLE(int width, int height, int depth, const unsigned char *buffer, int offset) {
  int elementCount = depth / 8;
  unsigned char elements[4];
  int decodeBufferLength = elementCount * width * height;
  unsigned char *decodeBuffer = (unsigned char *)tgaMalloc(decodeBufferLength);
  int decoded = 0;
  while (decoded < decodeBufferLength) {
    int packet = buffer[offset++] & 0xFF;
    if ((packet & 0x80) != 0) {
      int i, j, count;
      for (i = 0; i < elementCount; i++) {
        elements[i] = buffer[offset++];
      }
      count = (packet & 0x7F) + 1;
      for (i = 0; i < count; i++) {
        for (j = 0; j < elementCount; j++) {
          decodeBuffer[decoded++] = elements[j];
        }
      }
    } else {
      int count = (packet + 1) * elementCount;
      int i;
      for (i = 0; i < count; i++) {
        decodeBuffer[decoded++] = buffer[offset++];
      }
    }
  }
  return decodeBuffer;
}
```