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

```asm
<base32_encode>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x58,%rsp
  mov    %rdi,%r15
  mov    %rsi,0x8(%rsp)
  mov    %edx,%r13d
  mov    %ecx,0x10(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x48(%rsp)
  xor    %eax,%eax
  movabs $0x38676672646e6279,%rax
  movabs $0x787170636d6b6a65,%rdx
  mov    %rax,0x20(%rsp)
  mov    %rdx,0x28(%rsp)
  movabs $0x7a7369777531746f,%rax
  movabs $0x3936376835343361,%rdx
  mov    %rax,0x30(%rsp)
  mov    %rdx,0x38(%rsp)
  mov    %r13d,%eax
  mov    $0xcccccccd,%edx
  imul   %rdx,%rax
  shr    $0x22,%rax
  lea    (%rax,%rax,4),%eax
  mov    %r13d,%ebx
  sub    %eax,%ebx
  mov    %ebx,0x1c(%rsp)
  mov    %bl,0x1b(%rsp)
  test   %r13d,%r13d
  je     L152
  test   %ecx,%ecx
  je     L152
  mov    $0x0,%r12d
  mov    $0x0,%ebp
  jmp    L6
L216:
  lea    0x1(%rbp),%r14d
  mov    %ebp,%eax
  mov    0x8(%rsp),%rdi
  movsbl (%rdi,%rax,1),%edi
  call   <uchar@plt>
  mov    %eax,%ebx
  cmp    %r14d,%r13d
  jbe    L148
  lea    0x2(%rbp),%eax
  mov    %eax,0x4(%rsp)
  mov    %r14d,%r14d
  mov    0x8(%rsp),%rdi
  movsbl (%rdi,%r14,1),%edi
  call   <uchar@plt>
  mov    %al,0x1a(%rsp)
  mov    0x4(%rsp),%eax
  cmp    %eax,%r13d
  jbe    L147
  lea    0x3(%rbp),%r14d
  mov    %eax,%eax
  mov    0x8(%rsp),%rdi
  movsbl (%rdi,%rax,1),%edi
  call   <uchar@plt>
  mov    %al,0x4(%rsp)
  cmp    %r14d,%r13d
  jbe    L191
  lea    0x4(%rbp),%eax
  mov    %eax,0x14(%rsp)
  mov    %r14d,%r14d
  mov    0x8(%rsp),%rdi
  movsbl (%rdi,%r14,1),%edi
  call   <uchar@plt>
  mov    %eax,%r14d
  mov    0x14(%rsp),%eax
  cmp    %eax,%r13d
  jbe    L80
  add    $0x5,%ebp
  mov    %eax,%eax
  mov    0x8(%rsp),%rdi
  movsbl (%rdi,%rax,1),%edi
  call   <uchar@plt>
  mov    %eax,%edx
  jmp    L70
L80:
  mov    0x14(%rsp),%ebp
  mov    $0x0,%edx
  jmp    L70
L152:
  mov    $0x0,%r12d
L214:
  mov    0x1c(%rsp),%eax
  cmp    $0x1,%al
  je     L150
  cmp    $0x2,%al
  je     L85
  cmp    $0x3,%al
  je     L125
  cmp    $0x4,%al
  jne    L19
  sub    $0x1,%r12d
  mov    $0x1,%ecx
  jmp    L53
L150:
  movb   $0x6,0x1b(%rsp)
L125:
  sub    $0x1,%r12d
  movzbl 0x1b(%rsp),%ecx
L53:
  mov    %r12d,%eax
L196:
  mov    %eax,%edx
  sub    $0x1,%eax
  mov    %edx,%edx
  movb   $0x3d,(%r15,%rdx,1)
  mov    %r12d,%edx
  sub    %eax,%edx
  cmp    %ecx,%edx
  jb     L196
L19:
  mov    0x48(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L35
  mov    $0x0,%eax
  add    $0x58,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L85:
  movb   $0x4,0x1b(%rsp)
  jmp    L125
L191:
  mov    %r14d,%ebp
L222:
  mov    $0x0,%r14d
  mov    $0x0,%edx
L70:
  mov    %r12d,%ecx
  mov    %ebx,%eax
  shr    $0x3,%al
  and    $0x1f,%eax
  movzbl 0x20(%rsp,%rax,1),%eax
  mov    %al,(%r15,%rcx,1)
  lea    0x1(%r12),%ecx
  shl    $0x2,%ebx
  and    $0x1c,%ebx
  movzbl 0x1a(%rsp),%edi
  mov    %edi,%eax
  shr    $0x6,%al
  movzbl %al,%eax
  or     %eax,%ebx
  movslq %ebx,%rbx
  movzbl 0x20(%rsp,%rbx,1),%eax
  mov    %al,(%r15,%rcx,1)
  movzbl %dil,%eax
  lea    0x2(%r12),%esi
  mov    %eax,%ecx
  sar    %ecx
  and    $0x1f,%ecx
  movzbl 0x20(%rsp,%rcx,1),%ecx
  mov    %cl,(%r15,%rsi,1)
  lea    0x3(%r12),%esi
  shl    $0x4,%eax
  and    $0x10,%eax
  movzbl 0x4(%rsp),%ebx
  mov    %ebx,%ecx
  shr    $0x4,%cl
  movzbl %cl,%ecx
  or     %ecx,%eax
  cltq
  movzbl 0x20(%rsp,%rax,1),%eax
  mov    %al,(%r15,%rsi,1)
  lea    0x4(%r12),%esi
  mov    %ebx,%eax
  add    %eax,%eax
  and    $0x1e,%eax
  mov    %r14d,%ecx
  shr    $0x7,%cl
  movzbl %cl,%ecx
  or     %ecx,%eax
  cltq
  movzbl 0x20(%rsp,%rax,1),%eax
  mov    %al,(%r15,%rsi,1)
  movzbl %r14b,%eax
  lea    0x5(%r12),%esi
  mov    %eax,%ecx
  sar    $0x2,%ecx
  and    $0x1f,%ecx
  movzbl 0x20(%rsp,%rcx,1),%ecx
  mov    %cl,(%r15,%rsi,1)
  lea    0x7(%r12),%ecx
  lea    0x6(%r12),%edi
  shl    $0x3,%eax
  and    $0x18,%eax
  mov    %edx,%esi
  shr    $0x5,%sil
  movzbl %sil,%esi
  or     %esi,%eax
  cltq
  movzbl 0x20(%rsp,%rax,1),%eax
  mov    %al,(%r15,%rdi,1)
  add    $0x8,%r12d
  mov    %ecx,%eax
  and    $0x1f,%edx
  movzbl 0x20(%rsp,%rdx,1),%edx
  mov    %dl,(%r15,%rax,1)
  cmp    %r13d,%ebp
  jae    L214
  cmp    %r12d,0x10(%rsp)
  jbe    L214
L6:
  mov    $0x0,%ebx
  movb   $0x0,0x1a(%rsp)
  cmp    %ebp,%r13d
  ja     L216
L63:
  movb   $0x0,0x4(%rsp)
  jmp    L222
L148:
  mov    %r14d,%ebp
  movb   $0x0,0x1a(%rsp)
  jmp    L63
L147:
  mov    0x4(%rsp),%ebp
  jmp    L63
L35:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int base32_encode(char *dest, const char *src, unsigned int srclen, unsigned int outlen) {
  const char table[32] = "ybndrfg8ejkmcpqxot1uwisza345h769";
  unsigned int i = 0;
  unsigned int j = 0;
  unsigned char a = 0;
  unsigned char b = 0;
  unsigned char c = 0;
  unsigned char d = 0;
  unsigned char e = 0;
  unsigned char leftover_bytes = (srclen % 5);
  unsigned char replace_bytes = 0;
  const char padding[1] = "=";
  unsigned int iters = (srclen / 5);
  while (i < srclen && j < outlen) {
    a = i < srclen ? uchar(src[i++]) : 0;
    b = i < srclen ? uchar(src[i++]) : 0;
    c = i < srclen ? uchar(src[i++]) : 0;
    d = i < srclen ? uchar(src[i++]) : 0;
    e = i < srclen ? uchar(src[i++]) : 0;
    dest[j++] = table[(a >> 3)];
    dest[j++] = table[(((a & 0x07) << 2) | (b >> 6))];
    dest[j++] = table[(((b & 0x3F) >> 1))];
    dest[j++] = table[(((b & 0x01) << 4) | (c >> 4))];
    dest[j++] = table[(((c & 0x0F) << 1) | (d >> 7))];
    dest[j++] = table[(((d & 0x7F) >> 2))];
    dest[j++] = table[(((d & 0x03) << 3) | (e >> 5))];
    dest[j++] = table[(((e & 0x1F)))];
  }
  if (leftover_bytes == 1)
    replace_bytes = 6;
  else if (leftover_bytes == 2)
    replace_bytes = 4;
  else if (leftover_bytes == 3)
    replace_bytes = 3;
  else if (leftover_bytes == 4)
    replace_bytes = 1;
  j--;
  for (i = 0; i < replace_bytes; i++) {
    dest[j--] = padding[0];
  }
  return 0;
}
```