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

```asm
<unrle>:
  endbr64
  push   %r12
  mov    %rsi,%rdx
  mov    %rdi,%r8
  mov    %rdi,%rsi
  movabs $0x101010101010101,%r10
  push   %rbp
  push   %rbx
  nopl   0x0(%rax,%rax,1)
L317:
  movzbl (%rdx),%eax
  test   %al,%al
  jg     L171
L294:
  je     L124
  lea    0x2(%rdx),%r9
  mov    %rsi,%rcx
  lea    0x1(%rdx),%rbp
  sub    %r9,%rcx
  lea    0x1(%rax),%edi
  cmp    $0xe,%rcx
  jbe    L228
  cmp    $0xf8,%al
  ja     L228
  mov    %eax,%ecx
  neg    %ecx
  cmp    $0xf0,%al
  ja     L194
  movdqu 0x1(%rdx),%xmm0
  mov    %ecx,%r9d
  shr    $0x4,%r9b
  movups %xmm0,(%rsi)
  cmp    $0x1,%r9b
  je     L145
  movdqu 0x11(%rdx),%xmm1
  movups %xmm1,0x10(%rsi)
  cmp    $0x2,%r9b
  je     L145
  movdqu 0x21(%rdx),%xmm2
  movups %xmm2,0x20(%rsi)
  cmp    $0x3,%r9b
  je     L145
  movdqu 0x31(%rdx),%xmm3
  movups %xmm3,0x30(%rsi)
  cmp    $0x4,%r9b
  je     L145
  movdqu 0x41(%rdx),%xmm4
  movups %xmm4,0x40(%rsi)
  cmp    $0x5,%r9b
  je     L145
  movdqu 0x51(%rdx),%xmm5
  movups %xmm5,0x50(%rsi)
  cmp    $0x6,%r9b
  je     L145
  movdqu 0x61(%rdx),%xmm6
  movups %xmm6,0x60(%rsi)
  cmp    $0x7,%r9b
  je     L145
  movdqu 0x71(%rdx),%xmm7
  movups %xmm7,0x70(%rsi)
L145:
  mov    %ecx,%r12d
  mov    %rcx,%rbx
  and    $0xf0,%ebx
  and    $0xfffffff0,%r12d
  lea    0x0(%rbp,%rbx,1),%r11
  lea    (%rsi,%rbx,1),%r9
  add    %r12d,%edi
  cmp    %r12b,%cl
  je     L248
  sub    %r12d,%ecx
  lea    -0x1(%rcx),%r12d
  cmp    $0x6,%r12b
  jbe    L120
L265:
  mov    0x1(%rdx,%rbx,1),%rdx
  mov    %rdx,(%rsi,%rbx,1)
  mov    %ecx,%edx
  mov    %rcx,%rbx
  and    $0xf8,%ebx
  and    $0xfffffff8,%edx
  add    %rbx,%r11
  add    %rbx,%r9
  add    %edx,%edi
  cmp    %cl,%dl
  je     L248
L120:
  movzbl (%r11),%edx
  mov    %dl,(%r9)
  test   %dil,%dil
  je     L248
  movzbl 0x1(%r11),%edx
  mov    %dl,0x1(%r9)
  cmp    $0xff,%dil
  je     L248
  movzbl 0x2(%r11),%edx
  mov    %dl,0x2(%r9)
  cmp    $0xfe,%dil
  je     L248
  movzbl 0x3(%r11),%edx
  mov    %dl,0x3(%r9)
  cmp    $0xfd,%dil
  je     L248
  movzbl 0x4(%r11),%edx
  mov    %dl,0x4(%r9)
  cmp    $0xfc,%dil
  je     L248
  movzbl 0x5(%r11),%edx
  mov    %dl,0x5(%r9)
  cmp    $0xfb,%dil
  je     L248
  movzbl 0x6(%r11),%edx
  mov    %dl,0x6(%r9)
L248:
  not    %eax
L166:
  movzbl %al,%eax
  add    $0x1,%rax
  lea    0x0(%rbp,%rax,1),%rdx
  add    %rax,%rsi
  movzbl (%rdx),%eax
  test   %al,%al
  jle    L294
L171:
  movzbl %al,%r9d
  movzbl 0x1(%rdx),%eax
  lea    0x2(%rdx),%r11
  imul   %r10,%rax
  cmp    $0x8,%r9d
  jae    L229
  test   $0x4,%r9b
  jne    L173
  test   %r9d,%r9d
  je     L196
  mov    %al,(%rsi)
  test   $0x2,%r9b
  jne    L123
L196:
  add    %r9,%rsi
  mov    %r11,%rdx
  jmp    L317
  nopl   (%rax)
L229:
  lea    0x8(%rsi),%rdi
  mov    %rsi,%rcx
  mov    %rax,(%rsi)
  and    $0xfffffffffffffff8,%rdi
  mov    %rax,-0x8(%rsi,%r9,1)
  sub    %rdi,%rcx
  add    %r9d,%ecx
  shr    $0x3,%ecx
  rep stos %rax,%es:(%rdi)
  jmp    L196
  nopl   0x0(%rax)
L228:
  not    %eax
  xor    %ecx,%ecx
  movzbl %al,%r9d
  nopl   0x0(%rax,%rax,1)
L68:
  movzbl 0x1(%rdx,%rcx,1),%edi
  mov    %dil,(%rsi,%rcx,1)
  mov    %rcx,%rdi
  add    $0x1,%rcx
  cmp    %r9,%rdi
  jne    L68
  jmp    L166
  nopw   0x0(%rax,%rax,1)
L124:
  mov    %esi,%eax
  pop    %rbx
  pop    %rbp
  sub    %r8d,%eax
  pop    %r12
  ret
L194:
  mov    %rsi,%r9
  mov    %rbp,%r11
  xor    %ebx,%ebx
  jmp    L265
L173:
  mov    %eax,(%rsi)
  mov    %eax,-0x4(%rsi,%r9,1)
  jmp    L196
L123:
  mov    %ax,-0x2(%rsi,%r9,1)
  jmp    L196
```

assistant: ```c
int unrle(unsigned char *output, const unsigned char *input) {
  signed char count;
  unsigned char *out;
  unsigned char value;
  out = output;
  for (;;) {
    count = (signed char)*input++;
    if (count > 0) {
      value = *input++;
      while (count--)
        *out++ = value;
    } else if (count < 0) {
      while (count++)
        *out++ = *input++;
    } else
      break;
  }
  return (out - output);
}
```