user: 请将以下的汇编代码转换成C语言代码:

```asm
<decodeRLE>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %edx,%ebp
  mov    %rcx,%r13
  mov    %r8d,%r12d
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x7(%rdx),%ebx
  test   %edx,%edx
  cmovns %edx,%ebx
  sar    $0x3,%ebx
  imul   %ebx,%edi
  mov    %edi,%r14d
  imul   %esi,%r14d
  mov    %r14d,%edi
  call   <tgaMalloc@plt>
  mov    %rax,%rdi
  test   %r14d,%r14d
  jle    L4
  mov    $0x0,%r9d
  lea    0x1(%rax),%r11
  mov    $0x0,%r10d
  jmp    L162
L48:
  cmp    $0x7,%ebp
  jle    L11
  mov    $0x0,%eax
L111:
  movzbl 0x1(%rcx,%rax,1),%edx
  mov    %dl,0x4(%rsp,%rax,1)
  add    $0x1,%rax
  cmp    %eax,%ebx
  jg     L111
  lea    -0x1(%rbx),%eax
  cmp    $0x7,%ebp
  cmovle %r10d,%eax
  lea    0x2(%r12,%rax,1),%r12d
L54:
  and    $0x7f,%r8d
  add    $0x1,%r8d
  movzbl %r8b,%r8d
  mov    $0x0,%r15d
  jmp    L44
L11:
  mov    %esi,%r12d
  jmp    L54
L60:
  lea    (%rdi,%rax,1),%rdx
  movzbl 0x4(%rsp,%rax,1),%ecx
  mov    %cl,(%rdx,%rsi,1)
  add    $0x1,%rax
  cmp    %eax,%ebx
  jg     L60
  lea    -0x1(%rbx),%eax
  cmp    $0x7,%ebp
  cmovle %r10d,%eax
  lea    0x1(%r9,%rax,1),%r9d
L115:
  add    $0x1,%r15d
  cmp    %r8d,%r15d
  je     L94
L44:
  mov    $0x0,%eax
  movslq %r9d,%rsi
  cmp    $0x7,%ebp
  jg     L60
  jmp    L115
L106:
  movzbl 0x1(%rdx,%rax,1),%r12d
  mov    %r12b,(%rax)
  add    $0x1,%rax
  cmp    %r8,%rax
  jne    L106
  lea    (%rsi,%rcx,1),%r12d
  add    %ecx,%r9d
L94:
  cmp    %r14d,%r9d
  jge    L4
L162:
  lea    0x1(%r12),%esi
  movslq %r12d,%rdx
  lea    0x0(%r13,%rdx,1),%rcx
  movzbl (%rcx),%r8d
  test   %r8b,%r8b
  js     L48
  movzbl %r8b,%ecx
  add    $0x1,%ecx
  imul   %ebx,%ecx
  test   %ecx,%ecx
  jle    L113
  movslq %r9d,%r12
  lea    (%r12,%rdi,1),%rax
  lea    (%r11,%r12,1),%r8
  lea    -0x1(%rcx),%r15d
  add    %r15,%r8
  sub    %rdi,%rdx
  sub    %r12,%rdx
  add    %r13,%rdx
  jmp    L106
L113:
  mov    %esi,%r12d
  jmp    L94
L4:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L160
  mov    %rdi,%rax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L160:
  call   <__stack_chk_fail@plt>
```

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