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

```asm
<rle>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  test   %edx,%edx
  jle    L50
  mov    %rsi,%rbp
  mov    %edx,%ecx
  mov    %rdi,%r11
  xor    %r10d,%r10d
  mov    $0x2,%r14d
  nopl   0x0(%rax,%rax,1)
L268:
  movslq %r10d,%rbx
  lea    0x1(%r10),%eax
  lea    0x0(%rbp,%rbx,1),%r13
  movzbl 0x0(%r13),%esi
  cmp    %eax,%ecx
  jle    L255
  movslq %eax,%rdx
  mov    %r14d,%edi
  lea    0x7f(%r10),%r8d
  add    %rbp,%rdx
  sub    %edx,%edi
  jmp    L148
  nopw   0x0(%rax,%rax,1)
L317:
  add    $0x1,%eax
  lea    (%rdi,%rdx,1),%r9d
  cmp    %eax,%ecx
  je     L291
  add    $0x1,%rdx
  cmp    %r8d,%eax
  je     L260
L148:
  cmp    %sil,(%rdx)
  je     L317
  mov    %eax,%edx
  sub    %r10d,%edx
  cmp    $0x1,%edx
  je     L272
L234:
  mov    %eax,%edx
  mov    %sil,0x1(%r11)
  add    $0x2,%r11
  sub    %r10d,%edx
  mov    %eax,%r10d
  mov    %dl,-0x2(%r11)
L120:
  cmp    %ecx,%r10d
  jl     L268
L346:
  lea    0x1(%r11),%rax
  movb   $0x0,(%r11)
  pop    %rbx
  sub    %r12d,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   0x0(%rax,%rax,1)
L291:
  cmp    $0x1,%r9d
  jne    L234
  mov    %ecx,%eax
  nopl   0x0(%rax,%rax,1)
L255:
  mov    %r10d,%edx
  lea    0x1(%r11),%r9
  sub    %eax,%edx
  mov    %dl,(%r11)
  cmp    %r10d,%eax
  jle    L29
  mov    %eax,%esi
  lea    0x1(%rbp,%rbx,1),%rdi
  mov    %r9,%rdx
  sub    %r10d,%esi
  sub    %rdi,%rdx
  lea    -0x1(%rsi),%r8d
  cmp    $0xe,%rdx
  jbe    L125
  cmp    $0x6,%r8d
  jbe    L125
  cmp    $0xe,%r8d
  jbe    L362
  mov    %esi,%edi
  xor    %edx,%edx
  shr    $0x4,%edi
  shl    $0x4,%rdi
  nopw   0x0(%rax,%rax,1)
L357:
  movdqu 0x0(%r13,%rdx,1),%xmm0
  movups %xmm0,0x1(%r11,%rdx,1)
  add    $0x10,%rdx
  cmp    %rdx,%rdi
  jne    L357
  mov    %esi,%ebx
  and    $0xfffffff0,%ebx
  mov    %ebx,%edi
  add    %ebx,%r10d
  lea    (%r9,%rdi,1),%rdx
  cmp    %esi,%ebx
  je     L47
  sub    %ebx,%esi
  lea    -0x1(%rsi),%ebx
  cmp    $0x6,%ebx
  jbe    L207
L60:
  mov    0x0(%r13,%rdi,1),%rbx
  mov    %rbx,0x1(%r11,%rdi,1)
  mov    %esi,%edi
  and    $0xfffffff8,%edi
  mov    %edi,%r11d
  add    %edi,%r10d
  add    %r11,%rdx
  cmp    %edi,%esi
  je     L47
L207:
  movslq %r10d,%rsi
  movzbl 0x0(%rbp,%rsi,1),%esi
  mov    %sil,(%rdx)
  lea    0x1(%r10),%esi
  cmp    %esi,%eax
  jle    L47
  movslq %esi,%rsi
  movzbl 0x0(%rbp,%rsi,1),%esi
  mov    %sil,0x1(%rdx)
  lea    0x2(%r10),%esi
  cmp    %esi,%eax
  jle    L47
  movslq %esi,%rsi
  movzbl 0x0(%rbp,%rsi,1),%esi
  mov    %sil,0x2(%rdx)
  lea    0x3(%r10),%esi
  cmp    %esi,%eax
  jle    L47
  movslq %esi,%rsi
  movzbl 0x0(%rbp,%rsi,1),%esi
  mov    %sil,0x3(%rdx)
  lea    0x4(%r10),%esi
  cmp    %esi,%eax
  jle    L47
  movslq %esi,%rsi
  movzbl 0x0(%rbp,%rsi,1),%esi
  mov    %sil,0x4(%rdx)
  lea    0x5(%r10),%esi
  cmp    %esi,%eax
  jle    L47
  movslq %esi,%rsi
  add    $0x6,%r10d
  movzbl 0x0(%rbp,%rsi,1),%esi
  mov    %sil,0x5(%rdx)
  cmp    %r10d,%eax
  jle    L47
  movslq %r10d,%r10
  movzbl 0x0(%rbp,%r10,1),%esi
  mov    %sil,0x6(%rdx)
L47:
  mov    %r8d,%r8d
  mov    %eax,%r10d
  lea    0x1(%r9,%r8,1),%r11
  jmp    L120
  nopl   0x0(%rax,%rax,1)
L272:
  cmp    %eax,%ecx
  jle    L255
L24:
  movslq %eax,%rdx
  mov    %eax,%edi
  add    %rbp,%rdx
  sub    %r10d,%edi
  sub    %edx,%edi
  jmp    L4
  nop
L81:
  add    $0x1,%eax
  cmp    %eax,%ecx
  jle    L255
  add    $0x1,%rdx
  lea    (%rdi,%rdx,1),%esi
  cmp    $0x7e,%esi
  jg     L255
L4:
  movzbl (%rdx),%esi
  cmp    %sil,-0x1(%rdx)
  jne    L81
  cmp    $0x1,%eax
  jle    L81
  cmp    -0x2(%rdx),%sil
  jne    L81
  sub    $0x2,%eax
  jmp    L255
L260:
  cmp    $0x1,%r9d
  jne    L234
  jmp    L24
L125:
  sub    %rbx,%r11
  cs nopw 0x0(%rax,%rax,1)
L191:
  movzbl 0x0(%rbp,%rbx,1),%edx
  mov    %dl,0x1(%r11,%rbx,1)
  add    $0x1,%rbx
  cmp    %ebx,%eax
  jg     L191
  mov    %r8d,%r8d
  mov    %eax,%r10d
  lea    0x1(%r9,%r8,1),%r11
  jmp    L120
L29:
  mov    %r9,%r11
  mov    %eax,%r10d
  jmp    L120
L50:
  mov    %rdi,%r11
  jmp    L346
L362:
  mov    %r9,%rdx
  xor    %edi,%edi
  jmp    L60
```

assistant: ```c
int rle(unsigned char *output, const unsigned char *input, int len) {
  int count, index, i;
  unsigned char first;
  unsigned char *out;
  out = output;
  count = 0;
  while (count < len) {
    index = count;
    first = input[index++];
    while ((index < len) && (index - count < 127) && (input[index] == first))
      index++;
    if (index - count == 1) {
      while ((index < len) && (index - count < 127)) {
        if ((input[index] == input[index - 1]) && ((index > 1) && (input[index] == input[index - 2]))) {
          index -= 2;
          break;
        }
        index++;
      }
      *out++ = (unsigned char)(count - index);
      for (i = count; i < index; i++)
        *out++ = input[i];
    } else {
      *out++ = (unsigned char)(index - count);
      *out++ = first;
    }
    count = index;
  }
  *out++ = 0;
  return (out - output);
}
```