user: What would the C source look like for the assembly code provided here?

```asm
<fwrite_base32hex_nonquote>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x2008(%rsp)
  xor    %eax,%eax
  mov    %rdx,%r13
  mov    %rsi,%rax
  mov    %rdi,%rbx
  movabs $0xcccccccccccccccd,%rdx
  mov    %rsi,%r15
  mul    %rdx
  mov    %rsi,%rax
  shr    $0x2,%rdx
  lea    0x0(,%rdx,8),%r12d
  lea    (%rdx,%rdx,4),%rdx
  sub    %rdx,%rax
  mov    %r12d,%r14d
  cmp    $0x3,%rax
  je     L212
  cmp    $0x4,%rax
  je     L159
  cmp    $0x1,%rax
  je     L137
  cmp    $0x2,%rax
  jne    L101
  add    $0x4,%r14d
  add    $0x8,%r12d
L101:
  mov    %rsp,%rbp
  cmp    $0x1fff,%r12d
  jg     L226
L71:
  lea    -0x1(%r15),%rcx
  test   %r15,%r15
  je     L112
  movzbl (%rbx),%edx
  mov    %rbp,%rax
  jmp    L252
L131:
  movzbl 0x5(%rbx),%edx
  mov    %rsi,%rcx
  mov    %rdi,%rbx
L252:
  mov    %edx,%esi
  shl    $0x2,%edx
  shr    $0x3,%sil
  and    $0x1c,%edx
  mov    %sil,(%rax)
  mov    %dl,0x1(%rax)
  test   %rcx,%rcx
  je     L112
  movzbl 0x1(%rbx),%edx
  mov    %edx,%esi
  shr    $0x6,%sil
  or     %sil,0x1(%rax)
  mov    %edx,%esi
  shl    $0x4,%edx
  shr    %sil
  and    $0x10,%edx
  and    $0x1f,%esi
  mov    %dl,0x3(%rax)
  mov    %sil,0x2(%rax)
  cmp    $0x1,%rcx
  je     L112
  movzbl 0x2(%rbx),%edx
  mov    %edx,%esi
  add    %edx,%edx
  and    $0x1e,%edx
  shr    $0x4,%sil
  or     %sil,0x3(%rax)
  mov    %dl,0x4(%rax)
  cmp    $0x2,%rcx
  je     L112
  movzbl 0x3(%rbx),%edx
  mov    %edx,%esi
  shr    $0x7,%sil
  or     %sil,0x4(%rax)
  mov    %edx,%esi
  shl    $0x3,%edx
  shr    $0x2,%sil
  and    $0x18,%edx
  and    $0x1f,%esi
  mov    %dl,0x6(%rax)
  mov    %sil,0x5(%rax)
  cmp    $0x3,%rcx
  je     L112
  movzbl 0x4(%rbx),%edx
  lea    0x5(%rbx),%rdi
  mov    %edx,%esi
  and    $0x1f,%edx
  shr    $0x5,%sil
  mov    %dl,0x7(%rax)
  or     %sil,0x6(%rax)
  add    $0x8,%rax
  lea    -0x5(%rcx),%rsi
  cmp    $0x4,%rcx
  jne    L131
L112:
  movslq %r12d,%r15
  xor    %ebx,%ebx
  test   %r12d,%r12d
  jg     L257
  jmp    L248
  nopl   (%rax)
L18:
  movzbl 0x0(%rbp,%rbx,1),%eax
  cmp    $0x9,%al
  ja     L92
  add    $0x30,%eax
  mov    %al,0x0(%rbp,%rbx,1)
L230:
  add    $0x1,%rbx
  cmp    %rbx,%r15
  je     L275
L257:
  cmp    %ebx,%r14d
  jg     L18
  movb   $0x3d,0x0(%rbp,%rbx,1)
  add    $0x1,%rbx
  cmp    %rbx,%r15
  jne    L257
L275:
  movb   $0x0,0x0(%rbp,%r15,1)
  mov    %r13,%rcx
  mov    %r12d,%esi
  mov    %rbp,%rdi
  mov    $0x1,%edx
  call   <fwrite@plt>
  cmp    $0x1fff,%r12d
  jle    L238
  mov    %rbp,%rdi
  call   <free@plt>
L238:
  mov    0x2008(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L20
  add    $0x2018,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nop
L92:
  cmp    $0x1f,%al
  ja     L157
  add    $0x57,%eax
  mov    %al,0x0(%rbp,%rbx,1)
  jmp    L230
  nopl   (%rax)
L157:
  xor    %edi,%edi
  call   <assert@plt>
  jmp    L230
  nopl   0x0(%rax)
L226:
  lea    0x1(%r12),%edi
  call   <malloc@plt>
  mov    %rax,%rbp
  jmp    L71
  nopw   0x0(%rax,%rax,1)
L159:
  add    $0x7,%r14d
  add    $0x8,%r12d
  jmp    L101
  nopl   (%rax)
L212:
  add    $0x5,%r14d
  add    $0x8,%r12d
  jmp    L101
  nopl   (%rax)
L137:
  add    $0x2,%r14d
  add    $0x8,%r12d
  jmp    L101
  nopl   (%rax)
L248:
  movb   $0x0,0x0(%rbp,%r15,1)
  mov    %r13,%rcx
  mov    %r12d,%esi
  mov    %rbp,%rdi
  mov    $0x1,%edx
  call   <fwrite@plt>
  jmp    L238
L20:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void fwrite_base32hex_nonquote(char *p, size_t len, FILE *fp) {
  int out_len = 8 * (len / 5);
  int bufsize, i;
  int byte = 0;
  unsigned char s[8193];
  unsigned char *buf, *start;
  switch (len % 5) {
  case 1:
    out_len += 2;
    break;
  case 2:
    out_len += 4;
    break;
  case 3:
    out_len += 5;
    break;
  case 4:
    out_len += 7;
    break;
  }
  bufsize = 8 * (len / 5) + (len % 5 == 0 ? 0 : 8);
  if (bufsize < 8192) {
    buf = s;
  } else {
    buf = malloc(bufsize + 1);
  }
  start = buf;
  while (len--) {
    unsigned char n = *p;
    switch (byte) {
    case 0:
      buf[0] = n >> 3;
      buf[1] = (n & 0x07) << 2;
      break;
    case 1:
      buf[1] |= (n >> 6) & 0x03;
      buf[2] = (n >> 1) & 0x1f;
      buf[3] = (n & 0x01) << 4;
      break;
    case 2:
      buf[3] |= (n >> 4) & 0x0f;
      buf[4] = (n & 0x0f) << 1;
      break;
    case 3:
      buf[4] |= (n >> 7) & 0x01;
      buf[5] = (n >> 2) & 0x1f;
      buf[6] = (n & 0x03) << 3;
      break;
    case 4:
      buf[6] |= (n >> 5) & 0x07;
      buf[7] = n & 0x1f;
      break;
    }
    p++;
    byte = (byte + 1) % 5;
    if (byte == 0) {
      buf += 8;
    }
  }
  buf = start;
  for (i = 0; i < bufsize; i++) {
    if (i < out_len) {
      if (buf[i] < 10) {
        buf[i] += '0';
      } else if (buf[i] < 32) {
        buf[i] += 'a' - 10;
      } else {
        assert(0);
      }
    } else {
      buf[i] = '=';
    }
  }
  buf[bufsize] = '\0';
  fwrite(buf, bufsize, 1, fp);
  if (bufsize >= 8192) {
    free(buf);
  }
}
```