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

```asm
<decodeRLE>:
  endbr64
  push   %r15
  mov    %r8d,%r15d
  push   %r14
  mov    %rcx,%r14
  push   %r13
  lea    0x7(%rdx),%r13d
  push   %r12
  push   %rbp
  mov    %edx,%ebp
  push   %rbx
  sub    $0x38,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  test   %edx,%edx
  cmovns %edx,%r13d
  sar    $0x3,%r13d
  imul   %r13d,%edi
  imul   %esi,%edi
  mov    %edi,0xc(%rsp)
  mov    %edi,%ebx
  call   <tgaMalloc@plt>
  mov    %rax,%r12
  test   %ebx,%ebx
  jle    L262
  lea    0x1(%rax),%rax
  xor    %ebx,%ebx
  mov    %rax,0x18(%rsp)
  lea    -0x1(%r13),%eax
  mov    %eax,0x10(%rsp)
  nopl   0x0(%rax,%rax,1)
L295:
  movslq %r15d,%rcx
  lea    0x1(%r15),%r10d
  movzbl (%r14,%rcx,1),%r8d
  test   %r8b,%r8b
  js     L49
  lea    0x1(%r8),%eax
  movzbl %al,%eax
  imul   %r13d,%eax
  test   %eax,%eax
  jle    L53
  movslq %ebx,%r8
  lea    0x2(%r14,%rcx,1),%r11
  lea    -0x1(%rax),%edi
  lea    (%r12,%r8,1),%rdx
  mov    %rdx,%r9
  mov    %rdx,%rsi
  sub    %r11,%r9
  cmp    $0xe,%r9
  jbe    L81
  cmp    $0x6,%edi
  jbe    L81
  cmp    $0xe,%edi
  jbe    L89
  mov    %eax,%r8d
  lea    0x1(%rcx),%rdi
  shr    $0x4,%r8d
  sub    %rdx,%rdi
  sub    $0x1,%r8d
  add    %r14,%rdi
  shl    $0x4,%r8
  lea    0x10(%rdx,%r8,1),%r8
  nopw   0x0(%rax,%rax,1)
L137:
  movdqu (%rsi,%rdi,1),%xmm0
  add    $0x10,%rsi
  movups %xmm0,-0x10(%rsi)
  cmp    %r8,%rsi
  jne    L137
  mov    %eax,%esi
  and    $0xfffffff0,%esi
  mov    %esi,%r9d
  lea    (%r10,%rsi,1),%r8d
  lea    (%rbx,%rsi,1),%edi
  cmp    %esi,%eax
  je     L292
  mov    %eax,%r11d
  sub    %esi,%r11d
  lea    -0x1(%r11),%r15d
  cmp    $0x6,%r15d
  jbe    L42
L99:
  add    %r14,%rcx
  mov    0x1(%rsi,%rcx,1),%rcx
  mov    %rcx,(%rdx,%rsi,1)
  mov    %r11d,%edx
  and    $0xfffffff8,%edx
  add    %edx,%r8d
  add    %edx,%edi
  add    %edx,%r9d
  cmp    %edx,%r11d
  je     L292
L42:
  movslq %r8d,%rcx
  lea    0x1(%r8),%r11d
  lea    0x1(%rdi),%edx
  movzbl (%r14,%rcx,1),%esi
  movslq %edi,%rcx
  mov    %sil,(%r12,%rcx,1)
  lea    0x1(%r9),%ecx
  cmp    %ecx,%eax
  jle    L292
  movslq %r11d,%r11
  lea    0x2(%r8),%esi
  lea    0x2(%rdi),%ecx
  movslq %edx,%rdx
  movzbl (%r14,%r11,1),%r11d
  mov    %r11b,(%r12,%rdx,1)
  lea    0x2(%r9),%edx
  cmp    %edx,%eax
  jle    L292
  movslq %esi,%rsi
  lea    0x3(%r8),%r11d
  lea    0x3(%rdi),%edx
  movslq %ecx,%rcx
  movzbl (%r14,%rsi,1),%esi
  mov    %sil,(%r12,%rcx,1)
  lea    0x3(%r9),%ecx
  cmp    %ecx,%eax
  jle    L292
  movslq %r11d,%r11
  lea    0x4(%r8),%esi
  lea    0x4(%rdi),%ecx
  movslq %edx,%rdx
  movzbl (%r14,%r11,1),%r11d
  mov    %r11b,(%r12,%rdx,1)
  lea    0x4(%r9),%edx
  cmp    %edx,%eax
  jle    L292
  movslq %esi,%rsi
  lea    0x5(%r8),%r11d
  lea    0x5(%rdi),%edx
  movslq %ecx,%rcx
  movzbl (%r14,%rsi,1),%esi
  mov    %sil,(%r12,%rcx,1)
  lea    0x5(%r9),%ecx
  cmp    %ecx,%eax
  jle    L292
  movslq %r11d,%r11
  movslq %edx,%rdx
  add    $0x6,%r9d
  add    $0x6,%r8d
  movzbl (%r14,%r11,1),%ecx
  add    $0x6,%edi
  mov    %cl,(%r12,%rdx,1)
  cmp    %r9d,%eax
  jle    L292
  movslq %r8d,%r8
  movslq %edi,%rdi
  movzbl (%r14,%r8,1),%edx
  mov    %dl,(%r12,%rdi,1)
L292:
  lea    (%r10,%rax,1),%r15d
  add    %eax,%ebx
L216:
  cmp    0xc(%rsp),%ebx
  jl     L295
L262:
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L227
  add    $0x38,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  xchg   %ax,%ax
L49:
  cmp    $0x7,%ebp
  jle    L114
  mov    0x10(%rsp),%edx
  movslq %r10d,%rsi
  lea    0x24(%rsp),%rdi
  mov    %r8b,0x17(%rsp)
  add    %r14,%rsi
  add    $0x1,%rdx
  call   <memcpy@plt>
  mov    0x10(%rsp),%eax
  movzbl 0x17(%rsp),%r8d
  lea    0x2(%r15,%rax,1),%r15d
L9:
  and    $0x7f,%r8d
  movzbl 0x25(%rsp),%r9d
  movzbl 0x26(%rsp),%r10d
  xor    %edx,%edx
  lea    0x1(%r8),%eax
  movzbl 0x27(%rsp),%r11d
  movzbl 0x24(%rsp),%r8d
  movzbl %al,%eax
  nopw   0x0(%rax,%rax,1)
L187:
  cmp    $0x7,%ebp
  jle    L185
  movslq %ebx,%rsi
  lea    0x1(%rbx),%ecx
  mov    %r8b,(%r12,%rsi,1)
  cmp    $0xf,%ebp
  jle    L74
  movslq %ecx,%rdi
  lea    0x2(%rbx),%esi
  mov    %r9b,(%r12,%rdi,1)
  cmp    $0x2,%r13d
  je     L74
  movslq %esi,%rsi
  add    $0x3,%ebx
  mov    %r10b,(%r12,%rsi,1)
  cmp    $0x3,%r13d
  je     L74
  movslq %ebx,%rbx
  mov    %r11b,(%r12,%rbx,1)
L74:
  xor    %edi,%edi
  lea    -0x1(%r13),%ebx
  cmp    $0x7,%ebp
  cmovle %edi,%ebx
  add    %ecx,%ebx
L185:
  add    $0x1,%edx
  cmp    %edx,%eax
  jne    L187
  jmp    L216
L81:
  mov    0x18(%rsp),%rsi
  sub    %r12,%rcx
  sub    %r8,%rcx
  add    %r8,%rsi
  add    %r14,%rcx
  add    %rdi,%rsi
  nopl   0x0(%rax)
L299:
  movzbl 0x1(%rcx,%rdx,1),%edi
  add    $0x1,%rdx
  mov    %dil,-0x1(%rdx)
  cmp    %rsi,%rdx
  jne    L299
  jmp    L292
L114:
  mov    %r10d,%r15d
  jmp    L9
L53:
  mov    %r10d,%r15d
  jmp    L216
L89:
  mov    %eax,%r11d
  mov    %ebx,%edi
  mov    %r10d,%r8d
  xor    %esi,%esi
  xor    %r9d,%r9d
  jmp    L99
L227:
  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;
}
```