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

```asm
<gcr_encode>:
  endbr64
  push   %r15
  mov    %rdi,%r10
  mov    $0x17,%r11d
  mov    $0xa,%r15d
  push   %r14
  lea    D24(%rip),%rcx
  push   %r13
  xor    %r13d,%r13d
  push   %r12
  push   %rbp
  xor    %ebp,%ebp
  push   %rbx
  movzbl (%rdi),%eax
  jmp    L16
  xchg   %ax,%ax
L0:
  movzbl 0x4(%r10),%eax
  mov    %r8,%r10
L25:
  mov    %edi,%edx
  and    $0xf,%edi
  shr    $0x4,%dl
  movzbl (%rcx,%rdi,1),%r11d
  and    $0xf,%edx
  movzbl (%rcx,%rdx,1),%r15d
L16:
  mov    %rax,%rdx
  mov    %r11d,%r8d
  shl    $0x3,%r15d
  add    $0x5,%rsi
  shl    $0x6,%r8d
  and    $0xf,%edx
  shr    $0x2,%r11b
  movzbl (%rcx,%rdx,1),%edi
  mov    %eax,%edx
  or     %r11d,%r15d
  shr    $0x4,%dl
  and    $0xf,%edx
  mov    %edi,%r9d
  shl    $0x4,%edi
  movzbl (%rcx,%rdx,1),%edx
  shr    $0x4,%r9b
  mov    %dil,-0x1(%rsp)
  or     %r9d,%r8d
  add    %edx,%edx
  or     %edx,%r8d
  movzbl 0x1(%r10),%edx
  mov    %edx,%ebx
  shr    $0x4,%bl
  mov    %ebx,%edi
  mov    %rdx,%rbx
  and    $0xf,%edi
  and    $0xf,%ebx
  movzbl (%rcx,%rdi,1),%r9d
  movzbl (%rcx,%rbx,1),%edi
  mov    %r9d,%ebx
  shl    $0x2,%edi
  shl    $0x7,%ebx
  shr    %r9b
  or     %edi,%ebx
  mov    %bl,-0x2(%rsp)
  movzbl 0x2(%r10),%ebx
  mov    %r8b,-0x4(%rsi)
  movzbl -0x1(%rsp),%r8d
  mov    %ebx,%edi
  mov    %r15b,-0x5(%rsi)
  mov    %rbx,%r14
  xor    %ebx,%edx
  shr    $0x4,%dil
  or     %r9d,%r8d
  and    $0xf,%r14d
  xor    %eax,%edx
  and    $0xf,%edi
  mov    %r8b,-0x3(%rsi)
  lea    0x4(%r10),%r8
  movzbl (%rcx,%rdi,1),%edi
  mov    %edi,%r12d
  shr    $0x3,%dil
  or     -0x2(%rsp),%dil
  mov    %dil,-0x2(%rsi)
  shl    $0x5,%r12d
  or     (%rcx,%r14,1),%r12b
  mov    %r12b,-0x1(%rsi)
  movzbl 0x3(%r10),%edi
  xor    %edi,%edx
  xor    %edx,%r13d
  add    $0x4,%ebp
  cmp    $0x104,%ebp
  je     L33
  cmp    $0x100,%ebp
  jne    L0
  lea    D28(%rip),%rax
  lea    D28(%rip),%r10
  mov    %r13b,(%rax)
  mov    %r13d,%eax
  jmp    L25
  nopl   0x0(%rax)
L33:
  pop    %rbx
  xor    %eax,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
int gcr_encode(unsigned const char *block, unsigned char *encoded) {
  register unsigned char c = 0x07, h, l, g0, g1, g2, g3, g4;
  unsigned char chk = 0;
  int i;
  static const unsigned char gcr[] = {0x0a, 0x0b, 0x12, 0x13, 0x0e, 0x0f, 0x16, 0x17, 0x09, 0x19, 0x1a, 0x1b, 0x0d, 0x1d, 0x1e, 0x15};
  static unsigned char empty[] = {0x00, 0x00, 0x00, 0x00};
  for (i = 0; i <= 256; i += 4) {
    if (i == 256) {
      block = empty;
      empty[0] = chk;
    }
    h = gcr[c >> 4];
    l = gcr[c & 0x0f];
    g0 = (h << 3) | (l >> 2);
    g1 = (l & 0x03) << 6;
    chk ^= c = *(block++);
    h = gcr[c >> 4];
    l = gcr[c & 0x0f];
    g1 |= (h << 1) | (l >> 4);
    g2 = (l & 0x0f) << 4;
    chk ^= c = *(block++);
    h = gcr[c >> 4];
    l = gcr[c & 0x0f];
    g2 |= (h >> 1);
    g3 = ((h & 0x01) << 7) | (l << 2);
    chk ^= c = *(block++);
    h = gcr[c >> 4];
    l = gcr[c & 0x0f];
    g3 |= (h >> 3);
    g4 = ((h & 0x07) << 5) | (l);
    *(encoded++) = g0;
    *(encoded++) = g1;
    *(encoded++) = g2;
    *(encoded++) = g3;
    *(encoded++) = g4;
    chk ^= c = *(block++);
  }
  return 0;
}
```